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