@mastra/server 1.33.0-alpha.14 → 1.33.0-alpha.16
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/CHANGELOG.md +16 -0
- package/dist/{api-schema-manifest-H56IOQ7Q.cjs → api-schema-manifest-MFWM2IYT.cjs} +6 -6
- package/dist/{api-schema-manifest-H56IOQ7Q.cjs.map → api-schema-manifest-MFWM2IYT.cjs.map} +1 -1
- package/dist/{api-schema-manifest-SCZXY4HI.js → api-schema-manifest-W7V46W67.js} +4 -4
- package/dist/{api-schema-manifest-SCZXY4HI.js.map → api-schema-manifest-W7V46W67.js.map} +1 -1
- package/dist/{chunk-J6L4JMBT.cjs → chunk-2CFSCWYB.cjs} +7 -7
- package/dist/{chunk-J6L4JMBT.cjs.map → chunk-2CFSCWYB.cjs.map} +1 -1
- package/dist/{chunk-T3G3GPE3.cjs → chunk-3WBBCKFS.cjs} +83 -3970
- package/dist/chunk-3WBBCKFS.cjs.map +1 -0
- package/dist/{chunk-VSXPATYI.js → chunk-45VXNWVY.js} +4 -4
- package/dist/{chunk-VSXPATYI.js.map → chunk-45VXNWVY.js.map} +1 -1
- package/dist/{chunk-5CGIBJFA.cjs → chunk-4AF5BOBB.cjs} +12 -12
- package/dist/{chunk-5CGIBJFA.cjs.map → chunk-4AF5BOBB.cjs.map} +1 -1
- package/dist/chunk-4PBGZDMH.cjs +614 -0
- package/dist/chunk-4PBGZDMH.cjs.map +1 -0
- package/dist/{chunk-OMF7VJBL.js → chunk-4UMXWTGK.js} +4 -4
- package/dist/{chunk-OMF7VJBL.js.map → chunk-4UMXWTGK.js.map} +1 -1
- package/dist/{chunk-WXLLZARK.js → chunk-5KMAVRTH.js} +3 -3
- package/dist/{chunk-WXLLZARK.js.map → chunk-5KMAVRTH.js.map} +1 -1
- package/dist/{chunk-ZHOGHUAX.cjs → chunk-64KPSMDB.cjs} +28 -28
- package/dist/{chunk-ZHOGHUAX.cjs.map → chunk-64KPSMDB.cjs.map} +1 -1
- package/dist/{chunk-3RMKJTCU.cjs → chunk-6JO4HU6S.cjs} +10 -10
- package/dist/{chunk-3RMKJTCU.cjs.map → chunk-6JO4HU6S.cjs.map} +1 -1
- package/dist/{chunk-5SURXCX2.cjs → chunk-6KSZGG56.cjs} +10 -10
- package/dist/{chunk-5SURXCX2.cjs.map → chunk-6KSZGG56.cjs.map} +1 -1
- package/dist/{chunk-MGUB4XMC.cjs → chunk-6MLYT26T.cjs} +10 -10
- package/dist/{chunk-MGUB4XMC.cjs.map → chunk-6MLYT26T.cjs.map} +1 -1
- package/dist/{chunk-SBS6VJM2.cjs → chunk-7EETVLI2.cjs} +38 -38
- package/dist/{chunk-SBS6VJM2.cjs.map → chunk-7EETVLI2.cjs.map} +1 -1
- package/dist/{chunk-SYAGB4OG.js → chunk-7NGOF4XS.js} +5 -4
- package/dist/chunk-7NGOF4XS.js.map +1 -0
- package/dist/{chunk-EXI2FQQE.js → chunk-7PVVZLF7.js} +3 -3
- package/dist/{chunk-EXI2FQQE.js.map → chunk-7PVVZLF7.js.map} +1 -1
- package/dist/{chunk-7CCIRVMW.cjs → chunk-AGMODQ2J.cjs} +32 -32
- package/dist/{chunk-7CCIRVMW.cjs.map → chunk-AGMODQ2J.cjs.map} +1 -1
- package/dist/{chunk-AE7WAPJS.js → chunk-APSCZDR4.js} +3 -3
- package/dist/{chunk-AE7WAPJS.js.map → chunk-APSCZDR4.js.map} +1 -1
- package/dist/{chunk-UUK46T7P.js → chunk-B5GGWXNO.js} +4 -4
- package/dist/{chunk-UUK46T7P.js.map → chunk-B5GGWXNO.js.map} +1 -1
- package/dist/{chunk-WHTPC7MP.cjs → chunk-BMYFOYBH.cjs} +10 -10
- package/dist/{chunk-WHTPC7MP.cjs.map → chunk-BMYFOYBH.cjs.map} +1 -1
- package/dist/{chunk-GTLERIMC.js → chunk-BR3R3DQQ.js} +3 -3
- package/dist/{chunk-GTLERIMC.js.map → chunk-BR3R3DQQ.js.map} +1 -1
- package/dist/chunk-BSIAJKBX.cjs +4 -0
- package/dist/chunk-BSIAJKBX.cjs.map +1 -0
- package/dist/{chunk-XQCH52QI.cjs → chunk-BZXYO5VZ.cjs} +10 -10
- package/dist/{chunk-XQCH52QI.cjs.map → chunk-BZXYO5VZ.cjs.map} +1 -1
- package/dist/{chunk-FAEMMSQB.js → chunk-C5TT527L.js} +4 -4
- package/dist/{chunk-FAEMMSQB.js.map → chunk-C5TT527L.js.map} +1 -1
- package/dist/{chunk-DYHG4LMH.js → chunk-C6RCQJ2Z.js} +3 -3
- package/dist/{chunk-DYHG4LMH.js.map → chunk-C6RCQJ2Z.js.map} +1 -1
- package/dist/{chunk-54CKNFLM.cjs → chunk-COT4ZTGZ.cjs} +9 -9
- package/dist/{chunk-54CKNFLM.cjs.map → chunk-COT4ZTGZ.cjs.map} +1 -1
- package/dist/{chunk-T2TSJEGX.js → chunk-CSOQH4AK.js} +4 -4
- package/dist/{chunk-T2TSJEGX.js.map → chunk-CSOQH4AK.js.map} +1 -1
- package/dist/{chunk-2L6MRDXM.js → chunk-DFA4U26G.js} +3 -3
- package/dist/{chunk-2L6MRDXM.js.map → chunk-DFA4U26G.js.map} +1 -1
- package/dist/{chunk-2F6R22KQ.js → chunk-DFM7GOO4.js} +3 -3
- package/dist/{chunk-2F6R22KQ.js.map → chunk-DFM7GOO4.js.map} +1 -1
- package/dist/chunk-E6BG2C5U.js +3 -0
- package/dist/chunk-E6BG2C5U.js.map +1 -0
- package/dist/{chunk-XGKFSSPC.js → chunk-E7EMWFYN.js} +4 -4
- package/dist/{chunk-XGKFSSPC.js.map → chunk-E7EMWFYN.js.map} +1 -1
- package/dist/{chunk-GW475GAG.cjs → chunk-EIYUA4AX.cjs} +6 -6
- package/dist/{chunk-GW475GAG.cjs.map → chunk-EIYUA4AX.cjs.map} +1 -1
- package/dist/{chunk-VG5YTXWO.cjs → chunk-FCO2EQC6.cjs} +7 -7
- package/dist/{chunk-VG5YTXWO.cjs.map → chunk-FCO2EQC6.cjs.map} +1 -1
- package/dist/chunk-FT2N6D2N.cjs +3898 -0
- package/dist/chunk-FT2N6D2N.cjs.map +1 -0
- package/dist/{chunk-FZNUEGME.js → chunk-G5LV7OSI.js} +3 -3
- package/dist/{chunk-FZNUEGME.js.map → chunk-G5LV7OSI.js.map} +1 -1
- package/dist/{chunk-J2TNUEHZ.cjs → chunk-GXWNKZOD.cjs} +11 -11
- package/dist/{chunk-J2TNUEHZ.cjs.map → chunk-GXWNKZOD.cjs.map} +1 -1
- package/dist/{chunk-SQK6E6OB.cjs → chunk-H6HH44D5.cjs} +6 -6
- package/dist/{chunk-SQK6E6OB.cjs.map → chunk-H6HH44D5.cjs.map} +1 -1
- package/dist/{chunk-QYJ2Z4NM.cjs → chunk-HGMVVFDP.cjs} +28 -28
- package/dist/{chunk-QYJ2Z4NM.cjs.map → chunk-HGMVVFDP.cjs.map} +1 -1
- package/dist/{chunk-WYZWXMWT.js → chunk-I7ZTF2HK.js} +4 -4
- package/dist/{chunk-WYZWXMWT.js.map → chunk-I7ZTF2HK.js.map} +1 -1
- package/dist/{chunk-UG4TQYA5.js → chunk-IBZWGHQV.js} +4 -4
- package/dist/{chunk-UG4TQYA5.js.map → chunk-IBZWGHQV.js.map} +1 -1
- package/dist/{chunk-24XD6PRY.cjs → chunk-IJAASJBB.cjs} +6 -6
- package/dist/{chunk-24XD6PRY.cjs.map → chunk-IJAASJBB.cjs.map} +1 -1
- package/dist/{chunk-KBRQAVQ7.js → chunk-ITYCYE2S.js} +4 -4
- package/dist/{chunk-KBRQAVQ7.js.map → chunk-ITYCYE2S.js.map} +1 -1
- package/dist/chunk-JGW5HWOG.js +3889 -0
- package/dist/chunk-JGW5HWOG.js.map +1 -0
- package/dist/chunk-KKVBPEU6.cjs +544 -0
- package/dist/chunk-KKVBPEU6.cjs.map +1 -0
- package/dist/{chunk-3OED33MB.js → chunk-KMLEXUTX.js} +3 -3
- package/dist/{chunk-3OED33MB.js.map → chunk-KMLEXUTX.js.map} +1 -1
- package/dist/{chunk-UTA2JCM5.cjs → chunk-KPO4YSUU.cjs} +52 -52
- package/dist/{chunk-UTA2JCM5.cjs.map → chunk-KPO4YSUU.cjs.map} +1 -1
- package/dist/{chunk-3BMOLOBX.cjs → chunk-KYDOI34F.cjs} +10 -10
- package/dist/{chunk-3BMOLOBX.cjs.map → chunk-KYDOI34F.cjs.map} +1 -1
- package/dist/{chunk-SAWFPSUZ.js → chunk-L2OVPQXL.js} +3 -3
- package/dist/{chunk-SAWFPSUZ.js.map → chunk-L2OVPQXL.js.map} +1 -1
- package/dist/{chunk-GBFE3ATX.js → chunk-LDLL5EFD.js} +4 -4
- package/dist/{chunk-GBFE3ATX.js.map → chunk-LDLL5EFD.js.map} +1 -1
- package/dist/{chunk-5HTICUZW.cjs → chunk-LIW53IKN.cjs} +12 -12
- package/dist/{chunk-5HTICUZW.cjs.map → chunk-LIW53IKN.cjs.map} +1 -1
- package/dist/{chunk-QH24MMM4.cjs → chunk-LWMBJBWV.cjs} +24 -24
- package/dist/{chunk-QH24MMM4.cjs.map → chunk-LWMBJBWV.cjs.map} +1 -1
- package/dist/{chunk-XOVUIPJ5.cjs → chunk-LXB2YPEL.cjs} +8 -8
- package/dist/{chunk-XOVUIPJ5.cjs.map → chunk-LXB2YPEL.cjs.map} +1 -1
- package/dist/{chunk-VRW4RECS.js → chunk-NJNPWO2U.js} +37 -61
- package/dist/chunk-NJNPWO2U.js.map +1 -0
- package/dist/{chunk-6BX5UZ67.js → chunk-NKBFUK47.js} +3 -3
- package/dist/{chunk-6BX5UZ67.js.map → chunk-NKBFUK47.js.map} +1 -1
- package/dist/{chunk-DZVF6RQF.cjs → chunk-NS2TBDC7.cjs} +8 -8
- package/dist/{chunk-DZVF6RQF.cjs.map → chunk-NS2TBDC7.cjs.map} +1 -1
- package/dist/{chunk-7Y5IMVVS.js → chunk-NVTFYBJK.js} +4 -4
- package/dist/{chunk-7Y5IMVVS.js.map → chunk-NVTFYBJK.js.map} +1 -1
- package/dist/{chunk-EUI4PQF5.cjs → chunk-OJTOUPO5.cjs} +11 -11
- package/dist/{chunk-EUI4PQF5.cjs.map → chunk-OJTOUPO5.cjs.map} +1 -1
- package/dist/{chunk-RS2S4SBQ.cjs → chunk-OR37DTRU.cjs} +10 -10
- package/dist/{chunk-RS2S4SBQ.cjs.map → chunk-OR37DTRU.cjs.map} +1 -1
- package/dist/{chunk-GKWEP64R.cjs → chunk-QBJTV6J6.cjs} +5 -5
- package/dist/{chunk-GKWEP64R.cjs.map → chunk-QBJTV6J6.cjs.map} +1 -1
- package/dist/{chunk-HC7DEFY6.js → chunk-QOGXAX3L.js} +4 -4
- package/dist/{chunk-HC7DEFY6.js.map → chunk-QOGXAX3L.js.map} +1 -1
- package/dist/{chunk-YYTNZ4KH.js → chunk-R6MZNDPJ.js} +3 -3
- package/dist/{chunk-YYTNZ4KH.js.map → chunk-R6MZNDPJ.js.map} +1 -1
- package/dist/{chunk-CQOIFPKU.cjs → chunk-RZZ2QEMR.cjs} +17 -16
- package/dist/chunk-RZZ2QEMR.cjs.map +1 -0
- package/dist/{chunk-BQ4HXRAL.cjs → chunk-S2ZHO5NI.cjs} +11 -11
- package/dist/{chunk-BQ4HXRAL.cjs.map → chunk-S2ZHO5NI.cjs.map} +1 -1
- package/dist/{chunk-YY6BP6U2.js → chunk-S3KGEFOS.js} +6 -5
- package/dist/chunk-S3KGEFOS.js.map +1 -0
- package/dist/{chunk-4KCXZZ2I.js → chunk-S3RNHJLO.js} +3 -3
- package/dist/{chunk-4KCXZZ2I.js.map → chunk-S3RNHJLO.js.map} +1 -1
- package/dist/{chunk-VBFA6U5X.cjs → chunk-SCOS4OMV.cjs} +6 -6
- package/dist/{chunk-VBFA6U5X.cjs.map → chunk-SCOS4OMV.cjs.map} +1 -1
- package/dist/{chunk-D3MJC643.js → chunk-SGOBXOXA.js} +3 -3
- package/dist/{chunk-D3MJC643.js.map → chunk-SGOBXOXA.js.map} +1 -1
- package/dist/{chunk-MIWKRHIV.js → chunk-SJSR6N44.js} +6 -6
- package/dist/{chunk-MIWKRHIV.js.map → chunk-SJSR6N44.js.map} +1 -1
- package/dist/{chunk-VMHV5ATJ.js → chunk-SMKFE63B.js} +3 -3
- package/dist/{chunk-VMHV5ATJ.js.map → chunk-SMKFE63B.js.map} +1 -1
- package/dist/{chunk-CRN2HHZ4.cjs → chunk-TFQJA7WK.cjs} +13 -13
- package/dist/{chunk-CRN2HHZ4.cjs.map → chunk-TFQJA7WK.cjs.map} +1 -1
- package/dist/{chunk-HKZWPQSC.cjs → chunk-WFIBVKCP.cjs} +6 -6
- package/dist/{chunk-HKZWPQSC.cjs.map → chunk-WFIBVKCP.cjs.map} +1 -1
- package/dist/{chunk-GZQFBILP.js → chunk-WOUAM4PW.js} +3 -3
- package/dist/{chunk-GZQFBILP.js.map → chunk-WOUAM4PW.js.map} +1 -1
- package/dist/{chunk-JH5BL5V2.js → chunk-XP4JDZGU.js} +4 -4
- package/dist/{chunk-JH5BL5V2.js.map → chunk-XP4JDZGU.js.map} +1 -1
- package/dist/{chunk-ZCRTO66C.cjs → chunk-YJ66A6QD.cjs} +44 -43
- package/dist/chunk-YJ66A6QD.cjs.map +1 -0
- package/dist/{chunk-3GNDZVNF.js → chunk-YTH7NL2B.js} +3 -3
- package/dist/{chunk-3GNDZVNF.js.map → chunk-YTH7NL2B.js.map} +1 -1
- package/dist/{chunk-R2FHHF2M.js → chunk-YUMPAAZI.js} +4 -4
- package/dist/{chunk-R2FHHF2M.js.map → chunk-YUMPAAZI.js.map} +1 -1
- package/dist/{chunk-SALKEPIL.cjs → chunk-Z36ILXII.cjs} +10 -10
- package/dist/{chunk-SALKEPIL.cjs.map → chunk-Z36ILXII.cjs.map} +1 -1
- package/dist/chunk-Z5YIGHY3.js +527 -0
- package/dist/chunk-Z5YIGHY3.js.map +1 -0
- package/dist/{chunk-OG5H7763.cjs → chunk-ZD7C4XQM.cjs} +11 -11
- package/dist/{chunk-OG5H7763.cjs.map → chunk-ZD7C4XQM.cjs.map} +1 -1
- package/dist/{chunk-Y7PKRD75.js → chunk-ZEXNIBWR.js} +3 -3
- package/dist/{chunk-Y7PKRD75.js.map → chunk-ZEXNIBWR.js.map} +1 -1
- package/dist/{chunk-SW5NAE22.js → chunk-ZT2BLQRR.js} +83 -3964
- package/dist/chunk-ZT2BLQRR.js.map +1 -0
- package/dist/{chunk-TYOEQICH.cjs → chunk-ZVFA7UYX.cjs} +14 -14
- package/dist/{chunk-TYOEQICH.cjs.map → chunk-ZVFA7UYX.cjs.map} +1 -1
- package/dist/{chunk-M7WKIFTE.cjs → dist-QLRB64BV.cjs} +48 -542
- package/dist/dist-QLRB64BV.cjs.map +1 -0
- package/dist/{chunk-MU5LIFIL.js → dist-RHST5CLJ.js} +39 -524
- package/dist/dist-RHST5CLJ.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/server/handlers/a2a.cjs +14 -14
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-versions.cjs +8 -8
- package/dist/server/handlers/agent-versions.js +1 -1
- package/dist/server/handlers/agents.cjs +41 -41
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/auth.cjs +11 -11
- package/dist/server/handlers/auth.js +1 -1
- package/dist/server/handlers/background-tasks.cjs +4 -4
- package/dist/server/handlers/background-tasks.js +1 -1
- package/dist/server/handlers/channels.cjs +5 -5
- package/dist/server/handlers/channels.js +1 -1
- package/dist/server/handlers/conversations.cjs +5 -5
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/datasets.cjs +26 -26
- package/dist/server/handlers/datasets.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +8 -8
- package/dist/server/handlers/mcp-client-versions.js +1 -1
- package/dist/server/handlers/mcp.cjs +11 -11
- package/dist/server/handlers/mcp.js +1 -1
- package/dist/server/handlers/memory.cjs +27 -27
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +28 -28
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability.cjs +38 -38
- package/dist/server/handlers/observability.js +2 -2
- package/dist/server/handlers/processor-providers.cjs +3 -3
- package/dist/server/handlers/processor-providers.js +1 -1
- package/dist/server/handlers/processors.cjs +4 -4
- package/dist/server/handlers/processors.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +8 -8
- package/dist/server/handlers/prompt-block-versions.js +1 -1
- package/dist/server/handlers/responses.cjs +4 -4
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/schedules.cjs +6 -6
- package/dist/server/handlers/schedules.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +8 -8
- package/dist/server/handlers/scorer-versions.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +7 -7
- package/dist/server/handlers/stored-agents.js +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +6 -6
- package/dist/server/handlers/stored-mcp-clients.js +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
- package/dist/server/handlers/stored-prompt-blocks.js +1 -1
- package/dist/server/handlers/stored-scorers.cjs +6 -6
- package/dist/server/handlers/stored-scorers.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +7 -7
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/stored-workspaces.cjs +6 -6
- package/dist/server/handlers/stored-workspaces.js +1 -1
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tool-providers.cjs +5 -5
- package/dist/server/handlers/tool-providers.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/vector.cjs +16 -16
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -8
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +26 -26
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.cjs +26 -26
- package/dist/server/handlers/workspace.js +1 -1
- package/dist/server/handlers.cjs +35 -35
- package/dist/server/handlers.js +15 -15
- package/dist/server/schemas/index.cjs +232 -232
- package/dist/server/schemas/index.js +6 -6
- package/dist/server/server-adapter/index.cjs +22 -22
- package/dist/server/server-adapter/index.js +6 -6
- package/dist/server/server-adapter/routes/index.d.ts +1 -1
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/legacy.d.ts +1 -47
- package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-6UWC2NY3.cjs +0 -638
- package/dist/chunk-6UWC2NY3.cjs.map +0 -1
- package/dist/chunk-CQOIFPKU.cjs.map +0 -1
- package/dist/chunk-M7WKIFTE.cjs.map +0 -1
- package/dist/chunk-MU5LIFIL.js.map +0 -1
- package/dist/chunk-SW5NAE22.js.map +0 -1
- package/dist/chunk-SYAGB4OG.js.map +0 -1
- package/dist/chunk-T3G3GPE3.cjs.map +0 -1
- package/dist/chunk-VRW4RECS.js.map +0 -1
- package/dist/chunk-YY6BP6U2.js.map +0 -1
- package/dist/chunk-ZCRTO66C.cjs.map +0 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import z3, { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
2
|
-
import {
|
|
3
|
-
import { toStandardSchema as toStandardSchema$1 } from '@mastra/core/schema';
|
|
4
|
-
import { zodToJsonSchema as zodToJsonSchema$1 } from '@mastra/core/utils/zod-to-json';
|
|
5
|
-
import { z } from 'zod';
|
|
2
|
+
import { toJSONSchema } from 'zod/v4';
|
|
6
3
|
|
|
7
4
|
// ../schema-compat/dist/chunk-23HDOZLF.js
|
|
8
5
|
var VENDOR = "ai-sdk";
|
|
@@ -129,7 +126,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
129
126
|
// file that has been converted to a CommonJS file using a Babel-
|
|
130
127
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
131
128
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
132
|
-
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
129
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
133
130
|
mod
|
|
134
131
|
));
|
|
135
132
|
|
|
@@ -262,12 +259,12 @@ var require_code = __commonJS({
|
|
|
262
259
|
return item === "" || item === '""';
|
|
263
260
|
}
|
|
264
261
|
get str() {
|
|
265
|
-
var
|
|
266
|
-
return (
|
|
262
|
+
var _a;
|
|
263
|
+
return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
|
|
267
264
|
}
|
|
268
265
|
get names() {
|
|
269
|
-
var
|
|
270
|
-
return (
|
|
266
|
+
var _a;
|
|
267
|
+
return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce((names, c) => {
|
|
271
268
|
if (c instanceof Name)
|
|
272
269
|
names[c.str] = (names[c.str] || 0) + 1;
|
|
273
270
|
return names;
|
|
@@ -410,8 +407,8 @@ var require_scope = __commonJS({
|
|
|
410
407
|
return `${prefix}${ng.index++}`;
|
|
411
408
|
}
|
|
412
409
|
_nameGroup(prefix) {
|
|
413
|
-
var
|
|
414
|
-
if (((_b = (
|
|
410
|
+
var _a, _b;
|
|
411
|
+
if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
|
|
415
412
|
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
|
416
413
|
}
|
|
417
414
|
return this._names[prefix] = { prefix, index: 0 };
|
|
@@ -444,12 +441,12 @@ var require_scope = __commonJS({
|
|
|
444
441
|
return new ValueScopeName(prefix, this._newName(prefix));
|
|
445
442
|
}
|
|
446
443
|
value(nameOrPrefix, value) {
|
|
447
|
-
var
|
|
444
|
+
var _a;
|
|
448
445
|
if (value.ref === void 0)
|
|
449
446
|
throw new Error("CodeGen: ref must be passed in value");
|
|
450
447
|
const name = this.toName(nameOrPrefix);
|
|
451
448
|
const { prefix } = name;
|
|
452
|
-
const valueKey = (
|
|
449
|
+
const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref;
|
|
453
450
|
let vs = this._values[prefix];
|
|
454
451
|
if (vs) {
|
|
455
452
|
const _name = vs.get(valueKey);
|
|
@@ -764,8 +761,8 @@ var require_codegen = __commonJS({
|
|
|
764
761
|
return this;
|
|
765
762
|
}
|
|
766
763
|
optimizeNames(names, constants) {
|
|
767
|
-
var
|
|
768
|
-
this.else = (
|
|
764
|
+
var _a;
|
|
765
|
+
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
769
766
|
if (!(super.optimizeNames(names, constants) || this.else))
|
|
770
767
|
return;
|
|
771
768
|
this.condition = optimizeExpr(this.condition, names, constants);
|
|
@@ -869,16 +866,16 @@ var require_codegen = __commonJS({
|
|
|
869
866
|
return code;
|
|
870
867
|
}
|
|
871
868
|
optimizeNodes() {
|
|
872
|
-
var
|
|
869
|
+
var _a, _b;
|
|
873
870
|
super.optimizeNodes();
|
|
874
|
-
(
|
|
871
|
+
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
|
|
875
872
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
876
873
|
return this;
|
|
877
874
|
}
|
|
878
875
|
optimizeNames(names, constants) {
|
|
879
|
-
var
|
|
876
|
+
var _a, _b;
|
|
880
877
|
super.optimizeNames(names, constants);
|
|
881
|
-
(
|
|
878
|
+
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
882
879
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
|
883
880
|
return this;
|
|
884
881
|
}
|
|
@@ -1640,8 +1637,8 @@ var require_applicability = __commonJS({
|
|
|
1640
1637
|
}
|
|
1641
1638
|
exports$1.shouldUseGroup = shouldUseGroup;
|
|
1642
1639
|
function shouldUseRule(schema, rule) {
|
|
1643
|
-
var
|
|
1644
|
-
return schema[rule.keyword] !== void 0 || ((
|
|
1640
|
+
var _a;
|
|
1641
|
+
return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
|
|
1645
1642
|
}
|
|
1646
1643
|
exports$1.shouldUseRule = shouldUseRule;
|
|
1647
1644
|
}
|
|
@@ -2017,14 +2014,14 @@ var require_keyword = __commonJS({
|
|
|
2017
2014
|
}
|
|
2018
2015
|
exports$1.macroKeywordCode = macroKeywordCode;
|
|
2019
2016
|
function funcKeywordCode(cxt, def) {
|
|
2020
|
-
var
|
|
2017
|
+
var _a;
|
|
2021
2018
|
const { gen, keyword, schema, parentSchema, $data, it } = cxt;
|
|
2022
2019
|
checkAsyncKeyword(it, def);
|
|
2023
2020
|
const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
|
|
2024
2021
|
const validateRef = useKeyword(gen, keyword, validate);
|
|
2025
2022
|
const valid = gen.let("valid");
|
|
2026
2023
|
cxt.block$data(valid, validateKeyword);
|
|
2027
|
-
cxt.ok((
|
|
2024
|
+
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid);
|
|
2028
2025
|
function validateKeyword() {
|
|
2029
2026
|
if (def.errors === false) {
|
|
2030
2027
|
assignValid();
|
|
@@ -2055,8 +2052,8 @@ var require_keyword = __commonJS({
|
|
|
2055
2052
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
2056
2053
|
}
|
|
2057
2054
|
function reportErrs(errors) {
|
|
2058
|
-
var
|
|
2059
|
-
gen.if((0, codegen_1.not)((
|
|
2055
|
+
var _a2;
|
|
2056
|
+
gen.if((0, codegen_1.not)((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors);
|
|
2060
2057
|
}
|
|
2061
2058
|
}
|
|
2062
2059
|
exports$1.funcKeywordCode = funcKeywordCode;
|
|
@@ -2914,7 +2911,7 @@ var require_compile = __commonJS({
|
|
|
2914
2911
|
var validate_1 = require_validate();
|
|
2915
2912
|
var SchemaEnv = class {
|
|
2916
2913
|
constructor(env) {
|
|
2917
|
-
var
|
|
2914
|
+
var _a;
|
|
2918
2915
|
this.refs = {};
|
|
2919
2916
|
this.dynamicAnchors = {};
|
|
2920
2917
|
let schema;
|
|
@@ -2923,7 +2920,7 @@ var require_compile = __commonJS({
|
|
|
2923
2920
|
this.schema = env.schema;
|
|
2924
2921
|
this.schemaId = env.schemaId;
|
|
2925
2922
|
this.root = env.root || this;
|
|
2926
|
-
this.baseId = (
|
|
2923
|
+
this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
|
|
2927
2924
|
this.schemaPath = env.schemaPath;
|
|
2928
2925
|
this.localRefs = env.localRefs;
|
|
2929
2926
|
this.meta = env.meta;
|
|
@@ -3019,14 +3016,14 @@ var require_compile = __commonJS({
|
|
|
3019
3016
|
}
|
|
3020
3017
|
exports$1.compileSchema = compileSchema;
|
|
3021
3018
|
function resolveRef(root, baseId, ref) {
|
|
3022
|
-
var
|
|
3019
|
+
var _a;
|
|
3023
3020
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
3024
3021
|
const schOrFunc = root.refs[ref];
|
|
3025
3022
|
if (schOrFunc)
|
|
3026
3023
|
return schOrFunc;
|
|
3027
3024
|
let _sch = resolve.call(this, root, ref);
|
|
3028
3025
|
if (_sch === void 0) {
|
|
3029
|
-
const schema = (
|
|
3026
|
+
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
3030
3027
|
const { schemaId } = this.opts;
|
|
3031
3028
|
if (schema)
|
|
3032
3029
|
_sch = new SchemaEnv({ schema, schemaId, root, baseId });
|
|
@@ -3095,8 +3092,8 @@ var require_compile = __commonJS({
|
|
|
3095
3092
|
"definitions"
|
|
3096
3093
|
]);
|
|
3097
3094
|
function getJsonPointer(parsedRef, { baseId, schema, root }) {
|
|
3098
|
-
var
|
|
3099
|
-
if (((
|
|
3095
|
+
var _a;
|
|
3096
|
+
if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/")
|
|
3100
3097
|
return;
|
|
3101
3098
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
3102
3099
|
if (typeof schema === "boolean")
|
|
@@ -3940,9 +3937,9 @@ var require_core = __commonJS({
|
|
|
3940
3937
|
};
|
|
3941
3938
|
var MAX_EXPRESSION = 200;
|
|
3942
3939
|
function requiredOptions(o) {
|
|
3943
|
-
var
|
|
3940
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
3944
3941
|
const s = o.strict;
|
|
3945
|
-
const _optz = (
|
|
3942
|
+
const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
|
|
3946
3943
|
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
3947
3944
|
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
|
3948
3945
|
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
|
@@ -4251,7 +4248,7 @@ var require_core = __commonJS({
|
|
|
4251
4248
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
4252
4249
|
if (!errors || errors.length === 0)
|
|
4253
4250
|
return "No errors";
|
|
4254
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
4251
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg);
|
|
4255
4252
|
}
|
|
4256
4253
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
4257
4254
|
const rules = this.RULES.all;
|
|
@@ -4416,7 +4413,7 @@ var require_core = __commonJS({
|
|
|
4416
4413
|
}
|
|
4417
4414
|
}
|
|
4418
4415
|
function addRule(keyword, definition, dataType) {
|
|
4419
|
-
var
|
|
4416
|
+
var _a;
|
|
4420
4417
|
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
4421
4418
|
if (dataType && post)
|
|
4422
4419
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
@@ -4442,7 +4439,7 @@ var require_core = __commonJS({
|
|
|
4442
4439
|
else
|
|
4443
4440
|
ruleGroup.rules.push(rule);
|
|
4444
4441
|
RULES.all[keyword] = rule;
|
|
4445
|
-
(
|
|
4442
|
+
(_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd));
|
|
4446
4443
|
}
|
|
4447
4444
|
function addBeforeRule(ruleGroup, rule, before) {
|
|
4448
4445
|
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
@@ -4570,10 +4567,10 @@ var require_ref = __commonJS({
|
|
|
4570
4567
|
gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
|
|
4571
4568
|
}
|
|
4572
4569
|
function addEvaluatedFrom(source) {
|
|
4573
|
-
var
|
|
4570
|
+
var _a;
|
|
4574
4571
|
if (!it.opts.unevaluated)
|
|
4575
4572
|
return;
|
|
4576
|
-
const schEvaluated = (
|
|
4573
|
+
const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated;
|
|
4577
4574
|
if (it.props !== true) {
|
|
4578
4575
|
if (schEvaluated && !schEvaluated.dynamicProps) {
|
|
4579
4576
|
if (schEvaluated.props !== void 0) {
|
|
@@ -6113,7 +6110,7 @@ var require_discriminator = __commonJS({
|
|
|
6113
6110
|
return _valid;
|
|
6114
6111
|
}
|
|
6115
6112
|
function getMapping() {
|
|
6116
|
-
var
|
|
6113
|
+
var _a;
|
|
6117
6114
|
const oneOfMapping = {};
|
|
6118
6115
|
const topRequired = hasRequired(parentSchema);
|
|
6119
6116
|
let tagRequired = true;
|
|
@@ -6127,7 +6124,7 @@ var require_discriminator = __commonJS({
|
|
|
6127
6124
|
if (sch === void 0)
|
|
6128
6125
|
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
|
|
6129
6126
|
}
|
|
6130
|
-
const propSch = (
|
|
6127
|
+
const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName];
|
|
6131
6128
|
if (typeof propSch != "object") {
|
|
6132
6129
|
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
|
|
6133
6130
|
}
|
|
@@ -7147,9 +7144,9 @@ var require__ = __commonJS({
|
|
|
7147
7144
|
} });
|
|
7148
7145
|
}
|
|
7149
7146
|
});
|
|
7150
|
-
var import_ajv = __toESM(require_ajv());
|
|
7151
|
-
var import__ = __toESM(require__());
|
|
7152
|
-
var import_json_schema_traverse = __toESM(require_json_schema_traverse());
|
|
7147
|
+
var import_ajv = __toESM(require_ajv(), 1);
|
|
7148
|
+
var import__ = __toESM(require__(), 1);
|
|
7149
|
+
var import_json_schema_traverse = __toESM(require_json_schema_traverse(), 1);
|
|
7153
7150
|
var VENDOR2 = "json-schema";
|
|
7154
7151
|
var JsonSchemaWrapper = class {
|
|
7155
7152
|
#schema;
|
|
@@ -8011,11 +8008,11 @@ function parseMapDef(def, refs) {
|
|
|
8011
8008
|
|
|
8012
8009
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.3.6/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
8013
8010
|
function parseNativeEnumDef(def) {
|
|
8014
|
-
const
|
|
8011
|
+
const object = def.values;
|
|
8015
8012
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
8016
|
-
return typeof
|
|
8013
|
+
return typeof object[object[key]] !== "number";
|
|
8017
8014
|
});
|
|
8018
|
-
const actualValues = actualKeys.map((key) =>
|
|
8015
|
+
const actualValues = actualKeys.map((key) => object[key]);
|
|
8019
8016
|
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
8020
8017
|
return {
|
|
8021
8018
|
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
@@ -8465,17 +8462,17 @@ function parseDef(def, refs, forceResolution = false) {
|
|
|
8465
8462
|
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
8466
8463
|
refs.seen.set(def, newItem);
|
|
8467
8464
|
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
8468
|
-
const
|
|
8469
|
-
if (
|
|
8470
|
-
addMeta(def, refs,
|
|
8465
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
8466
|
+
if (jsonSchema) {
|
|
8467
|
+
addMeta(def, refs, jsonSchema);
|
|
8471
8468
|
}
|
|
8472
8469
|
if (refs.postProcess) {
|
|
8473
|
-
const postProcessResult = refs.postProcess(
|
|
8474
|
-
newItem.jsonSchema =
|
|
8470
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
8471
|
+
newItem.jsonSchema = jsonSchema;
|
|
8475
8472
|
return postProcessResult;
|
|
8476
8473
|
}
|
|
8477
|
-
newItem.jsonSchema =
|
|
8478
|
-
return
|
|
8474
|
+
newItem.jsonSchema = jsonSchema;
|
|
8475
|
+
return jsonSchema;
|
|
8479
8476
|
}
|
|
8480
8477
|
var get$ref = (item, refs) => {
|
|
8481
8478
|
switch (refs.$refStrategy) {
|
|
@@ -8493,14 +8490,14 @@ var get$ref = (item, refs) => {
|
|
|
8493
8490
|
}
|
|
8494
8491
|
}
|
|
8495
8492
|
};
|
|
8496
|
-
var addMeta = (def, refs,
|
|
8493
|
+
var addMeta = (def, refs, jsonSchema) => {
|
|
8497
8494
|
if (def.description) {
|
|
8498
|
-
|
|
8495
|
+
jsonSchema.description = def.description;
|
|
8499
8496
|
if (refs.markdownDescription) {
|
|
8500
|
-
|
|
8497
|
+
jsonSchema.markdownDescription = def.description;
|
|
8501
8498
|
}
|
|
8502
8499
|
}
|
|
8503
|
-
return
|
|
8500
|
+
return jsonSchema;
|
|
8504
8501
|
};
|
|
8505
8502
|
|
|
8506
8503
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.3.6/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
@@ -8569,14 +8566,14 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
8569
8566
|
var esm_default = zodToJsonSchema;
|
|
8570
8567
|
|
|
8571
8568
|
// ../schema-compat/dist/chunk-DLZFWLZ2.js
|
|
8572
|
-
var import_json_schema_traverse2 = __toESM(require_json_schema_traverse());
|
|
8569
|
+
var import_json_schema_traverse2 = __toESM(require_json_schema_traverse(), 1);
|
|
8573
8570
|
var TARGET_MAP = {
|
|
8574
8571
|
"draft-04": "jsonSchema7",
|
|
8575
8572
|
"draft-07": "jsonSchema7",
|
|
8576
8573
|
"draft-2020-12": "jsonSchema2019-09",
|
|
8577
8574
|
"openapi-3.0": "openApi3"
|
|
8578
8575
|
};
|
|
8579
|
-
function convertToJsonSchema(
|
|
8576
|
+
function convertToJsonSchema(zodSchema, options) {
|
|
8580
8577
|
const target = TARGET_MAP[options.target];
|
|
8581
8578
|
if (!target) {
|
|
8582
8579
|
const supportedTargets = Object.keys(TARGET_MAP);
|
|
@@ -8584,7 +8581,7 @@ function convertToJsonSchema(zodSchema2, options) {
|
|
|
8584
8581
|
`Unsupported JSON Schema target: "${options.target}". Supported targets are: ${supportedTargets.join(", ")}`
|
|
8585
8582
|
);
|
|
8586
8583
|
}
|
|
8587
|
-
const
|
|
8584
|
+
const jsonSchema = esm_default(zodSchema, {
|
|
8588
8585
|
$refStrategy: "none",
|
|
8589
8586
|
target,
|
|
8590
8587
|
override: (def) => {
|
|
@@ -8594,7 +8591,7 @@ function convertToJsonSchema(zodSchema2, options) {
|
|
|
8594
8591
|
return ignoreOverride;
|
|
8595
8592
|
}
|
|
8596
8593
|
});
|
|
8597
|
-
(0, import_json_schema_traverse2.default)(
|
|
8594
|
+
(0, import_json_schema_traverse2.default)(jsonSchema, {
|
|
8598
8595
|
cb: {
|
|
8599
8596
|
pre: (schema) => {
|
|
8600
8597
|
if (schema.type === "string" && schema.format === "email") {
|
|
@@ -8606,17 +8603,17 @@ function convertToJsonSchema(zodSchema2, options) {
|
|
|
8606
8603
|
// },
|
|
8607
8604
|
}
|
|
8608
8605
|
});
|
|
8609
|
-
return
|
|
8606
|
+
return jsonSchema;
|
|
8610
8607
|
}
|
|
8611
|
-
function toStandardSchema3(
|
|
8612
|
-
const wrapper = Object.create(
|
|
8613
|
-
const existingStandard =
|
|
8608
|
+
function toStandardSchema3(zodSchema) {
|
|
8609
|
+
const wrapper = Object.create(zodSchema);
|
|
8610
|
+
const existingStandard = zodSchema["~standard"];
|
|
8614
8611
|
const jsonSchemaConverter = {
|
|
8615
8612
|
input: (options) => {
|
|
8616
|
-
return convertToJsonSchema(
|
|
8613
|
+
return convertToJsonSchema(zodSchema, options);
|
|
8617
8614
|
},
|
|
8618
8615
|
output: (options) => {
|
|
8619
|
-
return convertToJsonSchema(
|
|
8616
|
+
return convertToJsonSchema(zodSchema, options);
|
|
8620
8617
|
}
|
|
8621
8618
|
};
|
|
8622
8619
|
Object.defineProperty(wrapper, "~standard", {
|
|
@@ -8635,7 +8632,7 @@ var ZOD_V4_TARGET_MAP = {
|
|
|
8635
8632
|
"draft-07": "draft-7",
|
|
8636
8633
|
"draft-04": "draft-4"
|
|
8637
8634
|
};
|
|
8638
|
-
function convertToJsonSchema2(
|
|
8635
|
+
function convertToJsonSchema2(zodSchema, options, adapterOptions) {
|
|
8639
8636
|
const target = SUPPORTED_TARGETS.has(options.target) ? options.target : "draft-07";
|
|
8640
8637
|
const jsonSchemaOptions = {
|
|
8641
8638
|
target: ZOD_V4_TARGET_MAP[target] ?? target
|
|
@@ -8646,17 +8643,17 @@ function convertToJsonSchema2(zodSchema2, options, adapterOptions) {
|
|
|
8646
8643
|
if (adapterOptions.override) {
|
|
8647
8644
|
jsonSchemaOptions.override = adapterOptions.override;
|
|
8648
8645
|
}
|
|
8649
|
-
return toJSONSchema(
|
|
8646
|
+
return toJSONSchema(zodSchema, jsonSchemaOptions);
|
|
8650
8647
|
}
|
|
8651
|
-
function toStandardSchema4(
|
|
8652
|
-
const wrapper = Object.create(
|
|
8653
|
-
const existingStandard =
|
|
8648
|
+
function toStandardSchema4(zodSchema, adapterOptions = {}) {
|
|
8649
|
+
const wrapper = Object.create(zodSchema);
|
|
8650
|
+
const existingStandard = zodSchema["~standard"];
|
|
8654
8651
|
const jsonSchemaConverter = {
|
|
8655
8652
|
input: (options) => {
|
|
8656
|
-
return convertToJsonSchema2(
|
|
8653
|
+
return convertToJsonSchema2(zodSchema, options, adapterOptions);
|
|
8657
8654
|
},
|
|
8658
8655
|
output: (options) => {
|
|
8659
|
-
return convertToJsonSchema2(
|
|
8656
|
+
return convertToJsonSchema2(zodSchema, options, adapterOptions);
|
|
8660
8657
|
}
|
|
8661
8658
|
};
|
|
8662
8659
|
Object.defineProperty(wrapper, "~standard", {
|
|
@@ -8671,19 +8668,19 @@ function toStandardSchema4(zodSchema2, adapterOptions = {}) {
|
|
|
8671
8668
|
return wrapper;
|
|
8672
8669
|
}
|
|
8673
8670
|
function jsonSchemaOverride(ctx) {
|
|
8674
|
-
const
|
|
8671
|
+
const zodSchema = ctx.zodSchema;
|
|
8675
8672
|
if (ctx.jsonSchema.type === "object" && ctx.jsonSchema.properties !== void 0 && !ctx.jsonSchema.additionalProperties) {
|
|
8676
8673
|
ctx.jsonSchema.additionalProperties = false;
|
|
8677
8674
|
}
|
|
8678
|
-
if (
|
|
8679
|
-
const isDateType =
|
|
8675
|
+
if (zodSchema) {
|
|
8676
|
+
const isDateType = zodSchema?.type === "date" || zodSchema?._def?.typeName === "ZodDate";
|
|
8680
8677
|
if (isDateType) {
|
|
8681
|
-
if (
|
|
8678
|
+
if (zodSchema?.type === "date") {
|
|
8682
8679
|
ctx.jsonSchema.type = "string";
|
|
8683
8680
|
ctx.jsonSchema.format = "date-time";
|
|
8684
8681
|
}
|
|
8685
|
-
ctx.jsonSchema["x-date"] = !
|
|
8686
|
-
} else if (
|
|
8682
|
+
ctx.jsonSchema["x-date"] = !zodSchema._zod?.def?.coerce;
|
|
8683
|
+
} else if (zodSchema?.type === "object" && zodSchema._zod?.def?.catchall?.type === "unknown") {
|
|
8687
8684
|
ctx.jsonSchema.additionalProperties = true;
|
|
8688
8685
|
}
|
|
8689
8686
|
}
|
|
@@ -8773,3895 +8770,17 @@ function isStandardSchemaWithJSON(value) {
|
|
|
8773
8770
|
function standardSchemaToJSONSchema(schema, options = {}) {
|
|
8774
8771
|
const { target = "draft-07", io = "output", override = JSON_SCHEMA_LIBRARY_OPTIONS.override } = options;
|
|
8775
8772
|
const jsonSchemaFn = schema["~standard"].jsonSchema[io];
|
|
8776
|
-
let
|
|
8773
|
+
let jsonSchema = jsonSchemaFn({
|
|
8777
8774
|
target,
|
|
8778
8775
|
libraryOptions: {
|
|
8779
8776
|
...JSON_SCHEMA_LIBRARY_OPTIONS,
|
|
8780
8777
|
override
|
|
8781
8778
|
}
|
|
8782
8779
|
});
|
|
8783
|
-
|
|
8784
|
-
return
|
|
8785
|
-
}
|
|
8786
|
-
var __create2 = Object.create;
|
|
8787
|
-
var __defProp2 = Object.defineProperty;
|
|
8788
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
8789
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
8790
|
-
var __getProtoOf2 = Object.getPrototypeOf;
|
|
8791
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
8792
|
-
var __commonJS2 = (cb, mod) => function __require2() {
|
|
8793
|
-
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8794
|
-
};
|
|
8795
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
8796
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8797
|
-
for (let key of __getOwnPropNames2(from))
|
|
8798
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
8799
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
8800
|
-
}
|
|
8801
|
-
return to;
|
|
8802
|
-
};
|
|
8803
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
8804
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
8805
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
8806
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
8807
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
8808
|
-
__defProp2(target, "default", { value: mod, enumerable: true }),
|
|
8809
|
-
mod
|
|
8810
|
-
));
|
|
8811
|
-
var require_secure_json_parse = __commonJS2({
|
|
8812
|
-
"../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports$1, module) {
|
|
8813
|
-
var hasBuffer = typeof Buffer !== "undefined";
|
|
8814
|
-
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
8815
|
-
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
8816
|
-
function _parse(text2, reviver, options) {
|
|
8817
|
-
if (options == null) {
|
|
8818
|
-
if (reviver !== null && typeof reviver === "object") {
|
|
8819
|
-
options = reviver;
|
|
8820
|
-
reviver = void 0;
|
|
8821
|
-
}
|
|
8822
|
-
}
|
|
8823
|
-
if (hasBuffer && Buffer.isBuffer(text2)) {
|
|
8824
|
-
text2 = text2.toString();
|
|
8825
|
-
}
|
|
8826
|
-
if (text2 && text2.charCodeAt(0) === 65279) {
|
|
8827
|
-
text2 = text2.slice(1);
|
|
8828
|
-
}
|
|
8829
|
-
const obj = JSON.parse(text2, reviver);
|
|
8830
|
-
if (obj === null || typeof obj !== "object") {
|
|
8831
|
-
return obj;
|
|
8832
|
-
}
|
|
8833
|
-
const protoAction = options && options.protoAction || "error";
|
|
8834
|
-
const constructorAction = options && options.constructorAction || "error";
|
|
8835
|
-
if (protoAction === "ignore" && constructorAction === "ignore") {
|
|
8836
|
-
return obj;
|
|
8837
|
-
}
|
|
8838
|
-
if (protoAction !== "ignore" && constructorAction !== "ignore") {
|
|
8839
|
-
if (suspectProtoRx.test(text2) === false && suspectConstructorRx.test(text2) === false) {
|
|
8840
|
-
return obj;
|
|
8841
|
-
}
|
|
8842
|
-
} else if (protoAction !== "ignore" && constructorAction === "ignore") {
|
|
8843
|
-
if (suspectProtoRx.test(text2) === false) {
|
|
8844
|
-
return obj;
|
|
8845
|
-
}
|
|
8846
|
-
} else {
|
|
8847
|
-
if (suspectConstructorRx.test(text2) === false) {
|
|
8848
|
-
return obj;
|
|
8849
|
-
}
|
|
8850
|
-
}
|
|
8851
|
-
return filter(obj, { protoAction, constructorAction, safe: options && options.safe });
|
|
8852
|
-
}
|
|
8853
|
-
function filter(obj, { protoAction = "error", constructorAction = "error", safe } = {}) {
|
|
8854
|
-
let next = [obj];
|
|
8855
|
-
while (next.length) {
|
|
8856
|
-
const nodes = next;
|
|
8857
|
-
next = [];
|
|
8858
|
-
for (const node of nodes) {
|
|
8859
|
-
if (protoAction !== "ignore" && Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
8860
|
-
if (safe === true) {
|
|
8861
|
-
return null;
|
|
8862
|
-
} else if (protoAction === "error") {
|
|
8863
|
-
throw new SyntaxError("Object contains forbidden prototype property");
|
|
8864
|
-
}
|
|
8865
|
-
delete node.__proto__;
|
|
8866
|
-
}
|
|
8867
|
-
if (constructorAction !== "ignore" && Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
8868
|
-
if (safe === true) {
|
|
8869
|
-
return null;
|
|
8870
|
-
} else if (constructorAction === "error") {
|
|
8871
|
-
throw new SyntaxError("Object contains forbidden prototype property");
|
|
8872
|
-
}
|
|
8873
|
-
delete node.constructor;
|
|
8874
|
-
}
|
|
8875
|
-
for (const key in node) {
|
|
8876
|
-
const value = node[key];
|
|
8877
|
-
if (value && typeof value === "object") {
|
|
8878
|
-
next.push(value);
|
|
8879
|
-
}
|
|
8880
|
-
}
|
|
8881
|
-
}
|
|
8882
|
-
}
|
|
8883
|
-
return obj;
|
|
8884
|
-
}
|
|
8885
|
-
function parse(text2, reviver, options) {
|
|
8886
|
-
const stackTraceLimit = Error.stackTraceLimit;
|
|
8887
|
-
Error.stackTraceLimit = 0;
|
|
8888
|
-
try {
|
|
8889
|
-
return _parse(text2, reviver, options);
|
|
8890
|
-
} finally {
|
|
8891
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
8892
|
-
}
|
|
8893
|
-
}
|
|
8894
|
-
function safeParse(text2, reviver) {
|
|
8895
|
-
const stackTraceLimit = Error.stackTraceLimit;
|
|
8896
|
-
Error.stackTraceLimit = 0;
|
|
8897
|
-
try {
|
|
8898
|
-
return _parse(text2, reviver, { safe: true });
|
|
8899
|
-
} catch (_e) {
|
|
8900
|
-
return null;
|
|
8901
|
-
} finally {
|
|
8902
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
8903
|
-
}
|
|
8904
|
-
}
|
|
8905
|
-
module.exports = parse;
|
|
8906
|
-
module.exports.default = parse;
|
|
8907
|
-
module.exports.parse = parse;
|
|
8908
|
-
module.exports.safeParse = safeParse;
|
|
8909
|
-
module.exports.scan = filter;
|
|
8910
|
-
}
|
|
8911
|
-
});
|
|
8912
|
-
var marker = "vercel.ai.error";
|
|
8913
|
-
var symbol = Symbol.for(marker);
|
|
8914
|
-
var _a;
|
|
8915
|
-
var _AISDKError = class _AISDKError2 extends Error {
|
|
8916
|
-
/**
|
|
8917
|
-
* Creates an AI SDK Error.
|
|
8918
|
-
*
|
|
8919
|
-
* @param {Object} params - The parameters for creating the error.
|
|
8920
|
-
* @param {string} params.name - The name of the error.
|
|
8921
|
-
* @param {string} params.message - The error message.
|
|
8922
|
-
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
8923
|
-
*/
|
|
8924
|
-
constructor({
|
|
8925
|
-
name: name142,
|
|
8926
|
-
message,
|
|
8927
|
-
cause
|
|
8928
|
-
}) {
|
|
8929
|
-
super(message);
|
|
8930
|
-
this[_a] = true;
|
|
8931
|
-
this.name = name142;
|
|
8932
|
-
this.cause = cause;
|
|
8933
|
-
}
|
|
8934
|
-
/**
|
|
8935
|
-
* Checks if the given error is an AI SDK Error.
|
|
8936
|
-
* @param {unknown} error - The error to check.
|
|
8937
|
-
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
8938
|
-
*/
|
|
8939
|
-
static isInstance(error) {
|
|
8940
|
-
return _AISDKError2.hasMarker(error, marker);
|
|
8941
|
-
}
|
|
8942
|
-
static hasMarker(error, marker152) {
|
|
8943
|
-
const markerSymbol = Symbol.for(marker152);
|
|
8944
|
-
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
8945
|
-
}
|
|
8946
|
-
};
|
|
8947
|
-
_a = symbol;
|
|
8948
|
-
var AISDKError = _AISDKError;
|
|
8949
|
-
function getErrorMessage(error) {
|
|
8950
|
-
if (error == null) {
|
|
8951
|
-
return "unknown error";
|
|
8952
|
-
}
|
|
8953
|
-
if (typeof error === "string") {
|
|
8954
|
-
return error;
|
|
8955
|
-
}
|
|
8956
|
-
if (error instanceof Error) {
|
|
8957
|
-
return error.message;
|
|
8958
|
-
}
|
|
8959
|
-
return JSON.stringify(error);
|
|
8960
|
-
}
|
|
8961
|
-
var name3 = "AI_InvalidArgumentError";
|
|
8962
|
-
var marker4 = `vercel.ai.error.${name3}`;
|
|
8963
|
-
var symbol4 = Symbol.for(marker4);
|
|
8964
|
-
var _a4;
|
|
8965
|
-
var InvalidArgumentError = class extends AISDKError {
|
|
8966
|
-
constructor({
|
|
8967
|
-
message,
|
|
8968
|
-
cause,
|
|
8969
|
-
argument
|
|
8970
|
-
}) {
|
|
8971
|
-
super({ name: name3, message, cause });
|
|
8972
|
-
this[_a4] = true;
|
|
8973
|
-
this.argument = argument;
|
|
8974
|
-
}
|
|
8975
|
-
static isInstance(error) {
|
|
8976
|
-
return AISDKError.hasMarker(error, marker4);
|
|
8977
|
-
}
|
|
8978
|
-
};
|
|
8979
|
-
_a4 = symbol4;
|
|
8980
|
-
var name6 = "AI_JSONParseError";
|
|
8981
|
-
var marker7 = `vercel.ai.error.${name6}`;
|
|
8982
|
-
var symbol7 = Symbol.for(marker7);
|
|
8983
|
-
var _a7;
|
|
8984
|
-
var JSONParseError = class extends AISDKError {
|
|
8985
|
-
constructor({ text: text2, cause }) {
|
|
8986
|
-
super({
|
|
8987
|
-
name: name6,
|
|
8988
|
-
message: `JSON parsing failed: Text: ${text2}.
|
|
8989
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
8990
|
-
cause
|
|
8991
|
-
});
|
|
8992
|
-
this[_a7] = true;
|
|
8993
|
-
this.text = text2;
|
|
8994
|
-
}
|
|
8995
|
-
static isInstance(error) {
|
|
8996
|
-
return AISDKError.hasMarker(error, marker7);
|
|
8997
|
-
}
|
|
8998
|
-
};
|
|
8999
|
-
_a7 = symbol7;
|
|
9000
|
-
var name12 = "AI_TypeValidationError";
|
|
9001
|
-
var marker13 = `vercel.ai.error.${name12}`;
|
|
9002
|
-
var symbol13 = Symbol.for(marker13);
|
|
9003
|
-
var _a13;
|
|
9004
|
-
var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
|
|
9005
|
-
constructor({ value, cause }) {
|
|
9006
|
-
super({
|
|
9007
|
-
name: name12,
|
|
9008
|
-
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
9009
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
9010
|
-
cause
|
|
9011
|
-
});
|
|
9012
|
-
this[_a13] = true;
|
|
9013
|
-
this.value = value;
|
|
9014
|
-
}
|
|
9015
|
-
static isInstance(error) {
|
|
9016
|
-
return AISDKError.hasMarker(error, marker13);
|
|
9017
|
-
}
|
|
9018
|
-
/**
|
|
9019
|
-
* Wraps an error into a TypeValidationError.
|
|
9020
|
-
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
9021
|
-
* Otherwise, it creates a new TypeValidationError.
|
|
9022
|
-
*
|
|
9023
|
-
* @param {Object} params - The parameters for wrapping the error.
|
|
9024
|
-
* @param {unknown} params.value - The value that failed validation.
|
|
9025
|
-
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
9026
|
-
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
9027
|
-
*/
|
|
9028
|
-
static wrap({
|
|
9029
|
-
value,
|
|
9030
|
-
cause
|
|
9031
|
-
}) {
|
|
9032
|
-
return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
|
|
9033
|
-
}
|
|
9034
|
-
};
|
|
9035
|
-
_a13 = symbol13;
|
|
9036
|
-
var TypeValidationError = _TypeValidationError;
|
|
9037
|
-
var customAlphabet = (alphabet, defaultSize = 21) => {
|
|
9038
|
-
return (size = defaultSize) => {
|
|
9039
|
-
let id = "";
|
|
9040
|
-
let i = size | 0;
|
|
9041
|
-
while (i--) {
|
|
9042
|
-
id += alphabet[Math.random() * alphabet.length | 0];
|
|
9043
|
-
}
|
|
9044
|
-
return id;
|
|
9045
|
-
};
|
|
9046
|
-
};
|
|
9047
|
-
var import_secure_json_parse = __toESM2(require_secure_json_parse());
|
|
9048
|
-
function convertAsyncIteratorToReadableStream(iterator) {
|
|
9049
|
-
return new ReadableStream({
|
|
9050
|
-
/**
|
|
9051
|
-
* Called when the consumer wants to pull more data from the stream.
|
|
9052
|
-
*
|
|
9053
|
-
* @param {ReadableStreamDefaultController<T>} controller - The controller to enqueue data into the stream.
|
|
9054
|
-
* @returns {Promise<void>}
|
|
9055
|
-
*/
|
|
9056
|
-
async pull(controller) {
|
|
9057
|
-
try {
|
|
9058
|
-
const { value, done } = await iterator.next();
|
|
9059
|
-
if (done) {
|
|
9060
|
-
controller.close();
|
|
9061
|
-
} else {
|
|
9062
|
-
controller.enqueue(value);
|
|
9063
|
-
}
|
|
9064
|
-
} catch (error) {
|
|
9065
|
-
controller.error(error);
|
|
9066
|
-
}
|
|
9067
|
-
},
|
|
9068
|
-
/**
|
|
9069
|
-
* Called when the consumer cancels the stream.
|
|
9070
|
-
*/
|
|
9071
|
-
cancel() {
|
|
9072
|
-
}
|
|
9073
|
-
});
|
|
9074
|
-
}
|
|
9075
|
-
var createIdGenerator = ({
|
|
9076
|
-
prefix,
|
|
9077
|
-
size: defaultSize = 16,
|
|
9078
|
-
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
9079
|
-
separator = "-"
|
|
9080
|
-
} = {}) => {
|
|
9081
|
-
const generator = customAlphabet(alphabet, defaultSize);
|
|
9082
|
-
if (prefix == null) {
|
|
9083
|
-
return generator;
|
|
9084
|
-
}
|
|
9085
|
-
if (alphabet.includes(separator)) {
|
|
9086
|
-
throw new InvalidArgumentError({
|
|
9087
|
-
argument: "separator",
|
|
9088
|
-
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
9089
|
-
});
|
|
9090
|
-
}
|
|
9091
|
-
return (size) => `${prefix}${separator}${generator(size)}`;
|
|
9092
|
-
};
|
|
9093
|
-
createIdGenerator();
|
|
9094
|
-
var validatorSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.validator");
|
|
9095
|
-
function validator(validate) {
|
|
9096
|
-
return { [validatorSymbol]: true, validate };
|
|
9097
|
-
}
|
|
9098
|
-
function isValidator(value) {
|
|
9099
|
-
return typeof value === "object" && value !== null && validatorSymbol in value && value[validatorSymbol] === true && "validate" in value;
|
|
9100
|
-
}
|
|
9101
|
-
function asValidator(value) {
|
|
9102
|
-
return isValidator(value) ? value : zodValidator(value);
|
|
9103
|
-
}
|
|
9104
|
-
function zodValidator(zodSchema2) {
|
|
9105
|
-
return validator((value) => {
|
|
9106
|
-
const result = zodSchema2.safeParse(value);
|
|
9107
|
-
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
9108
|
-
});
|
|
9109
|
-
}
|
|
9110
|
-
function safeValidateTypes({
|
|
9111
|
-
value,
|
|
9112
|
-
schema
|
|
9113
|
-
}) {
|
|
9114
|
-
const validator2 = asValidator(schema);
|
|
9115
|
-
try {
|
|
9116
|
-
if (validator2.validate == null) {
|
|
9117
|
-
return { success: true, value };
|
|
9118
|
-
}
|
|
9119
|
-
const result = validator2.validate(value);
|
|
9120
|
-
if (result.success) {
|
|
9121
|
-
return result;
|
|
9122
|
-
}
|
|
9123
|
-
return {
|
|
9124
|
-
success: false,
|
|
9125
|
-
error: TypeValidationError.wrap({ value, cause: result.error })
|
|
9126
|
-
};
|
|
9127
|
-
} catch (error) {
|
|
9128
|
-
return {
|
|
9129
|
-
success: false,
|
|
9130
|
-
error: TypeValidationError.wrap({ value, cause: error })
|
|
9131
|
-
};
|
|
9132
|
-
}
|
|
9133
|
-
}
|
|
9134
|
-
function safeParseJSON({
|
|
9135
|
-
text: text2,
|
|
9136
|
-
schema
|
|
9137
|
-
}) {
|
|
9138
|
-
try {
|
|
9139
|
-
const value = import_secure_json_parse.default.parse(text2);
|
|
9140
|
-
if (schema == null) {
|
|
9141
|
-
return { success: true, value, rawValue: value };
|
|
9142
|
-
}
|
|
9143
|
-
const validationResult = safeValidateTypes({ value, schema });
|
|
9144
|
-
return validationResult.success ? { ...validationResult, rawValue: value } : validationResult;
|
|
9145
|
-
} catch (error) {
|
|
9146
|
-
return {
|
|
9147
|
-
success: false,
|
|
9148
|
-
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text2, cause: error })
|
|
9149
|
-
};
|
|
9150
|
-
}
|
|
9151
|
-
}
|
|
9152
|
-
var ignoreOverride2 = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
9153
|
-
var defaultOptions2 = {
|
|
9154
|
-
name: void 0,
|
|
9155
|
-
$refStrategy: "root",
|
|
9156
|
-
basePath: ["#"],
|
|
9157
|
-
effectStrategy: "input",
|
|
9158
|
-
pipeStrategy: "all",
|
|
9159
|
-
dateStrategy: "format:date-time",
|
|
9160
|
-
mapStrategy: "entries",
|
|
9161
|
-
removeAdditionalStrategy: "passthrough",
|
|
9162
|
-
allowedAdditionalProperties: true,
|
|
9163
|
-
rejectedAdditionalProperties: false,
|
|
9164
|
-
definitionPath: "definitions",
|
|
9165
|
-
target: "jsonSchema7",
|
|
9166
|
-
strictUnions: false,
|
|
9167
|
-
definitions: {},
|
|
9168
|
-
errorMessages: false,
|
|
9169
|
-
markdownDescription: false,
|
|
9170
|
-
patternStrategy: "escape",
|
|
9171
|
-
applyRegexFlags: false,
|
|
9172
|
-
emailStrategy: "format:email",
|
|
9173
|
-
base64Strategy: "contentEncoding:base64",
|
|
9174
|
-
nameStrategy: "ref",
|
|
9175
|
-
openAiAnyTypeName: "OpenAiAnyType"
|
|
9176
|
-
};
|
|
9177
|
-
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
9178
|
-
...defaultOptions2,
|
|
9179
|
-
name: options
|
|
9180
|
-
} : {
|
|
9181
|
-
...defaultOptions2,
|
|
9182
|
-
...options
|
|
9183
|
-
};
|
|
9184
|
-
var getRefs2 = (options) => {
|
|
9185
|
-
const _options = getDefaultOptions2(options);
|
|
9186
|
-
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
9187
|
-
return {
|
|
9188
|
-
..._options,
|
|
9189
|
-
flags: { hasReferencedOpenAiAnyType: false },
|
|
9190
|
-
currentPath,
|
|
9191
|
-
propertyPath: void 0,
|
|
9192
|
-
seen: new Map(Object.entries(_options.definitions).map(([name17, def]) => [
|
|
9193
|
-
def._def,
|
|
9194
|
-
{
|
|
9195
|
-
def: def._def,
|
|
9196
|
-
path: [..._options.basePath, _options.definitionPath, name17],
|
|
9197
|
-
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
9198
|
-
jsonSchema: void 0
|
|
9199
|
-
}
|
|
9200
|
-
]))
|
|
9201
|
-
};
|
|
9202
|
-
};
|
|
9203
|
-
function addErrorMessage2(res, key, errorMessage, refs) {
|
|
9204
|
-
if (!refs?.errorMessages)
|
|
9205
|
-
return;
|
|
9206
|
-
if (errorMessage) {
|
|
9207
|
-
res.errorMessage = {
|
|
9208
|
-
...res.errorMessage,
|
|
9209
|
-
[key]: errorMessage
|
|
9210
|
-
};
|
|
9211
|
-
}
|
|
9212
|
-
}
|
|
9213
|
-
function setResponseValueAndErrors2(res, key, value, errorMessage, refs) {
|
|
9214
|
-
res[key] = value;
|
|
9215
|
-
addErrorMessage2(res, key, errorMessage, refs);
|
|
9216
|
-
}
|
|
9217
|
-
var getRelativePath2 = (pathA, pathB) => {
|
|
9218
|
-
let i = 0;
|
|
9219
|
-
for (; i < pathA.length && i < pathB.length; i++) {
|
|
9220
|
-
if (pathA[i] !== pathB[i])
|
|
9221
|
-
break;
|
|
9222
|
-
}
|
|
9223
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
9224
|
-
};
|
|
9225
|
-
function parseAnyDef2(refs) {
|
|
9226
|
-
if (refs.target !== "openAi") {
|
|
9227
|
-
return {};
|
|
9228
|
-
}
|
|
9229
|
-
const anyDefinitionPath = [
|
|
9230
|
-
...refs.basePath,
|
|
9231
|
-
refs.definitionPath,
|
|
9232
|
-
refs.openAiAnyTypeName
|
|
9233
|
-
];
|
|
9234
|
-
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
9235
|
-
return {
|
|
9236
|
-
$ref: refs.$refStrategy === "relative" ? getRelativePath2(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
9237
|
-
};
|
|
9238
|
-
}
|
|
9239
|
-
function parseArrayDef2(def, refs) {
|
|
9240
|
-
const res = {
|
|
9241
|
-
type: "array"
|
|
9242
|
-
};
|
|
9243
|
-
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
|
|
9244
|
-
res.items = parseDef2(def.type._def, {
|
|
9245
|
-
...refs,
|
|
9246
|
-
currentPath: [...refs.currentPath, "items"]
|
|
9247
|
-
});
|
|
9248
|
-
}
|
|
9249
|
-
if (def.minLength) {
|
|
9250
|
-
setResponseValueAndErrors2(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
9251
|
-
}
|
|
9252
|
-
if (def.maxLength) {
|
|
9253
|
-
setResponseValueAndErrors2(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
9254
|
-
}
|
|
9255
|
-
if (def.exactLength) {
|
|
9256
|
-
setResponseValueAndErrors2(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
9257
|
-
setResponseValueAndErrors2(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
9258
|
-
}
|
|
9259
|
-
return res;
|
|
9260
|
-
}
|
|
9261
|
-
function parseBigintDef2(def, refs) {
|
|
9262
|
-
const res = {
|
|
9263
|
-
type: "integer",
|
|
9264
|
-
format: "int64"
|
|
9265
|
-
};
|
|
9266
|
-
if (!def.checks)
|
|
9267
|
-
return res;
|
|
9268
|
-
for (const check of def.checks) {
|
|
9269
|
-
switch (check.kind) {
|
|
9270
|
-
case "min":
|
|
9271
|
-
if (refs.target === "jsonSchema7") {
|
|
9272
|
-
if (check.inclusive) {
|
|
9273
|
-
setResponseValueAndErrors2(res, "minimum", check.value, check.message, refs);
|
|
9274
|
-
} else {
|
|
9275
|
-
setResponseValueAndErrors2(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
9276
|
-
}
|
|
9277
|
-
} else {
|
|
9278
|
-
if (!check.inclusive) {
|
|
9279
|
-
res.exclusiveMinimum = true;
|
|
9280
|
-
}
|
|
9281
|
-
setResponseValueAndErrors2(res, "minimum", check.value, check.message, refs);
|
|
9282
|
-
}
|
|
9283
|
-
break;
|
|
9284
|
-
case "max":
|
|
9285
|
-
if (refs.target === "jsonSchema7") {
|
|
9286
|
-
if (check.inclusive) {
|
|
9287
|
-
setResponseValueAndErrors2(res, "maximum", check.value, check.message, refs);
|
|
9288
|
-
} else {
|
|
9289
|
-
setResponseValueAndErrors2(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
9290
|
-
}
|
|
9291
|
-
} else {
|
|
9292
|
-
if (!check.inclusive) {
|
|
9293
|
-
res.exclusiveMaximum = true;
|
|
9294
|
-
}
|
|
9295
|
-
setResponseValueAndErrors2(res, "maximum", check.value, check.message, refs);
|
|
9296
|
-
}
|
|
9297
|
-
break;
|
|
9298
|
-
case "multipleOf":
|
|
9299
|
-
setResponseValueAndErrors2(res, "multipleOf", check.value, check.message, refs);
|
|
9300
|
-
break;
|
|
9301
|
-
}
|
|
9302
|
-
}
|
|
9303
|
-
return res;
|
|
9304
|
-
}
|
|
9305
|
-
function parseBooleanDef2() {
|
|
9306
|
-
return {
|
|
9307
|
-
type: "boolean"
|
|
9308
|
-
};
|
|
9309
|
-
}
|
|
9310
|
-
function parseBrandedDef2(_def, refs) {
|
|
9311
|
-
return parseDef2(_def.type._def, refs);
|
|
9312
|
-
}
|
|
9313
|
-
var parseCatchDef2 = (def, refs) => {
|
|
9314
|
-
return parseDef2(def.innerType._def, refs);
|
|
9315
|
-
};
|
|
9316
|
-
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
9317
|
-
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
9318
|
-
if (Array.isArray(strategy)) {
|
|
9319
|
-
return {
|
|
9320
|
-
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
9321
|
-
};
|
|
9322
|
-
}
|
|
9323
|
-
switch (strategy) {
|
|
9324
|
-
case "string":
|
|
9325
|
-
case "format:date-time":
|
|
9326
|
-
return {
|
|
9327
|
-
type: "string",
|
|
9328
|
-
format: "date-time"
|
|
9329
|
-
};
|
|
9330
|
-
case "format:date":
|
|
9331
|
-
return {
|
|
9332
|
-
type: "string",
|
|
9333
|
-
format: "date"
|
|
9334
|
-
};
|
|
9335
|
-
case "integer":
|
|
9336
|
-
return integerDateParser2(def, refs);
|
|
9337
|
-
}
|
|
9338
|
-
}
|
|
9339
|
-
var integerDateParser2 = (def, refs) => {
|
|
9340
|
-
const res = {
|
|
9341
|
-
type: "integer",
|
|
9342
|
-
format: "unix-time"
|
|
9343
|
-
};
|
|
9344
|
-
if (refs.target === "openApi3") {
|
|
9345
|
-
return res;
|
|
9346
|
-
}
|
|
9347
|
-
for (const check of def.checks) {
|
|
9348
|
-
switch (check.kind) {
|
|
9349
|
-
case "min":
|
|
9350
|
-
setResponseValueAndErrors2(
|
|
9351
|
-
res,
|
|
9352
|
-
"minimum",
|
|
9353
|
-
check.value,
|
|
9354
|
-
// This is in milliseconds
|
|
9355
|
-
check.message,
|
|
9356
|
-
refs
|
|
9357
|
-
);
|
|
9358
|
-
break;
|
|
9359
|
-
case "max":
|
|
9360
|
-
setResponseValueAndErrors2(
|
|
9361
|
-
res,
|
|
9362
|
-
"maximum",
|
|
9363
|
-
check.value,
|
|
9364
|
-
// This is in milliseconds
|
|
9365
|
-
check.message,
|
|
9366
|
-
refs
|
|
9367
|
-
);
|
|
9368
|
-
break;
|
|
9369
|
-
}
|
|
9370
|
-
}
|
|
9371
|
-
return res;
|
|
9372
|
-
};
|
|
9373
|
-
function parseDefaultDef2(_def, refs) {
|
|
9374
|
-
return {
|
|
9375
|
-
...parseDef2(_def.innerType._def, refs),
|
|
9376
|
-
default: _def.defaultValue()
|
|
9377
|
-
};
|
|
9378
|
-
}
|
|
9379
|
-
function parseEffectsDef2(_def, refs) {
|
|
9380
|
-
return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2(refs);
|
|
9381
|
-
}
|
|
9382
|
-
function parseEnumDef2(def) {
|
|
9383
|
-
return {
|
|
9384
|
-
type: "string",
|
|
9385
|
-
enum: Array.from(def.values)
|
|
9386
|
-
};
|
|
9387
|
-
}
|
|
9388
|
-
var isJsonSchema7AllOfType2 = (type) => {
|
|
9389
|
-
if ("type" in type && type.type === "string")
|
|
9390
|
-
return false;
|
|
9391
|
-
return "allOf" in type;
|
|
9392
|
-
};
|
|
9393
|
-
function parseIntersectionDef2(def, refs) {
|
|
9394
|
-
const allOf = [
|
|
9395
|
-
parseDef2(def.left._def, {
|
|
9396
|
-
...refs,
|
|
9397
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
9398
|
-
}),
|
|
9399
|
-
parseDef2(def.right._def, {
|
|
9400
|
-
...refs,
|
|
9401
|
-
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
9402
|
-
})
|
|
9403
|
-
].filter((x) => !!x);
|
|
9404
|
-
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
|
|
9405
|
-
const mergedAllOf = [];
|
|
9406
|
-
allOf.forEach((schema) => {
|
|
9407
|
-
if (isJsonSchema7AllOfType2(schema)) {
|
|
9408
|
-
mergedAllOf.push(...schema.allOf);
|
|
9409
|
-
if (schema.unevaluatedProperties === void 0) {
|
|
9410
|
-
unevaluatedProperties = void 0;
|
|
9411
|
-
}
|
|
9412
|
-
} else {
|
|
9413
|
-
let nestedSchema = schema;
|
|
9414
|
-
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
9415
|
-
const { additionalProperties, ...rest } = schema;
|
|
9416
|
-
nestedSchema = rest;
|
|
9417
|
-
} else {
|
|
9418
|
-
unevaluatedProperties = void 0;
|
|
9419
|
-
}
|
|
9420
|
-
mergedAllOf.push(nestedSchema);
|
|
9421
|
-
}
|
|
9422
|
-
});
|
|
9423
|
-
return mergedAllOf.length ? {
|
|
9424
|
-
allOf: mergedAllOf,
|
|
9425
|
-
...unevaluatedProperties
|
|
9426
|
-
} : void 0;
|
|
9427
|
-
}
|
|
9428
|
-
function parseLiteralDef2(def, refs) {
|
|
9429
|
-
const parsedType = typeof def.value;
|
|
9430
|
-
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
9431
|
-
return {
|
|
9432
|
-
type: Array.isArray(def.value) ? "array" : "object"
|
|
9433
|
-
};
|
|
9434
|
-
}
|
|
9435
|
-
if (refs.target === "openApi3") {
|
|
9436
|
-
return {
|
|
9437
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
9438
|
-
enum: [def.value]
|
|
9439
|
-
};
|
|
9440
|
-
}
|
|
9441
|
-
return {
|
|
9442
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
9443
|
-
const: def.value
|
|
9444
|
-
};
|
|
9445
|
-
}
|
|
9446
|
-
var emojiRegex2 = void 0;
|
|
9447
|
-
var zodPatterns2 = {
|
|
9448
|
-
/**
|
|
9449
|
-
* `c` was changed to `[cC]` to replicate /i flag
|
|
9450
|
-
*/
|
|
9451
|
-
cuid: /^[cC][^\s-]{8,}$/,
|
|
9452
|
-
cuid2: /^[0-9a-z]+$/,
|
|
9453
|
-
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
9454
|
-
/**
|
|
9455
|
-
* `a-z` was added to replicate /i flag
|
|
9456
|
-
*/
|
|
9457
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
9458
|
-
/**
|
|
9459
|
-
* Constructed a valid Unicode RegExp
|
|
9460
|
-
*
|
|
9461
|
-
* Lazily instantiate since this type of regex isn't supported
|
|
9462
|
-
* in all envs (e.g. React Native).
|
|
9463
|
-
*
|
|
9464
|
-
* See:
|
|
9465
|
-
* https://github.com/colinhacks/zod/issues/2433
|
|
9466
|
-
* Fix in Zod:
|
|
9467
|
-
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
9468
|
-
*/
|
|
9469
|
-
emoji: () => {
|
|
9470
|
-
if (emojiRegex2 === void 0) {
|
|
9471
|
-
emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
9472
|
-
}
|
|
9473
|
-
return emojiRegex2;
|
|
9474
|
-
},
|
|
9475
|
-
/**
|
|
9476
|
-
* Unused
|
|
9477
|
-
*/
|
|
9478
|
-
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}$/,
|
|
9479
|
-
/**
|
|
9480
|
-
* Unused
|
|
9481
|
-
*/
|
|
9482
|
-
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])$/,
|
|
9483
|
-
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])$/,
|
|
9484
|
-
/**
|
|
9485
|
-
* Unused
|
|
9486
|
-
*/
|
|
9487
|
-
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})))$/,
|
|
9488
|
-
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])$/,
|
|
9489
|
-
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
9490
|
-
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
9491
|
-
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
9492
|
-
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
9493
|
-
};
|
|
9494
|
-
function parseStringDef2(def, refs) {
|
|
9495
|
-
const res = {
|
|
9496
|
-
type: "string"
|
|
9497
|
-
};
|
|
9498
|
-
if (def.checks) {
|
|
9499
|
-
for (const check of def.checks) {
|
|
9500
|
-
switch (check.kind) {
|
|
9501
|
-
case "min":
|
|
9502
|
-
setResponseValueAndErrors2(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
9503
|
-
break;
|
|
9504
|
-
case "max":
|
|
9505
|
-
setResponseValueAndErrors2(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
9506
|
-
break;
|
|
9507
|
-
case "email":
|
|
9508
|
-
switch (refs.emailStrategy) {
|
|
9509
|
-
case "format:email":
|
|
9510
|
-
addFormat2(res, "email", check.message, refs);
|
|
9511
|
-
break;
|
|
9512
|
-
case "format:idn-email":
|
|
9513
|
-
addFormat2(res, "idn-email", check.message, refs);
|
|
9514
|
-
break;
|
|
9515
|
-
case "pattern:zod":
|
|
9516
|
-
addPattern2(res, zodPatterns2.email, check.message, refs);
|
|
9517
|
-
break;
|
|
9518
|
-
}
|
|
9519
|
-
break;
|
|
9520
|
-
case "url":
|
|
9521
|
-
addFormat2(res, "uri", check.message, refs);
|
|
9522
|
-
break;
|
|
9523
|
-
case "uuid":
|
|
9524
|
-
addFormat2(res, "uuid", check.message, refs);
|
|
9525
|
-
break;
|
|
9526
|
-
case "regex":
|
|
9527
|
-
addPattern2(res, check.regex, check.message, refs);
|
|
9528
|
-
break;
|
|
9529
|
-
case "cuid":
|
|
9530
|
-
addPattern2(res, zodPatterns2.cuid, check.message, refs);
|
|
9531
|
-
break;
|
|
9532
|
-
case "cuid2":
|
|
9533
|
-
addPattern2(res, zodPatterns2.cuid2, check.message, refs);
|
|
9534
|
-
break;
|
|
9535
|
-
case "startsWith":
|
|
9536
|
-
addPattern2(res, RegExp(`^${escapeLiteralCheckValue2(check.value, refs)}`), check.message, refs);
|
|
9537
|
-
break;
|
|
9538
|
-
case "endsWith":
|
|
9539
|
-
addPattern2(res, RegExp(`${escapeLiteralCheckValue2(check.value, refs)}$`), check.message, refs);
|
|
9540
|
-
break;
|
|
9541
|
-
case "datetime":
|
|
9542
|
-
addFormat2(res, "date-time", check.message, refs);
|
|
9543
|
-
break;
|
|
9544
|
-
case "date":
|
|
9545
|
-
addFormat2(res, "date", check.message, refs);
|
|
9546
|
-
break;
|
|
9547
|
-
case "time":
|
|
9548
|
-
addFormat2(res, "time", check.message, refs);
|
|
9549
|
-
break;
|
|
9550
|
-
case "duration":
|
|
9551
|
-
addFormat2(res, "duration", check.message, refs);
|
|
9552
|
-
break;
|
|
9553
|
-
case "length":
|
|
9554
|
-
setResponseValueAndErrors2(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
9555
|
-
setResponseValueAndErrors2(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
9556
|
-
break;
|
|
9557
|
-
case "includes": {
|
|
9558
|
-
addPattern2(res, RegExp(escapeLiteralCheckValue2(check.value, refs)), check.message, refs);
|
|
9559
|
-
break;
|
|
9560
|
-
}
|
|
9561
|
-
case "ip": {
|
|
9562
|
-
if (check.version !== "v6") {
|
|
9563
|
-
addFormat2(res, "ipv4", check.message, refs);
|
|
9564
|
-
}
|
|
9565
|
-
if (check.version !== "v4") {
|
|
9566
|
-
addFormat2(res, "ipv6", check.message, refs);
|
|
9567
|
-
}
|
|
9568
|
-
break;
|
|
9569
|
-
}
|
|
9570
|
-
case "base64url":
|
|
9571
|
-
addPattern2(res, zodPatterns2.base64url, check.message, refs);
|
|
9572
|
-
break;
|
|
9573
|
-
case "jwt":
|
|
9574
|
-
addPattern2(res, zodPatterns2.jwt, check.message, refs);
|
|
9575
|
-
break;
|
|
9576
|
-
case "cidr": {
|
|
9577
|
-
if (check.version !== "v6") {
|
|
9578
|
-
addPattern2(res, zodPatterns2.ipv4Cidr, check.message, refs);
|
|
9579
|
-
}
|
|
9580
|
-
if (check.version !== "v4") {
|
|
9581
|
-
addPattern2(res, zodPatterns2.ipv6Cidr, check.message, refs);
|
|
9582
|
-
}
|
|
9583
|
-
break;
|
|
9584
|
-
}
|
|
9585
|
-
case "emoji":
|
|
9586
|
-
addPattern2(res, zodPatterns2.emoji(), check.message, refs);
|
|
9587
|
-
break;
|
|
9588
|
-
case "ulid": {
|
|
9589
|
-
addPattern2(res, zodPatterns2.ulid, check.message, refs);
|
|
9590
|
-
break;
|
|
9591
|
-
}
|
|
9592
|
-
case "base64": {
|
|
9593
|
-
switch (refs.base64Strategy) {
|
|
9594
|
-
case "format:binary": {
|
|
9595
|
-
addFormat2(res, "binary", check.message, refs);
|
|
9596
|
-
break;
|
|
9597
|
-
}
|
|
9598
|
-
case "contentEncoding:base64": {
|
|
9599
|
-
setResponseValueAndErrors2(res, "contentEncoding", "base64", check.message, refs);
|
|
9600
|
-
break;
|
|
9601
|
-
}
|
|
9602
|
-
case "pattern:zod": {
|
|
9603
|
-
addPattern2(res, zodPatterns2.base64, check.message, refs);
|
|
9604
|
-
break;
|
|
9605
|
-
}
|
|
9606
|
-
}
|
|
9607
|
-
break;
|
|
9608
|
-
}
|
|
9609
|
-
case "nanoid": {
|
|
9610
|
-
addPattern2(res, zodPatterns2.nanoid, check.message, refs);
|
|
9611
|
-
}
|
|
9612
|
-
}
|
|
9613
|
-
}
|
|
9614
|
-
}
|
|
9615
|
-
return res;
|
|
9616
|
-
}
|
|
9617
|
-
function escapeLiteralCheckValue2(literal, refs) {
|
|
9618
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal) : literal;
|
|
9619
|
-
}
|
|
9620
|
-
var ALPHA_NUMERIC2 = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
9621
|
-
function escapeNonAlphaNumeric2(source) {
|
|
9622
|
-
let result = "";
|
|
9623
|
-
for (let i = 0; i < source.length; i++) {
|
|
9624
|
-
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
9625
|
-
result += "\\";
|
|
9626
|
-
}
|
|
9627
|
-
result += source[i];
|
|
9628
|
-
}
|
|
9629
|
-
return result;
|
|
9630
|
-
}
|
|
9631
|
-
function addFormat2(schema, value, message, refs) {
|
|
9632
|
-
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
9633
|
-
if (!schema.anyOf) {
|
|
9634
|
-
schema.anyOf = [];
|
|
9635
|
-
}
|
|
9636
|
-
if (schema.format) {
|
|
9637
|
-
schema.anyOf.push({
|
|
9638
|
-
format: schema.format,
|
|
9639
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
9640
|
-
errorMessage: { format: schema.errorMessage.format }
|
|
9641
|
-
}
|
|
9642
|
-
});
|
|
9643
|
-
delete schema.format;
|
|
9644
|
-
if (schema.errorMessage) {
|
|
9645
|
-
delete schema.errorMessage.format;
|
|
9646
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
9647
|
-
delete schema.errorMessage;
|
|
9648
|
-
}
|
|
9649
|
-
}
|
|
9650
|
-
}
|
|
9651
|
-
schema.anyOf.push({
|
|
9652
|
-
format: value,
|
|
9653
|
-
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
9654
|
-
});
|
|
9655
|
-
} else {
|
|
9656
|
-
setResponseValueAndErrors2(schema, "format", value, message, refs);
|
|
9657
|
-
}
|
|
9658
|
-
}
|
|
9659
|
-
function addPattern2(schema, regex, message, refs) {
|
|
9660
|
-
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
9661
|
-
if (!schema.allOf) {
|
|
9662
|
-
schema.allOf = [];
|
|
9663
|
-
}
|
|
9664
|
-
if (schema.pattern) {
|
|
9665
|
-
schema.allOf.push({
|
|
9666
|
-
pattern: schema.pattern,
|
|
9667
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
9668
|
-
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
9669
|
-
}
|
|
9670
|
-
});
|
|
9671
|
-
delete schema.pattern;
|
|
9672
|
-
if (schema.errorMessage) {
|
|
9673
|
-
delete schema.errorMessage.pattern;
|
|
9674
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
9675
|
-
delete schema.errorMessage;
|
|
9676
|
-
}
|
|
9677
|
-
}
|
|
9678
|
-
}
|
|
9679
|
-
schema.allOf.push({
|
|
9680
|
-
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
9681
|
-
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
9682
|
-
});
|
|
9683
|
-
} else {
|
|
9684
|
-
setResponseValueAndErrors2(schema, "pattern", stringifyRegExpWithFlags2(regex, refs), message, refs);
|
|
9685
|
-
}
|
|
9686
|
-
}
|
|
9687
|
-
function stringifyRegExpWithFlags2(regex, refs) {
|
|
9688
|
-
if (!refs.applyRegexFlags || !regex.flags) {
|
|
9689
|
-
return regex.source;
|
|
9690
|
-
}
|
|
9691
|
-
const flags = {
|
|
9692
|
-
i: regex.flags.includes("i"),
|
|
9693
|
-
m: regex.flags.includes("m"),
|
|
9694
|
-
s: regex.flags.includes("s")
|
|
9695
|
-
// `.` matches newlines
|
|
9696
|
-
};
|
|
9697
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
9698
|
-
let pattern = "";
|
|
9699
|
-
let isEscaped = false;
|
|
9700
|
-
let inCharGroup = false;
|
|
9701
|
-
let inCharRange = false;
|
|
9702
|
-
for (let i = 0; i < source.length; i++) {
|
|
9703
|
-
if (isEscaped) {
|
|
9704
|
-
pattern += source[i];
|
|
9705
|
-
isEscaped = false;
|
|
9706
|
-
continue;
|
|
9707
|
-
}
|
|
9708
|
-
if (flags.i) {
|
|
9709
|
-
if (inCharGroup) {
|
|
9710
|
-
if (source[i].match(/[a-z]/)) {
|
|
9711
|
-
if (inCharRange) {
|
|
9712
|
-
pattern += source[i];
|
|
9713
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
9714
|
-
inCharRange = false;
|
|
9715
|
-
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
9716
|
-
pattern += source[i];
|
|
9717
|
-
inCharRange = true;
|
|
9718
|
-
} else {
|
|
9719
|
-
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
9720
|
-
}
|
|
9721
|
-
continue;
|
|
9722
|
-
}
|
|
9723
|
-
} else if (source[i].match(/[a-z]/)) {
|
|
9724
|
-
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
9725
|
-
continue;
|
|
9726
|
-
}
|
|
9727
|
-
}
|
|
9728
|
-
if (flags.m) {
|
|
9729
|
-
if (source[i] === "^") {
|
|
9730
|
-
pattern += `(^|(?<=[\r
|
|
9731
|
-
]))`;
|
|
9732
|
-
continue;
|
|
9733
|
-
} else if (source[i] === "$") {
|
|
9734
|
-
pattern += `($|(?=[\r
|
|
9735
|
-
]))`;
|
|
9736
|
-
continue;
|
|
9737
|
-
}
|
|
9738
|
-
}
|
|
9739
|
-
if (flags.s && source[i] === ".") {
|
|
9740
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
9741
|
-
` : `[${source[i]}\r
|
|
9742
|
-
]`;
|
|
9743
|
-
continue;
|
|
9744
|
-
}
|
|
9745
|
-
pattern += source[i];
|
|
9746
|
-
if (source[i] === "\\") {
|
|
9747
|
-
isEscaped = true;
|
|
9748
|
-
} else if (inCharGroup && source[i] === "]") {
|
|
9749
|
-
inCharGroup = false;
|
|
9750
|
-
} else if (!inCharGroup && source[i] === "[") {
|
|
9751
|
-
inCharGroup = true;
|
|
9752
|
-
}
|
|
9753
|
-
}
|
|
9754
|
-
return pattern;
|
|
9755
|
-
}
|
|
9756
|
-
function parseRecordDef2(def, refs) {
|
|
9757
|
-
if (refs.target === "openAi") {
|
|
9758
|
-
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
9759
|
-
}
|
|
9760
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
9761
|
-
return {
|
|
9762
|
-
type: "object",
|
|
9763
|
-
required: def.keyType._def.values,
|
|
9764
|
-
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
9765
|
-
...acc,
|
|
9766
|
-
[key]: parseDef2(def.valueType._def, {
|
|
9767
|
-
...refs,
|
|
9768
|
-
currentPath: [...refs.currentPath, "properties", key]
|
|
9769
|
-
}) ?? parseAnyDef2(refs)
|
|
9770
|
-
}), {}),
|
|
9771
|
-
additionalProperties: refs.rejectedAdditionalProperties
|
|
9772
|
-
};
|
|
9773
|
-
}
|
|
9774
|
-
const schema = {
|
|
9775
|
-
type: "object",
|
|
9776
|
-
additionalProperties: parseDef2(def.valueType._def, {
|
|
9777
|
-
...refs,
|
|
9778
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
9779
|
-
}) ?? refs.allowedAdditionalProperties
|
|
9780
|
-
};
|
|
9781
|
-
if (refs.target === "openApi3") {
|
|
9782
|
-
return schema;
|
|
9783
|
-
}
|
|
9784
|
-
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
9785
|
-
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
9786
|
-
return {
|
|
9787
|
-
...schema,
|
|
9788
|
-
propertyNames: keyType
|
|
9789
|
-
};
|
|
9790
|
-
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
9791
|
-
return {
|
|
9792
|
-
...schema,
|
|
9793
|
-
propertyNames: {
|
|
9794
|
-
enum: def.keyType._def.values
|
|
9795
|
-
}
|
|
9796
|
-
};
|
|
9797
|
-
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
9798
|
-
const { type, ...keyType } = parseBrandedDef2(def.keyType._def, refs);
|
|
9799
|
-
return {
|
|
9800
|
-
...schema,
|
|
9801
|
-
propertyNames: keyType
|
|
9802
|
-
};
|
|
9803
|
-
}
|
|
9804
|
-
return schema;
|
|
9805
|
-
}
|
|
9806
|
-
function parseMapDef2(def, refs) {
|
|
9807
|
-
if (refs.mapStrategy === "record") {
|
|
9808
|
-
return parseRecordDef2(def, refs);
|
|
9809
|
-
}
|
|
9810
|
-
const keys = parseDef2(def.keyType._def, {
|
|
9811
|
-
...refs,
|
|
9812
|
-
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
9813
|
-
}) || parseAnyDef2(refs);
|
|
9814
|
-
const values = parseDef2(def.valueType._def, {
|
|
9815
|
-
...refs,
|
|
9816
|
-
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
9817
|
-
}) || parseAnyDef2(refs);
|
|
9818
|
-
return {
|
|
9819
|
-
type: "array",
|
|
9820
|
-
maxItems: 125,
|
|
9821
|
-
items: {
|
|
9822
|
-
type: "array",
|
|
9823
|
-
items: [keys, values],
|
|
9824
|
-
minItems: 2,
|
|
9825
|
-
maxItems: 2
|
|
9826
|
-
}
|
|
9827
|
-
};
|
|
9828
|
-
}
|
|
9829
|
-
function parseNativeEnumDef2(def) {
|
|
9830
|
-
const object2 = def.values;
|
|
9831
|
-
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
9832
|
-
return typeof object2[object2[key]] !== "number";
|
|
9833
|
-
});
|
|
9834
|
-
const actualValues = actualKeys.map((key) => object2[key]);
|
|
9835
|
-
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
9836
|
-
return {
|
|
9837
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
9838
|
-
enum: actualValues
|
|
9839
|
-
};
|
|
9840
|
-
}
|
|
9841
|
-
function parseNeverDef2(refs) {
|
|
9842
|
-
return refs.target === "openAi" ? void 0 : {
|
|
9843
|
-
not: parseAnyDef2({
|
|
9844
|
-
...refs,
|
|
9845
|
-
currentPath: [...refs.currentPath, "not"]
|
|
9846
|
-
})
|
|
9847
|
-
};
|
|
9848
|
-
}
|
|
9849
|
-
function parseNullDef2(refs) {
|
|
9850
|
-
return refs.target === "openApi3" ? {
|
|
9851
|
-
enum: ["null"],
|
|
9852
|
-
nullable: true
|
|
9853
|
-
} : {
|
|
9854
|
-
type: "null"
|
|
9855
|
-
};
|
|
9856
|
-
}
|
|
9857
|
-
var primitiveMappings2 = {
|
|
9858
|
-
ZodString: "string",
|
|
9859
|
-
ZodNumber: "number",
|
|
9860
|
-
ZodBigInt: "integer",
|
|
9861
|
-
ZodBoolean: "boolean",
|
|
9862
|
-
ZodNull: "null"
|
|
9863
|
-
};
|
|
9864
|
-
function parseUnionDef2(def, refs) {
|
|
9865
|
-
if (refs.target === "openApi3")
|
|
9866
|
-
return asAnyOf2(def, refs);
|
|
9867
|
-
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
9868
|
-
if (options.every((x) => x._def.typeName in primitiveMappings2 && (!x._def.checks || !x._def.checks.length))) {
|
|
9869
|
-
const types = options.reduce((types2, x) => {
|
|
9870
|
-
const type = primitiveMappings2[x._def.typeName];
|
|
9871
|
-
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
9872
|
-
}, []);
|
|
9873
|
-
return {
|
|
9874
|
-
type: types.length > 1 ? types : types[0]
|
|
9875
|
-
};
|
|
9876
|
-
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
9877
|
-
const types = options.reduce((acc, x) => {
|
|
9878
|
-
const type = typeof x._def.value;
|
|
9879
|
-
switch (type) {
|
|
9880
|
-
case "string":
|
|
9881
|
-
case "number":
|
|
9882
|
-
case "boolean":
|
|
9883
|
-
return [...acc, type];
|
|
9884
|
-
case "bigint":
|
|
9885
|
-
return [...acc, "integer"];
|
|
9886
|
-
case "object":
|
|
9887
|
-
if (x._def.value === null)
|
|
9888
|
-
return [...acc, "null"];
|
|
9889
|
-
case "symbol":
|
|
9890
|
-
case "undefined":
|
|
9891
|
-
case "function":
|
|
9892
|
-
default:
|
|
9893
|
-
return acc;
|
|
9894
|
-
}
|
|
9895
|
-
}, []);
|
|
9896
|
-
if (types.length === options.length) {
|
|
9897
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
9898
|
-
return {
|
|
9899
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
9900
|
-
enum: options.reduce((acc, x) => {
|
|
9901
|
-
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
9902
|
-
}, [])
|
|
9903
|
-
};
|
|
9904
|
-
}
|
|
9905
|
-
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
9906
|
-
return {
|
|
9907
|
-
type: "string",
|
|
9908
|
-
enum: options.reduce((acc, x) => [
|
|
9909
|
-
...acc,
|
|
9910
|
-
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
9911
|
-
], [])
|
|
9912
|
-
};
|
|
9913
|
-
}
|
|
9914
|
-
return asAnyOf2(def, refs);
|
|
9915
|
-
}
|
|
9916
|
-
var asAnyOf2 = (def, refs) => {
|
|
9917
|
-
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef2(x._def, {
|
|
9918
|
-
...refs,
|
|
9919
|
-
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
9920
|
-
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
9921
|
-
return anyOf.length ? { anyOf } : void 0;
|
|
9922
|
-
};
|
|
9923
|
-
function parseNullableDef2(def, refs) {
|
|
9924
|
-
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
9925
|
-
if (refs.target === "openApi3") {
|
|
9926
|
-
return {
|
|
9927
|
-
type: primitiveMappings2[def.innerType._def.typeName],
|
|
9928
|
-
nullable: true
|
|
9929
|
-
};
|
|
9930
|
-
}
|
|
9931
|
-
return {
|
|
9932
|
-
type: [
|
|
9933
|
-
primitiveMappings2[def.innerType._def.typeName],
|
|
9934
|
-
"null"
|
|
9935
|
-
]
|
|
9936
|
-
};
|
|
9937
|
-
}
|
|
9938
|
-
if (refs.target === "openApi3") {
|
|
9939
|
-
const base2 = parseDef2(def.innerType._def, {
|
|
9940
|
-
...refs,
|
|
9941
|
-
currentPath: [...refs.currentPath]
|
|
9942
|
-
});
|
|
9943
|
-
if (base2 && "$ref" in base2)
|
|
9944
|
-
return { allOf: [base2], nullable: true };
|
|
9945
|
-
return base2 && { ...base2, nullable: true };
|
|
9946
|
-
}
|
|
9947
|
-
const base = parseDef2(def.innerType._def, {
|
|
9948
|
-
...refs,
|
|
9949
|
-
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
9950
|
-
});
|
|
9951
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
9952
|
-
}
|
|
9953
|
-
function parseNumberDef2(def, refs) {
|
|
9954
|
-
const res = {
|
|
9955
|
-
type: "number"
|
|
9956
|
-
};
|
|
9957
|
-
if (!def.checks)
|
|
9958
|
-
return res;
|
|
9959
|
-
for (const check of def.checks) {
|
|
9960
|
-
switch (check.kind) {
|
|
9961
|
-
case "int":
|
|
9962
|
-
res.type = "integer";
|
|
9963
|
-
addErrorMessage2(res, "type", check.message, refs);
|
|
9964
|
-
break;
|
|
9965
|
-
case "min":
|
|
9966
|
-
if (refs.target === "jsonSchema7") {
|
|
9967
|
-
if (check.inclusive) {
|
|
9968
|
-
setResponseValueAndErrors2(res, "minimum", check.value, check.message, refs);
|
|
9969
|
-
} else {
|
|
9970
|
-
setResponseValueAndErrors2(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
9971
|
-
}
|
|
9972
|
-
} else {
|
|
9973
|
-
if (!check.inclusive) {
|
|
9974
|
-
res.exclusiveMinimum = true;
|
|
9975
|
-
}
|
|
9976
|
-
setResponseValueAndErrors2(res, "minimum", check.value, check.message, refs);
|
|
9977
|
-
}
|
|
9978
|
-
break;
|
|
9979
|
-
case "max":
|
|
9980
|
-
if (refs.target === "jsonSchema7") {
|
|
9981
|
-
if (check.inclusive) {
|
|
9982
|
-
setResponseValueAndErrors2(res, "maximum", check.value, check.message, refs);
|
|
9983
|
-
} else {
|
|
9984
|
-
setResponseValueAndErrors2(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
9985
|
-
}
|
|
9986
|
-
} else {
|
|
9987
|
-
if (!check.inclusive) {
|
|
9988
|
-
res.exclusiveMaximum = true;
|
|
9989
|
-
}
|
|
9990
|
-
setResponseValueAndErrors2(res, "maximum", check.value, check.message, refs);
|
|
9991
|
-
}
|
|
9992
|
-
break;
|
|
9993
|
-
case "multipleOf":
|
|
9994
|
-
setResponseValueAndErrors2(res, "multipleOf", check.value, check.message, refs);
|
|
9995
|
-
break;
|
|
9996
|
-
}
|
|
9997
|
-
}
|
|
9998
|
-
return res;
|
|
9999
|
-
}
|
|
10000
|
-
function parseObjectDef2(def, refs) {
|
|
10001
|
-
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
10002
|
-
const result = {
|
|
10003
|
-
type: "object",
|
|
10004
|
-
properties: {}
|
|
10005
|
-
};
|
|
10006
|
-
const required = [];
|
|
10007
|
-
const shape = def.shape();
|
|
10008
|
-
for (const propName in shape) {
|
|
10009
|
-
let propDef = shape[propName];
|
|
10010
|
-
if (propDef === void 0 || propDef._def === void 0) {
|
|
10011
|
-
continue;
|
|
10012
|
-
}
|
|
10013
|
-
let propOptional = safeIsOptional2(propDef);
|
|
10014
|
-
if (propOptional && forceOptionalIntoNullable) {
|
|
10015
|
-
if (propDef._def.typeName === "ZodOptional") {
|
|
10016
|
-
propDef = propDef._def.innerType;
|
|
10017
|
-
}
|
|
10018
|
-
if (!propDef.isNullable()) {
|
|
10019
|
-
propDef = propDef.nullable();
|
|
10020
|
-
}
|
|
10021
|
-
propOptional = false;
|
|
10022
|
-
}
|
|
10023
|
-
const parsedDef = parseDef2(propDef._def, {
|
|
10024
|
-
...refs,
|
|
10025
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
|
10026
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
|
10027
|
-
});
|
|
10028
|
-
if (parsedDef === void 0) {
|
|
10029
|
-
continue;
|
|
10030
|
-
}
|
|
10031
|
-
result.properties[propName] = parsedDef;
|
|
10032
|
-
if (!propOptional) {
|
|
10033
|
-
required.push(propName);
|
|
10034
|
-
}
|
|
10035
|
-
}
|
|
10036
|
-
if (required.length) {
|
|
10037
|
-
result.required = required;
|
|
10038
|
-
}
|
|
10039
|
-
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
10040
|
-
if (additionalProperties !== void 0) {
|
|
10041
|
-
result.additionalProperties = additionalProperties;
|
|
10042
|
-
}
|
|
10043
|
-
return result;
|
|
10044
|
-
}
|
|
10045
|
-
function decideAdditionalProperties2(def, refs) {
|
|
10046
|
-
if (def.catchall._def.typeName !== "ZodNever") {
|
|
10047
|
-
return parseDef2(def.catchall._def, {
|
|
10048
|
-
...refs,
|
|
10049
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10050
|
-
});
|
|
10051
|
-
}
|
|
10052
|
-
switch (def.unknownKeys) {
|
|
10053
|
-
case "passthrough":
|
|
10054
|
-
return refs.allowedAdditionalProperties;
|
|
10055
|
-
case "strict":
|
|
10056
|
-
return refs.rejectedAdditionalProperties;
|
|
10057
|
-
case "strip":
|
|
10058
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
10059
|
-
}
|
|
10060
|
-
}
|
|
10061
|
-
function safeIsOptional2(schema) {
|
|
10062
|
-
try {
|
|
10063
|
-
return schema.isOptional();
|
|
10064
|
-
} catch {
|
|
10065
|
-
return true;
|
|
10066
|
-
}
|
|
10067
|
-
}
|
|
10068
|
-
var parseOptionalDef2 = (def, refs) => {
|
|
10069
|
-
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
10070
|
-
return parseDef2(def.innerType._def, refs);
|
|
10071
|
-
}
|
|
10072
|
-
const innerSchema = parseDef2(def.innerType._def, {
|
|
10073
|
-
...refs,
|
|
10074
|
-
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
10075
|
-
});
|
|
10076
|
-
return innerSchema ? {
|
|
10077
|
-
anyOf: [
|
|
10078
|
-
{
|
|
10079
|
-
not: parseAnyDef2(refs)
|
|
10080
|
-
},
|
|
10081
|
-
innerSchema
|
|
10082
|
-
]
|
|
10083
|
-
} : parseAnyDef2(refs);
|
|
10084
|
-
};
|
|
10085
|
-
var parsePipelineDef2 = (def, refs) => {
|
|
10086
|
-
if (refs.pipeStrategy === "input") {
|
|
10087
|
-
return parseDef2(def.in._def, refs);
|
|
10088
|
-
} else if (refs.pipeStrategy === "output") {
|
|
10089
|
-
return parseDef2(def.out._def, refs);
|
|
10090
|
-
}
|
|
10091
|
-
const a = parseDef2(def.in._def, {
|
|
10092
|
-
...refs,
|
|
10093
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
10094
|
-
});
|
|
10095
|
-
const b = parseDef2(def.out._def, {
|
|
10096
|
-
...refs,
|
|
10097
|
-
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
10098
|
-
});
|
|
10099
|
-
return {
|
|
10100
|
-
allOf: [a, b].filter((x) => x !== void 0)
|
|
10101
|
-
};
|
|
10102
|
-
};
|
|
10103
|
-
function parsePromiseDef2(def, refs) {
|
|
10104
|
-
return parseDef2(def.type._def, refs);
|
|
10105
|
-
}
|
|
10106
|
-
function parseSetDef2(def, refs) {
|
|
10107
|
-
const items = parseDef2(def.valueType._def, {
|
|
10108
|
-
...refs,
|
|
10109
|
-
currentPath: [...refs.currentPath, "items"]
|
|
10110
|
-
});
|
|
10111
|
-
const schema = {
|
|
10112
|
-
type: "array",
|
|
10113
|
-
uniqueItems: true,
|
|
10114
|
-
items
|
|
10115
|
-
};
|
|
10116
|
-
if (def.minSize) {
|
|
10117
|
-
setResponseValueAndErrors2(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
10118
|
-
}
|
|
10119
|
-
if (def.maxSize) {
|
|
10120
|
-
setResponseValueAndErrors2(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
10121
|
-
}
|
|
10122
|
-
return schema;
|
|
10123
|
-
}
|
|
10124
|
-
function parseTupleDef2(def, refs) {
|
|
10125
|
-
if (def.rest) {
|
|
10126
|
-
return {
|
|
10127
|
-
type: "array",
|
|
10128
|
-
minItems: def.items.length,
|
|
10129
|
-
items: def.items.map((x, i) => parseDef2(x._def, {
|
|
10130
|
-
...refs,
|
|
10131
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10132
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
10133
|
-
additionalItems: parseDef2(def.rest._def, {
|
|
10134
|
-
...refs,
|
|
10135
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
10136
|
-
})
|
|
10137
|
-
};
|
|
10138
|
-
} else {
|
|
10139
|
-
return {
|
|
10140
|
-
type: "array",
|
|
10141
|
-
minItems: def.items.length,
|
|
10142
|
-
maxItems: def.items.length,
|
|
10143
|
-
items: def.items.map((x, i) => parseDef2(x._def, {
|
|
10144
|
-
...refs,
|
|
10145
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10146
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
10147
|
-
};
|
|
10148
|
-
}
|
|
10149
|
-
}
|
|
10150
|
-
function parseUndefinedDef2(refs) {
|
|
10151
|
-
return {
|
|
10152
|
-
not: parseAnyDef2(refs)
|
|
10153
|
-
};
|
|
10154
|
-
}
|
|
10155
|
-
function parseUnknownDef2(refs) {
|
|
10156
|
-
return parseAnyDef2(refs);
|
|
10157
|
-
}
|
|
10158
|
-
var parseReadonlyDef2 = (def, refs) => {
|
|
10159
|
-
return parseDef2(def.innerType._def, refs);
|
|
10160
|
-
};
|
|
10161
|
-
var selectParser2 = (def, typeName, refs) => {
|
|
10162
|
-
switch (typeName) {
|
|
10163
|
-
case ZodFirstPartyTypeKind.ZodString:
|
|
10164
|
-
return parseStringDef2(def, refs);
|
|
10165
|
-
case ZodFirstPartyTypeKind.ZodNumber:
|
|
10166
|
-
return parseNumberDef2(def, refs);
|
|
10167
|
-
case ZodFirstPartyTypeKind.ZodObject:
|
|
10168
|
-
return parseObjectDef2(def, refs);
|
|
10169
|
-
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
10170
|
-
return parseBigintDef2(def, refs);
|
|
10171
|
-
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
10172
|
-
return parseBooleanDef2();
|
|
10173
|
-
case ZodFirstPartyTypeKind.ZodDate:
|
|
10174
|
-
return parseDateDef2(def, refs);
|
|
10175
|
-
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
10176
|
-
return parseUndefinedDef2(refs);
|
|
10177
|
-
case ZodFirstPartyTypeKind.ZodNull:
|
|
10178
|
-
return parseNullDef2(refs);
|
|
10179
|
-
case ZodFirstPartyTypeKind.ZodArray:
|
|
10180
|
-
return parseArrayDef2(def, refs);
|
|
10181
|
-
case ZodFirstPartyTypeKind.ZodUnion:
|
|
10182
|
-
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
10183
|
-
return parseUnionDef2(def, refs);
|
|
10184
|
-
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
10185
|
-
return parseIntersectionDef2(def, refs);
|
|
10186
|
-
case ZodFirstPartyTypeKind.ZodTuple:
|
|
10187
|
-
return parseTupleDef2(def, refs);
|
|
10188
|
-
case ZodFirstPartyTypeKind.ZodRecord:
|
|
10189
|
-
return parseRecordDef2(def, refs);
|
|
10190
|
-
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
10191
|
-
return parseLiteralDef2(def, refs);
|
|
10192
|
-
case ZodFirstPartyTypeKind.ZodEnum:
|
|
10193
|
-
return parseEnumDef2(def);
|
|
10194
|
-
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
10195
|
-
return parseNativeEnumDef2(def);
|
|
10196
|
-
case ZodFirstPartyTypeKind.ZodNullable:
|
|
10197
|
-
return parseNullableDef2(def, refs);
|
|
10198
|
-
case ZodFirstPartyTypeKind.ZodOptional:
|
|
10199
|
-
return parseOptionalDef2(def, refs);
|
|
10200
|
-
case ZodFirstPartyTypeKind.ZodMap:
|
|
10201
|
-
return parseMapDef2(def, refs);
|
|
10202
|
-
case ZodFirstPartyTypeKind.ZodSet:
|
|
10203
|
-
return parseSetDef2(def, refs);
|
|
10204
|
-
case ZodFirstPartyTypeKind.ZodLazy:
|
|
10205
|
-
return () => def.getter()._def;
|
|
10206
|
-
case ZodFirstPartyTypeKind.ZodPromise:
|
|
10207
|
-
return parsePromiseDef2(def, refs);
|
|
10208
|
-
case ZodFirstPartyTypeKind.ZodNaN:
|
|
10209
|
-
case ZodFirstPartyTypeKind.ZodNever:
|
|
10210
|
-
return parseNeverDef2(refs);
|
|
10211
|
-
case ZodFirstPartyTypeKind.ZodEffects:
|
|
10212
|
-
return parseEffectsDef2(def, refs);
|
|
10213
|
-
case ZodFirstPartyTypeKind.ZodAny:
|
|
10214
|
-
return parseAnyDef2(refs);
|
|
10215
|
-
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
10216
|
-
return parseUnknownDef2(refs);
|
|
10217
|
-
case ZodFirstPartyTypeKind.ZodDefault:
|
|
10218
|
-
return parseDefaultDef2(def, refs);
|
|
10219
|
-
case ZodFirstPartyTypeKind.ZodBranded:
|
|
10220
|
-
return parseBrandedDef2(def, refs);
|
|
10221
|
-
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
10222
|
-
return parseReadonlyDef2(def, refs);
|
|
10223
|
-
case ZodFirstPartyTypeKind.ZodCatch:
|
|
10224
|
-
return parseCatchDef2(def, refs);
|
|
10225
|
-
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
10226
|
-
return parsePipelineDef2(def, refs);
|
|
10227
|
-
case ZodFirstPartyTypeKind.ZodFunction:
|
|
10228
|
-
case ZodFirstPartyTypeKind.ZodVoid:
|
|
10229
|
-
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
10230
|
-
return void 0;
|
|
10231
|
-
default:
|
|
10232
|
-
return /* @__PURE__ */ ((_) => void 0)();
|
|
10233
|
-
}
|
|
10234
|
-
};
|
|
10235
|
-
function parseDef2(def, refs, forceResolution = false) {
|
|
10236
|
-
const seenItem = refs.seen.get(def);
|
|
10237
|
-
if (refs.override) {
|
|
10238
|
-
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
10239
|
-
if (overrideResult !== ignoreOverride2) {
|
|
10240
|
-
return overrideResult;
|
|
10241
|
-
}
|
|
10242
|
-
}
|
|
10243
|
-
if (seenItem && !forceResolution) {
|
|
10244
|
-
const seenSchema = get$ref2(seenItem, refs);
|
|
10245
|
-
if (seenSchema !== void 0) {
|
|
10246
|
-
return seenSchema;
|
|
10247
|
-
}
|
|
10248
|
-
}
|
|
10249
|
-
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
10250
|
-
refs.seen.set(def, newItem);
|
|
10251
|
-
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
10252
|
-
const jsonSchema2 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10253
|
-
if (jsonSchema2) {
|
|
10254
|
-
addMeta2(def, refs, jsonSchema2);
|
|
10255
|
-
}
|
|
10256
|
-
if (refs.postProcess) {
|
|
10257
|
-
const postProcessResult = refs.postProcess(jsonSchema2, def, refs);
|
|
10258
|
-
newItem.jsonSchema = jsonSchema2;
|
|
10259
|
-
return postProcessResult;
|
|
10260
|
-
}
|
|
10261
|
-
newItem.jsonSchema = jsonSchema2;
|
|
10262
|
-
return jsonSchema2;
|
|
10263
|
-
}
|
|
10264
|
-
var get$ref2 = (item, refs) => {
|
|
10265
|
-
switch (refs.$refStrategy) {
|
|
10266
|
-
case "root":
|
|
10267
|
-
return { $ref: item.path.join("/") };
|
|
10268
|
-
case "relative":
|
|
10269
|
-
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
10270
|
-
case "none":
|
|
10271
|
-
case "seen": {
|
|
10272
|
-
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
10273
|
-
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
10274
|
-
return parseAnyDef2(refs);
|
|
10275
|
-
}
|
|
10276
|
-
return refs.$refStrategy === "seen" ? parseAnyDef2(refs) : void 0;
|
|
10277
|
-
}
|
|
10278
|
-
}
|
|
10279
|
-
};
|
|
10280
|
-
var addMeta2 = (def, refs, jsonSchema2) => {
|
|
10281
|
-
if (def.description) {
|
|
10282
|
-
jsonSchema2.description = def.description;
|
|
10283
|
-
if (refs.markdownDescription) {
|
|
10284
|
-
jsonSchema2.markdownDescription = def.description;
|
|
10285
|
-
}
|
|
10286
|
-
}
|
|
10287
|
-
return jsonSchema2;
|
|
10288
|
-
};
|
|
10289
|
-
var zodToJsonSchema22 = (schema, options) => {
|
|
10290
|
-
const refs = getRefs2(options);
|
|
10291
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name18, schema2]) => ({
|
|
10292
|
-
...acc,
|
|
10293
|
-
[name18]: parseDef2(schema2._def, {
|
|
10294
|
-
...refs,
|
|
10295
|
-
currentPath: [...refs.basePath, refs.definitionPath, name18]
|
|
10296
|
-
}, true) ?? parseAnyDef2(refs)
|
|
10297
|
-
}), {}) : void 0;
|
|
10298
|
-
const name17 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
10299
|
-
const main = parseDef2(schema._def, name17 === void 0 ? refs : {
|
|
10300
|
-
...refs,
|
|
10301
|
-
currentPath: [...refs.basePath, refs.definitionPath, name17]
|
|
10302
|
-
}, false) ?? parseAnyDef2(refs);
|
|
10303
|
-
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10304
|
-
if (title !== void 0) {
|
|
10305
|
-
main.title = title;
|
|
10306
|
-
}
|
|
10307
|
-
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
10308
|
-
if (!definitions) {
|
|
10309
|
-
definitions = {};
|
|
10310
|
-
}
|
|
10311
|
-
if (!definitions[refs.openAiAnyTypeName]) {
|
|
10312
|
-
definitions[refs.openAiAnyTypeName] = {
|
|
10313
|
-
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
|
|
10314
|
-
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
10315
|
-
items: {
|
|
10316
|
-
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
10317
|
-
...refs.basePath,
|
|
10318
|
-
refs.definitionPath,
|
|
10319
|
-
refs.openAiAnyTypeName
|
|
10320
|
-
].join("/")
|
|
10321
|
-
}
|
|
10322
|
-
};
|
|
10323
|
-
}
|
|
10324
|
-
}
|
|
10325
|
-
const combined = name17 === void 0 ? definitions ? {
|
|
10326
|
-
...main,
|
|
10327
|
-
[refs.definitionPath]: definitions
|
|
10328
|
-
} : main : {
|
|
10329
|
-
$ref: [
|
|
10330
|
-
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10331
|
-
refs.definitionPath,
|
|
10332
|
-
name17
|
|
10333
|
-
].join("/"),
|
|
10334
|
-
[refs.definitionPath]: {
|
|
10335
|
-
...definitions,
|
|
10336
|
-
[name17]: main
|
|
10337
|
-
}
|
|
10338
|
-
};
|
|
10339
|
-
if (refs.target === "jsonSchema7") {
|
|
10340
|
-
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10341
|
-
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
10342
|
-
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
10343
|
-
}
|
|
10344
|
-
if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
|
|
10345
|
-
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
10346
|
-
}
|
|
10347
|
-
return combined;
|
|
10348
|
-
};
|
|
10349
|
-
var esm_default2 = zodToJsonSchema22;
|
|
10350
|
-
function fixJson(input) {
|
|
10351
|
-
const stack = ["ROOT"];
|
|
10352
|
-
let lastValidIndex = -1;
|
|
10353
|
-
let literalStart = null;
|
|
10354
|
-
function processValueStart(char, i, swapState) {
|
|
10355
|
-
{
|
|
10356
|
-
switch (char) {
|
|
10357
|
-
case '"': {
|
|
10358
|
-
lastValidIndex = i;
|
|
10359
|
-
stack.pop();
|
|
10360
|
-
stack.push(swapState);
|
|
10361
|
-
stack.push("INSIDE_STRING");
|
|
10362
|
-
break;
|
|
10363
|
-
}
|
|
10364
|
-
case "f":
|
|
10365
|
-
case "t":
|
|
10366
|
-
case "n": {
|
|
10367
|
-
lastValidIndex = i;
|
|
10368
|
-
literalStart = i;
|
|
10369
|
-
stack.pop();
|
|
10370
|
-
stack.push(swapState);
|
|
10371
|
-
stack.push("INSIDE_LITERAL");
|
|
10372
|
-
break;
|
|
10373
|
-
}
|
|
10374
|
-
case "-": {
|
|
10375
|
-
stack.pop();
|
|
10376
|
-
stack.push(swapState);
|
|
10377
|
-
stack.push("INSIDE_NUMBER");
|
|
10378
|
-
break;
|
|
10379
|
-
}
|
|
10380
|
-
case "0":
|
|
10381
|
-
case "1":
|
|
10382
|
-
case "2":
|
|
10383
|
-
case "3":
|
|
10384
|
-
case "4":
|
|
10385
|
-
case "5":
|
|
10386
|
-
case "6":
|
|
10387
|
-
case "7":
|
|
10388
|
-
case "8":
|
|
10389
|
-
case "9": {
|
|
10390
|
-
lastValidIndex = i;
|
|
10391
|
-
stack.pop();
|
|
10392
|
-
stack.push(swapState);
|
|
10393
|
-
stack.push("INSIDE_NUMBER");
|
|
10394
|
-
break;
|
|
10395
|
-
}
|
|
10396
|
-
case "{": {
|
|
10397
|
-
lastValidIndex = i;
|
|
10398
|
-
stack.pop();
|
|
10399
|
-
stack.push(swapState);
|
|
10400
|
-
stack.push("INSIDE_OBJECT_START");
|
|
10401
|
-
break;
|
|
10402
|
-
}
|
|
10403
|
-
case "[": {
|
|
10404
|
-
lastValidIndex = i;
|
|
10405
|
-
stack.pop();
|
|
10406
|
-
stack.push(swapState);
|
|
10407
|
-
stack.push("INSIDE_ARRAY_START");
|
|
10408
|
-
break;
|
|
10409
|
-
}
|
|
10410
|
-
}
|
|
10411
|
-
}
|
|
10412
|
-
}
|
|
10413
|
-
function processAfterObjectValue(char, i) {
|
|
10414
|
-
switch (char) {
|
|
10415
|
-
case ",": {
|
|
10416
|
-
stack.pop();
|
|
10417
|
-
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
|
10418
|
-
break;
|
|
10419
|
-
}
|
|
10420
|
-
case "}": {
|
|
10421
|
-
lastValidIndex = i;
|
|
10422
|
-
stack.pop();
|
|
10423
|
-
break;
|
|
10424
|
-
}
|
|
10425
|
-
}
|
|
10426
|
-
}
|
|
10427
|
-
function processAfterArrayValue(char, i) {
|
|
10428
|
-
switch (char) {
|
|
10429
|
-
case ",": {
|
|
10430
|
-
stack.pop();
|
|
10431
|
-
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
10432
|
-
break;
|
|
10433
|
-
}
|
|
10434
|
-
case "]": {
|
|
10435
|
-
lastValidIndex = i;
|
|
10436
|
-
stack.pop();
|
|
10437
|
-
break;
|
|
10438
|
-
}
|
|
10439
|
-
}
|
|
10440
|
-
}
|
|
10441
|
-
for (let i = 0; i < input.length; i++) {
|
|
10442
|
-
const char = input[i];
|
|
10443
|
-
const currentState = stack[stack.length - 1];
|
|
10444
|
-
switch (currentState) {
|
|
10445
|
-
case "ROOT":
|
|
10446
|
-
processValueStart(char, i, "FINISH");
|
|
10447
|
-
break;
|
|
10448
|
-
case "INSIDE_OBJECT_START": {
|
|
10449
|
-
switch (char) {
|
|
10450
|
-
case '"': {
|
|
10451
|
-
stack.pop();
|
|
10452
|
-
stack.push("INSIDE_OBJECT_KEY");
|
|
10453
|
-
break;
|
|
10454
|
-
}
|
|
10455
|
-
case "}": {
|
|
10456
|
-
lastValidIndex = i;
|
|
10457
|
-
stack.pop();
|
|
10458
|
-
break;
|
|
10459
|
-
}
|
|
10460
|
-
}
|
|
10461
|
-
break;
|
|
10462
|
-
}
|
|
10463
|
-
case "INSIDE_OBJECT_AFTER_COMMA": {
|
|
10464
|
-
switch (char) {
|
|
10465
|
-
case '"': {
|
|
10466
|
-
stack.pop();
|
|
10467
|
-
stack.push("INSIDE_OBJECT_KEY");
|
|
10468
|
-
break;
|
|
10469
|
-
}
|
|
10470
|
-
}
|
|
10471
|
-
break;
|
|
10472
|
-
}
|
|
10473
|
-
case "INSIDE_OBJECT_KEY": {
|
|
10474
|
-
switch (char) {
|
|
10475
|
-
case '"': {
|
|
10476
|
-
stack.pop();
|
|
10477
|
-
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
|
10478
|
-
break;
|
|
10479
|
-
}
|
|
10480
|
-
}
|
|
10481
|
-
break;
|
|
10482
|
-
}
|
|
10483
|
-
case "INSIDE_OBJECT_AFTER_KEY": {
|
|
10484
|
-
switch (char) {
|
|
10485
|
-
case ":": {
|
|
10486
|
-
stack.pop();
|
|
10487
|
-
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
|
10488
|
-
break;
|
|
10489
|
-
}
|
|
10490
|
-
}
|
|
10491
|
-
break;
|
|
10492
|
-
}
|
|
10493
|
-
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
|
10494
|
-
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
|
10495
|
-
break;
|
|
10496
|
-
}
|
|
10497
|
-
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
10498
|
-
processAfterObjectValue(char, i);
|
|
10499
|
-
break;
|
|
10500
|
-
}
|
|
10501
|
-
case "INSIDE_STRING": {
|
|
10502
|
-
switch (char) {
|
|
10503
|
-
case '"': {
|
|
10504
|
-
stack.pop();
|
|
10505
|
-
lastValidIndex = i;
|
|
10506
|
-
break;
|
|
10507
|
-
}
|
|
10508
|
-
case "\\": {
|
|
10509
|
-
stack.push("INSIDE_STRING_ESCAPE");
|
|
10510
|
-
break;
|
|
10511
|
-
}
|
|
10512
|
-
default: {
|
|
10513
|
-
lastValidIndex = i;
|
|
10514
|
-
}
|
|
10515
|
-
}
|
|
10516
|
-
break;
|
|
10517
|
-
}
|
|
10518
|
-
case "INSIDE_ARRAY_START": {
|
|
10519
|
-
switch (char) {
|
|
10520
|
-
case "]": {
|
|
10521
|
-
lastValidIndex = i;
|
|
10522
|
-
stack.pop();
|
|
10523
|
-
break;
|
|
10524
|
-
}
|
|
10525
|
-
default: {
|
|
10526
|
-
lastValidIndex = i;
|
|
10527
|
-
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
10528
|
-
break;
|
|
10529
|
-
}
|
|
10530
|
-
}
|
|
10531
|
-
break;
|
|
10532
|
-
}
|
|
10533
|
-
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
10534
|
-
switch (char) {
|
|
10535
|
-
case ",": {
|
|
10536
|
-
stack.pop();
|
|
10537
|
-
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
10538
|
-
break;
|
|
10539
|
-
}
|
|
10540
|
-
case "]": {
|
|
10541
|
-
lastValidIndex = i;
|
|
10542
|
-
stack.pop();
|
|
10543
|
-
break;
|
|
10544
|
-
}
|
|
10545
|
-
default: {
|
|
10546
|
-
lastValidIndex = i;
|
|
10547
|
-
break;
|
|
10548
|
-
}
|
|
10549
|
-
}
|
|
10550
|
-
break;
|
|
10551
|
-
}
|
|
10552
|
-
case "INSIDE_ARRAY_AFTER_COMMA": {
|
|
10553
|
-
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
10554
|
-
break;
|
|
10555
|
-
}
|
|
10556
|
-
case "INSIDE_STRING_ESCAPE": {
|
|
10557
|
-
stack.pop();
|
|
10558
|
-
lastValidIndex = i;
|
|
10559
|
-
break;
|
|
10560
|
-
}
|
|
10561
|
-
case "INSIDE_NUMBER": {
|
|
10562
|
-
switch (char) {
|
|
10563
|
-
case "0":
|
|
10564
|
-
case "1":
|
|
10565
|
-
case "2":
|
|
10566
|
-
case "3":
|
|
10567
|
-
case "4":
|
|
10568
|
-
case "5":
|
|
10569
|
-
case "6":
|
|
10570
|
-
case "7":
|
|
10571
|
-
case "8":
|
|
10572
|
-
case "9": {
|
|
10573
|
-
lastValidIndex = i;
|
|
10574
|
-
break;
|
|
10575
|
-
}
|
|
10576
|
-
case "e":
|
|
10577
|
-
case "E":
|
|
10578
|
-
case "-":
|
|
10579
|
-
case ".": {
|
|
10580
|
-
break;
|
|
10581
|
-
}
|
|
10582
|
-
case ",": {
|
|
10583
|
-
stack.pop();
|
|
10584
|
-
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
10585
|
-
processAfterArrayValue(char, i);
|
|
10586
|
-
}
|
|
10587
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
10588
|
-
processAfterObjectValue(char, i);
|
|
10589
|
-
}
|
|
10590
|
-
break;
|
|
10591
|
-
}
|
|
10592
|
-
case "}": {
|
|
10593
|
-
stack.pop();
|
|
10594
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
10595
|
-
processAfterObjectValue(char, i);
|
|
10596
|
-
}
|
|
10597
|
-
break;
|
|
10598
|
-
}
|
|
10599
|
-
case "]": {
|
|
10600
|
-
stack.pop();
|
|
10601
|
-
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
10602
|
-
processAfterArrayValue(char, i);
|
|
10603
|
-
}
|
|
10604
|
-
break;
|
|
10605
|
-
}
|
|
10606
|
-
default: {
|
|
10607
|
-
stack.pop();
|
|
10608
|
-
break;
|
|
10609
|
-
}
|
|
10610
|
-
}
|
|
10611
|
-
break;
|
|
10612
|
-
}
|
|
10613
|
-
case "INSIDE_LITERAL": {
|
|
10614
|
-
const partialLiteral = input.substring(literalStart, i + 1);
|
|
10615
|
-
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
|
10616
|
-
stack.pop();
|
|
10617
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
10618
|
-
processAfterObjectValue(char, i);
|
|
10619
|
-
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
10620
|
-
processAfterArrayValue(char, i);
|
|
10621
|
-
}
|
|
10622
|
-
} else {
|
|
10623
|
-
lastValidIndex = i;
|
|
10624
|
-
}
|
|
10625
|
-
break;
|
|
10626
|
-
}
|
|
10627
|
-
}
|
|
10628
|
-
}
|
|
10629
|
-
let result = input.slice(0, lastValidIndex + 1);
|
|
10630
|
-
for (let i = stack.length - 1; i >= 0; i--) {
|
|
10631
|
-
const state = stack[i];
|
|
10632
|
-
switch (state) {
|
|
10633
|
-
case "INSIDE_STRING": {
|
|
10634
|
-
result += '"';
|
|
10635
|
-
break;
|
|
10636
|
-
}
|
|
10637
|
-
case "INSIDE_OBJECT_KEY":
|
|
10638
|
-
case "INSIDE_OBJECT_AFTER_KEY":
|
|
10639
|
-
case "INSIDE_OBJECT_AFTER_COMMA":
|
|
10640
|
-
case "INSIDE_OBJECT_START":
|
|
10641
|
-
case "INSIDE_OBJECT_BEFORE_VALUE":
|
|
10642
|
-
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
10643
|
-
result += "}";
|
|
10644
|
-
break;
|
|
10645
|
-
}
|
|
10646
|
-
case "INSIDE_ARRAY_START":
|
|
10647
|
-
case "INSIDE_ARRAY_AFTER_COMMA":
|
|
10648
|
-
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
10649
|
-
result += "]";
|
|
10650
|
-
break;
|
|
10651
|
-
}
|
|
10652
|
-
case "INSIDE_LITERAL": {
|
|
10653
|
-
const partialLiteral = input.substring(literalStart, input.length);
|
|
10654
|
-
if ("true".startsWith(partialLiteral)) {
|
|
10655
|
-
result += "true".slice(partialLiteral.length);
|
|
10656
|
-
} else if ("false".startsWith(partialLiteral)) {
|
|
10657
|
-
result += "false".slice(partialLiteral.length);
|
|
10658
|
-
} else if ("null".startsWith(partialLiteral)) {
|
|
10659
|
-
result += "null".slice(partialLiteral.length);
|
|
10660
|
-
}
|
|
10661
|
-
}
|
|
10662
|
-
}
|
|
10663
|
-
}
|
|
10664
|
-
return result;
|
|
10665
|
-
}
|
|
10666
|
-
function parsePartialJson(jsonText) {
|
|
10667
|
-
if (jsonText === void 0) {
|
|
10668
|
-
return { value: void 0, state: "undefined-input" };
|
|
10669
|
-
}
|
|
10670
|
-
let result = safeParseJSON({ text: jsonText });
|
|
10671
|
-
if (result.success) {
|
|
10672
|
-
return { value: result.value, state: "successful-parse" };
|
|
10673
|
-
}
|
|
10674
|
-
result = safeParseJSON({ text: fixJson(jsonText) });
|
|
10675
|
-
if (result.success) {
|
|
10676
|
-
return { value: result.value, state: "repaired-parse" };
|
|
10677
|
-
}
|
|
10678
|
-
return { value: void 0, state: "failed-parse" };
|
|
10679
|
-
}
|
|
10680
|
-
var textStreamPart2 = {
|
|
10681
|
-
code: "0",
|
|
10682
|
-
name: "text",
|
|
10683
|
-
parse: (value) => {
|
|
10684
|
-
if (typeof value !== "string") {
|
|
10685
|
-
throw new Error('"text" parts expect a string value.');
|
|
10686
|
-
}
|
|
10687
|
-
return { type: "text", value };
|
|
10688
|
-
}
|
|
10689
|
-
};
|
|
10690
|
-
var dataStreamPart = {
|
|
10691
|
-
code: "2",
|
|
10692
|
-
name: "data",
|
|
10693
|
-
parse: (value) => {
|
|
10694
|
-
if (!Array.isArray(value)) {
|
|
10695
|
-
throw new Error('"data" parts expect an array value.');
|
|
10696
|
-
}
|
|
10697
|
-
return { type: "data", value };
|
|
10698
|
-
}
|
|
10699
|
-
};
|
|
10700
|
-
var errorStreamPart2 = {
|
|
10701
|
-
code: "3",
|
|
10702
|
-
name: "error",
|
|
10703
|
-
parse: (value) => {
|
|
10704
|
-
if (typeof value !== "string") {
|
|
10705
|
-
throw new Error('"error" parts expect a string value.');
|
|
10706
|
-
}
|
|
10707
|
-
return { type: "error", value };
|
|
10708
|
-
}
|
|
10709
|
-
};
|
|
10710
|
-
var messageAnnotationsStreamPart = {
|
|
10711
|
-
code: "8",
|
|
10712
|
-
name: "message_annotations",
|
|
10713
|
-
parse: (value) => {
|
|
10714
|
-
if (!Array.isArray(value)) {
|
|
10715
|
-
throw new Error('"message_annotations" parts expect an array value.');
|
|
10716
|
-
}
|
|
10717
|
-
return { type: "message_annotations", value };
|
|
10718
|
-
}
|
|
10719
|
-
};
|
|
10720
|
-
var toolCallStreamPart = {
|
|
10721
|
-
code: "9",
|
|
10722
|
-
name: "tool_call",
|
|
10723
|
-
parse: (value) => {
|
|
10724
|
-
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("toolName" in value) || typeof value.toolName !== "string" || !("args" in value) || typeof value.args !== "object") {
|
|
10725
|
-
throw new Error(
|
|
10726
|
-
'"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.'
|
|
10727
|
-
);
|
|
10728
|
-
}
|
|
10729
|
-
return {
|
|
10730
|
-
type: "tool_call",
|
|
10731
|
-
value
|
|
10732
|
-
};
|
|
10733
|
-
}
|
|
10734
|
-
};
|
|
10735
|
-
var toolResultStreamPart = {
|
|
10736
|
-
code: "a",
|
|
10737
|
-
name: "tool_result",
|
|
10738
|
-
parse: (value) => {
|
|
10739
|
-
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("result" in value)) {
|
|
10740
|
-
throw new Error(
|
|
10741
|
-
'"tool_result" parts expect an object with a "toolCallId" and a "result" property.'
|
|
10742
|
-
);
|
|
10743
|
-
}
|
|
10744
|
-
return {
|
|
10745
|
-
type: "tool_result",
|
|
10746
|
-
value
|
|
10747
|
-
};
|
|
10748
|
-
}
|
|
10749
|
-
};
|
|
10750
|
-
var toolCallStreamingStartStreamPart = {
|
|
10751
|
-
code: "b",
|
|
10752
|
-
name: "tool_call_streaming_start",
|
|
10753
|
-
parse: (value) => {
|
|
10754
|
-
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("toolName" in value) || typeof value.toolName !== "string") {
|
|
10755
|
-
throw new Error(
|
|
10756
|
-
'"tool_call_streaming_start" parts expect an object with a "toolCallId" and "toolName" property.'
|
|
10757
|
-
);
|
|
10758
|
-
}
|
|
10759
|
-
return {
|
|
10760
|
-
type: "tool_call_streaming_start",
|
|
10761
|
-
value
|
|
10762
|
-
};
|
|
10763
|
-
}
|
|
10764
|
-
};
|
|
10765
|
-
var toolCallDeltaStreamPart = {
|
|
10766
|
-
code: "c",
|
|
10767
|
-
name: "tool_call_delta",
|
|
10768
|
-
parse: (value) => {
|
|
10769
|
-
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("argsTextDelta" in value) || typeof value.argsTextDelta !== "string") {
|
|
10770
|
-
throw new Error(
|
|
10771
|
-
'"tool_call_delta" parts expect an object with a "toolCallId" and "argsTextDelta" property.'
|
|
10772
|
-
);
|
|
10773
|
-
}
|
|
10774
|
-
return {
|
|
10775
|
-
type: "tool_call_delta",
|
|
10776
|
-
value
|
|
10777
|
-
};
|
|
10778
|
-
}
|
|
10779
|
-
};
|
|
10780
|
-
var finishMessageStreamPart = {
|
|
10781
|
-
code: "d",
|
|
10782
|
-
name: "finish_message",
|
|
10783
|
-
parse: (value) => {
|
|
10784
|
-
if (value == null || typeof value !== "object" || !("finishReason" in value) || typeof value.finishReason !== "string") {
|
|
10785
|
-
throw new Error(
|
|
10786
|
-
'"finish_message" parts expect an object with a "finishReason" property.'
|
|
10787
|
-
);
|
|
10788
|
-
}
|
|
10789
|
-
const result = {
|
|
10790
|
-
finishReason: value.finishReason
|
|
10791
|
-
};
|
|
10792
|
-
if ("usage" in value && value.usage != null && typeof value.usage === "object" && "promptTokens" in value.usage && "completionTokens" in value.usage) {
|
|
10793
|
-
result.usage = {
|
|
10794
|
-
promptTokens: typeof value.usage.promptTokens === "number" ? value.usage.promptTokens : Number.NaN,
|
|
10795
|
-
completionTokens: typeof value.usage.completionTokens === "number" ? value.usage.completionTokens : Number.NaN
|
|
10796
|
-
};
|
|
10797
|
-
}
|
|
10798
|
-
return {
|
|
10799
|
-
type: "finish_message",
|
|
10800
|
-
value: result
|
|
10801
|
-
};
|
|
10802
|
-
}
|
|
10803
|
-
};
|
|
10804
|
-
var finishStepStreamPart = {
|
|
10805
|
-
code: "e",
|
|
10806
|
-
name: "finish_step",
|
|
10807
|
-
parse: (value) => {
|
|
10808
|
-
if (value == null || typeof value !== "object" || !("finishReason" in value) || typeof value.finishReason !== "string") {
|
|
10809
|
-
throw new Error(
|
|
10810
|
-
'"finish_step" parts expect an object with a "finishReason" property.'
|
|
10811
|
-
);
|
|
10812
|
-
}
|
|
10813
|
-
const result = {
|
|
10814
|
-
finishReason: value.finishReason,
|
|
10815
|
-
isContinued: false
|
|
10816
|
-
};
|
|
10817
|
-
if ("usage" in value && value.usage != null && typeof value.usage === "object" && "promptTokens" in value.usage && "completionTokens" in value.usage) {
|
|
10818
|
-
result.usage = {
|
|
10819
|
-
promptTokens: typeof value.usage.promptTokens === "number" ? value.usage.promptTokens : Number.NaN,
|
|
10820
|
-
completionTokens: typeof value.usage.completionTokens === "number" ? value.usage.completionTokens : Number.NaN
|
|
10821
|
-
};
|
|
10822
|
-
}
|
|
10823
|
-
if ("isContinued" in value && typeof value.isContinued === "boolean") {
|
|
10824
|
-
result.isContinued = value.isContinued;
|
|
10825
|
-
}
|
|
10826
|
-
return {
|
|
10827
|
-
type: "finish_step",
|
|
10828
|
-
value: result
|
|
10829
|
-
};
|
|
10830
|
-
}
|
|
10831
|
-
};
|
|
10832
|
-
var startStepStreamPart = {
|
|
10833
|
-
code: "f",
|
|
10834
|
-
name: "start_step",
|
|
10835
|
-
parse: (value) => {
|
|
10836
|
-
if (value == null || typeof value !== "object" || !("messageId" in value) || typeof value.messageId !== "string") {
|
|
10837
|
-
throw new Error(
|
|
10838
|
-
'"start_step" parts expect an object with an "id" property.'
|
|
10839
|
-
);
|
|
10840
|
-
}
|
|
10841
|
-
return {
|
|
10842
|
-
type: "start_step",
|
|
10843
|
-
value: {
|
|
10844
|
-
messageId: value.messageId
|
|
10845
|
-
}
|
|
10846
|
-
};
|
|
10847
|
-
}
|
|
10848
|
-
};
|
|
10849
|
-
var reasoningStreamPart = {
|
|
10850
|
-
code: "g",
|
|
10851
|
-
name: "reasoning",
|
|
10852
|
-
parse: (value) => {
|
|
10853
|
-
if (typeof value !== "string") {
|
|
10854
|
-
throw new Error('"reasoning" parts expect a string value.');
|
|
10855
|
-
}
|
|
10856
|
-
return { type: "reasoning", value };
|
|
10857
|
-
}
|
|
10858
|
-
};
|
|
10859
|
-
var sourcePart = {
|
|
10860
|
-
code: "h",
|
|
10861
|
-
name: "source",
|
|
10862
|
-
parse: (value) => {
|
|
10863
|
-
if (value == null || typeof value !== "object") {
|
|
10864
|
-
throw new Error('"source" parts expect a Source object.');
|
|
10865
|
-
}
|
|
10866
|
-
return {
|
|
10867
|
-
type: "source",
|
|
10868
|
-
value
|
|
10869
|
-
};
|
|
10870
|
-
}
|
|
10871
|
-
};
|
|
10872
|
-
var redactedReasoningStreamPart = {
|
|
10873
|
-
code: "i",
|
|
10874
|
-
name: "redacted_reasoning",
|
|
10875
|
-
parse: (value) => {
|
|
10876
|
-
if (value == null || typeof value !== "object" || !("data" in value) || typeof value.data !== "string") {
|
|
10877
|
-
throw new Error(
|
|
10878
|
-
'"redacted_reasoning" parts expect an object with a "data" property.'
|
|
10879
|
-
);
|
|
10880
|
-
}
|
|
10881
|
-
return { type: "redacted_reasoning", value: { data: value.data } };
|
|
10882
|
-
}
|
|
10883
|
-
};
|
|
10884
|
-
var reasoningSignatureStreamPart = {
|
|
10885
|
-
code: "j",
|
|
10886
|
-
name: "reasoning_signature",
|
|
10887
|
-
parse: (value) => {
|
|
10888
|
-
if (value == null || typeof value !== "object" || !("signature" in value) || typeof value.signature !== "string") {
|
|
10889
|
-
throw new Error(
|
|
10890
|
-
'"reasoning_signature" parts expect an object with a "signature" property.'
|
|
10891
|
-
);
|
|
10892
|
-
}
|
|
10893
|
-
return {
|
|
10894
|
-
type: "reasoning_signature",
|
|
10895
|
-
value: { signature: value.signature }
|
|
10896
|
-
};
|
|
10897
|
-
}
|
|
10898
|
-
};
|
|
10899
|
-
var fileStreamPart = {
|
|
10900
|
-
code: "k",
|
|
10901
|
-
name: "file",
|
|
10902
|
-
parse: (value) => {
|
|
10903
|
-
if (value == null || typeof value !== "object" || !("data" in value) || typeof value.data !== "string" || !("mimeType" in value) || typeof value.mimeType !== "string") {
|
|
10904
|
-
throw new Error(
|
|
10905
|
-
'"file" parts expect an object with a "data" and "mimeType" property.'
|
|
10906
|
-
);
|
|
10907
|
-
}
|
|
10908
|
-
return { type: "file", value };
|
|
10909
|
-
}
|
|
10910
|
-
};
|
|
10911
|
-
var dataStreamParts = [
|
|
10912
|
-
textStreamPart2,
|
|
10913
|
-
dataStreamPart,
|
|
10914
|
-
errorStreamPart2,
|
|
10915
|
-
messageAnnotationsStreamPart,
|
|
10916
|
-
toolCallStreamPart,
|
|
10917
|
-
toolResultStreamPart,
|
|
10918
|
-
toolCallStreamingStartStreamPart,
|
|
10919
|
-
toolCallDeltaStreamPart,
|
|
10920
|
-
finishMessageStreamPart,
|
|
10921
|
-
finishStepStreamPart,
|
|
10922
|
-
startStepStreamPart,
|
|
10923
|
-
reasoningStreamPart,
|
|
10924
|
-
sourcePart,
|
|
10925
|
-
redactedReasoningStreamPart,
|
|
10926
|
-
reasoningSignatureStreamPart,
|
|
10927
|
-
fileStreamPart
|
|
10928
|
-
];
|
|
10929
|
-
Object.fromEntries(
|
|
10930
|
-
dataStreamParts.map((part) => [part.code, part])
|
|
10931
|
-
);
|
|
10932
|
-
Object.fromEntries(
|
|
10933
|
-
dataStreamParts.map((part) => [part.name, part.code])
|
|
10934
|
-
);
|
|
10935
|
-
function formatDataStreamPart(type, value) {
|
|
10936
|
-
const streamPart = dataStreamParts.find((part) => part.name === type);
|
|
10937
|
-
if (!streamPart) {
|
|
10938
|
-
throw new Error(`Invalid stream part type: ${type}`);
|
|
10939
|
-
}
|
|
10940
|
-
return `${streamPart.code}:${JSON.stringify(value)}
|
|
10941
|
-
`;
|
|
10942
|
-
}
|
|
10943
|
-
function zodSchema(zodSchema2, options) {
|
|
10944
|
-
var _a17;
|
|
10945
|
-
const useReferences = (_a17 = void 0) != null ? _a17 : false;
|
|
10946
|
-
return jsonSchema(
|
|
10947
|
-
esm_default2(zodSchema2, {
|
|
10948
|
-
$refStrategy: useReferences ? "root" : "none",
|
|
10949
|
-
target: "jsonSchema7"
|
|
10950
|
-
// note: openai mode breaks various gemini conversions
|
|
10951
|
-
}),
|
|
10952
|
-
{
|
|
10953
|
-
validate: (value) => {
|
|
10954
|
-
const result = zodSchema2.safeParse(value);
|
|
10955
|
-
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10956
|
-
}
|
|
10957
|
-
}
|
|
10958
|
-
);
|
|
10959
|
-
}
|
|
10960
|
-
var schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
10961
|
-
function jsonSchema(jsonSchema2, {
|
|
10962
|
-
validate
|
|
10963
|
-
} = {}) {
|
|
10964
|
-
return {
|
|
10965
|
-
[schemaSymbol]: true,
|
|
10966
|
-
_type: void 0,
|
|
10967
|
-
// should never be used directly
|
|
10968
|
-
[validatorSymbol]: true,
|
|
10969
|
-
jsonSchema: jsonSchema2,
|
|
10970
|
-
validate
|
|
10971
|
-
};
|
|
10972
|
-
}
|
|
10973
|
-
function isSchema(value) {
|
|
10974
|
-
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
10975
|
-
}
|
|
10976
|
-
function asSchema(schema) {
|
|
10977
|
-
return isSchema(schema) ? schema : zodSchema(schema);
|
|
10978
|
-
}
|
|
10979
|
-
var _globalThis = typeof globalThis === "object" ? globalThis : global;
|
|
10980
|
-
var VERSION = "1.9.0";
|
|
10981
|
-
var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
10982
|
-
function _makeCompatibilityCheck(ownVersion) {
|
|
10983
|
-
var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
|
|
10984
|
-
var rejectedVersions = /* @__PURE__ */ new Set();
|
|
10985
|
-
var myVersionMatch = ownVersion.match(re);
|
|
10986
|
-
if (!myVersionMatch) {
|
|
10987
|
-
return function() {
|
|
10988
|
-
return false;
|
|
10989
|
-
};
|
|
10990
|
-
}
|
|
10991
|
-
var ownVersionParsed = {
|
|
10992
|
-
major: +myVersionMatch[1],
|
|
10993
|
-
minor: +myVersionMatch[2],
|
|
10994
|
-
patch: +myVersionMatch[3],
|
|
10995
|
-
prerelease: myVersionMatch[4]
|
|
10996
|
-
};
|
|
10997
|
-
if (ownVersionParsed.prerelease != null) {
|
|
10998
|
-
return function isExactmatch(globalVersion) {
|
|
10999
|
-
return globalVersion === ownVersion;
|
|
11000
|
-
};
|
|
11001
|
-
}
|
|
11002
|
-
function _reject(v) {
|
|
11003
|
-
rejectedVersions.add(v);
|
|
11004
|
-
return false;
|
|
11005
|
-
}
|
|
11006
|
-
function _accept(v) {
|
|
11007
|
-
acceptedVersions.add(v);
|
|
11008
|
-
return true;
|
|
11009
|
-
}
|
|
11010
|
-
return function isCompatible2(globalVersion) {
|
|
11011
|
-
if (acceptedVersions.has(globalVersion)) {
|
|
11012
|
-
return true;
|
|
11013
|
-
}
|
|
11014
|
-
if (rejectedVersions.has(globalVersion)) {
|
|
11015
|
-
return false;
|
|
11016
|
-
}
|
|
11017
|
-
var globalVersionMatch = globalVersion.match(re);
|
|
11018
|
-
if (!globalVersionMatch) {
|
|
11019
|
-
return _reject(globalVersion);
|
|
11020
|
-
}
|
|
11021
|
-
var globalVersionParsed = {
|
|
11022
|
-
major: +globalVersionMatch[1],
|
|
11023
|
-
minor: +globalVersionMatch[2],
|
|
11024
|
-
patch: +globalVersionMatch[3],
|
|
11025
|
-
prerelease: globalVersionMatch[4]
|
|
11026
|
-
};
|
|
11027
|
-
if (globalVersionParsed.prerelease != null) {
|
|
11028
|
-
return _reject(globalVersion);
|
|
11029
|
-
}
|
|
11030
|
-
if (ownVersionParsed.major !== globalVersionParsed.major) {
|
|
11031
|
-
return _reject(globalVersion);
|
|
11032
|
-
}
|
|
11033
|
-
if (ownVersionParsed.major === 0) {
|
|
11034
|
-
if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
|
|
11035
|
-
return _accept(globalVersion);
|
|
11036
|
-
}
|
|
11037
|
-
return _reject(globalVersion);
|
|
11038
|
-
}
|
|
11039
|
-
if (ownVersionParsed.minor <= globalVersionParsed.minor) {
|
|
11040
|
-
return _accept(globalVersion);
|
|
11041
|
-
}
|
|
11042
|
-
return _reject(globalVersion);
|
|
11043
|
-
};
|
|
11044
|
-
}
|
|
11045
|
-
var isCompatible = _makeCompatibilityCheck(VERSION);
|
|
11046
|
-
var major = VERSION.split(".")[0];
|
|
11047
|
-
var GLOBAL_OPENTELEMETRY_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major);
|
|
11048
|
-
var _global = _globalThis;
|
|
11049
|
-
function registerGlobal(type, instance, diag, allowOverride) {
|
|
11050
|
-
var _a17;
|
|
11051
|
-
if (allowOverride === void 0) {
|
|
11052
|
-
allowOverride = false;
|
|
11053
|
-
}
|
|
11054
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a17 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a17 !== void 0 ? _a17 : {
|
|
11055
|
-
version: VERSION
|
|
11056
|
-
};
|
|
11057
|
-
if (!allowOverride && api[type]) {
|
|
11058
|
-
var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
|
|
11059
|
-
diag.error(err.stack || err.message);
|
|
11060
|
-
return false;
|
|
11061
|
-
}
|
|
11062
|
-
if (api.version !== VERSION) {
|
|
11063
|
-
var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
|
|
11064
|
-
diag.error(err.stack || err.message);
|
|
11065
|
-
return false;
|
|
11066
|
-
}
|
|
11067
|
-
api[type] = instance;
|
|
11068
|
-
diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
|
|
11069
|
-
return true;
|
|
11070
|
-
}
|
|
11071
|
-
function getGlobal(type) {
|
|
11072
|
-
var _a17, _b;
|
|
11073
|
-
var globalVersion = (_a17 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a17 === void 0 ? void 0 : _a17.version;
|
|
11074
|
-
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
11075
|
-
return;
|
|
11076
|
-
}
|
|
11077
|
-
return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
|
|
11078
|
-
}
|
|
11079
|
-
function unregisterGlobal(type, diag) {
|
|
11080
|
-
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
|
|
11081
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
|
|
11082
|
-
if (api) {
|
|
11083
|
-
delete api[type];
|
|
11084
|
-
}
|
|
11085
|
-
}
|
|
11086
|
-
var __read = function(o, n) {
|
|
11087
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11088
|
-
if (!m) return o;
|
|
11089
|
-
var i = m.call(o), r, ar = [], e;
|
|
11090
|
-
try {
|
|
11091
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
11092
|
-
} catch (error) {
|
|
11093
|
-
e = { error };
|
|
11094
|
-
} finally {
|
|
11095
|
-
try {
|
|
11096
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
11097
|
-
} finally {
|
|
11098
|
-
if (e) throw e.error;
|
|
11099
|
-
}
|
|
11100
|
-
}
|
|
11101
|
-
return ar;
|
|
11102
|
-
};
|
|
11103
|
-
var __spreadArray = function(to, from, pack) {
|
|
11104
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11105
|
-
if (ar || !(i in from)) {
|
|
11106
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11107
|
-
ar[i] = from[i];
|
|
11108
|
-
}
|
|
11109
|
-
}
|
|
11110
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11111
|
-
};
|
|
11112
|
-
var DiagComponentLogger = (
|
|
11113
|
-
/** @class */
|
|
11114
|
-
(function() {
|
|
11115
|
-
function DiagComponentLogger2(props) {
|
|
11116
|
-
this._namespace = props.namespace || "DiagComponentLogger";
|
|
11117
|
-
}
|
|
11118
|
-
DiagComponentLogger2.prototype.debug = function() {
|
|
11119
|
-
var args = [];
|
|
11120
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11121
|
-
args[_i] = arguments[_i];
|
|
11122
|
-
}
|
|
11123
|
-
return logProxy("debug", this._namespace, args);
|
|
11124
|
-
};
|
|
11125
|
-
DiagComponentLogger2.prototype.error = function() {
|
|
11126
|
-
var args = [];
|
|
11127
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11128
|
-
args[_i] = arguments[_i];
|
|
11129
|
-
}
|
|
11130
|
-
return logProxy("error", this._namespace, args);
|
|
11131
|
-
};
|
|
11132
|
-
DiagComponentLogger2.prototype.info = function() {
|
|
11133
|
-
var args = [];
|
|
11134
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11135
|
-
args[_i] = arguments[_i];
|
|
11136
|
-
}
|
|
11137
|
-
return logProxy("info", this._namespace, args);
|
|
11138
|
-
};
|
|
11139
|
-
DiagComponentLogger2.prototype.warn = function() {
|
|
11140
|
-
var args = [];
|
|
11141
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11142
|
-
args[_i] = arguments[_i];
|
|
11143
|
-
}
|
|
11144
|
-
return logProxy("warn", this._namespace, args);
|
|
11145
|
-
};
|
|
11146
|
-
DiagComponentLogger2.prototype.verbose = function() {
|
|
11147
|
-
var args = [];
|
|
11148
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11149
|
-
args[_i] = arguments[_i];
|
|
11150
|
-
}
|
|
11151
|
-
return logProxy("verbose", this._namespace, args);
|
|
11152
|
-
};
|
|
11153
|
-
return DiagComponentLogger2;
|
|
11154
|
-
})()
|
|
11155
|
-
);
|
|
11156
|
-
function logProxy(funcName, namespace, args) {
|
|
11157
|
-
var logger = getGlobal("diag");
|
|
11158
|
-
if (!logger) {
|
|
11159
|
-
return;
|
|
11160
|
-
}
|
|
11161
|
-
args.unshift(namespace);
|
|
11162
|
-
return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
|
|
11163
|
-
}
|
|
11164
|
-
var DiagLogLevel;
|
|
11165
|
-
(function(DiagLogLevel2) {
|
|
11166
|
-
DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
|
|
11167
|
-
DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
|
|
11168
|
-
DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
|
|
11169
|
-
DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
|
|
11170
|
-
DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
|
|
11171
|
-
DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
|
|
11172
|
-
DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
|
|
11173
|
-
})(DiagLogLevel || (DiagLogLevel = {}));
|
|
11174
|
-
function createLogLevelDiagLogger(maxLevel, logger) {
|
|
11175
|
-
if (maxLevel < DiagLogLevel.NONE) {
|
|
11176
|
-
maxLevel = DiagLogLevel.NONE;
|
|
11177
|
-
} else if (maxLevel > DiagLogLevel.ALL) {
|
|
11178
|
-
maxLevel = DiagLogLevel.ALL;
|
|
11179
|
-
}
|
|
11180
|
-
logger = logger || {};
|
|
11181
|
-
function _filterFunc(funcName, theLevel) {
|
|
11182
|
-
var theFunc = logger[funcName];
|
|
11183
|
-
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
11184
|
-
return theFunc.bind(logger);
|
|
11185
|
-
}
|
|
11186
|
-
return function() {
|
|
11187
|
-
};
|
|
11188
|
-
}
|
|
11189
|
-
return {
|
|
11190
|
-
error: _filterFunc("error", DiagLogLevel.ERROR),
|
|
11191
|
-
warn: _filterFunc("warn", DiagLogLevel.WARN),
|
|
11192
|
-
info: _filterFunc("info", DiagLogLevel.INFO),
|
|
11193
|
-
debug: _filterFunc("debug", DiagLogLevel.DEBUG),
|
|
11194
|
-
verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
|
|
11195
|
-
};
|
|
11196
|
-
}
|
|
11197
|
-
var __read2 = function(o, n) {
|
|
11198
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11199
|
-
if (!m) return o;
|
|
11200
|
-
var i = m.call(o), r, ar = [], e;
|
|
11201
|
-
try {
|
|
11202
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
11203
|
-
} catch (error) {
|
|
11204
|
-
e = { error };
|
|
11205
|
-
} finally {
|
|
11206
|
-
try {
|
|
11207
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
11208
|
-
} finally {
|
|
11209
|
-
if (e) throw e.error;
|
|
11210
|
-
}
|
|
11211
|
-
}
|
|
11212
|
-
return ar;
|
|
11213
|
-
};
|
|
11214
|
-
var __spreadArray2 = function(to, from, pack) {
|
|
11215
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11216
|
-
if (ar || !(i in from)) {
|
|
11217
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11218
|
-
ar[i] = from[i];
|
|
11219
|
-
}
|
|
11220
|
-
}
|
|
11221
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11222
|
-
};
|
|
11223
|
-
var API_NAME = "diag";
|
|
11224
|
-
var DiagAPI = (
|
|
11225
|
-
/** @class */
|
|
11226
|
-
(function() {
|
|
11227
|
-
function DiagAPI2() {
|
|
11228
|
-
function _logProxy(funcName) {
|
|
11229
|
-
return function() {
|
|
11230
|
-
var args = [];
|
|
11231
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11232
|
-
args[_i] = arguments[_i];
|
|
11233
|
-
}
|
|
11234
|
-
var logger = getGlobal("diag");
|
|
11235
|
-
if (!logger)
|
|
11236
|
-
return;
|
|
11237
|
-
return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
|
|
11238
|
-
};
|
|
11239
|
-
}
|
|
11240
|
-
var self = this;
|
|
11241
|
-
var setLogger = function(logger, optionsOrLogLevel) {
|
|
11242
|
-
var _a17, _b, _c;
|
|
11243
|
-
if (optionsOrLogLevel === void 0) {
|
|
11244
|
-
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
11245
|
-
}
|
|
11246
|
-
if (logger === self) {
|
|
11247
|
-
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
11248
|
-
self.error((_a17 = err.stack) !== null && _a17 !== void 0 ? _a17 : err.message);
|
|
11249
|
-
return false;
|
|
11250
|
-
}
|
|
11251
|
-
if (typeof optionsOrLogLevel === "number") {
|
|
11252
|
-
optionsOrLogLevel = {
|
|
11253
|
-
logLevel: optionsOrLogLevel
|
|
11254
|
-
};
|
|
11255
|
-
}
|
|
11256
|
-
var oldLogger = getGlobal("diag");
|
|
11257
|
-
var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
|
|
11258
|
-
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
11259
|
-
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
11260
|
-
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
11261
|
-
newLogger.warn("Current logger will overwrite one already registered from " + stack);
|
|
11262
|
-
}
|
|
11263
|
-
return registerGlobal("diag", newLogger, self, true);
|
|
11264
|
-
};
|
|
11265
|
-
self.setLogger = setLogger;
|
|
11266
|
-
self.disable = function() {
|
|
11267
|
-
unregisterGlobal(API_NAME, self);
|
|
11268
|
-
};
|
|
11269
|
-
self.createComponentLogger = function(options) {
|
|
11270
|
-
return new DiagComponentLogger(options);
|
|
11271
|
-
};
|
|
11272
|
-
self.verbose = _logProxy("verbose");
|
|
11273
|
-
self.debug = _logProxy("debug");
|
|
11274
|
-
self.info = _logProxy("info");
|
|
11275
|
-
self.warn = _logProxy("warn");
|
|
11276
|
-
self.error = _logProxy("error");
|
|
11277
|
-
}
|
|
11278
|
-
DiagAPI2.instance = function() {
|
|
11279
|
-
if (!this._instance) {
|
|
11280
|
-
this._instance = new DiagAPI2();
|
|
11281
|
-
}
|
|
11282
|
-
return this._instance;
|
|
11283
|
-
};
|
|
11284
|
-
return DiagAPI2;
|
|
11285
|
-
})()
|
|
11286
|
-
);
|
|
11287
|
-
function createContextKey(description) {
|
|
11288
|
-
return Symbol.for(description);
|
|
11289
|
-
}
|
|
11290
|
-
var BaseContext = (
|
|
11291
|
-
/** @class */
|
|
11292
|
-
/* @__PURE__ */ (function() {
|
|
11293
|
-
function BaseContext2(parentContext) {
|
|
11294
|
-
var self = this;
|
|
11295
|
-
self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
|
|
11296
|
-
self.getValue = function(key) {
|
|
11297
|
-
return self._currentContext.get(key);
|
|
11298
|
-
};
|
|
11299
|
-
self.setValue = function(key, value) {
|
|
11300
|
-
var context = new BaseContext2(self._currentContext);
|
|
11301
|
-
context._currentContext.set(key, value);
|
|
11302
|
-
return context;
|
|
11303
|
-
};
|
|
11304
|
-
self.deleteValue = function(key) {
|
|
11305
|
-
var context = new BaseContext2(self._currentContext);
|
|
11306
|
-
context._currentContext.delete(key);
|
|
11307
|
-
return context;
|
|
11308
|
-
};
|
|
11309
|
-
}
|
|
11310
|
-
return BaseContext2;
|
|
11311
|
-
})()
|
|
11312
|
-
);
|
|
11313
|
-
var ROOT_CONTEXT = new BaseContext();
|
|
11314
|
-
var __read3 = function(o, n) {
|
|
11315
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11316
|
-
if (!m) return o;
|
|
11317
|
-
var i = m.call(o), r, ar = [], e;
|
|
11318
|
-
try {
|
|
11319
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
11320
|
-
} catch (error) {
|
|
11321
|
-
e = { error };
|
|
11322
|
-
} finally {
|
|
11323
|
-
try {
|
|
11324
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
11325
|
-
} finally {
|
|
11326
|
-
if (e) throw e.error;
|
|
11327
|
-
}
|
|
11328
|
-
}
|
|
11329
|
-
return ar;
|
|
11330
|
-
};
|
|
11331
|
-
var __spreadArray3 = function(to, from, pack) {
|
|
11332
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11333
|
-
if (ar || !(i in from)) {
|
|
11334
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11335
|
-
ar[i] = from[i];
|
|
11336
|
-
}
|
|
11337
|
-
}
|
|
11338
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11339
|
-
};
|
|
11340
|
-
var NoopContextManager = (
|
|
11341
|
-
/** @class */
|
|
11342
|
-
(function() {
|
|
11343
|
-
function NoopContextManager2() {
|
|
11344
|
-
}
|
|
11345
|
-
NoopContextManager2.prototype.active = function() {
|
|
11346
|
-
return ROOT_CONTEXT;
|
|
11347
|
-
};
|
|
11348
|
-
NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
|
|
11349
|
-
var args = [];
|
|
11350
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
11351
|
-
args[_i - 3] = arguments[_i];
|
|
11352
|
-
}
|
|
11353
|
-
return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
|
|
11354
|
-
};
|
|
11355
|
-
NoopContextManager2.prototype.bind = function(_context, target) {
|
|
11356
|
-
return target;
|
|
11357
|
-
};
|
|
11358
|
-
NoopContextManager2.prototype.enable = function() {
|
|
11359
|
-
return this;
|
|
11360
|
-
};
|
|
11361
|
-
NoopContextManager2.prototype.disable = function() {
|
|
11362
|
-
return this;
|
|
11363
|
-
};
|
|
11364
|
-
return NoopContextManager2;
|
|
11365
|
-
})()
|
|
11366
|
-
);
|
|
11367
|
-
var __read4 = function(o, n) {
|
|
11368
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11369
|
-
if (!m) return o;
|
|
11370
|
-
var i = m.call(o), r, ar = [], e;
|
|
11371
|
-
try {
|
|
11372
|
-
while (!(r = i.next()).done) ar.push(r.value);
|
|
11373
|
-
} catch (error) {
|
|
11374
|
-
e = { error };
|
|
11375
|
-
} finally {
|
|
11376
|
-
try {
|
|
11377
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
11378
|
-
} finally {
|
|
11379
|
-
if (e) throw e.error;
|
|
11380
|
-
}
|
|
11381
|
-
}
|
|
11382
|
-
return ar;
|
|
11383
|
-
};
|
|
11384
|
-
var __spreadArray4 = function(to, from, pack) {
|
|
11385
|
-
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11386
|
-
if (ar || !(i in from)) {
|
|
11387
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11388
|
-
ar[i] = from[i];
|
|
11389
|
-
}
|
|
11390
|
-
}
|
|
11391
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11392
|
-
};
|
|
11393
|
-
var API_NAME2 = "context";
|
|
11394
|
-
var NOOP_CONTEXT_MANAGER = new NoopContextManager();
|
|
11395
|
-
var ContextAPI = (
|
|
11396
|
-
/** @class */
|
|
11397
|
-
(function() {
|
|
11398
|
-
function ContextAPI2() {
|
|
11399
|
-
}
|
|
11400
|
-
ContextAPI2.getInstance = function() {
|
|
11401
|
-
if (!this._instance) {
|
|
11402
|
-
this._instance = new ContextAPI2();
|
|
11403
|
-
}
|
|
11404
|
-
return this._instance;
|
|
11405
|
-
};
|
|
11406
|
-
ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
|
|
11407
|
-
return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
|
|
11408
|
-
};
|
|
11409
|
-
ContextAPI2.prototype.active = function() {
|
|
11410
|
-
return this._getContextManager().active();
|
|
11411
|
-
};
|
|
11412
|
-
ContextAPI2.prototype.with = function(context, fn, thisArg) {
|
|
11413
|
-
var _a17;
|
|
11414
|
-
var args = [];
|
|
11415
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
11416
|
-
args[_i - 3] = arguments[_i];
|
|
11417
|
-
}
|
|
11418
|
-
return (_a17 = this._getContextManager()).with.apply(_a17, __spreadArray4([context, fn, thisArg], __read4(args), false));
|
|
11419
|
-
};
|
|
11420
|
-
ContextAPI2.prototype.bind = function(context, target) {
|
|
11421
|
-
return this._getContextManager().bind(context, target);
|
|
11422
|
-
};
|
|
11423
|
-
ContextAPI2.prototype._getContextManager = function() {
|
|
11424
|
-
return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
|
|
11425
|
-
};
|
|
11426
|
-
ContextAPI2.prototype.disable = function() {
|
|
11427
|
-
this._getContextManager().disable();
|
|
11428
|
-
unregisterGlobal(API_NAME2, DiagAPI.instance());
|
|
11429
|
-
};
|
|
11430
|
-
return ContextAPI2;
|
|
11431
|
-
})()
|
|
11432
|
-
);
|
|
11433
|
-
var TraceFlags;
|
|
11434
|
-
(function(TraceFlags2) {
|
|
11435
|
-
TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
|
|
11436
|
-
TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
|
|
11437
|
-
})(TraceFlags || (TraceFlags = {}));
|
|
11438
|
-
var INVALID_SPANID = "0000000000000000";
|
|
11439
|
-
var INVALID_TRACEID = "00000000000000000000000000000000";
|
|
11440
|
-
var INVALID_SPAN_CONTEXT = {
|
|
11441
|
-
traceId: INVALID_TRACEID,
|
|
11442
|
-
spanId: INVALID_SPANID,
|
|
11443
|
-
traceFlags: TraceFlags.NONE
|
|
11444
|
-
};
|
|
11445
|
-
var NonRecordingSpan = (
|
|
11446
|
-
/** @class */
|
|
11447
|
-
(function() {
|
|
11448
|
-
function NonRecordingSpan2(_spanContext) {
|
|
11449
|
-
if (_spanContext === void 0) {
|
|
11450
|
-
_spanContext = INVALID_SPAN_CONTEXT;
|
|
11451
|
-
}
|
|
11452
|
-
this._spanContext = _spanContext;
|
|
11453
|
-
}
|
|
11454
|
-
NonRecordingSpan2.prototype.spanContext = function() {
|
|
11455
|
-
return this._spanContext;
|
|
11456
|
-
};
|
|
11457
|
-
NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
|
|
11458
|
-
return this;
|
|
11459
|
-
};
|
|
11460
|
-
NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
|
|
11461
|
-
return this;
|
|
11462
|
-
};
|
|
11463
|
-
NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
|
|
11464
|
-
return this;
|
|
11465
|
-
};
|
|
11466
|
-
NonRecordingSpan2.prototype.addLink = function(_link) {
|
|
11467
|
-
return this;
|
|
11468
|
-
};
|
|
11469
|
-
NonRecordingSpan2.prototype.addLinks = function(_links) {
|
|
11470
|
-
return this;
|
|
11471
|
-
};
|
|
11472
|
-
NonRecordingSpan2.prototype.setStatus = function(_status) {
|
|
11473
|
-
return this;
|
|
11474
|
-
};
|
|
11475
|
-
NonRecordingSpan2.prototype.updateName = function(_name) {
|
|
11476
|
-
return this;
|
|
11477
|
-
};
|
|
11478
|
-
NonRecordingSpan2.prototype.end = function(_endTime) {
|
|
11479
|
-
};
|
|
11480
|
-
NonRecordingSpan2.prototype.isRecording = function() {
|
|
11481
|
-
return false;
|
|
11482
|
-
};
|
|
11483
|
-
NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
|
|
11484
|
-
};
|
|
11485
|
-
return NonRecordingSpan2;
|
|
11486
|
-
})()
|
|
11487
|
-
);
|
|
11488
|
-
var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
|
|
11489
|
-
function getSpan(context) {
|
|
11490
|
-
return context.getValue(SPAN_KEY) || void 0;
|
|
11491
|
-
}
|
|
11492
|
-
function getActiveSpan() {
|
|
11493
|
-
return getSpan(ContextAPI.getInstance().active());
|
|
11494
|
-
}
|
|
11495
|
-
function setSpan(context, span) {
|
|
11496
|
-
return context.setValue(SPAN_KEY, span);
|
|
11497
|
-
}
|
|
11498
|
-
function deleteSpan(context) {
|
|
11499
|
-
return context.deleteValue(SPAN_KEY);
|
|
11500
|
-
}
|
|
11501
|
-
function setSpanContext(context, spanContext) {
|
|
11502
|
-
return setSpan(context, new NonRecordingSpan(spanContext));
|
|
11503
|
-
}
|
|
11504
|
-
function getSpanContext(context) {
|
|
11505
|
-
var _a17;
|
|
11506
|
-
return (_a17 = getSpan(context)) === null || _a17 === void 0 ? void 0 : _a17.spanContext();
|
|
11507
|
-
}
|
|
11508
|
-
var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
|
|
11509
|
-
var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
|
|
11510
|
-
function isValidTraceId(traceId) {
|
|
11511
|
-
return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
|
|
11512
|
-
}
|
|
11513
|
-
function isValidSpanId(spanId) {
|
|
11514
|
-
return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
|
|
11515
|
-
}
|
|
11516
|
-
function isSpanContextValid(spanContext) {
|
|
11517
|
-
return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
|
|
11518
|
-
}
|
|
11519
|
-
function wrapSpanContext(spanContext) {
|
|
11520
|
-
return new NonRecordingSpan(spanContext);
|
|
11521
|
-
}
|
|
11522
|
-
var contextApi = ContextAPI.getInstance();
|
|
11523
|
-
var NoopTracer = (
|
|
11524
|
-
/** @class */
|
|
11525
|
-
(function() {
|
|
11526
|
-
function NoopTracer2() {
|
|
11527
|
-
}
|
|
11528
|
-
NoopTracer2.prototype.startSpan = function(name17, options, context) {
|
|
11529
|
-
if (context === void 0) {
|
|
11530
|
-
context = contextApi.active();
|
|
11531
|
-
}
|
|
11532
|
-
var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
11533
|
-
if (root) {
|
|
11534
|
-
return new NonRecordingSpan();
|
|
11535
|
-
}
|
|
11536
|
-
var parentFromContext = context && getSpanContext(context);
|
|
11537
|
-
if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
|
|
11538
|
-
return new NonRecordingSpan(parentFromContext);
|
|
11539
|
-
} else {
|
|
11540
|
-
return new NonRecordingSpan();
|
|
11541
|
-
}
|
|
11542
|
-
};
|
|
11543
|
-
NoopTracer2.prototype.startActiveSpan = function(name17, arg2, arg3, arg4) {
|
|
11544
|
-
var opts;
|
|
11545
|
-
var ctx;
|
|
11546
|
-
var fn;
|
|
11547
|
-
if (arguments.length < 2) {
|
|
11548
|
-
return;
|
|
11549
|
-
} else if (arguments.length === 2) {
|
|
11550
|
-
fn = arg2;
|
|
11551
|
-
} else if (arguments.length === 3) {
|
|
11552
|
-
opts = arg2;
|
|
11553
|
-
fn = arg3;
|
|
11554
|
-
} else {
|
|
11555
|
-
opts = arg2;
|
|
11556
|
-
ctx = arg3;
|
|
11557
|
-
fn = arg4;
|
|
11558
|
-
}
|
|
11559
|
-
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
11560
|
-
var span = this.startSpan(name17, opts, parentContext);
|
|
11561
|
-
var contextWithSpanSet = setSpan(parentContext, span);
|
|
11562
|
-
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
11563
|
-
};
|
|
11564
|
-
return NoopTracer2;
|
|
11565
|
-
})()
|
|
11566
|
-
);
|
|
11567
|
-
function isSpanContext(spanContext) {
|
|
11568
|
-
return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
|
|
11569
|
-
}
|
|
11570
|
-
var NOOP_TRACER = new NoopTracer();
|
|
11571
|
-
var ProxyTracer = (
|
|
11572
|
-
/** @class */
|
|
11573
|
-
(function() {
|
|
11574
|
-
function ProxyTracer2(_provider, name17, version, options) {
|
|
11575
|
-
this._provider = _provider;
|
|
11576
|
-
this.name = name17;
|
|
11577
|
-
this.version = version;
|
|
11578
|
-
this.options = options;
|
|
11579
|
-
}
|
|
11580
|
-
ProxyTracer2.prototype.startSpan = function(name17, options, context) {
|
|
11581
|
-
return this._getTracer().startSpan(name17, options, context);
|
|
11582
|
-
};
|
|
11583
|
-
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
11584
|
-
var tracer = this._getTracer();
|
|
11585
|
-
return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
|
|
11586
|
-
};
|
|
11587
|
-
ProxyTracer2.prototype._getTracer = function() {
|
|
11588
|
-
if (this._delegate) {
|
|
11589
|
-
return this._delegate;
|
|
11590
|
-
}
|
|
11591
|
-
var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
11592
|
-
if (!tracer) {
|
|
11593
|
-
return NOOP_TRACER;
|
|
11594
|
-
}
|
|
11595
|
-
this._delegate = tracer;
|
|
11596
|
-
return this._delegate;
|
|
11597
|
-
};
|
|
11598
|
-
return ProxyTracer2;
|
|
11599
|
-
})()
|
|
11600
|
-
);
|
|
11601
|
-
var NoopTracerProvider = (
|
|
11602
|
-
/** @class */
|
|
11603
|
-
(function() {
|
|
11604
|
-
function NoopTracerProvider2() {
|
|
11605
|
-
}
|
|
11606
|
-
NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
|
|
11607
|
-
return new NoopTracer();
|
|
11608
|
-
};
|
|
11609
|
-
return NoopTracerProvider2;
|
|
11610
|
-
})()
|
|
11611
|
-
);
|
|
11612
|
-
var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
|
|
11613
|
-
var ProxyTracerProvider = (
|
|
11614
|
-
/** @class */
|
|
11615
|
-
(function() {
|
|
11616
|
-
function ProxyTracerProvider2() {
|
|
11617
|
-
}
|
|
11618
|
-
ProxyTracerProvider2.prototype.getTracer = function(name17, version, options) {
|
|
11619
|
-
var _a17;
|
|
11620
|
-
return (_a17 = this.getDelegateTracer(name17, version, options)) !== null && _a17 !== void 0 ? _a17 : new ProxyTracer(this, name17, version, options);
|
|
11621
|
-
};
|
|
11622
|
-
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
11623
|
-
var _a17;
|
|
11624
|
-
return (_a17 = this._delegate) !== null && _a17 !== void 0 ? _a17 : NOOP_TRACER_PROVIDER;
|
|
11625
|
-
};
|
|
11626
|
-
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
11627
|
-
this._delegate = delegate;
|
|
11628
|
-
};
|
|
11629
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(name17, version, options) {
|
|
11630
|
-
var _a17;
|
|
11631
|
-
return (_a17 = this._delegate) === null || _a17 === void 0 ? void 0 : _a17.getTracer(name17, version, options);
|
|
11632
|
-
};
|
|
11633
|
-
return ProxyTracerProvider2;
|
|
11634
|
-
})()
|
|
11635
|
-
);
|
|
11636
|
-
var SpanStatusCode;
|
|
11637
|
-
(function(SpanStatusCode2) {
|
|
11638
|
-
SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
|
|
11639
|
-
SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
|
|
11640
|
-
SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
|
|
11641
|
-
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
11642
|
-
var API_NAME3 = "trace";
|
|
11643
|
-
var TraceAPI = (
|
|
11644
|
-
/** @class */
|
|
11645
|
-
(function() {
|
|
11646
|
-
function TraceAPI2() {
|
|
11647
|
-
this._proxyTracerProvider = new ProxyTracerProvider();
|
|
11648
|
-
this.wrapSpanContext = wrapSpanContext;
|
|
11649
|
-
this.isSpanContextValid = isSpanContextValid;
|
|
11650
|
-
this.deleteSpan = deleteSpan;
|
|
11651
|
-
this.getSpan = getSpan;
|
|
11652
|
-
this.getActiveSpan = getActiveSpan;
|
|
11653
|
-
this.getSpanContext = getSpanContext;
|
|
11654
|
-
this.setSpan = setSpan;
|
|
11655
|
-
this.setSpanContext = setSpanContext;
|
|
11656
|
-
}
|
|
11657
|
-
TraceAPI2.getInstance = function() {
|
|
11658
|
-
if (!this._instance) {
|
|
11659
|
-
this._instance = new TraceAPI2();
|
|
11660
|
-
}
|
|
11661
|
-
return this._instance;
|
|
11662
|
-
};
|
|
11663
|
-
TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
|
|
11664
|
-
var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
|
|
11665
|
-
if (success) {
|
|
11666
|
-
this._proxyTracerProvider.setDelegate(provider);
|
|
11667
|
-
}
|
|
11668
|
-
return success;
|
|
11669
|
-
};
|
|
11670
|
-
TraceAPI2.prototype.getTracerProvider = function() {
|
|
11671
|
-
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
11672
|
-
};
|
|
11673
|
-
TraceAPI2.prototype.getTracer = function(name17, version) {
|
|
11674
|
-
return this.getTracerProvider().getTracer(name17, version);
|
|
11675
|
-
};
|
|
11676
|
-
TraceAPI2.prototype.disable = function() {
|
|
11677
|
-
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
11678
|
-
this._proxyTracerProvider = new ProxyTracerProvider();
|
|
11679
|
-
};
|
|
11680
|
-
return TraceAPI2;
|
|
11681
|
-
})()
|
|
11682
|
-
);
|
|
11683
|
-
TraceAPI.getInstance();
|
|
11684
|
-
var __defProp22 = Object.defineProperty;
|
|
11685
|
-
var __export = (target, all) => {
|
|
11686
|
-
for (var name17 in all)
|
|
11687
|
-
__defProp22(target, name17, { get: all[name17], enumerable: true });
|
|
11688
|
-
};
|
|
11689
|
-
function prepareResponseHeaders(headers, {
|
|
11690
|
-
contentType,
|
|
11691
|
-
dataStreamVersion
|
|
11692
|
-
}) {
|
|
11693
|
-
const responseHeaders = new Headers(headers != null ? headers : {});
|
|
11694
|
-
if (!responseHeaders.has("Content-Type")) {
|
|
11695
|
-
responseHeaders.set("Content-Type", contentType);
|
|
11696
|
-
}
|
|
11697
|
-
{
|
|
11698
|
-
responseHeaders.set("X-Vercel-AI-Data-Stream", dataStreamVersion);
|
|
11699
|
-
}
|
|
11700
|
-
return responseHeaders;
|
|
11701
|
-
}
|
|
11702
|
-
var name42 = "AI_NoObjectGeneratedError";
|
|
11703
|
-
var marker42 = `vercel.ai.error.${name42}`;
|
|
11704
|
-
var symbol42 = Symbol.for(marker42);
|
|
11705
|
-
var _a42;
|
|
11706
|
-
var NoObjectGeneratedError = class extends AISDKError {
|
|
11707
|
-
constructor({
|
|
11708
|
-
message = "No object generated.",
|
|
11709
|
-
cause,
|
|
11710
|
-
text: text2,
|
|
11711
|
-
response,
|
|
11712
|
-
usage,
|
|
11713
|
-
finishReason
|
|
11714
|
-
}) {
|
|
11715
|
-
super({ name: name42, message, cause });
|
|
11716
|
-
this[_a42] = true;
|
|
11717
|
-
this.text = text2;
|
|
11718
|
-
this.response = response;
|
|
11719
|
-
this.usage = usage;
|
|
11720
|
-
this.finishReason = finishReason;
|
|
11721
|
-
}
|
|
11722
|
-
static isInstance(error) {
|
|
11723
|
-
return AISDKError.hasMarker(error, marker42);
|
|
11724
|
-
}
|
|
11725
|
-
};
|
|
11726
|
-
_a42 = symbol42;
|
|
11727
|
-
var dataContentSchema = z.union([
|
|
11728
|
-
z.string(),
|
|
11729
|
-
z.instanceof(Uint8Array),
|
|
11730
|
-
z.instanceof(ArrayBuffer),
|
|
11731
|
-
z.custom(
|
|
11732
|
-
// Buffer might not be available in some environments such as CloudFlare:
|
|
11733
|
-
(value) => {
|
|
11734
|
-
var _a17, _b;
|
|
11735
|
-
return (_b = (_a17 = globalThis.Buffer) == null ? void 0 : _a17.isBuffer(value)) != null ? _b : false;
|
|
11736
|
-
},
|
|
11737
|
-
{ message: "Must be a Buffer" }
|
|
11738
|
-
)
|
|
11739
|
-
]);
|
|
11740
|
-
var jsonValueSchema = z.lazy(
|
|
11741
|
-
() => z.union([
|
|
11742
|
-
z.null(),
|
|
11743
|
-
z.string(),
|
|
11744
|
-
z.number(),
|
|
11745
|
-
z.boolean(),
|
|
11746
|
-
z.record(z.string(), jsonValueSchema),
|
|
11747
|
-
z.array(jsonValueSchema)
|
|
11748
|
-
])
|
|
11749
|
-
);
|
|
11750
|
-
var providerMetadataSchema = z.record(
|
|
11751
|
-
z.string(),
|
|
11752
|
-
z.record(z.string(), jsonValueSchema)
|
|
11753
|
-
);
|
|
11754
|
-
var toolResultContentSchema = z.array(
|
|
11755
|
-
z.union([
|
|
11756
|
-
z.object({ type: z.literal("text"), text: z.string() }),
|
|
11757
|
-
z.object({
|
|
11758
|
-
type: z.literal("image"),
|
|
11759
|
-
data: z.string(),
|
|
11760
|
-
mimeType: z.string().optional()
|
|
11761
|
-
})
|
|
11762
|
-
])
|
|
11763
|
-
);
|
|
11764
|
-
var textPartSchema = z.object({
|
|
11765
|
-
type: z.literal("text"),
|
|
11766
|
-
text: z.string(),
|
|
11767
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11768
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11769
|
-
});
|
|
11770
|
-
var imagePartSchema = z.object({
|
|
11771
|
-
type: z.literal("image"),
|
|
11772
|
-
image: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
11773
|
-
mimeType: z.string().optional(),
|
|
11774
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11775
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11776
|
-
});
|
|
11777
|
-
var filePartSchema = z.object({
|
|
11778
|
-
type: z.literal("file"),
|
|
11779
|
-
data: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
11780
|
-
filename: z.string().optional(),
|
|
11781
|
-
mimeType: z.string(),
|
|
11782
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11783
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11784
|
-
});
|
|
11785
|
-
var reasoningPartSchema = z.object({
|
|
11786
|
-
type: z.literal("reasoning"),
|
|
11787
|
-
text: z.string(),
|
|
11788
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11789
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11790
|
-
});
|
|
11791
|
-
var redactedReasoningPartSchema = z.object({
|
|
11792
|
-
type: z.literal("redacted-reasoning"),
|
|
11793
|
-
data: z.string(),
|
|
11794
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11795
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11796
|
-
});
|
|
11797
|
-
var toolCallPartSchema = z.object({
|
|
11798
|
-
type: z.literal("tool-call"),
|
|
11799
|
-
toolCallId: z.string(),
|
|
11800
|
-
toolName: z.string(),
|
|
11801
|
-
args: z.unknown(),
|
|
11802
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11803
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11804
|
-
});
|
|
11805
|
-
var toolResultPartSchema = z.object({
|
|
11806
|
-
type: z.literal("tool-result"),
|
|
11807
|
-
toolCallId: z.string(),
|
|
11808
|
-
toolName: z.string(),
|
|
11809
|
-
result: z.unknown(),
|
|
11810
|
-
content: toolResultContentSchema.optional(),
|
|
11811
|
-
isError: z.boolean().optional(),
|
|
11812
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11813
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11814
|
-
});
|
|
11815
|
-
var coreSystemMessageSchema = z.object({
|
|
11816
|
-
role: z.literal("system"),
|
|
11817
|
-
content: z.string(),
|
|
11818
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11819
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11820
|
-
});
|
|
11821
|
-
var coreUserMessageSchema = z.object({
|
|
11822
|
-
role: z.literal("user"),
|
|
11823
|
-
content: z.union([
|
|
11824
|
-
z.string(),
|
|
11825
|
-
z.array(z.union([textPartSchema, imagePartSchema, filePartSchema]))
|
|
11826
|
-
]),
|
|
11827
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11828
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11829
|
-
});
|
|
11830
|
-
var coreAssistantMessageSchema = z.object({
|
|
11831
|
-
role: z.literal("assistant"),
|
|
11832
|
-
content: z.union([
|
|
11833
|
-
z.string(),
|
|
11834
|
-
z.array(
|
|
11835
|
-
z.union([
|
|
11836
|
-
textPartSchema,
|
|
11837
|
-
filePartSchema,
|
|
11838
|
-
reasoningPartSchema,
|
|
11839
|
-
redactedReasoningPartSchema,
|
|
11840
|
-
toolCallPartSchema
|
|
11841
|
-
])
|
|
11842
|
-
)
|
|
11843
|
-
]),
|
|
11844
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11845
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11846
|
-
});
|
|
11847
|
-
var coreToolMessageSchema = z.object({
|
|
11848
|
-
role: z.literal("tool"),
|
|
11849
|
-
content: z.array(toolResultPartSchema),
|
|
11850
|
-
providerOptions: providerMetadataSchema.optional(),
|
|
11851
|
-
experimental_providerMetadata: providerMetadataSchema.optional()
|
|
11852
|
-
});
|
|
11853
|
-
z.union([
|
|
11854
|
-
coreSystemMessageSchema,
|
|
11855
|
-
coreUserMessageSchema,
|
|
11856
|
-
coreAssistantMessageSchema,
|
|
11857
|
-
coreToolMessageSchema
|
|
11858
|
-
]);
|
|
11859
|
-
var DEFAULT_SCHEMA_PREFIX = "JSON schema:";
|
|
11860
|
-
var DEFAULT_SCHEMA_SUFFIX = "You MUST answer with a JSON object that matches the JSON schema above.";
|
|
11861
|
-
var DEFAULT_GENERIC_SUFFIX = "You MUST answer with JSON.";
|
|
11862
|
-
function injectJsonInstruction({
|
|
11863
|
-
prompt,
|
|
11864
|
-
schema,
|
|
11865
|
-
schemaPrefix = schema != null ? DEFAULT_SCHEMA_PREFIX : void 0,
|
|
11866
|
-
schemaSuffix = schema != null ? DEFAULT_SCHEMA_SUFFIX : DEFAULT_GENERIC_SUFFIX
|
|
11867
|
-
}) {
|
|
11868
|
-
return [
|
|
11869
|
-
prompt != null && prompt.length > 0 ? prompt : void 0,
|
|
11870
|
-
prompt != null && prompt.length > 0 ? "" : void 0,
|
|
11871
|
-
// add a newline if prompt is not null
|
|
11872
|
-
schemaPrefix,
|
|
11873
|
-
schema != null ? JSON.stringify(schema) : void 0,
|
|
11874
|
-
schemaSuffix
|
|
11875
|
-
].filter((line) => line != null).join("\n");
|
|
11876
|
-
}
|
|
11877
|
-
createIdGenerator({ prefix: "aiobj", size: 24 });
|
|
11878
|
-
createIdGenerator({ prefix: "aiobj", size: 24 });
|
|
11879
|
-
createIdGenerator({
|
|
11880
|
-
prefix: "aitxt",
|
|
11881
|
-
size: 24
|
|
11882
|
-
});
|
|
11883
|
-
createIdGenerator({
|
|
11884
|
-
prefix: "msg",
|
|
11885
|
-
size: 24
|
|
11886
|
-
});
|
|
11887
|
-
var output_exports = {};
|
|
11888
|
-
__export(output_exports, {
|
|
11889
|
-
object: () => object,
|
|
11890
|
-
text: () => text
|
|
11891
|
-
});
|
|
11892
|
-
var text = () => ({
|
|
11893
|
-
type: "text",
|
|
11894
|
-
responseFormat: () => ({ type: "text" }),
|
|
11895
|
-
injectIntoSystemPrompt({ system }) {
|
|
11896
|
-
return system;
|
|
11897
|
-
},
|
|
11898
|
-
parsePartial({ text: text2 }) {
|
|
11899
|
-
return { partial: text2 };
|
|
11900
|
-
},
|
|
11901
|
-
parseOutput({ text: text2 }) {
|
|
11902
|
-
return text2;
|
|
11903
|
-
}
|
|
11904
|
-
});
|
|
11905
|
-
var object = ({
|
|
11906
|
-
schema: inputSchema
|
|
11907
|
-
}) => {
|
|
11908
|
-
const schema = asSchema(inputSchema);
|
|
11909
|
-
return {
|
|
11910
|
-
type: "object",
|
|
11911
|
-
responseFormat: ({ model }) => ({
|
|
11912
|
-
type: "json",
|
|
11913
|
-
schema: model.supportsStructuredOutputs ? schema.jsonSchema : void 0
|
|
11914
|
-
}),
|
|
11915
|
-
injectIntoSystemPrompt({ system, model }) {
|
|
11916
|
-
return model.supportsStructuredOutputs ? system : injectJsonInstruction({
|
|
11917
|
-
prompt: system,
|
|
11918
|
-
schema: schema.jsonSchema
|
|
11919
|
-
});
|
|
11920
|
-
},
|
|
11921
|
-
parsePartial({ text: text2 }) {
|
|
11922
|
-
const result = parsePartialJson(text2);
|
|
11923
|
-
switch (result.state) {
|
|
11924
|
-
case "failed-parse":
|
|
11925
|
-
case "undefined-input":
|
|
11926
|
-
return void 0;
|
|
11927
|
-
case "repaired-parse":
|
|
11928
|
-
case "successful-parse":
|
|
11929
|
-
return {
|
|
11930
|
-
// Note: currently no validation of partial results:
|
|
11931
|
-
partial: result.value
|
|
11932
|
-
};
|
|
11933
|
-
default: {
|
|
11934
|
-
const _exhaustiveCheck = result.state;
|
|
11935
|
-
throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
|
|
11936
|
-
}
|
|
11937
|
-
}
|
|
11938
|
-
},
|
|
11939
|
-
parseOutput({ text: text2 }, context) {
|
|
11940
|
-
const parseResult = safeParseJSON({ text: text2 });
|
|
11941
|
-
if (!parseResult.success) {
|
|
11942
|
-
throw new NoObjectGeneratedError({
|
|
11943
|
-
message: "No object generated: could not parse the response.",
|
|
11944
|
-
cause: parseResult.error,
|
|
11945
|
-
text: text2,
|
|
11946
|
-
response: context.response,
|
|
11947
|
-
usage: context.usage,
|
|
11948
|
-
finishReason: context.finishReason
|
|
11949
|
-
});
|
|
11950
|
-
}
|
|
11951
|
-
const validationResult = safeValidateTypes({
|
|
11952
|
-
value: parseResult.value,
|
|
11953
|
-
schema
|
|
11954
|
-
});
|
|
11955
|
-
if (!validationResult.success) {
|
|
11956
|
-
throw new NoObjectGeneratedError({
|
|
11957
|
-
message: "No object generated: response did not match schema.",
|
|
11958
|
-
cause: validationResult.error,
|
|
11959
|
-
text: text2,
|
|
11960
|
-
response: context.response,
|
|
11961
|
-
usage: context.usage,
|
|
11962
|
-
finishReason: context.finishReason
|
|
11963
|
-
});
|
|
11964
|
-
}
|
|
11965
|
-
return validationResult.value;
|
|
11966
|
-
}
|
|
11967
|
-
};
|
|
11968
|
-
};
|
|
11969
|
-
function mergeStreams(stream1, stream2) {
|
|
11970
|
-
const reader1 = stream1.getReader();
|
|
11971
|
-
const reader2 = stream2.getReader();
|
|
11972
|
-
let lastRead1 = void 0;
|
|
11973
|
-
let lastRead2 = void 0;
|
|
11974
|
-
let stream1Done = false;
|
|
11975
|
-
let stream2Done = false;
|
|
11976
|
-
async function readStream1(controller) {
|
|
11977
|
-
try {
|
|
11978
|
-
if (lastRead1 == null) {
|
|
11979
|
-
lastRead1 = reader1.read();
|
|
11980
|
-
}
|
|
11981
|
-
const result = await lastRead1;
|
|
11982
|
-
lastRead1 = void 0;
|
|
11983
|
-
if (!result.done) {
|
|
11984
|
-
controller.enqueue(result.value);
|
|
11985
|
-
} else {
|
|
11986
|
-
controller.close();
|
|
11987
|
-
}
|
|
11988
|
-
} catch (error) {
|
|
11989
|
-
controller.error(error);
|
|
11990
|
-
}
|
|
11991
|
-
}
|
|
11992
|
-
async function readStream2(controller) {
|
|
11993
|
-
try {
|
|
11994
|
-
if (lastRead2 == null) {
|
|
11995
|
-
lastRead2 = reader2.read();
|
|
11996
|
-
}
|
|
11997
|
-
const result = await lastRead2;
|
|
11998
|
-
lastRead2 = void 0;
|
|
11999
|
-
if (!result.done) {
|
|
12000
|
-
controller.enqueue(result.value);
|
|
12001
|
-
} else {
|
|
12002
|
-
controller.close();
|
|
12003
|
-
}
|
|
12004
|
-
} catch (error) {
|
|
12005
|
-
controller.error(error);
|
|
12006
|
-
}
|
|
12007
|
-
}
|
|
12008
|
-
return new ReadableStream({
|
|
12009
|
-
async pull(controller) {
|
|
12010
|
-
try {
|
|
12011
|
-
if (stream1Done) {
|
|
12012
|
-
await readStream2(controller);
|
|
12013
|
-
return;
|
|
12014
|
-
}
|
|
12015
|
-
if (stream2Done) {
|
|
12016
|
-
await readStream1(controller);
|
|
12017
|
-
return;
|
|
12018
|
-
}
|
|
12019
|
-
if (lastRead1 == null) {
|
|
12020
|
-
lastRead1 = reader1.read();
|
|
12021
|
-
}
|
|
12022
|
-
if (lastRead2 == null) {
|
|
12023
|
-
lastRead2 = reader2.read();
|
|
12024
|
-
}
|
|
12025
|
-
const { result, reader } = await Promise.race([
|
|
12026
|
-
lastRead1.then((result2) => ({ result: result2, reader: reader1 })),
|
|
12027
|
-
lastRead2.then((result2) => ({ result: result2, reader: reader2 }))
|
|
12028
|
-
]);
|
|
12029
|
-
if (!result.done) {
|
|
12030
|
-
controller.enqueue(result.value);
|
|
12031
|
-
}
|
|
12032
|
-
if (reader === reader1) {
|
|
12033
|
-
lastRead1 = void 0;
|
|
12034
|
-
if (result.done) {
|
|
12035
|
-
await readStream2(controller);
|
|
12036
|
-
stream1Done = true;
|
|
12037
|
-
}
|
|
12038
|
-
} else {
|
|
12039
|
-
lastRead2 = void 0;
|
|
12040
|
-
if (result.done) {
|
|
12041
|
-
stream2Done = true;
|
|
12042
|
-
await readStream1(controller);
|
|
12043
|
-
}
|
|
12044
|
-
}
|
|
12045
|
-
} catch (error) {
|
|
12046
|
-
controller.error(error);
|
|
12047
|
-
}
|
|
12048
|
-
},
|
|
12049
|
-
cancel() {
|
|
12050
|
-
reader1.cancel();
|
|
12051
|
-
reader2.cancel();
|
|
12052
|
-
}
|
|
12053
|
-
});
|
|
12054
|
-
}
|
|
12055
|
-
createIdGenerator({
|
|
12056
|
-
prefix: "aitxt",
|
|
12057
|
-
size: 24
|
|
12058
|
-
});
|
|
12059
|
-
createIdGenerator({
|
|
12060
|
-
prefix: "msg",
|
|
12061
|
-
size: 24
|
|
12062
|
-
});
|
|
12063
|
-
var ClientOrServerImplementationSchema = z.object({
|
|
12064
|
-
name: z.string(),
|
|
12065
|
-
version: z.string()
|
|
12066
|
-
}).passthrough();
|
|
12067
|
-
var BaseParamsSchema = z.object({
|
|
12068
|
-
_meta: z.optional(z.object({}).passthrough())
|
|
12069
|
-
}).passthrough();
|
|
12070
|
-
var ResultSchema = BaseParamsSchema;
|
|
12071
|
-
var RequestSchema = z.object({
|
|
12072
|
-
method: z.string(),
|
|
12073
|
-
params: z.optional(BaseParamsSchema)
|
|
12074
|
-
});
|
|
12075
|
-
var ServerCapabilitiesSchema = z.object({
|
|
12076
|
-
experimental: z.optional(z.object({}).passthrough()),
|
|
12077
|
-
logging: z.optional(z.object({}).passthrough()),
|
|
12078
|
-
prompts: z.optional(
|
|
12079
|
-
z.object({
|
|
12080
|
-
listChanged: z.optional(z.boolean())
|
|
12081
|
-
}).passthrough()
|
|
12082
|
-
),
|
|
12083
|
-
resources: z.optional(
|
|
12084
|
-
z.object({
|
|
12085
|
-
subscribe: z.optional(z.boolean()),
|
|
12086
|
-
listChanged: z.optional(z.boolean())
|
|
12087
|
-
}).passthrough()
|
|
12088
|
-
),
|
|
12089
|
-
tools: z.optional(
|
|
12090
|
-
z.object({
|
|
12091
|
-
listChanged: z.optional(z.boolean())
|
|
12092
|
-
}).passthrough()
|
|
12093
|
-
)
|
|
12094
|
-
}).passthrough();
|
|
12095
|
-
ResultSchema.extend({
|
|
12096
|
-
protocolVersion: z.string(),
|
|
12097
|
-
capabilities: ServerCapabilitiesSchema,
|
|
12098
|
-
serverInfo: ClientOrServerImplementationSchema,
|
|
12099
|
-
instructions: z.optional(z.string())
|
|
12100
|
-
});
|
|
12101
|
-
var PaginatedResultSchema = ResultSchema.extend({
|
|
12102
|
-
nextCursor: z.optional(z.string())
|
|
12103
|
-
});
|
|
12104
|
-
var ToolSchema = z.object({
|
|
12105
|
-
name: z.string(),
|
|
12106
|
-
description: z.optional(z.string()),
|
|
12107
|
-
inputSchema: z.object({
|
|
12108
|
-
type: z.literal("object"),
|
|
12109
|
-
properties: z.optional(z.object({}).passthrough())
|
|
12110
|
-
}).passthrough()
|
|
12111
|
-
}).passthrough();
|
|
12112
|
-
PaginatedResultSchema.extend({
|
|
12113
|
-
tools: z.array(ToolSchema)
|
|
12114
|
-
});
|
|
12115
|
-
var TextContentSchema = z.object({
|
|
12116
|
-
type: z.literal("text"),
|
|
12117
|
-
text: z.string()
|
|
12118
|
-
}).passthrough();
|
|
12119
|
-
var ImageContentSchema = z.object({
|
|
12120
|
-
type: z.literal("image"),
|
|
12121
|
-
data: z.string().base64(),
|
|
12122
|
-
mimeType: z.string()
|
|
12123
|
-
}).passthrough();
|
|
12124
|
-
var ResourceContentsSchema = z.object({
|
|
12125
|
-
/**
|
|
12126
|
-
* The URI of this resource.
|
|
12127
|
-
*/
|
|
12128
|
-
uri: z.string(),
|
|
12129
|
-
/**
|
|
12130
|
-
* The MIME type of this resource, if known.
|
|
12131
|
-
*/
|
|
12132
|
-
mimeType: z.optional(z.string())
|
|
12133
|
-
}).passthrough();
|
|
12134
|
-
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
12135
|
-
text: z.string()
|
|
12136
|
-
});
|
|
12137
|
-
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
12138
|
-
blob: z.string().base64()
|
|
12139
|
-
});
|
|
12140
|
-
var EmbeddedResourceSchema = z.object({
|
|
12141
|
-
type: z.literal("resource"),
|
|
12142
|
-
resource: z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
12143
|
-
}).passthrough();
|
|
12144
|
-
ResultSchema.extend({
|
|
12145
|
-
content: z.array(
|
|
12146
|
-
z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
|
|
12147
|
-
),
|
|
12148
|
-
isError: z.boolean().default(false).optional()
|
|
12149
|
-
}).or(
|
|
12150
|
-
ResultSchema.extend({
|
|
12151
|
-
toolResult: z.unknown()
|
|
12152
|
-
})
|
|
12153
|
-
);
|
|
12154
|
-
var JSONRPC_VERSION = "2.0";
|
|
12155
|
-
var JSONRPCRequestSchema = z.object({
|
|
12156
|
-
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
12157
|
-
id: z.union([z.string(), z.number().int()])
|
|
12158
|
-
}).merge(RequestSchema).strict();
|
|
12159
|
-
var JSONRPCResponseSchema = z.object({
|
|
12160
|
-
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
12161
|
-
id: z.union([z.string(), z.number().int()]),
|
|
12162
|
-
result: ResultSchema
|
|
12163
|
-
}).strict();
|
|
12164
|
-
var JSONRPCErrorSchema = z.object({
|
|
12165
|
-
jsonrpc: z.literal(JSONRPC_VERSION),
|
|
12166
|
-
id: z.union([z.string(), z.number().int()]),
|
|
12167
|
-
error: z.object({
|
|
12168
|
-
code: z.number().int(),
|
|
12169
|
-
message: z.string(),
|
|
12170
|
-
data: z.optional(z.unknown())
|
|
12171
|
-
})
|
|
12172
|
-
}).strict();
|
|
12173
|
-
var JSONRPCNotificationSchema = z.object({
|
|
12174
|
-
jsonrpc: z.literal(JSONRPC_VERSION)
|
|
12175
|
-
}).merge(
|
|
12176
|
-
z.object({
|
|
12177
|
-
method: z.string(),
|
|
12178
|
-
params: z.optional(BaseParamsSchema)
|
|
12179
|
-
})
|
|
12180
|
-
).strict();
|
|
12181
|
-
z.union([
|
|
12182
|
-
JSONRPCRequestSchema,
|
|
12183
|
-
JSONRPCNotificationSchema,
|
|
12184
|
-
JSONRPCResponseSchema,
|
|
12185
|
-
JSONRPCErrorSchema
|
|
12186
|
-
]);
|
|
12187
|
-
var langchain_adapter_exports = {};
|
|
12188
|
-
__export(langchain_adapter_exports, {
|
|
12189
|
-
mergeIntoDataStream: () => mergeIntoDataStream,
|
|
12190
|
-
toDataStream: () => toDataStream,
|
|
12191
|
-
toDataStreamResponse: () => toDataStreamResponse
|
|
12192
|
-
});
|
|
12193
|
-
function createCallbacksTransformer(callbacks = {}) {
|
|
12194
|
-
const textEncoder = new TextEncoder();
|
|
12195
|
-
let aggregatedResponse = "";
|
|
12196
|
-
return new TransformStream({
|
|
12197
|
-
async start() {
|
|
12198
|
-
if (callbacks.onStart)
|
|
12199
|
-
await callbacks.onStart();
|
|
12200
|
-
},
|
|
12201
|
-
async transform(message, controller) {
|
|
12202
|
-
controller.enqueue(textEncoder.encode(message));
|
|
12203
|
-
aggregatedResponse += message;
|
|
12204
|
-
if (callbacks.onToken)
|
|
12205
|
-
await callbacks.onToken(message);
|
|
12206
|
-
if (callbacks.onText && typeof message === "string") {
|
|
12207
|
-
await callbacks.onText(message);
|
|
12208
|
-
}
|
|
12209
|
-
},
|
|
12210
|
-
async flush() {
|
|
12211
|
-
if (callbacks.onCompletion) {
|
|
12212
|
-
await callbacks.onCompletion(aggregatedResponse);
|
|
12213
|
-
}
|
|
12214
|
-
if (callbacks.onFinal) {
|
|
12215
|
-
await callbacks.onFinal(aggregatedResponse);
|
|
12216
|
-
}
|
|
12217
|
-
}
|
|
12218
|
-
});
|
|
12219
|
-
}
|
|
12220
|
-
function toDataStreamInternal(stream, callbacks) {
|
|
12221
|
-
return stream.pipeThrough(
|
|
12222
|
-
new TransformStream({
|
|
12223
|
-
transform: async (value, controller) => {
|
|
12224
|
-
var _a17;
|
|
12225
|
-
if (typeof value === "string") {
|
|
12226
|
-
controller.enqueue(value);
|
|
12227
|
-
return;
|
|
12228
|
-
}
|
|
12229
|
-
if ("event" in value) {
|
|
12230
|
-
if (value.event === "on_chat_model_stream") {
|
|
12231
|
-
forwardAIMessageChunk(
|
|
12232
|
-
(_a17 = value.data) == null ? void 0 : _a17.chunk,
|
|
12233
|
-
controller
|
|
12234
|
-
);
|
|
12235
|
-
}
|
|
12236
|
-
return;
|
|
12237
|
-
}
|
|
12238
|
-
forwardAIMessageChunk(value, controller);
|
|
12239
|
-
}
|
|
12240
|
-
})
|
|
12241
|
-
).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(new TextDecoderStream()).pipeThrough(
|
|
12242
|
-
new TransformStream({
|
|
12243
|
-
transform: async (chunk, controller) => {
|
|
12244
|
-
controller.enqueue(formatDataStreamPart("text", chunk));
|
|
12245
|
-
}
|
|
12246
|
-
})
|
|
12247
|
-
);
|
|
12248
|
-
}
|
|
12249
|
-
function toDataStream(stream, callbacks) {
|
|
12250
|
-
return toDataStreamInternal(stream, callbacks).pipeThrough(
|
|
12251
|
-
new TextEncoderStream()
|
|
12252
|
-
);
|
|
12253
|
-
}
|
|
12254
|
-
function toDataStreamResponse(stream, options) {
|
|
12255
|
-
var _a17;
|
|
12256
|
-
const dataStream = toDataStreamInternal(
|
|
12257
|
-
stream,
|
|
12258
|
-
options == null ? void 0 : options.callbacks
|
|
12259
|
-
).pipeThrough(new TextEncoderStream());
|
|
12260
|
-
const data = options == null ? void 0 : options.data;
|
|
12261
|
-
const init = options == null ? void 0 : options.init;
|
|
12262
|
-
const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
|
|
12263
|
-
return new Response(responseStream, {
|
|
12264
|
-
status: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,
|
|
12265
|
-
statusText: init == null ? void 0 : init.statusText,
|
|
12266
|
-
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
|
12267
|
-
contentType: "text/plain; charset=utf-8",
|
|
12268
|
-
dataStreamVersion: "v1"
|
|
12269
|
-
})
|
|
12270
|
-
});
|
|
12271
|
-
}
|
|
12272
|
-
function mergeIntoDataStream(stream, options) {
|
|
12273
|
-
options.dataStream.merge(toDataStreamInternal(stream, options.callbacks));
|
|
12274
|
-
}
|
|
12275
|
-
function forwardAIMessageChunk(chunk, controller) {
|
|
12276
|
-
if (typeof chunk.content === "string") {
|
|
12277
|
-
controller.enqueue(chunk.content);
|
|
12278
|
-
} else {
|
|
12279
|
-
const content = chunk.content;
|
|
12280
|
-
for (const item of content) {
|
|
12281
|
-
if (item.type === "text") {
|
|
12282
|
-
controller.enqueue(item.text);
|
|
12283
|
-
}
|
|
12284
|
-
}
|
|
12285
|
-
}
|
|
12286
|
-
}
|
|
12287
|
-
var llamaindex_adapter_exports = {};
|
|
12288
|
-
__export(llamaindex_adapter_exports, {
|
|
12289
|
-
mergeIntoDataStream: () => mergeIntoDataStream2,
|
|
12290
|
-
toDataStream: () => toDataStream2,
|
|
12291
|
-
toDataStreamResponse: () => toDataStreamResponse2
|
|
12292
|
-
});
|
|
12293
|
-
function toDataStreamInternal2(stream, callbacks) {
|
|
12294
|
-
const trimStart = trimStartOfStream();
|
|
12295
|
-
return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]()).pipeThrough(
|
|
12296
|
-
new TransformStream({
|
|
12297
|
-
async transform(message, controller) {
|
|
12298
|
-
controller.enqueue(trimStart(message.delta));
|
|
12299
|
-
}
|
|
12300
|
-
})
|
|
12301
|
-
).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(new TextDecoderStream()).pipeThrough(
|
|
12302
|
-
new TransformStream({
|
|
12303
|
-
transform: async (chunk, controller) => {
|
|
12304
|
-
controller.enqueue(formatDataStreamPart("text", chunk));
|
|
12305
|
-
}
|
|
12306
|
-
})
|
|
12307
|
-
);
|
|
12308
|
-
}
|
|
12309
|
-
function toDataStream2(stream, callbacks) {
|
|
12310
|
-
return toDataStreamInternal2(stream, callbacks).pipeThrough(
|
|
12311
|
-
new TextEncoderStream()
|
|
12312
|
-
);
|
|
12313
|
-
}
|
|
12314
|
-
function toDataStreamResponse2(stream, options = {}) {
|
|
12315
|
-
var _a17;
|
|
12316
|
-
const { init, data, callbacks } = options;
|
|
12317
|
-
const dataStream = toDataStreamInternal2(stream, callbacks).pipeThrough(
|
|
12318
|
-
new TextEncoderStream()
|
|
12319
|
-
);
|
|
12320
|
-
const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
|
|
12321
|
-
return new Response(responseStream, {
|
|
12322
|
-
status: (_a17 = init == null ? void 0 : init.status) != null ? _a17 : 200,
|
|
12323
|
-
statusText: init == null ? void 0 : init.statusText,
|
|
12324
|
-
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
|
12325
|
-
contentType: "text/plain; charset=utf-8",
|
|
12326
|
-
dataStreamVersion: "v1"
|
|
12327
|
-
})
|
|
12328
|
-
});
|
|
12329
|
-
}
|
|
12330
|
-
function mergeIntoDataStream2(stream, options) {
|
|
12331
|
-
options.dataStream.merge(toDataStreamInternal2(stream, options.callbacks));
|
|
12332
|
-
}
|
|
12333
|
-
function trimStartOfStream() {
|
|
12334
|
-
let isStreamStart = true;
|
|
12335
|
-
return (text2) => {
|
|
12336
|
-
if (isStreamStart) {
|
|
12337
|
-
text2 = text2.trimStart();
|
|
12338
|
-
if (text2)
|
|
12339
|
-
isStreamStart = false;
|
|
12340
|
-
}
|
|
12341
|
-
return text2;
|
|
12342
|
-
};
|
|
12343
|
-
}
|
|
12344
|
-
__toESM(require_json_schema_traverse());
|
|
12345
|
-
|
|
12346
|
-
// src/server/server-adapter/openapi-utils.ts
|
|
12347
|
-
function generateRouteOpenAPI({
|
|
12348
|
-
method,
|
|
12349
|
-
path,
|
|
12350
|
-
summary,
|
|
12351
|
-
description,
|
|
12352
|
-
tags = [],
|
|
12353
|
-
pathParamSchema,
|
|
12354
|
-
queryParamSchema,
|
|
12355
|
-
bodySchema,
|
|
12356
|
-
responseSchema,
|
|
12357
|
-
deprecated
|
|
12358
|
-
}) {
|
|
12359
|
-
const route = {
|
|
12360
|
-
summary: summary || `${method} ${path}`,
|
|
12361
|
-
description,
|
|
12362
|
-
tags,
|
|
12363
|
-
deprecated,
|
|
12364
|
-
responses: {
|
|
12365
|
-
200: {
|
|
12366
|
-
description: "Successful response"
|
|
12367
|
-
}
|
|
12368
|
-
}
|
|
12369
|
-
};
|
|
12370
|
-
if (pathParamSchema || queryParamSchema) {
|
|
12371
|
-
route.requestParams = {};
|
|
12372
|
-
if (pathParamSchema) {
|
|
12373
|
-
route.requestParams.path = pathParamSchema;
|
|
12374
|
-
}
|
|
12375
|
-
if (queryParamSchema) {
|
|
12376
|
-
route.requestParams.query = queryParamSchema;
|
|
12377
|
-
}
|
|
12378
|
-
}
|
|
12379
|
-
if (bodySchema) {
|
|
12380
|
-
route.requestBody = {
|
|
12381
|
-
content: {
|
|
12382
|
-
"application/json": {
|
|
12383
|
-
schema: bodySchema
|
|
12384
|
-
}
|
|
12385
|
-
}
|
|
12386
|
-
};
|
|
12387
|
-
}
|
|
12388
|
-
if (responseSchema) {
|
|
12389
|
-
route.responses[200] = {
|
|
12390
|
-
description: "Successful response",
|
|
12391
|
-
content: {
|
|
12392
|
-
"application/json": {
|
|
12393
|
-
schema: responseSchema
|
|
12394
|
-
}
|
|
12395
|
-
}
|
|
12396
|
-
};
|
|
12397
|
-
}
|
|
12398
|
-
return route;
|
|
12399
|
-
}
|
|
12400
|
-
function schemaToJsonSchema(schema) {
|
|
12401
|
-
const standardSchema = toStandardSchema$1(schema);
|
|
12402
|
-
return standardSchemaToJSONSchema(standardSchema);
|
|
12403
|
-
}
|
|
12404
|
-
function convertToJsonSchema3(spec) {
|
|
12405
|
-
const converted = {
|
|
12406
|
-
summary: spec.summary,
|
|
12407
|
-
description: spec.description,
|
|
12408
|
-
tags: spec.tags,
|
|
12409
|
-
responses: {}
|
|
12410
|
-
};
|
|
12411
|
-
const parameters = [];
|
|
12412
|
-
if (spec.requestParams?.path) {
|
|
12413
|
-
const pathSchema = schemaToJsonSchema(spec.requestParams.path);
|
|
12414
|
-
const properties = pathSchema.properties || {};
|
|
12415
|
-
Object.entries(properties).forEach(([name, schema]) => {
|
|
12416
|
-
parameters.push({
|
|
12417
|
-
name,
|
|
12418
|
-
in: "path",
|
|
12419
|
-
required: true,
|
|
12420
|
-
description: schema.description || `The ${name} parameter`,
|
|
12421
|
-
schema
|
|
12422
|
-
});
|
|
12423
|
-
});
|
|
12424
|
-
}
|
|
12425
|
-
if (spec.requestParams?.query) {
|
|
12426
|
-
const querySchema = schemaToJsonSchema(spec.requestParams.query);
|
|
12427
|
-
const properties = querySchema.properties || {};
|
|
12428
|
-
const required = querySchema.required || [];
|
|
12429
|
-
Object.entries(properties).forEach(([name, schema]) => {
|
|
12430
|
-
parameters.push({
|
|
12431
|
-
name,
|
|
12432
|
-
in: "query",
|
|
12433
|
-
required: required.includes(name),
|
|
12434
|
-
description: schema.description || `Query parameter: ${name}`,
|
|
12435
|
-
schema
|
|
12436
|
-
});
|
|
12437
|
-
});
|
|
12438
|
-
}
|
|
12439
|
-
if (parameters.length > 0) {
|
|
12440
|
-
converted.parameters = parameters;
|
|
12441
|
-
}
|
|
12442
|
-
if (spec.requestBody?.content?.["application/json"]?.schema) {
|
|
12443
|
-
converted.requestBody = {
|
|
12444
|
-
required: true,
|
|
12445
|
-
content: {
|
|
12446
|
-
"application/json": {
|
|
12447
|
-
schema: schemaToJsonSchema(spec.requestBody.content["application/json"].schema)
|
|
12448
|
-
}
|
|
12449
|
-
}
|
|
12450
|
-
};
|
|
12451
|
-
}
|
|
12452
|
-
Object.entries(spec.responses).forEach(([statusCode, response]) => {
|
|
12453
|
-
converted.responses[statusCode] = {
|
|
12454
|
-
description: response.description
|
|
12455
|
-
};
|
|
12456
|
-
if (response.content?.["application/json"]?.schema) {
|
|
12457
|
-
converted.responses[statusCode].content = {
|
|
12458
|
-
"application/json": {
|
|
12459
|
-
schema: schemaToJsonSchema(response.content["application/json"].schema)
|
|
12460
|
-
}
|
|
12461
|
-
};
|
|
12462
|
-
}
|
|
12463
|
-
});
|
|
12464
|
-
return converted;
|
|
12465
|
-
}
|
|
12466
|
-
function generateOpenAPIDocument(routes, info) {
|
|
12467
|
-
const paths = /* @__PURE__ */ Object.create(null);
|
|
12468
|
-
routes.forEach((route) => {
|
|
12469
|
-
if (!route.openapi) return;
|
|
12470
|
-
const openapiPath = route.path.replace(/:(\w+)/g, "{$1}");
|
|
12471
|
-
if (!paths[openapiPath]) {
|
|
12472
|
-
paths[openapiPath] = /* @__PURE__ */ Object.create(null);
|
|
12473
|
-
}
|
|
12474
|
-
paths[openapiPath][route.method.toLowerCase()] = convertToJsonSchema3(route.openapi);
|
|
12475
|
-
});
|
|
12476
|
-
return {
|
|
12477
|
-
openapi: "3.1.0",
|
|
12478
|
-
info: {
|
|
12479
|
-
title: info.title,
|
|
12480
|
-
version: info.version,
|
|
12481
|
-
description: info.description
|
|
12482
|
-
},
|
|
12483
|
-
paths
|
|
12484
|
-
};
|
|
12485
|
-
}
|
|
12486
|
-
function convertCustomRoutesToOpenAPIPaths(routes) {
|
|
12487
|
-
const paths = {};
|
|
12488
|
-
for (const route of routes) {
|
|
12489
|
-
if (!route.openapi || route.openapi.hide) {
|
|
12490
|
-
continue;
|
|
12491
|
-
}
|
|
12492
|
-
if (route.method === "ALL") {
|
|
12493
|
-
continue;
|
|
12494
|
-
}
|
|
12495
|
-
const openapiPath = route.path.replace(/:(\w+)/g, "{$1}");
|
|
12496
|
-
if (!paths[openapiPath]) {
|
|
12497
|
-
paths[openapiPath] = {};
|
|
12498
|
-
}
|
|
12499
|
-
const method = route.method.toLowerCase();
|
|
12500
|
-
const openapi = route.openapi;
|
|
12501
|
-
const operation = {
|
|
12502
|
-
summary: openapi.summary || `${route.method} ${route.path}`,
|
|
12503
|
-
description: openapi.description,
|
|
12504
|
-
tags: openapi.tags || ["custom"],
|
|
12505
|
-
deprecated: openapi.deprecated,
|
|
12506
|
-
externalDocs: openapi.externalDocs,
|
|
12507
|
-
security: openapi.security,
|
|
12508
|
-
servers: openapi.servers
|
|
12509
|
-
};
|
|
12510
|
-
if (openapi.parameters && Array.isArray(openapi.parameters)) {
|
|
12511
|
-
operation.parameters = openapi.parameters.map((param) => {
|
|
12512
|
-
if (param.schema && typeof param.schema === "object" && "_def" in param.schema) {
|
|
12513
|
-
return {
|
|
12514
|
-
...param,
|
|
12515
|
-
schema: zodToJsonSchema$1(param.schema, "openApi3", "none")
|
|
12516
|
-
};
|
|
12517
|
-
}
|
|
12518
|
-
return param;
|
|
12519
|
-
});
|
|
12520
|
-
}
|
|
12521
|
-
if (openapi.requestBody) {
|
|
12522
|
-
const requestBody = openapi.requestBody;
|
|
12523
|
-
operation.requestBody = { ...requestBody };
|
|
12524
|
-
if (requestBody.content) {
|
|
12525
|
-
operation.requestBody.content = {};
|
|
12526
|
-
for (const [mediaType, mediaContent] of Object.entries(requestBody.content)) {
|
|
12527
|
-
if (mediaContent?.schema && typeof mediaContent.schema === "object" && "_def" in mediaContent.schema) {
|
|
12528
|
-
operation.requestBody.content[mediaType] = {
|
|
12529
|
-
...mediaContent,
|
|
12530
|
-
schema: zodToJsonSchema$1(mediaContent.schema, "openApi3", "none")
|
|
12531
|
-
};
|
|
12532
|
-
} else {
|
|
12533
|
-
operation.requestBody.content[mediaType] = mediaContent;
|
|
12534
|
-
}
|
|
12535
|
-
}
|
|
12536
|
-
}
|
|
12537
|
-
}
|
|
12538
|
-
if (openapi.responses) {
|
|
12539
|
-
operation.responses = {};
|
|
12540
|
-
for (const [statusCode, response] of Object.entries(openapi.responses)) {
|
|
12541
|
-
if (!response) continue;
|
|
12542
|
-
if ("$ref" in response) {
|
|
12543
|
-
operation.responses[statusCode] = response;
|
|
12544
|
-
continue;
|
|
12545
|
-
}
|
|
12546
|
-
operation.responses[statusCode] = { ...response };
|
|
12547
|
-
if (response.content) {
|
|
12548
|
-
operation.responses[statusCode].content = {};
|
|
12549
|
-
for (const [mediaType, mediaContent] of Object.entries(response.content)) {
|
|
12550
|
-
if (mediaContent?.schema && typeof mediaContent.schema === "object" && "_def" in mediaContent.schema) {
|
|
12551
|
-
operation.responses[statusCode].content[mediaType] = {
|
|
12552
|
-
...mediaContent,
|
|
12553
|
-
schema: zodToJsonSchema$1(mediaContent.schema, "openApi3", "none")
|
|
12554
|
-
};
|
|
12555
|
-
} else {
|
|
12556
|
-
operation.responses[statusCode].content[mediaType] = mediaContent;
|
|
12557
|
-
}
|
|
12558
|
-
}
|
|
12559
|
-
}
|
|
12560
|
-
}
|
|
12561
|
-
} else {
|
|
12562
|
-
operation.responses = {
|
|
12563
|
-
200: {
|
|
12564
|
-
description: "Successful response"
|
|
12565
|
-
}
|
|
12566
|
-
};
|
|
12567
|
-
}
|
|
12568
|
-
Object.keys(operation).forEach((key) => {
|
|
12569
|
-
if (operation[key] === void 0) {
|
|
12570
|
-
delete operation[key];
|
|
12571
|
-
}
|
|
12572
|
-
});
|
|
12573
|
-
paths[openapiPath][method] = operation;
|
|
12574
|
-
}
|
|
12575
|
-
return paths;
|
|
12576
|
-
}
|
|
12577
|
-
function pickParams(schema, params) {
|
|
12578
|
-
const keys = Object.keys(schema.shape);
|
|
12579
|
-
const result = {};
|
|
12580
|
-
for (const key of keys) {
|
|
12581
|
-
if (key in params) {
|
|
12582
|
-
result[key] = params[key];
|
|
12583
|
-
}
|
|
12584
|
-
}
|
|
12585
|
-
return result;
|
|
12586
|
-
}
|
|
12587
|
-
function jsonQueryParam(schema) {
|
|
12588
|
-
return z$1.union([
|
|
12589
|
-
schema,
|
|
12590
|
-
// Already the expected type (non-string input)
|
|
12591
|
-
z$1.string().transform((val, ctx) => {
|
|
12592
|
-
try {
|
|
12593
|
-
const parsed = JSON.parse(val);
|
|
12594
|
-
const result = schema.safeParse(parsed);
|
|
12595
|
-
if (!result.success) {
|
|
12596
|
-
for (const issue of result.error.issues) {
|
|
12597
|
-
ctx.addIssue({
|
|
12598
|
-
code: z$1.ZodIssueCode.custom,
|
|
12599
|
-
message: issue.message,
|
|
12600
|
-
path: issue.path
|
|
12601
|
-
});
|
|
12602
|
-
}
|
|
12603
|
-
return z$1.NEVER;
|
|
12604
|
-
}
|
|
12605
|
-
return result.data;
|
|
12606
|
-
} catch (e) {
|
|
12607
|
-
ctx.addIssue({
|
|
12608
|
-
code: z$1.ZodIssueCode.custom,
|
|
12609
|
-
message: `Invalid JSON: ${e instanceof Error ? e.message : "parse error"}`
|
|
12610
|
-
});
|
|
12611
|
-
return z$1.NEVER;
|
|
12612
|
-
}
|
|
12613
|
-
})
|
|
12614
|
-
]);
|
|
12615
|
-
}
|
|
12616
|
-
function isComplexType(schema) {
|
|
12617
|
-
let inner = schema;
|
|
12618
|
-
while (inner instanceof ZodOptional || inner instanceof ZodNullable) {
|
|
12619
|
-
inner = inner.unwrap();
|
|
12620
|
-
}
|
|
12621
|
-
return inner instanceof ZodArray || inner instanceof ZodRecord || inner instanceof ZodObject;
|
|
12622
|
-
}
|
|
12623
|
-
function wrapSchemaForQueryParams(schema) {
|
|
12624
|
-
const newShape = {};
|
|
12625
|
-
const shape = schema.shape;
|
|
12626
|
-
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
12627
|
-
if (isComplexType(fieldSchema)) {
|
|
12628
|
-
newShape[key] = jsonQueryParam(fieldSchema);
|
|
12629
|
-
} else {
|
|
12630
|
-
newShape[key] = fieldSchema;
|
|
12631
|
-
}
|
|
12632
|
-
}
|
|
12633
|
-
return z$1.object(newShape);
|
|
12634
|
-
}
|
|
12635
|
-
function createRoute(config) {
|
|
12636
|
-
const { summary, description, tags, deprecated, requiresAuth, requiresPermission, onValidationError, ...baseRoute } = config;
|
|
12637
|
-
const openapi = config.method !== "ALL" ? generateRouteOpenAPI({
|
|
12638
|
-
method: config.method,
|
|
12639
|
-
path: config.path,
|
|
12640
|
-
summary,
|
|
12641
|
-
description,
|
|
12642
|
-
tags,
|
|
12643
|
-
pathParamSchema: config.pathParamSchema,
|
|
12644
|
-
queryParamSchema: config.queryParamSchema,
|
|
12645
|
-
bodySchema: config.bodySchema,
|
|
12646
|
-
responseSchema: config.responseSchema,
|
|
12647
|
-
deprecated
|
|
12648
|
-
}) : void 0;
|
|
12649
|
-
return {
|
|
12650
|
-
...baseRoute,
|
|
12651
|
-
openapi,
|
|
12652
|
-
deprecated,
|
|
12653
|
-
requiresAuth,
|
|
12654
|
-
requiresPermission,
|
|
12655
|
-
onValidationError
|
|
12656
|
-
};
|
|
12657
|
-
}
|
|
12658
|
-
function createPublicRoute(config) {
|
|
12659
|
-
return createRoute({
|
|
12660
|
-
...config,
|
|
12661
|
-
requiresAuth: false
|
|
12662
|
-
});
|
|
8780
|
+
jsonSchema = JSON.parse(JSON.stringify(jsonSchema));
|
|
8781
|
+
return jsonSchema;
|
|
12663
8782
|
}
|
|
12664
8783
|
|
|
12665
|
-
export {
|
|
12666
|
-
//# sourceMappingURL=chunk-
|
|
12667
|
-
//# sourceMappingURL=chunk-
|
|
8784
|
+
export { __toESM, isStandardSchemaWithJSON, require_json_schema_traverse, standardSchemaToJSONSchema, toStandardSchema5 };
|
|
8785
|
+
//# sourceMappingURL=chunk-ZT2BLQRR.js.map
|
|
8786
|
+
//# sourceMappingURL=chunk-ZT2BLQRR.js.map
|