@zythum02/fello-server 0.1.54 → 0.1.55
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/out/renderer/assets/{_baseUniq-DYINnBRJ.js → _baseUniq-BdLqGxOi.js} +1 -1
- package/out/renderer/assets/_baseUniq-BdLqGxOi.js.br +0 -0
- package/out/renderer/assets/_baseUniq-BdLqGxOi.js.gz +0 -0
- package/out/renderer/assets/{arc-BSUyw88k.js → arc-UpL8po5R.js} +1 -1
- package/out/renderer/assets/arc-UpL8po5R.js.br +0 -0
- package/out/renderer/assets/arc-UpL8po5R.js.gz +0 -0
- package/out/renderer/assets/{architectureDiagram-Q4EWVU46-Cxb8DhYZ.js → architectureDiagram-Q4EWVU46-ManEkEbl.js} +6 -6
- package/out/renderer/assets/architectureDiagram-Q4EWVU46-ManEkEbl.js.br +0 -0
- package/out/renderer/assets/architectureDiagram-Q4EWVU46-ManEkEbl.js.gz +0 -0
- package/out/renderer/assets/arrow-left-BnuWerui.js +14 -0
- package/out/renderer/assets/arrow-up-quD46bYg.js +36 -0
- package/out/renderer/assets/{automation-CQAOpWYp.js → automation-cVl19jbl.js} +22 -9
- package/out/renderer/assets/automation-cVl19jbl.js.br +0 -0
- package/out/renderer/assets/automation-cVl19jbl.js.gz +0 -0
- package/out/renderer/assets/{blockDiagram-DXYQGD6D-CFozis-v.js → blockDiagram-DXYQGD6D-B7n8X8F6.js} +7 -7
- package/out/renderer/assets/blockDiagram-DXYQGD6D-B7n8X8F6.js.br +0 -0
- package/out/renderer/assets/blockDiagram-DXYQGD6D-B7n8X8F6.js.gz +0 -0
- package/out/renderer/assets/{c4Diagram-AHTNJAMY-CcDDkZUp.js → c4Diagram-AHTNJAMY-BoP_JNY0.js} +3 -3
- package/out/renderer/assets/c4Diagram-AHTNJAMY-BoP_JNY0.js.br +0 -0
- package/out/renderer/assets/c4Diagram-AHTNJAMY-BoP_JNY0.js.gz +0 -0
- package/out/renderer/assets/{channel-B-VC_ZcK.js → channel-BTAU8ahK.js} +1 -1
- package/out/renderer/assets/{chunk-4BX2VUAB-ClHmnOTC.js → chunk-4BX2VUAB-BCKz1EgZ.js} +1 -1
- package/out/renderer/assets/{chunk-4TB4RGXK-mwOvn19G.js → chunk-4TB4RGXK-B2HhnMqB.js} +5 -5
- package/out/renderer/assets/chunk-4TB4RGXK-B2HhnMqB.js.br +0 -0
- package/out/renderer/assets/chunk-4TB4RGXK-B2HhnMqB.js.gz +0 -0
- package/out/renderer/assets/{chunk-55IACEB6-CE8f6iip.js → chunk-55IACEB6-Drurz_4k.js} +1 -1
- package/out/renderer/assets/{chunk-EDXVE4YY-CU7aY96h.js → chunk-EDXVE4YY-Xfghcg7b.js} +1 -1
- package/out/renderer/assets/chunk-EDXVE4YY-Xfghcg7b.js.br +0 -0
- package/out/renderer/assets/chunk-EDXVE4YY-Xfghcg7b.js.gz +0 -0
- package/out/renderer/assets/{chunk-FMBD7UC4-B38kFkjv.js → chunk-FMBD7UC4-Birgz8kz.js} +1 -1
- package/out/renderer/assets/{chunk-OYMX7WX6-BriTCtaz.js → chunk-OYMX7WX6-Cv4jgShd.js} +3 -3
- package/out/renderer/assets/chunk-OYMX7WX6-Cv4jgShd.js.br +0 -0
- package/out/renderer/assets/chunk-OYMX7WX6-Cv4jgShd.js.gz +0 -0
- package/out/renderer/assets/{chunk-QZHKN3VN-BwJ37p5G.js → chunk-QZHKN3VN-DkqKjktH.js} +1 -1
- package/out/renderer/assets/{chunk-YZCP3GAM-BlHAYoQe.js → chunk-YZCP3GAM-CJK_tBTq.js} +1 -1
- package/out/renderer/assets/chunk-YZCP3GAM-CJK_tBTq.js.br +0 -0
- package/out/renderer/assets/chunk-YZCP3GAM-CJK_tBTq.js.gz +0 -0
- package/out/renderer/assets/circle-x-C9_Yp0Tg.js +16 -0
- package/out/renderer/assets/{classDiagram-6PBFFD2Q-D01ZMeaj.js → classDiagram-6PBFFD2Q-Bf4To0VI.js} +7 -7
- package/out/renderer/assets/{classDiagram-v2-HSJHXN6E-D01ZMeaj.js → classDiagram-v2-HSJHXN6E-Bf4To0VI.js} +7 -7
- package/out/renderer/assets/{clone-qctAbdCx.js → clone-Ci5J50Pn.js} +1 -1
- package/out/renderer/assets/{code-editor-tm0AYOLz.js → code-editor-BwPwET3m.js} +2 -2
- package/out/renderer/assets/code-editor-BwPwET3m.js.br +0 -0
- package/out/renderer/assets/code-editor-BwPwET3m.js.gz +0 -0
- package/out/renderer/assets/{collapsible-DD6NlDid.js → collapsible-CMQ8h8ID.js} +43 -53
- package/out/renderer/assets/collapsible-CMQ8h8ID.js.br +0 -0
- package/out/renderer/assets/collapsible-CMQ8h8ID.js.gz +0 -0
- package/out/renderer/assets/command-nKlwdb6i.js +19 -0
- package/out/renderer/assets/comment-ui-runtime-BsK8pmUT-C8f5Wrup.js +53 -0
- package/out/renderer/assets/comment-ui-runtime-BsK8pmUT-C8f5Wrup.js.br +0 -0
- package/out/renderer/assets/comment-ui-runtime-BsK8pmUT-C8f5Wrup.js.gz +0 -0
- package/out/renderer/assets/{cose-bilkent-S5V4N54A-CF4brbsf.js → cose-bilkent-S5V4N54A-BZpcn2q9.js} +2 -2
- package/out/renderer/assets/cose-bilkent-S5V4N54A-BZpcn2q9.js.br +0 -0
- package/out/renderer/assets/cose-bilkent-S5V4N54A-BZpcn2q9.js.gz +0 -0
- package/out/renderer/assets/{dagre-KV5264BT-C6I5VgRp.js → dagre-KV5264BT-onHZodsn.js} +7 -7
- package/out/renderer/assets/dagre-KV5264BT-onHZodsn.js.br +0 -0
- package/out/renderer/assets/dagre-KV5264BT-onHZodsn.js.gz +0 -0
- package/out/renderer/assets/delimited-text-worker-host-BVY-Ecni-D1eBZLWW.js +25 -0
- package/out/renderer/assets/delimited-text-worker-host-BVY-Ecni-D1eBZLWW.js.br +0 -0
- package/out/renderer/assets/delimited-text-worker-host-BVY-Ecni-D1eBZLWW.js.gz +0 -0
- package/out/renderer/assets/{diagram-5BDNPKRD-BAO72D5R.js → diagram-5BDNPKRD-y3QVYwp7.js} +7 -7
- package/out/renderer/assets/diagram-5BDNPKRD-y3QVYwp7.js.br +0 -0
- package/out/renderer/assets/diagram-5BDNPKRD-y3QVYwp7.js.gz +0 -0
- package/out/renderer/assets/{diagram-G4DWMVQ6-BmpkrtJs.js → diagram-G4DWMVQ6-LB3RUjrJ.js} +7 -7
- package/out/renderer/assets/diagram-G4DWMVQ6-LB3RUjrJ.js.br +0 -0
- package/out/renderer/assets/diagram-G4DWMVQ6-LB3RUjrJ.js.gz +0 -0
- package/out/renderer/assets/{diagram-MMDJMWI5-8keZZjgB.js → diagram-MMDJMWI5-7NpY26IL.js} +6 -6
- package/out/renderer/assets/diagram-MMDJMWI5-7NpY26IL.js.br +0 -0
- package/out/renderer/assets/diagram-MMDJMWI5-7NpY26IL.js.gz +0 -0
- package/out/renderer/assets/{diagram-TYMM5635-Be4uDvHI.js → diagram-TYMM5635-DRM1RRr4.js} +6 -6
- package/out/renderer/assets/diagram-TYMM5635-DRM1RRr4.js.br +0 -0
- package/out/renderer/assets/diagram-TYMM5635-DRM1RRr4.js.gz +0 -0
- package/out/renderer/assets/docx_parser_bg-C1Wf3n7F.wasm +0 -0
- package/out/renderer/assets/ellipsis-D_eCkauJ.js +16 -0
- package/out/renderer/assets/{erDiagram-SMLLAGMA-C6IgAbhi.js → erDiagram-SMLLAGMA-DNIZ639C.js} +5 -5
- package/out/renderer/assets/erDiagram-SMLLAGMA-DNIZ639C.js.br +0 -0
- package/out/renderer/assets/erDiagram-SMLLAGMA-DNIZ639C.js.gz +0 -0
- package/out/renderer/assets/{field-BPsDfe4e.js → field-YZTi9Jxc.js} +1 -1
- package/out/renderer/assets/field-YZTi9Jxc.js.br +0 -0
- package/out/renderer/assets/field-YZTi9Jxc.js.gz +0 -0
- package/out/renderer/assets/file-text-DDtS1g4Q.js +23 -0
- package/out/renderer/assets/{flowDiagram-DWJPFMVM-vbYKBn4t.js → flowDiagram-DWJPFMVM-C0ghMibN.js} +7 -7
- package/out/renderer/assets/flowDiagram-DWJPFMVM-C0ghMibN.js.br +0 -0
- package/out/renderer/assets/flowDiagram-DWJPFMVM-C0ghMibN.js.gz +0 -0
- package/out/renderer/assets/{ganttDiagram-T4ZO3ILL-AxXIe9I4.js → ganttDiagram-T4ZO3ILL-tqeHqMu4.js} +3 -3
- package/out/renderer/assets/ganttDiagram-T4ZO3ILL-tqeHqMu4.js.br +0 -0
- package/out/renderer/assets/ganttDiagram-T4ZO3ILL-tqeHqMu4.js.gz +0 -0
- package/out/renderer/assets/{gitGraphDiagram-UUTBAWPF-DSipARMB.js → gitGraphDiagram-UUTBAWPF-D6acFhfE.js} +7 -7
- package/out/renderer/assets/gitGraphDiagram-UUTBAWPF-D6acFhfE.js.br +0 -0
- package/out/renderer/assets/gitGraphDiagram-UUTBAWPF-D6acFhfE.js.gz +0 -0
- package/out/renderer/assets/{graph-mNaHfg3r.js → graph-DqFGMaSz.js} +2 -2
- package/out/renderer/assets/graph-DqFGMaSz.js.br +0 -0
- package/out/renderer/assets/graph-DqFGMaSz.js.gz +0 -0
- package/out/renderer/assets/highlighted-body-KPVGNVTW-D2IZ7Enb.js +18 -0
- package/out/renderer/assets/index-BZTYKZe8.css +382 -0
- package/out/renderer/assets/index-BZTYKZe8.css.br +0 -0
- package/out/renderer/assets/index-BZTYKZe8.css.gz +0 -0
- package/out/renderer/assets/{index-BUwXrbHW.js → index-BeEZXfJZ.js} +4974 -2444
- package/out/renderer/assets/index-BeEZXfJZ.js.br +0 -0
- package/out/renderer/assets/index-BeEZXfJZ.js.gz +0 -0
- package/out/renderer/assets/{infoDiagram-42DDH7IO-ThYxaM6U.js → infoDiagram-42DDH7IO-BJeydI3V.js} +5 -5
- package/out/renderer/assets/infoDiagram-42DDH7IO-BJeydI3V.js.br +0 -0
- package/out/renderer/assets/infoDiagram-42DDH7IO-BJeydI3V.js.gz +0 -0
- package/out/renderer/assets/{ishikawaDiagram-UXIWVN3A-EcWEDDQ3.js → ishikawaDiagram-UXIWVN3A-DPgToD8D.js} +2 -2
- package/out/renderer/assets/ishikawaDiagram-UXIWVN3A-DPgToD8D.js.br +0 -0
- package/out/renderer/assets/ishikawaDiagram-UXIWVN3A-DPgToD8D.js.gz +0 -0
- package/out/renderer/assets/{item-Dph2aCdz.js → item-SQsw2AyN.js} +1 -1
- package/out/renderer/assets/item-SQsw2AyN.js.br +0 -0
- package/out/renderer/assets/item-SQsw2AyN.js.gz +0 -0
- package/out/renderer/assets/{journeyDiagram-VCZTEJTY-Ct6VLkXK.js → journeyDiagram-VCZTEJTY-CAnZXd__.js} +5 -5
- package/out/renderer/assets/journeyDiagram-VCZTEJTY-CAnZXd__.js.br +0 -0
- package/out/renderer/assets/journeyDiagram-VCZTEJTY-CAnZXd__.js.gz +0 -0
- package/out/renderer/assets/{kanban-definition-6JOO6SKY-DHWulQen.js → kanban-definition-6JOO6SKY-VCfgwCTi.js} +3 -3
- package/out/renderer/assets/kanban-definition-6JOO6SKY-VCfgwCTi.js.br +0 -0
- package/out/renderer/assets/kanban-definition-6JOO6SKY-VCfgwCTi.js.gz +0 -0
- package/out/renderer/assets/{layout-pfquJ3N_.js → layout-lw2KhCMB.js} +4 -4
- package/out/renderer/assets/layout-lw2KhCMB.js.br +0 -0
- package/out/renderer/assets/layout-lw2KhCMB.js.gz +0 -0
- package/out/renderer/assets/{linear-CdfVBcAB.js → linear-DmbMR7a-.js} +1 -1
- package/out/renderer/assets/linear-DmbMR7a-.js.br +0 -0
- package/out/renderer/assets/linear-DmbMR7a-.js.gz +0 -0
- package/out/renderer/assets/link-2-CWpGKoWR.js +40 -0
- package/out/renderer/assets/link-2-CWpGKoWR.js.br +0 -0
- package/out/renderer/assets/link-2-CWpGKoWR.js.gz +0 -0
- package/out/renderer/assets/{mermaid-GHXKKRXX-CqMNodCp.js → mermaid-HWGCJPDP-BufLuIVq.js} +2175 -1421
- package/out/renderer/assets/mermaid-HWGCJPDP-BufLuIVq.js.br +0 -0
- package/out/renderer/assets/mermaid-HWGCJPDP-BufLuIVq.js.gz +0 -0
- package/out/renderer/assets/mic-UZHvCQhw.js +32 -0
- package/out/renderer/assets/{min-CiK16GFr.js → min-BCqStlR1.js} +2 -2
- package/out/renderer/assets/min-BCqStlR1.js.br +0 -0
- package/out/renderer/assets/min-BCqStlR1.js.gz +0 -0
- package/out/renderer/assets/{mindmap-definition-QFDTVHPH-BvmM-Xdx.js → mindmap-definition-QFDTVHPH-C0dBO3f9.js} +4 -4
- package/out/renderer/assets/mindmap-definition-QFDTVHPH-C0dBO3f9.js.br +0 -0
- package/out/renderer/assets/mindmap-definition-QFDTVHPH-C0dBO3f9.js.gz +0 -0
- package/out/renderer/assets/open-guide-CWoE2W97.js +25 -0
- package/out/renderer/assets/package-search-SZPcR_1L.js +24 -0
- package/out/renderer/assets/{pdf-worker-wrapper-D6dv_dnM.js → pdf-worker-wrapper-BhxTGpd_.js} +4272 -4031
- package/out/renderer/assets/pdf-worker-wrapper-BhxTGpd_.js.br +0 -0
- package/out/renderer/assets/pdf-worker-wrapper-BhxTGpd_.js.gz +0 -0
- package/out/renderer/assets/{pieDiagram-DEJITSTG-CQY4NZ_4.js → pieDiagram-DEJITSTG-Dv_tH6Z_.js} +7 -7
- package/out/renderer/assets/pieDiagram-DEJITSTG-Dv_tH6Z_.js.br +0 -0
- package/out/renderer/assets/pieDiagram-DEJITSTG-Dv_tH6Z_.js.gz +0 -0
- package/out/renderer/assets/plus-BZ0wwKkh.js +14 -0
- package/out/renderer/assets/pptx_parser_bg-DWVXsmNT.wasm +0 -0
- package/out/renderer/assets/{quadrantDiagram-34T5L4WZ-BiDWKNht.js → quadrantDiagram-34T5L4WZ-Cvsj5cyu.js} +3 -3
- package/out/renderer/assets/quadrantDiagram-34T5L4WZ-Cvsj5cyu.js.br +0 -0
- package/out/renderer/assets/quadrantDiagram-34T5L4WZ-Cvsj5cyu.js.gz +0 -0
- package/out/renderer/assets/render-worker-CeK_iqK3-CEdVqR_f.js +10 -0
- package/out/renderer/assets/render-worker-CeK_iqK3-CEdVqR_f.js.br +0 -0
- package/out/renderer/assets/render-worker-CeK_iqK3-CEdVqR_f.js.gz +0 -0
- package/out/renderer/assets/render-worker-DusrDhPk-5_1DCyiC.js +11 -0
- package/out/renderer/assets/render-worker-DusrDhPk-5_1DCyiC.js.br +0 -0
- package/out/renderer/assets/render-worker-DusrDhPk-5_1DCyiC.js.gz +0 -0
- package/out/renderer/assets/render-worker-host-BfbnEChF-eMcx2LD6.js +7 -0
- package/out/renderer/assets/render-worker-host-DNL9dWRh-0PvDWYen.js +7 -0
- package/out/renderer/assets/render-worker-host-IkHrYOci-Bq59hMNS.js +7 -0
- package/out/renderer/assets/render-worker-n2ZG0lrQ-wiQeYL70.js +31 -0
- package/out/renderer/assets/render-worker-n2ZG0lrQ-wiQeYL70.js.br +0 -0
- package/out/renderer/assets/render-worker-n2ZG0lrQ-wiQeYL70.js.gz +0 -0
- package/out/renderer/assets/{requirementDiagram-MS252O5E-D-KxL9Tf.js → requirementDiagram-MS252O5E-CxM7H308.js} +4 -4
- package/out/renderer/assets/requirementDiagram-MS252O5E-CxM7H308.js.br +0 -0
- package/out/renderer/assets/requirementDiagram-MS252O5E-CxM7H308.js.gz +0 -0
- package/out/renderer/assets/{resizable-ObbINbIB.js → resizable-DD8ADhVy.js} +216 -207
- package/out/renderer/assets/resizable-DD8ADhVy.js.br +0 -0
- package/out/renderer/assets/resizable-DD8ADhVy.js.gz +0 -0
- package/out/renderer/assets/{sankeyDiagram-XADWPNL6-BIFbqkzs.js → sankeyDiagram-XADWPNL6-BGTOA6ee.js} +2 -2
- package/out/renderer/assets/sankeyDiagram-XADWPNL6-BGTOA6ee.js.br +0 -0
- package/out/renderer/assets/sankeyDiagram-XADWPNL6-BGTOA6ee.js.gz +0 -0
- package/out/renderer/assets/{schedule-BtuArq_x.js → schedule-DMyyz9A1.js} +24 -13
- package/out/renderer/assets/schedule-DMyyz9A1.js.br +0 -0
- package/out/renderer/assets/schedule-DMyyz9A1.js.gz +0 -0
- package/out/renderer/assets/{schemas-c0X-G5_P.js → schemas-BL-_QQNp.js} +2248 -1112
- package/out/renderer/assets/schemas-BL-_QQNp.js.br +0 -0
- package/out/renderer/assets/schemas-BL-_QQNp.js.gz +0 -0
- package/out/renderer/assets/search-XexOgLud.js +26 -0
- package/out/renderer/assets/{sequenceDiagram-FGHM5R23-DQX-_zuj.js → sequenceDiagram-FGHM5R23-DezlXo1X.js} +4 -4
- package/out/renderer/assets/sequenceDiagram-FGHM5R23-DezlXo1X.js.br +0 -0
- package/out/renderer/assets/sequenceDiagram-FGHM5R23-DezlXo1X.js.gz +0 -0
- package/out/renderer/assets/{session-C_1BpGhU.js → session-DQEqHTKb.js} +326 -226
- package/out/renderer/assets/session-DQEqHTKb.js.br +0 -0
- package/out/renderer/assets/session-DQEqHTKb.js.gz +0 -0
- package/out/renderer/assets/{setting-dialog-D1_-4H95.js → setting-dialog-BdiZbd8J.js} +79 -25
- package/out/renderer/assets/setting-dialog-BdiZbd8J.js.br +0 -0
- package/out/renderer/assets/setting-dialog-BdiZbd8J.js.gz +0 -0
- package/out/renderer/assets/settings-2-q22Cv4G7.js +16 -0
- package/out/renderer/assets/{settings-agents-BtuYXQ1V.js → settings-agents-f3HkdiTw.js} +11 -11
- package/out/renderer/assets/settings-agents-f3HkdiTw.js.br +0 -0
- package/out/renderer/assets/settings-agents-f3HkdiTw.js.gz +0 -0
- package/out/renderer/assets/{settings-general-cHqsKFFa.js → settings-general-BcCOVmx3.js} +41 -40
- package/out/renderer/assets/settings-general-BcCOVmx3.js.br +0 -0
- package/out/renderer/assets/settings-general-BcCOVmx3.js.gz +0 -0
- package/out/renderer/assets/{settings-ilink-BR1Vd9t9.js → settings-ilink-Da336Koc.js} +15 -10
- package/out/renderer/assets/settings-ilink-Da336Koc.js.br +0 -0
- package/out/renderer/assets/settings-ilink-Da336Koc.js.gz +0 -0
- package/out/renderer/assets/{settings-image-generation-MUHYnpbm.js → settings-image-generation-RmWs73ZG.js} +8 -8
- package/out/renderer/assets/settings-image-generation-RmWs73ZG.js.br +0 -0
- package/out/renderer/assets/settings-image-generation-RmWs73ZG.js.gz +0 -0
- package/out/renderer/assets/{settings-layout-SBihzFfb.js → settings-layout-DL6ZEzgP.js} +21 -16
- package/out/renderer/assets/settings-layout-DL6ZEzgP.js.br +0 -0
- package/out/renderer/assets/settings-layout-DL6ZEzgP.js.gz +0 -0
- package/out/renderer/assets/{settings-mcp-Co88s-0y.js → settings-mcp-BKW8JKtO.js} +25 -20
- package/out/renderer/assets/settings-mcp-BKW8JKtO.js.br +0 -0
- package/out/renderer/assets/settings-mcp-BKW8JKtO.js.gz +0 -0
- package/out/renderer/assets/{settings-memory-CNH9gHYC.js → settings-memory-o4r-_vob.js} +13 -8
- package/out/renderer/assets/settings-memory-o4r-_vob.js.br +0 -0
- package/out/renderer/assets/settings-memory-o4r-_vob.js.gz +0 -0
- package/out/renderer/assets/{settings-shortcuts-C1s7YIMj.js → settings-shortcuts-BmUGS1q_.js} +31 -18
- package/out/renderer/assets/settings-shortcuts-BmUGS1q_.js.br +0 -0
- package/out/renderer/assets/settings-shortcuts-BmUGS1q_.js.gz +0 -0
- package/out/renderer/assets/{settings-snippets-DGgI6mxm.js → settings-snippets-CpAOJmDF.js} +8 -8
- package/out/renderer/assets/settings-snippets-CpAOJmDF.js.br +0 -0
- package/out/renderer/assets/settings-snippets-CpAOJmDF.js.gz +0 -0
- package/out/renderer/assets/{settings-speech-to-text-CV0xM7yz.js → settings-speech-to-text-C8KHNGE4.js} +7 -7
- package/out/renderer/assets/settings-speech-to-text-C8KHNGE4.js.br +0 -0
- package/out/renderer/assets/settings-speech-to-text-C8KHNGE4.js.gz +0 -0
- package/out/renderer/assets/{settings-webui-Bj9dJDcm.js → settings-webui-DIEKvTrI.js} +2 -2
- package/out/renderer/assets/settings-webui-DIEKvTrI.js.br +0 -0
- package/out/renderer/assets/settings-webui-DIEKvTrI.js.gz +0 -0
- package/out/renderer/assets/{skills-installed-Bhd5a33I.js → skills-installed-BuWBDk6r.js} +5 -5
- package/out/renderer/assets/skills-installed-BuWBDk6r.js.br +0 -0
- package/out/renderer/assets/skills-installed-BuWBDk6r.js.gz +0 -0
- package/out/renderer/assets/{skills-layout-DZFDa1cw.js → skills-layout-ByPhfHG6.js} +2 -2
- package/out/renderer/assets/skills-layout-ByPhfHG6.js.br +0 -0
- package/out/renderer/assets/skills-layout-ByPhfHG6.js.gz +0 -0
- package/out/renderer/assets/{skills-skills-sh-DF59nekm.js → skills-skills-sh-wR7YNmAJ.js} +4 -4
- package/out/renderer/assets/skills-skills-sh-wR7YNmAJ.js.br +0 -0
- package/out/renderer/assets/skills-skills-sh-wR7YNmAJ.js.gz +0 -0
- package/out/renderer/assets/{sortable.esm-BlhN8Kkg.js → sortable.esm-BWvT9HIK.js} +15 -10
- package/out/renderer/assets/sortable.esm-BWvT9HIK.js.br +0 -0
- package/out/renderer/assets/sortable.esm-BWvT9HIK.js.gz +0 -0
- package/out/renderer/assets/{standard-schema-CGAs4bGi.js → standard-schema-BkTVIf7N.js} +376 -170
- package/out/renderer/assets/standard-schema-BkTVIf7N.js.br +0 -0
- package/out/renderer/assets/standard-schema-BkTVIf7N.js.gz +0 -0
- package/out/renderer/assets/{stateDiagram-FHFEXIEX-DappRrGm.js → stateDiagram-FHFEXIEX-xdKKCs-p.js} +9 -9
- package/out/renderer/assets/stateDiagram-FHFEXIEX-xdKKCs-p.js.br +0 -0
- package/out/renderer/assets/stateDiagram-FHFEXIEX-xdKKCs-p.js.gz +0 -0
- package/out/renderer/assets/{stateDiagram-v2-QKLJ7IA2-mbgJN2Ya.js → stateDiagram-v2-QKLJ7IA2-BaaiQ6Kr.js} +5 -5
- package/out/renderer/assets/{task-C7tCZ6e3.js → task-PHAOSE-W.js} +12 -12
- package/out/renderer/assets/task-PHAOSE-W.js.br +0 -0
- package/out/renderer/assets/task-PHAOSE-W.js.gz +0 -0
- package/out/renderer/assets/{textarea-DNSPhqFr.js → textarea-1ZWl3C-x.js} +1 -1
- package/out/renderer/assets/{timeline-definition-GMOUNBTQ-o8XIUDyn.js → timeline-definition-GMOUNBTQ-DFLeLybV.js} +3 -3
- package/out/renderer/assets/timeline-definition-GMOUNBTQ-DFLeLybV.js.br +0 -0
- package/out/renderer/assets/timeline-definition-GMOUNBTQ-DFLeLybV.js.gz +0 -0
- package/out/renderer/assets/{vennDiagram-DHZGUBPP-mnc6bpmR.js → vennDiagram-DHZGUBPP-PKmZLY7H.js} +2 -2
- package/out/renderer/assets/vennDiagram-DHZGUBPP-PKmZLY7H.js.br +0 -0
- package/out/renderer/assets/vennDiagram-DHZGUBPP-PKmZLY7H.js.gz +0 -0
- package/out/renderer/assets/{wardley-RL74JXVD-wdJYeEiD.js → wardley-RL74JXVD-BCH2vKnv.js} +4 -4
- package/out/renderer/assets/wardley-RL74JXVD-BCH2vKnv.js.br +0 -0
- package/out/renderer/assets/wardley-RL74JXVD-BCH2vKnv.js.gz +0 -0
- package/out/renderer/assets/{wardleyDiagram-NUSXRM2D-Ddx6k7tJ.js → wardleyDiagram-NUSXRM2D-Bkd3xMno.js} +6 -6
- package/out/renderer/assets/wardleyDiagram-NUSXRM2D-Bkd3xMno.js.br +0 -0
- package/out/renderer/assets/wardleyDiagram-NUSXRM2D-Bkd3xMno.js.gz +0 -0
- package/out/renderer/assets/wrench-8H0LZ83G.js +48 -0
- package/out/renderer/assets/wrench-8H0LZ83G.js.br +0 -0
- package/out/renderer/assets/wrench-8H0LZ83G.js.gz +0 -0
- package/out/renderer/assets/{xlsx-view-CQd4jbk-.js → xlsx-view-BYx5Ha2P.js} +49960 -32647
- package/out/renderer/assets/xlsx-view-BYx5Ha2P.js.br +0 -0
- package/out/renderer/assets/xlsx-view-BYx5Ha2P.js.gz +0 -0
- package/out/renderer/assets/{xlsx-view-Chm2gOCI.css → xlsx-view-CylPXjk8.css} +592 -530
- package/out/renderer/assets/xlsx-view-CylPXjk8.css.br +0 -0
- package/out/renderer/assets/xlsx-view-CylPXjk8.css.gz +0 -0
- package/out/renderer/assets/xlsx_parser_bg-B1AkeRhV.wasm +0 -0
- package/out/renderer/assets/{xychartDiagram-5P7HB3ND-VIQ9wuz0.js → xychartDiagram-5P7HB3ND-DCOm4uPr.js} +3 -3
- package/out/renderer/assets/xychartDiagram-5P7HB3ND-DCOm4uPr.js.br +0 -0
- package/out/renderer/assets/xychartDiagram-5P7HB3ND-DCOm4uPr.js.gz +0 -0
- package/out/renderer/index.html +2 -2
- package/out/renderer/index.html.br +0 -0
- package/out/renderer/index.html.gz +0 -0
- package/out/server/main.js +45 -6
- package/package.json +16 -16
- package/out/renderer/assets/_baseUniq-DYINnBRJ.js.br +0 -0
- package/out/renderer/assets/_baseUniq-DYINnBRJ.js.gz +0 -0
- package/out/renderer/assets/arc-BSUyw88k.js.br +0 -0
- package/out/renderer/assets/arc-BSUyw88k.js.gz +0 -0
- package/out/renderer/assets/architectureDiagram-Q4EWVU46-Cxb8DhYZ.js.br +0 -0
- package/out/renderer/assets/architectureDiagram-Q4EWVU46-Cxb8DhYZ.js.gz +0 -0
- package/out/renderer/assets/arrow-left-CQqe9rrj.js +0 -9
- package/out/renderer/assets/arrow-up-1eI4tva4.js +0 -21
- package/out/renderer/assets/automation-CQAOpWYp.js.br +0 -0
- package/out/renderer/assets/automation-CQAOpWYp.js.gz +0 -0
- package/out/renderer/assets/blockDiagram-DXYQGD6D-CFozis-v.js.br +0 -0
- package/out/renderer/assets/blockDiagram-DXYQGD6D-CFozis-v.js.gz +0 -0
- package/out/renderer/assets/c4Diagram-AHTNJAMY-CcDDkZUp.js.br +0 -0
- package/out/renderer/assets/c4Diagram-AHTNJAMY-CcDDkZUp.js.gz +0 -0
- package/out/renderer/assets/chunk-4TB4RGXK-mwOvn19G.js.br +0 -0
- package/out/renderer/assets/chunk-4TB4RGXK-mwOvn19G.js.gz +0 -0
- package/out/renderer/assets/chunk-EDXVE4YY-CU7aY96h.js.br +0 -0
- package/out/renderer/assets/chunk-EDXVE4YY-CU7aY96h.js.gz +0 -0
- package/out/renderer/assets/chunk-OYMX7WX6-BriTCtaz.js.br +0 -0
- package/out/renderer/assets/chunk-OYMX7WX6-BriTCtaz.js.gz +0 -0
- package/out/renderer/assets/chunk-YZCP3GAM-BlHAYoQe.js.br +0 -0
- package/out/renderer/assets/chunk-YZCP3GAM-BlHAYoQe.js.gz +0 -0
- package/out/renderer/assets/circle-x-D_gJIgxf.js +0 -10
- package/out/renderer/assets/code-editor-tm0AYOLz.js.br +0 -0
- package/out/renderer/assets/code-editor-tm0AYOLz.js.gz +0 -0
- package/out/renderer/assets/collapsible-DD6NlDid.js.br +0 -0
- package/out/renderer/assets/collapsible-DD6NlDid.js.gz +0 -0
- package/out/renderer/assets/command-BF4jOeoL.js +0 -11
- package/out/renderer/assets/cose-bilkent-S5V4N54A-CF4brbsf.js.br +0 -0
- package/out/renderer/assets/cose-bilkent-S5V4N54A-CF4brbsf.js.gz +0 -0
- package/out/renderer/assets/dagre-KV5264BT-C6I5VgRp.js.br +0 -0
- package/out/renderer/assets/dagre-KV5264BT-C6I5VgRp.js.gz +0 -0
- package/out/renderer/assets/diagram-5BDNPKRD-BAO72D5R.js.br +0 -0
- package/out/renderer/assets/diagram-5BDNPKRD-BAO72D5R.js.gz +0 -0
- package/out/renderer/assets/diagram-G4DWMVQ6-BmpkrtJs.js.br +0 -0
- package/out/renderer/assets/diagram-G4DWMVQ6-BmpkrtJs.js.gz +0 -0
- package/out/renderer/assets/diagram-MMDJMWI5-8keZZjgB.js.br +0 -0
- package/out/renderer/assets/diagram-MMDJMWI5-8keZZjgB.js.gz +0 -0
- package/out/renderer/assets/diagram-TYMM5635-Be4uDvHI.js.br +0 -0
- package/out/renderer/assets/diagram-TYMM5635-Be4uDvHI.js.gz +0 -0
- package/out/renderer/assets/docx_parser_bg-CIRepKGp.wasm +0 -0
- package/out/renderer/assets/ellipsis-92s4sSUO.js +0 -10
- package/out/renderer/assets/erDiagram-SMLLAGMA-C6IgAbhi.js.br +0 -0
- package/out/renderer/assets/erDiagram-SMLLAGMA-C6IgAbhi.js.gz +0 -0
- package/out/renderer/assets/field-BPsDfe4e.js.br +0 -0
- package/out/renderer/assets/field-BPsDfe4e.js.gz +0 -0
- package/out/renderer/assets/file-text-ITbWr8iW.js +0 -18
- package/out/renderer/assets/flowDiagram-DWJPFMVM-vbYKBn4t.js.br +0 -0
- package/out/renderer/assets/flowDiagram-DWJPFMVM-vbYKBn4t.js.gz +0 -0
- package/out/renderer/assets/ganttDiagram-T4ZO3ILL-AxXIe9I4.js.br +0 -0
- package/out/renderer/assets/ganttDiagram-T4ZO3ILL-AxXIe9I4.js.gz +0 -0
- package/out/renderer/assets/gitGraphDiagram-UUTBAWPF-DSipARMB.js.br +0 -0
- package/out/renderer/assets/gitGraphDiagram-UUTBAWPF-DSipARMB.js.gz +0 -0
- package/out/renderer/assets/graph-mNaHfg3r.js.br +0 -0
- package/out/renderer/assets/graph-mNaHfg3r.js.gz +0 -0
- package/out/renderer/assets/highlighted-body-OFNGDK62-8846XFj-.js +0 -18
- package/out/renderer/assets/index-BUwXrbHW.js.br +0 -0
- package/out/renderer/assets/index-BUwXrbHW.js.gz +0 -0
- package/out/renderer/assets/index-DOIzYXAl.css +0 -382
- package/out/renderer/assets/index-DOIzYXAl.css.br +0 -0
- package/out/renderer/assets/index-DOIzYXAl.css.gz +0 -0
- package/out/renderer/assets/infoDiagram-42DDH7IO-ThYxaM6U.js.br +0 -0
- package/out/renderer/assets/infoDiagram-42DDH7IO-ThYxaM6U.js.gz +0 -0
- package/out/renderer/assets/ishikawaDiagram-UXIWVN3A-EcWEDDQ3.js.br +0 -0
- package/out/renderer/assets/ishikawaDiagram-UXIWVN3A-EcWEDDQ3.js.gz +0 -0
- package/out/renderer/assets/item-Dph2aCdz.js.br +0 -0
- package/out/renderer/assets/item-Dph2aCdz.js.gz +0 -0
- package/out/renderer/assets/journeyDiagram-VCZTEJTY-Ct6VLkXK.js.br +0 -0
- package/out/renderer/assets/journeyDiagram-VCZTEJTY-Ct6VLkXK.js.gz +0 -0
- package/out/renderer/assets/kanban-definition-6JOO6SKY-DHWulQen.js.br +0 -0
- package/out/renderer/assets/kanban-definition-6JOO6SKY-DHWulQen.js.gz +0 -0
- package/out/renderer/assets/layout-pfquJ3N_.js.br +0 -0
- package/out/renderer/assets/layout-pfquJ3N_.js.gz +0 -0
- package/out/renderer/assets/linear-CdfVBcAB.js.br +0 -0
- package/out/renderer/assets/linear-CdfVBcAB.js.gz +0 -0
- package/out/renderer/assets/link-2-DpdZfD3m.js +0 -24
- package/out/renderer/assets/mermaid-GHXKKRXX-CqMNodCp.js.br +0 -0
- package/out/renderer/assets/mermaid-GHXKKRXX-CqMNodCp.js.gz +0 -0
- package/out/renderer/assets/mic-CT1bYBEV.js +0 -22
- package/out/renderer/assets/min-CiK16GFr.js.br +0 -0
- package/out/renderer/assets/min-CiK16GFr.js.gz +0 -0
- package/out/renderer/assets/mindmap-definition-QFDTVHPH-BvmM-Xdx.js.br +0 -0
- package/out/renderer/assets/mindmap-definition-QFDTVHPH-BvmM-Xdx.js.gz +0 -0
- package/out/renderer/assets/open-guide-BqiUQfrM.js +0 -20
- package/out/renderer/assets/package-search-BxIuIl9F.js +0 -19
- package/out/renderer/assets/pdf-worker-wrapper-D6dv_dnM.js.br +0 -0
- package/out/renderer/assets/pdf-worker-wrapper-D6dv_dnM.js.gz +0 -0
- package/out/renderer/assets/pieDiagram-DEJITSTG-CQY4NZ_4.js.br +0 -0
- package/out/renderer/assets/pieDiagram-DEJITSTG-CQY4NZ_4.js.gz +0 -0
- package/out/renderer/assets/plus-C5XdFVFm.js +0 -9
- package/out/renderer/assets/pptx_parser_bg-Dnsy0qwf.wasm +0 -0
- package/out/renderer/assets/quadrantDiagram-34T5L4WZ-BiDWKNht.js.br +0 -0
- package/out/renderer/assets/quadrantDiagram-34T5L4WZ-BiDWKNht.js.gz +0 -0
- package/out/renderer/assets/render-worker-host-BG3a7brz-Q7Y2znhP.js +0 -25
- package/out/renderer/assets/render-worker-host-BG3a7brz-Q7Y2znhP.js.br +0 -0
- package/out/renderer/assets/render-worker-host-BG3a7brz-Q7Y2znhP.js.gz +0 -0
- package/out/renderer/assets/render-worker-host-CsB-dPJv-gJhIrzf_.js +0 -25
- package/out/renderer/assets/render-worker-host-CsB-dPJv-gJhIrzf_.js.br +0 -0
- package/out/renderer/assets/render-worker-host-CsB-dPJv-gJhIrzf_.js.gz +0 -0
- package/out/renderer/assets/render-worker-host-Cyv5Hkbh-BAiWfcv_.js +0 -25
- package/out/renderer/assets/render-worker-host-Cyv5Hkbh-BAiWfcv_.js.br +0 -0
- package/out/renderer/assets/render-worker-host-Cyv5Hkbh-BAiWfcv_.js.gz +0 -0
- package/out/renderer/assets/requirementDiagram-MS252O5E-D-KxL9Tf.js.br +0 -0
- package/out/renderer/assets/requirementDiagram-MS252O5E-D-KxL9Tf.js.gz +0 -0
- package/out/renderer/assets/resizable-ObbINbIB.js.br +0 -0
- package/out/renderer/assets/resizable-ObbINbIB.js.gz +0 -0
- package/out/renderer/assets/sankeyDiagram-XADWPNL6-BIFbqkzs.js.br +0 -0
- package/out/renderer/assets/sankeyDiagram-XADWPNL6-BIFbqkzs.js.gz +0 -0
- package/out/renderer/assets/schedule-BtuArq_x.js.br +0 -0
- package/out/renderer/assets/schedule-BtuArq_x.js.gz +0 -0
- package/out/renderer/assets/schemas-c0X-G5_P.js.br +0 -0
- package/out/renderer/assets/schemas-c0X-G5_P.js.gz +0 -0
- package/out/renderer/assets/search-TCnuQyCi.js +0 -16
- package/out/renderer/assets/sequenceDiagram-FGHM5R23-DQX-_zuj.js.br +0 -0
- package/out/renderer/assets/sequenceDiagram-FGHM5R23-DQX-_zuj.js.gz +0 -0
- package/out/renderer/assets/session-C_1BpGhU.js.br +0 -0
- package/out/renderer/assets/session-C_1BpGhU.js.gz +0 -0
- package/out/renderer/assets/setting-dialog-D1_-4H95.js.br +0 -0
- package/out/renderer/assets/setting-dialog-D1_-4H95.js.gz +0 -0
- package/out/renderer/assets/settings-2-BwfZrIw6.js +0 -11
- package/out/renderer/assets/settings-agents-BtuYXQ1V.js.br +0 -0
- package/out/renderer/assets/settings-agents-BtuYXQ1V.js.gz +0 -0
- package/out/renderer/assets/settings-general-cHqsKFFa.js.br +0 -0
- package/out/renderer/assets/settings-general-cHqsKFFa.js.gz +0 -0
- package/out/renderer/assets/settings-ilink-BR1Vd9t9.js.br +0 -0
- package/out/renderer/assets/settings-ilink-BR1Vd9t9.js.gz +0 -0
- package/out/renderer/assets/settings-image-generation-MUHYnpbm.js.br +0 -0
- package/out/renderer/assets/settings-image-generation-MUHYnpbm.js.gz +0 -0
- package/out/renderer/assets/settings-layout-SBihzFfb.js.br +0 -0
- package/out/renderer/assets/settings-layout-SBihzFfb.js.gz +0 -0
- package/out/renderer/assets/settings-mcp-Co88s-0y.js.br +0 -0
- package/out/renderer/assets/settings-mcp-Co88s-0y.js.gz +0 -0
- package/out/renderer/assets/settings-memory-CNH9gHYC.js.br +0 -0
- package/out/renderer/assets/settings-memory-CNH9gHYC.js.gz +0 -0
- package/out/renderer/assets/settings-shortcuts-C1s7YIMj.js.br +0 -0
- package/out/renderer/assets/settings-shortcuts-C1s7YIMj.js.gz +0 -0
- package/out/renderer/assets/settings-snippets-DGgI6mxm.js.br +0 -0
- package/out/renderer/assets/settings-snippets-DGgI6mxm.js.gz +0 -0
- package/out/renderer/assets/settings-speech-to-text-CV0xM7yz.js.br +0 -0
- package/out/renderer/assets/settings-speech-to-text-CV0xM7yz.js.gz +0 -0
- package/out/renderer/assets/settings-webui-Bj9dJDcm.js.br +0 -0
- package/out/renderer/assets/settings-webui-Bj9dJDcm.js.gz +0 -0
- package/out/renderer/assets/skills-installed-Bhd5a33I.js.br +0 -0
- package/out/renderer/assets/skills-installed-Bhd5a33I.js.gz +0 -0
- package/out/renderer/assets/skills-layout-DZFDa1cw.js.br +0 -0
- package/out/renderer/assets/skills-layout-DZFDa1cw.js.gz +0 -0
- package/out/renderer/assets/skills-skills-sh-DF59nekm.js.br +0 -0
- package/out/renderer/assets/skills-skills-sh-DF59nekm.js.gz +0 -0
- package/out/renderer/assets/sortable.esm-BlhN8Kkg.js.br +0 -0
- package/out/renderer/assets/sortable.esm-BlhN8Kkg.js.gz +0 -0
- package/out/renderer/assets/standard-schema-CGAs4bGi.js.br +0 -0
- package/out/renderer/assets/standard-schema-CGAs4bGi.js.gz +0 -0
- package/out/renderer/assets/stateDiagram-FHFEXIEX-DappRrGm.js.br +0 -0
- package/out/renderer/assets/stateDiagram-FHFEXIEX-DappRrGm.js.gz +0 -0
- package/out/renderer/assets/task-C7tCZ6e3.js.br +0 -0
- package/out/renderer/assets/task-C7tCZ6e3.js.gz +0 -0
- package/out/renderer/assets/timeline-definition-GMOUNBTQ-o8XIUDyn.js.br +0 -0
- package/out/renderer/assets/timeline-definition-GMOUNBTQ-o8XIUDyn.js.gz +0 -0
- package/out/renderer/assets/vennDiagram-DHZGUBPP-mnc6bpmR.js.br +0 -0
- package/out/renderer/assets/vennDiagram-DHZGUBPP-mnc6bpmR.js.gz +0 -0
- package/out/renderer/assets/wardley-RL74JXVD-wdJYeEiD.js.br +0 -0
- package/out/renderer/assets/wardley-RL74JXVD-wdJYeEiD.js.gz +0 -0
- package/out/renderer/assets/wardleyDiagram-NUSXRM2D-Ddx6k7tJ.js.br +0 -0
- package/out/renderer/assets/wardleyDiagram-NUSXRM2D-Ddx6k7tJ.js.gz +0 -0
- package/out/renderer/assets/wrench-BsjH8RPm.js +0 -33
- package/out/renderer/assets/wrench-BsjH8RPm.js.br +0 -0
- package/out/renderer/assets/wrench-BsjH8RPm.js.gz +0 -0
- package/out/renderer/assets/xlsx-view-CQd4jbk-.js.br +0 -0
- package/out/renderer/assets/xlsx-view-CQd4jbk-.js.gz +0 -0
- package/out/renderer/assets/xlsx-view-Chm2gOCI.css.br +0 -0
- package/out/renderer/assets/xlsx-view-Chm2gOCI.css.gz +0 -0
- package/out/renderer/assets/xlsx_parser_bg-BM7cLtfq.wasm +0 -0
- package/out/renderer/assets/xychartDiagram-5P7HB3ND-VIQ9wuz0.js.br +0 -0
- package/out/renderer/assets/xychartDiagram-5P7HB3ND-VIQ9wuz0.js.gz +0 -0
|
@@ -1,91 +1,32 @@
|
|
|
1
|
-
var _a$1;
|
|
2
|
-
function $constructor(name, initializer2, params) {
|
|
3
|
-
function init(inst, def) {
|
|
4
|
-
if (!inst._zod) {
|
|
5
|
-
Object.defineProperty(inst, "_zod", {
|
|
6
|
-
value: {
|
|
7
|
-
def,
|
|
8
|
-
constr: _,
|
|
9
|
-
traits: /* @__PURE__ */ new Set()
|
|
10
|
-
},
|
|
11
|
-
enumerable: false
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
if (inst._zod.traits.has(name)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
inst._zod.traits.add(name);
|
|
18
|
-
initializer2(inst, def);
|
|
19
|
-
const proto = _.prototype;
|
|
20
|
-
const keys = Object.keys(proto);
|
|
21
|
-
for (let i = 0; i < keys.length; i++) {
|
|
22
|
-
const k = keys[i];
|
|
23
|
-
if (!(k in inst)) {
|
|
24
|
-
inst[k] = proto[k].bind(inst);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const Parent = params?.Parent ?? Object;
|
|
29
|
-
class Definition extends Parent {
|
|
30
|
-
}
|
|
31
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
32
|
-
function _(def) {
|
|
33
|
-
var _a2;
|
|
34
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
35
|
-
init(inst, def);
|
|
36
|
-
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
37
|
-
for (const fn of inst._zod.deferred) {
|
|
38
|
-
fn();
|
|
39
|
-
}
|
|
40
|
-
return inst;
|
|
41
|
-
}
|
|
42
|
-
Object.defineProperty(_, "init", { value: init });
|
|
43
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
44
|
-
value: (inst) => {
|
|
45
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
46
|
-
return true;
|
|
47
|
-
return inst?._zod?.traits?.has(name);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(_, "name", { value: name });
|
|
51
|
-
return _;
|
|
52
|
-
}
|
|
53
|
-
class $ZodAsyncError extends Error {
|
|
54
|
-
constructor() {
|
|
55
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
class $ZodEncodeError extends Error {
|
|
59
|
-
constructor(name) {
|
|
60
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
61
|
-
this.name = "ZodEncodeError";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
65
|
-
const globalConfig = globalThis.__zod_globalConfig;
|
|
66
|
-
function config(newConfig) {
|
|
67
|
-
return globalConfig;
|
|
68
|
-
}
|
|
69
1
|
function getEnumValues(entries) {
|
|
70
2
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
71
3
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
72
4
|
return values;
|
|
73
5
|
}
|
|
6
|
+
function joinValues(array2, separator = "|") {
|
|
7
|
+
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
8
|
+
}
|
|
74
9
|
function jsonStringifyReplacer(_, value) {
|
|
75
10
|
if (typeof value === "bigint")
|
|
76
11
|
return value.toString();
|
|
77
12
|
return value;
|
|
78
13
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
14
|
+
class Cached {
|
|
15
|
+
constructor(getter) {
|
|
16
|
+
this._getter = getter;
|
|
17
|
+
this._value = void 0;
|
|
18
|
+
}
|
|
19
|
+
get value() {
|
|
20
|
+
const getter = this._getter;
|
|
21
|
+
if (getter !== void 0) {
|
|
22
|
+
this._value = getter();
|
|
23
|
+
this._getter = void 0;
|
|
87
24
|
}
|
|
88
|
-
|
|
25
|
+
return this._value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function cached(getter) {
|
|
29
|
+
return new Cached(getter);
|
|
89
30
|
}
|
|
90
31
|
function nullish(input) {
|
|
91
32
|
return input === null || input === void 0;
|
|
@@ -98,34 +39,11 @@ function cleanRegex(source) {
|
|
|
98
39
|
function floatSafeRemainder(val, step) {
|
|
99
40
|
const ratio = val / step;
|
|
100
41
|
const roundedRatio = Math.round(ratio);
|
|
101
|
-
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
42
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
102
43
|
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
103
44
|
return 0;
|
|
104
45
|
return ratio - roundedRatio;
|
|
105
46
|
}
|
|
106
|
-
const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
107
|
-
function defineLazy(object2, key, getter) {
|
|
108
|
-
let value = void 0;
|
|
109
|
-
Object.defineProperty(object2, key, {
|
|
110
|
-
get() {
|
|
111
|
-
if (value === EVALUATING) {
|
|
112
|
-
return void 0;
|
|
113
|
-
}
|
|
114
|
-
if (value === void 0) {
|
|
115
|
-
value = EVALUATING;
|
|
116
|
-
value = getter();
|
|
117
|
-
}
|
|
118
|
-
return value;
|
|
119
|
-
},
|
|
120
|
-
set(v) {
|
|
121
|
-
Object.defineProperty(object2, key, {
|
|
122
|
-
value: v
|
|
123
|
-
// configurable: true,
|
|
124
|
-
});
|
|
125
|
-
},
|
|
126
|
-
configurable: true
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
47
|
function assignProp(target, prop, value) {
|
|
130
48
|
Object.defineProperty(target, prop, {
|
|
131
49
|
value,
|
|
@@ -134,6 +52,56 @@ function assignProp(target, prop, value) {
|
|
|
134
52
|
configurable: true
|
|
135
53
|
});
|
|
136
54
|
}
|
|
55
|
+
function rawShape(def) {
|
|
56
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
57
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
58
|
+
}
|
|
59
|
+
function sourceShape(schema) {
|
|
60
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
61
|
+
}
|
|
62
|
+
function deferProp(target, key, getter) {
|
|
63
|
+
Object.defineProperty(target, key, {
|
|
64
|
+
get() {
|
|
65
|
+
const value = getter();
|
|
66
|
+
assignProp(this, key, value);
|
|
67
|
+
return value;
|
|
68
|
+
},
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function putProp(target, key, value) {
|
|
74
|
+
if (key in target)
|
|
75
|
+
assignProp(target, key, value);
|
|
76
|
+
else
|
|
77
|
+
target[key] = value;
|
|
78
|
+
}
|
|
79
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
80
|
+
const raw = sourceShape(source);
|
|
81
|
+
for (const key of keys) {
|
|
82
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
83
|
+
if (!desc.enumerable)
|
|
84
|
+
continue;
|
|
85
|
+
if (desc.get) {
|
|
86
|
+
deferProp(target, key, () => {
|
|
87
|
+
const value = source._zod.def.shape[key];
|
|
88
|
+
return wrap ? wrap(value, key) : value;
|
|
89
|
+
});
|
|
90
|
+
} else
|
|
91
|
+
putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function mirrorProps(target, source) {
|
|
95
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
96
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
97
|
+
if (!desc.enumerable)
|
|
98
|
+
continue;
|
|
99
|
+
if (desc.get)
|
|
100
|
+
deferProp(target, key, () => source[key]);
|
|
101
|
+
else
|
|
102
|
+
putProp(target, key, desc.value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
137
105
|
function mergeDefs(...defs) {
|
|
138
106
|
const mergedDescriptors = {};
|
|
139
107
|
for (const def of defs) {
|
|
@@ -221,17 +189,28 @@ function normalizeParams(_params) {
|
|
|
221
189
|
return { ...params, error: () => params.error };
|
|
222
190
|
return params;
|
|
223
191
|
}
|
|
192
|
+
function stringifyPrimitive(value) {
|
|
193
|
+
if (typeof value === "bigint")
|
|
194
|
+
return value.toString() + "n";
|
|
195
|
+
if (typeof value === "string")
|
|
196
|
+
return `"${value}"`;
|
|
197
|
+
return `${value}`;
|
|
198
|
+
}
|
|
224
199
|
function optionalKeys(shape) {
|
|
225
200
|
return Object.keys(shape).filter((k) => {
|
|
226
|
-
return shape[k]._zod.optin
|
|
201
|
+
return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
|
|
227
202
|
});
|
|
228
203
|
}
|
|
229
|
-
const NUMBER_FORMAT_RANGES = {
|
|
204
|
+
const NUMBER_FORMAT_RANGES = /* @__PURE__ */ (() => ({
|
|
230
205
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
231
206
|
int32: [-2147483648, 2147483647],
|
|
232
207
|
uint32: [0, 4294967295],
|
|
233
208
|
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
234
209
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
210
|
+
}))();
|
|
211
|
+
const BIGINT_FORMAT_RANGES = {
|
|
212
|
+
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
213
|
+
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
235
214
|
};
|
|
236
215
|
function pick(schema, mask) {
|
|
237
216
|
const currDef = schema._zod.def;
|
|
@@ -240,23 +219,21 @@ function pick(schema, mask) {
|
|
|
240
219
|
if (hasChecks) {
|
|
241
220
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
242
221
|
}
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
});
|
|
259
|
-
return clone(schema, def);
|
|
222
|
+
const newShape = {};
|
|
223
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
224
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
225
|
+
}
|
|
226
|
+
function maskedKeys(schema, mask) {
|
|
227
|
+
const raw = sourceShape(schema);
|
|
228
|
+
const keys = [];
|
|
229
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
230
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
231
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
232
|
+
}
|
|
233
|
+
if (mask[key])
|
|
234
|
+
keys.push(key);
|
|
235
|
+
}
|
|
236
|
+
return keys;
|
|
260
237
|
}
|
|
261
238
|
function omit(schema, mask) {
|
|
262
239
|
const currDef = schema._zod.def;
|
|
@@ -265,23 +242,10 @@ function omit(schema, mask) {
|
|
|
265
242
|
if (hasChecks) {
|
|
266
243
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
267
244
|
}
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (!(key in currDef.shape)) {
|
|
273
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
274
|
-
}
|
|
275
|
-
if (!mask[key])
|
|
276
|
-
continue;
|
|
277
|
-
delete newShape[key];
|
|
278
|
-
}
|
|
279
|
-
assignProp(this, "shape", newShape);
|
|
280
|
-
return newShape;
|
|
281
|
-
},
|
|
282
|
-
checks: []
|
|
283
|
-
});
|
|
284
|
-
return clone(schema, def);
|
|
245
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
246
|
+
const newShape = {};
|
|
247
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
248
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
285
249
|
}
|
|
286
250
|
function extend(schema, shape) {
|
|
287
251
|
if (!isPlainObject(shape)) {
|
|
@@ -290,45 +254,39 @@ function extend(schema, shape) {
|
|
|
290
254
|
const checks = schema._zod.def.checks;
|
|
291
255
|
const hasChecks = checks && checks.length > 0;
|
|
292
256
|
if (hasChecks) {
|
|
293
|
-
const existingShape = schema
|
|
294
|
-
for (const key
|
|
257
|
+
const existingShape = sourceShape(schema);
|
|
258
|
+
for (const key of Reflect.ownKeys(shape)) {
|
|
295
259
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
296
260
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
297
261
|
}
|
|
298
262
|
}
|
|
299
263
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return clone(schema, def);
|
|
264
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
265
|
+
}
|
|
266
|
+
function extended(schema, shape) {
|
|
267
|
+
const newShape = {};
|
|
268
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
269
|
+
mirrorProps(newShape, shape);
|
|
270
|
+
return newShape;
|
|
308
271
|
}
|
|
309
272
|
function safeExtend(schema, shape) {
|
|
310
273
|
if (!isPlainObject(shape)) {
|
|
311
274
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
312
275
|
}
|
|
313
|
-
|
|
314
|
-
get shape() {
|
|
315
|
-
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
316
|
-
assignProp(this, "shape", _shape);
|
|
317
|
-
return _shape;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
return clone(schema, def);
|
|
276
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
321
277
|
}
|
|
322
278
|
function merge(a, b) {
|
|
279
|
+
if (!b?._zod?.def) {
|
|
280
|
+
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
281
|
+
}
|
|
323
282
|
if (a._zod.def.checks?.length) {
|
|
324
283
|
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
325
284
|
}
|
|
285
|
+
const newShape = {};
|
|
286
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
287
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
326
288
|
const def = mergeDefs(a._zod.def, {
|
|
327
|
-
|
|
328
|
-
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
329
|
-
assignProp(this, "shape", _shape);
|
|
330
|
-
return _shape;
|
|
331
|
-
},
|
|
289
|
+
shape: newShape,
|
|
332
290
|
get catchall() {
|
|
333
291
|
return b._zod.def.catchall;
|
|
334
292
|
},
|
|
@@ -336,74 +294,26 @@ function merge(a, b) {
|
|
|
336
294
|
});
|
|
337
295
|
return clone(a, def);
|
|
338
296
|
}
|
|
339
|
-
function partial(Class, schema, mask) {
|
|
297
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
340
298
|
const currDef = schema._zod.def;
|
|
341
299
|
const checks = currDef.checks;
|
|
342
300
|
const hasChecks = checks && checks.length > 0;
|
|
343
301
|
if (hasChecks) {
|
|
344
|
-
throw new Error(
|
|
345
|
-
}
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (mask) {
|
|
351
|
-
for (const key in mask) {
|
|
352
|
-
if (!(key in oldShape)) {
|
|
353
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
354
|
-
}
|
|
355
|
-
if (!mask[key])
|
|
356
|
-
continue;
|
|
357
|
-
shape[key] = Class ? new Class({
|
|
358
|
-
type: "optional",
|
|
359
|
-
innerType: oldShape[key]
|
|
360
|
-
}) : oldShape[key];
|
|
361
|
-
}
|
|
362
|
-
} else {
|
|
363
|
-
for (const key in oldShape) {
|
|
364
|
-
shape[key] = Class ? new Class({
|
|
365
|
-
type: "optional",
|
|
366
|
-
innerType: oldShape[key]
|
|
367
|
-
}) : oldShape[key];
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
assignProp(this, "shape", shape);
|
|
371
|
-
return shape;
|
|
372
|
-
},
|
|
373
|
-
checks: []
|
|
374
|
-
});
|
|
375
|
-
return clone(schema, def);
|
|
302
|
+
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
303
|
+
}
|
|
304
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
305
|
+
const newShape = {};
|
|
306
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value })));
|
|
307
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
|
|
376
308
|
}
|
|
377
309
|
function required(Class, schema, mask) {
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
throw new Error(`Unrecognized key: "${key}"`);
|
|
386
|
-
}
|
|
387
|
-
if (!mask[key])
|
|
388
|
-
continue;
|
|
389
|
-
shape[key] = new Class({
|
|
390
|
-
type: "nonoptional",
|
|
391
|
-
innerType: oldShape[key]
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
for (const key in oldShape) {
|
|
396
|
-
shape[key] = new Class({
|
|
397
|
-
type: "nonoptional",
|
|
398
|
-
innerType: oldShape[key]
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
assignProp(this, "shape", shape);
|
|
403
|
-
return shape;
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
return clone(schema, def);
|
|
310
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
311
|
+
const newShape = {};
|
|
312
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => (
|
|
313
|
+
// overwrite with non-optional
|
|
314
|
+
selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value })
|
|
315
|
+
));
|
|
316
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
407
317
|
}
|
|
408
318
|
function aborted(x, startIndex = 0) {
|
|
409
319
|
if (x.aborted === true)
|
|
@@ -436,15 +346,49 @@ function prefixIssues(path, issues) {
|
|
|
436
346
|
function unwrapMessage(message) {
|
|
437
347
|
return typeof message === "string" ? message : message?.message;
|
|
438
348
|
}
|
|
349
|
+
function attachSchema(issues, start, inst) {
|
|
350
|
+
var _a2;
|
|
351
|
+
for (let i = start; i < issues.length; i++) {
|
|
352
|
+
(_a2 = issues[i]).schema ?? (_a2.schema = inst);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
439
355
|
function finalizeIssue(iss, ctx, config2) {
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
356
|
+
var _a2;
|
|
357
|
+
const traits = iss.inst?._zod?.traits;
|
|
358
|
+
if (traits?.has("$ZodType")) {
|
|
359
|
+
if (traits.has("$ZodCheck"))
|
|
360
|
+
(_a2 = iss).schema ?? (_a2.schema = iss.inst);
|
|
361
|
+
else
|
|
362
|
+
iss.schema = iss.inst;
|
|
363
|
+
}
|
|
364
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
|
|
365
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
366
|
+
const full = {};
|
|
367
|
+
for (const k of Object.keys(iss)) {
|
|
368
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
|
|
369
|
+
continue;
|
|
370
|
+
full[k] = iss[k];
|
|
371
|
+
}
|
|
372
|
+
full.path ?? (full.path = []);
|
|
373
|
+
full.message = message;
|
|
444
374
|
if (ctx?.reportInput) {
|
|
445
|
-
|
|
375
|
+
full.input = iss.input;
|
|
446
376
|
}
|
|
447
|
-
return
|
|
377
|
+
return full;
|
|
378
|
+
}
|
|
379
|
+
const highSurrogate = /[\uD800-\uDBFF]/;
|
|
380
|
+
function codePointLength(str) {
|
|
381
|
+
const units = str.length;
|
|
382
|
+
if (!highSurrogate.test(str))
|
|
383
|
+
return units;
|
|
384
|
+
let count = units;
|
|
385
|
+
for (let i = 0; i < units - 1; i++) {
|
|
386
|
+
if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
387
|
+
count--;
|
|
388
|
+
i++;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return count;
|
|
448
392
|
}
|
|
449
393
|
function getLengthableOrigin(input) {
|
|
450
394
|
if (Array.isArray(input))
|
|
@@ -453,6 +397,27 @@ function getLengthableOrigin(input) {
|
|
|
453
397
|
return "string";
|
|
454
398
|
return "unknown";
|
|
455
399
|
}
|
|
400
|
+
function parsedType(data) {
|
|
401
|
+
const t = typeof data;
|
|
402
|
+
switch (t) {
|
|
403
|
+
case "number": {
|
|
404
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
405
|
+
}
|
|
406
|
+
case "object": {
|
|
407
|
+
if (data === null) {
|
|
408
|
+
return "null";
|
|
409
|
+
}
|
|
410
|
+
if (Array.isArray(data)) {
|
|
411
|
+
return "array";
|
|
412
|
+
}
|
|
413
|
+
const obj = data;
|
|
414
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
415
|
+
return obj.constructor.name;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return t;
|
|
420
|
+
}
|
|
456
421
|
function issue(...args) {
|
|
457
422
|
const [iss, input, inst] = args;
|
|
458
423
|
if (typeof iss === "string") {
|
|
@@ -465,41 +430,299 @@ function issue(...args) {
|
|
|
465
430
|
}
|
|
466
431
|
return { ...iss };
|
|
467
432
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
433
|
+
function members(proto, table) {
|
|
434
|
+
for (const key in table) {
|
|
435
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
436
|
+
if (desc.get)
|
|
437
|
+
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
438
|
+
else
|
|
439
|
+
defineBound(proto, key, desc.value);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function own(inst, key, value, enumerable = true) {
|
|
443
|
+
Object.defineProperty(inst, key, { configurable: true, writable: true, enumerable, value });
|
|
444
|
+
return value;
|
|
445
|
+
}
|
|
446
|
+
function hide(inst, key, value) {
|
|
447
|
+
return own(inst, key, value, false);
|
|
448
|
+
}
|
|
449
|
+
function derived(computes, table) {
|
|
450
|
+
for (const key in computes) {
|
|
451
|
+
const compute = computes[key];
|
|
452
|
+
Object.defineProperty(table, key, {
|
|
453
|
+
configurable: true,
|
|
454
|
+
enumerable: true,
|
|
455
|
+
get() {
|
|
456
|
+
return own(this, key, compute(this));
|
|
457
|
+
},
|
|
458
|
+
set(value) {
|
|
459
|
+
own(this, key, value);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return table;
|
|
464
|
+
}
|
|
465
|
+
function defineBound(proto, key, fn) {
|
|
466
|
+
Object.defineProperty(proto, key, {
|
|
467
|
+
configurable: true,
|
|
468
|
+
get() {
|
|
469
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
470
|
+
},
|
|
471
|
+
set(value) {
|
|
472
|
+
own(this, key, value);
|
|
473
|
+
}
|
|
473
474
|
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
475
|
+
}
|
|
476
|
+
function claim(inst, sentinel) {
|
|
477
|
+
const proto = Object.getPrototypeOf(inst);
|
|
478
|
+
return sentinel in proto ? void 0 : proto;
|
|
479
|
+
}
|
|
480
|
+
let installing;
|
|
481
|
+
let broke = false;
|
|
482
|
+
const breaker = {
|
|
483
|
+
configurable: true,
|
|
484
|
+
get() {
|
|
485
|
+
broke = true;
|
|
486
|
+
return void 0;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
function defineLazyInternal(inst, key, compute) {
|
|
490
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
491
|
+
if (key in proto && installing !== inst._zod) {
|
|
492
|
+
installing = void 0;
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
installing = inst._zod;
|
|
496
|
+
Object.defineProperty(proto, key, {
|
|
497
|
+
configurable: true,
|
|
498
|
+
get() {
|
|
499
|
+
Object.defineProperty(this, key, breaker);
|
|
500
|
+
const outer = broke;
|
|
501
|
+
broke = false;
|
|
502
|
+
try {
|
|
503
|
+
const value = compute(this);
|
|
504
|
+
if (broke)
|
|
505
|
+
delete this[key];
|
|
506
|
+
else
|
|
507
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
508
|
+
broke = broke || outer;
|
|
509
|
+
return value;
|
|
510
|
+
} catch (err) {
|
|
511
|
+
delete this[key];
|
|
512
|
+
broke = broke || outer;
|
|
513
|
+
throw err;
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
set(value) {
|
|
517
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
518
|
+
}
|
|
477
519
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
520
|
+
}
|
|
521
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
522
|
+
const proto = claim(inst, key);
|
|
523
|
+
if (!proto)
|
|
524
|
+
return;
|
|
525
|
+
Object.defineProperty(proto, key, {
|
|
526
|
+
configurable: true,
|
|
527
|
+
get() {
|
|
528
|
+
const desc = { configurable: true, writable: true, enumerable, value: void 0 };
|
|
529
|
+
Object.defineProperty(this, key, desc);
|
|
530
|
+
desc.value = make(this);
|
|
531
|
+
Object.defineProperty(this, key, desc);
|
|
532
|
+
return desc.value;
|
|
533
|
+
},
|
|
534
|
+
set(value) {
|
|
535
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, enumerable, value });
|
|
536
|
+
}
|
|
482
537
|
});
|
|
538
|
+
}
|
|
539
|
+
const CONSTANT_CATCH = "~constantCatch";
|
|
540
|
+
function constantCatch(value) {
|
|
541
|
+
const fn = () => value;
|
|
542
|
+
fn[CONSTANT_CATCH] = true;
|
|
543
|
+
return fn;
|
|
544
|
+
}
|
|
545
|
+
var _a$1;
|
|
546
|
+
const _zodDesc = { value: void 0, enumerable: false };
|
|
547
|
+
let _E = "captureStackTrace" in Error ? Error : null;
|
|
548
|
+
function newError(Definition) {
|
|
549
|
+
const E = _E;
|
|
550
|
+
if (E) {
|
|
551
|
+
const saved = E.stackTraceLimit;
|
|
552
|
+
if (typeof saved === "number") {
|
|
553
|
+
try {
|
|
554
|
+
E.stackTraceLimit = 0;
|
|
555
|
+
} catch {
|
|
556
|
+
_E = null;
|
|
557
|
+
return new Definition();
|
|
558
|
+
}
|
|
559
|
+
try {
|
|
560
|
+
return new Definition();
|
|
561
|
+
} finally {
|
|
562
|
+
E.stackTraceLimit = saved;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return new Definition();
|
|
567
|
+
}
|
|
568
|
+
function $constructor(name, initializer2, proto, params) {
|
|
569
|
+
const zodProto = {};
|
|
570
|
+
function Internals(def) {
|
|
571
|
+
this.def = def;
|
|
572
|
+
this.constr = _;
|
|
573
|
+
this.traits = /* @__PURE__ */ new Set();
|
|
574
|
+
}
|
|
575
|
+
Internals.prototype = zodProto;
|
|
576
|
+
const protoMembers = proto;
|
|
577
|
+
const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
|
|
578
|
+
function init(inst, def) {
|
|
579
|
+
if (!inst._zod) {
|
|
580
|
+
_zodDesc.value = new Internals(def);
|
|
581
|
+
try {
|
|
582
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
583
|
+
} finally {
|
|
584
|
+
_zodDesc.value = void 0;
|
|
585
|
+
}
|
|
586
|
+
} else if (inst._zod.traits.has(name)) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
inst._zod.traits.add(name);
|
|
590
|
+
initializer2(inst, def);
|
|
591
|
+
if (initialized) {
|
|
592
|
+
const own2 = Object.getPrototypeOf(inst);
|
|
593
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
594
|
+
let up = own2;
|
|
595
|
+
while (up && up !== ctorProto)
|
|
596
|
+
up = Object.getPrototypeOf(up);
|
|
597
|
+
const target = up ?? own2;
|
|
598
|
+
if (!initialized.has(target)) {
|
|
599
|
+
initialized.add(target);
|
|
600
|
+
members(target, protoMembers);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const proto2 = _.prototype;
|
|
604
|
+
for (const k in proto2) {
|
|
605
|
+
if (!Object.prototype.hasOwnProperty.call(proto2, k))
|
|
606
|
+
continue;
|
|
607
|
+
if (!(k in inst)) {
|
|
608
|
+
inst[k] = proto2[k].bind(inst);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const Parent = params?.Parent ?? Object;
|
|
613
|
+
class Definition extends Parent {
|
|
614
|
+
}
|
|
615
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
616
|
+
function _(def) {
|
|
617
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
618
|
+
init(inst, def);
|
|
619
|
+
const deferred = inst._zod.deferred;
|
|
620
|
+
if (deferred) {
|
|
621
|
+
for (const fn of deferred) {
|
|
622
|
+
fn();
|
|
623
|
+
}
|
|
624
|
+
inst._zod.deferred = void 0;
|
|
625
|
+
}
|
|
626
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
627
|
+
if (pp)
|
|
628
|
+
pp(inst);
|
|
629
|
+
return inst;
|
|
630
|
+
}
|
|
631
|
+
Object.defineProperty(_, "init", { value: init });
|
|
632
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
633
|
+
value: (inst) => {
|
|
634
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
635
|
+
return true;
|
|
636
|
+
return inst?._zod?.traits?.has(name);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
Object.defineProperty(_, "name", { value: name });
|
|
640
|
+
return _;
|
|
641
|
+
}
|
|
642
|
+
class $ZodAsyncError extends Error {
|
|
643
|
+
constructor() {
|
|
644
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
class $ZodEncodeError extends Error {
|
|
648
|
+
constructor(name) {
|
|
649
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
650
|
+
this.name = "ZodEncodeError";
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
654
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
655
|
+
function config(newConfig) {
|
|
656
|
+
if (newConfig)
|
|
657
|
+
Object.assign(globalConfig, newConfig);
|
|
658
|
+
return globalConfig;
|
|
659
|
+
}
|
|
660
|
+
function _getMessage() {
|
|
661
|
+
const internals = this._zod;
|
|
662
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
663
|
+
return internals.message;
|
|
664
|
+
}
|
|
665
|
+
function _setMessage(value) {
|
|
666
|
+
this._zod.message = value;
|
|
667
|
+
}
|
|
668
|
+
const _messageDesc = {
|
|
669
|
+
get: _getMessage,
|
|
670
|
+
set: _setMessage,
|
|
671
|
+
enumerable: true,
|
|
672
|
+
configurable: true
|
|
673
|
+
};
|
|
674
|
+
const _issuesDesc = { value: void 0, enumerable: false };
|
|
675
|
+
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
676
|
+
const initializer$1 = (inst, def) => {
|
|
677
|
+
inst.name = "$ZodError";
|
|
678
|
+
_issuesDesc.value = def;
|
|
679
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
680
|
+
_issuesDesc.value = void 0;
|
|
681
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
682
|
+
const proto = Object.getPrototypeOf(inst);
|
|
683
|
+
if (!_installedToString.has(proto)) {
|
|
684
|
+
_installedToString.add(proto);
|
|
685
|
+
Object.defineProperty(proto, "toString", {
|
|
686
|
+
configurable: true,
|
|
687
|
+
enumerable: false,
|
|
688
|
+
get() {
|
|
689
|
+
const value = () => this.message;
|
|
690
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
691
|
+
return value;
|
|
692
|
+
},
|
|
693
|
+
set(value) {
|
|
694
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
}
|
|
483
698
|
};
|
|
484
699
|
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
485
|
-
|
|
486
|
-
|
|
700
|
+
function node(obj, key, make) {
|
|
701
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
702
|
+
if (key === "__proto__") {
|
|
703
|
+
Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
704
|
+
} else {
|
|
705
|
+
obj[key] = make();
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return obj[key];
|
|
709
|
+
}
|
|
710
|
+
function flattenError(error2, mapper = (issue2) => issue2.message) {
|
|
487
711
|
const fieldErrors = {};
|
|
488
712
|
const formErrors = [];
|
|
489
|
-
for (const sub of
|
|
713
|
+
for (const sub of error2.issues) {
|
|
490
714
|
if (sub.path.length > 0) {
|
|
491
|
-
fieldErrors
|
|
492
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
715
|
+
node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
493
716
|
} else {
|
|
494
717
|
formErrors.push(mapper(sub));
|
|
495
718
|
}
|
|
496
719
|
}
|
|
497
720
|
return { formErrors, fieldErrors };
|
|
498
721
|
}
|
|
499
|
-
function formatError(
|
|
722
|
+
function formatError(error2, mapper = (issue2) => issue2.message) {
|
|
500
723
|
const fieldErrors = { _errors: [] };
|
|
501
|
-
const processError = (
|
|
502
|
-
for (const issue2 of
|
|
724
|
+
const processError = (error3, path = []) => {
|
|
725
|
+
for (const issue2 of error3.issues) {
|
|
503
726
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
504
727
|
issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
|
|
505
728
|
} else if (issue2.code === "invalid_key") {
|
|
@@ -516,83 +739,165 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
516
739
|
while (i < fullpath.length) {
|
|
517
740
|
const el = fullpath[i];
|
|
518
741
|
const terminal = i === fullpath.length - 1;
|
|
519
|
-
if (
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
742
|
+
if (el === "_errors") {
|
|
743
|
+
if (terminal)
|
|
744
|
+
curr._errors.push(mapper(issue2));
|
|
745
|
+
i++;
|
|
746
|
+
continue;
|
|
524
747
|
}
|
|
525
|
-
curr
|
|
748
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) {
|
|
749
|
+
Object.defineProperty(curr, el, {
|
|
750
|
+
value: { _errors: [] },
|
|
751
|
+
enumerable: true,
|
|
752
|
+
writable: true,
|
|
753
|
+
configurable: true
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
const node2 = curr[el];
|
|
757
|
+
if (terminal) {
|
|
758
|
+
node2._errors.push(mapper(issue2));
|
|
759
|
+
}
|
|
760
|
+
curr = node2;
|
|
526
761
|
i++;
|
|
527
762
|
}
|
|
528
763
|
}
|
|
529
764
|
}
|
|
530
765
|
}
|
|
531
766
|
};
|
|
532
|
-
processError(
|
|
767
|
+
processError(error2);
|
|
533
768
|
return fieldErrors;
|
|
534
769
|
}
|
|
535
|
-
|
|
770
|
+
function finalizeParams(callee, params) {
|
|
771
|
+
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
772
|
+
}
|
|
773
|
+
const _parse = (_Err) => {
|
|
774
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
775
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
776
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
777
|
+
if (result instanceof Promise) {
|
|
778
|
+
throw new $ZodAsyncError();
|
|
779
|
+
}
|
|
780
|
+
if (result.issues.length) {
|
|
781
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
782
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
783
|
+
throw e;
|
|
784
|
+
}
|
|
785
|
+
return result.value;
|
|
786
|
+
};
|
|
787
|
+
return fn;
|
|
788
|
+
};
|
|
789
|
+
const _parseAsync = (_Err) => {
|
|
790
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
791
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
792
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
793
|
+
if (result instanceof Promise)
|
|
794
|
+
result = await result;
|
|
795
|
+
if (result.issues.length) {
|
|
796
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
797
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
798
|
+
throw e;
|
|
799
|
+
}
|
|
800
|
+
return result.value;
|
|
801
|
+
};
|
|
802
|
+
return fn;
|
|
803
|
+
};
|
|
804
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
536
805
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
537
806
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
538
807
|
if (result instanceof Promise) {
|
|
539
808
|
throw new $ZodAsyncError();
|
|
540
809
|
}
|
|
541
|
-
|
|
542
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
543
|
-
captureStackTrace(e, _params?.callee);
|
|
544
|
-
throw e;
|
|
545
|
-
}
|
|
546
|
-
return result.value;
|
|
810
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
547
811
|
};
|
|
548
|
-
|
|
812
|
+
function failure(Err, issues, ctx) {
|
|
813
|
+
let error2;
|
|
814
|
+
return {
|
|
815
|
+
success: false,
|
|
816
|
+
get error() {
|
|
817
|
+
if (!error2) {
|
|
818
|
+
error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
819
|
+
issues = void 0;
|
|
820
|
+
ctx = void 0;
|
|
821
|
+
}
|
|
822
|
+
return error2;
|
|
823
|
+
},
|
|
824
|
+
set error(e) {
|
|
825
|
+
error2 = e;
|
|
826
|
+
issues = void 0;
|
|
827
|
+
ctx = void 0;
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
549
832
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
550
833
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
551
834
|
if (result instanceof Promise)
|
|
552
835
|
result = await result;
|
|
553
|
-
|
|
554
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
555
|
-
captureStackTrace(e, params?.callee);
|
|
556
|
-
throw e;
|
|
557
|
-
}
|
|
558
|
-
return result.value;
|
|
836
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
559
837
|
};
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
838
|
+
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
839
|
+
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
840
|
+
const validate = ((schema, value, _ctx) => {
|
|
841
|
+
const validator = schema._zod.bag.validator;
|
|
842
|
+
if (validator !== void 0) {
|
|
843
|
+
if (validator(value) !== COMPILE_INVALID)
|
|
844
|
+
return true;
|
|
845
|
+
if (validator.definite === true && _ctx === void 0)
|
|
846
|
+
return false;
|
|
847
|
+
}
|
|
848
|
+
return validateFallback(schema, value, _ctx);
|
|
849
|
+
});
|
|
850
|
+
function validateFallback(schema, value, _ctx) {
|
|
851
|
+
const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
|
|
852
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
853
|
+
let result;
|
|
854
|
+
if (fallbackRun) {
|
|
855
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
856
|
+
result = fallbackRun({ value, issues: [] }, ctx);
|
|
857
|
+
} else {
|
|
858
|
+
result = schema._zod.run({ value, issues: [] }, ctx);
|
|
859
|
+
}
|
|
563
860
|
if (result instanceof Promise) {
|
|
564
861
|
throw new $ZodAsyncError();
|
|
565
862
|
}
|
|
566
|
-
return result.issues.length
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
} : {
|
|
570
|
-
};
|
|
571
|
-
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
572
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
573
|
-
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
863
|
+
return result.issues.length === 0;
|
|
864
|
+
}
|
|
865
|
+
const validateAsync$1 = async (schema, value, _ctx) => {
|
|
866
|
+
const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
|
|
574
867
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
575
868
|
if (result instanceof Promise)
|
|
576
869
|
result = await result;
|
|
577
|
-
return result.issues.length
|
|
578
|
-
success: false,
|
|
579
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
580
|
-
} : { success: true, data: result.value };
|
|
870
|
+
return result.issues.length === 0;
|
|
581
871
|
};
|
|
582
|
-
const
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
|
|
872
|
+
const _encode = (_Err) => {
|
|
873
|
+
const parse2 = _parse(_Err);
|
|
874
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
875
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
876
|
+
return parse2(schema, value, ctx, finalizeParams(fn, _params));
|
|
877
|
+
};
|
|
878
|
+
return fn;
|
|
586
879
|
};
|
|
587
|
-
const _decode = (_Err) =>
|
|
588
|
-
|
|
880
|
+
const _decode = (_Err) => {
|
|
881
|
+
const parse2 = _parse(_Err);
|
|
882
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
883
|
+
return parse2(schema, value, _ctx, finalizeParams(fn, _params));
|
|
884
|
+
};
|
|
885
|
+
return fn;
|
|
589
886
|
};
|
|
590
|
-
const _encodeAsync = (_Err) =>
|
|
591
|
-
const
|
|
592
|
-
|
|
887
|
+
const _encodeAsync = (_Err) => {
|
|
888
|
+
const parseAsync2 = _parseAsync(_Err);
|
|
889
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
890
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
891
|
+
return await parseAsync2(schema, value, ctx, finalizeParams(fn, _params));
|
|
892
|
+
};
|
|
893
|
+
return fn;
|
|
593
894
|
};
|
|
594
|
-
const _decodeAsync = (_Err) =>
|
|
595
|
-
|
|
895
|
+
const _decodeAsync = (_Err) => {
|
|
896
|
+
const parseAsync2 = _parseAsync(_Err);
|
|
897
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
898
|
+
return await parseAsync2(schema, value, _ctx, finalizeParams(fn, _params));
|
|
899
|
+
};
|
|
900
|
+
return fn;
|
|
596
901
|
};
|
|
597
902
|
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
598
903
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
@@ -610,55 +915,55 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
610
915
|
};
|
|
611
916
|
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
612
917
|
const cuid2 = /^[0-9a-z]+$/;
|
|
613
|
-
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{
|
|
918
|
+
const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
614
919
|
const xid = /^[0-9a-vA-V]{20}$/;
|
|
615
920
|
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
616
921
|
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
617
|
-
|
|
922
|
+
function nanoidOfLength(length) {
|
|
923
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
924
|
+
}
|
|
925
|
+
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
618
926
|
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
619
927
|
const uuid = (version2) => {
|
|
620
928
|
if (!version2)
|
|
621
929
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
622
930
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
623
931
|
};
|
|
624
|
-
const email = /^(
|
|
625
|
-
const _emoji$1 = `^(\\p{Extended_Pictographic}
|
|
932
|
+
const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
933
|
+
const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
626
934
|
function emoji() {
|
|
627
935
|
return new RegExp(_emoji$1, "u");
|
|
628
936
|
}
|
|
629
937
|
const 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])$/;
|
|
630
938
|
const ipv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))$/;
|
|
631
939
|
const cidrv4 = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
632
|
-
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
940
|
+
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
633
941
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
634
|
-
const base64url = /^[A-Za-z0-9_-]
|
|
942
|
+
const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
635
943
|
const httpProtocol = /^https?$/;
|
|
636
944
|
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
637
945
|
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
638
|
-
|
|
946
|
+
function anchor(source) {
|
|
947
|
+
return new RegExp(`^${source}$`);
|
|
948
|
+
}
|
|
949
|
+
const date = /* @__PURE__ */ anchor(dateSource);
|
|
639
950
|
function timeSource(args) {
|
|
640
951
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
641
|
-
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
952
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
642
953
|
return regex;
|
|
643
954
|
}
|
|
644
|
-
function time
|
|
955
|
+
function time(args) {
|
|
645
956
|
return new RegExp(`^${timeSource(args)}$`);
|
|
646
957
|
}
|
|
647
|
-
function datetime
|
|
648
|
-
const time2 = timeSource({ precision: args.precision });
|
|
958
|
+
function datetime(args) {
|
|
649
959
|
const opts = ["Z"];
|
|
650
|
-
if (args.local)
|
|
651
|
-
opts.push("");
|
|
652
960
|
if (args.offset)
|
|
653
961
|
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
654
|
-
const
|
|
962
|
+
const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
|
|
963
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
655
964
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
656
965
|
}
|
|
657
|
-
const
|
|
658
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
659
|
-
return new RegExp(`^${regex}$`);
|
|
660
|
-
};
|
|
661
|
-
const integer = /^-?\d+$/;
|
|
966
|
+
const anyString = /^[\s\S]{0,}$/;
|
|
662
967
|
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
663
968
|
const boolean$1 = /^(?:true|false)$/i;
|
|
664
969
|
const lowercase = /^[^A-Z]*$/;
|
|
@@ -669,6 +974,10 @@ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
|
669
974
|
inst._zod.def = def;
|
|
670
975
|
(_a2 = inst._zod).onattach ?? (_a2.onattach = []);
|
|
671
976
|
});
|
|
977
|
+
const _whenHasLength = (payload) => {
|
|
978
|
+
const val = payload.value;
|
|
979
|
+
return !nullish(val) && val.length !== void 0;
|
|
980
|
+
};
|
|
672
981
|
const numericOriginMap = {
|
|
673
982
|
number: "number",
|
|
674
983
|
bigint: "bigint",
|
|
@@ -677,22 +986,12 @@ const numericOriginMap = {
|
|
|
677
986
|
const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
678
987
|
$ZodCheck.init(inst, def);
|
|
679
988
|
const origin = numericOriginMap[typeof def.value];
|
|
680
|
-
inst._zod.onattach.push((inst2) => {
|
|
681
|
-
const bag = inst2._zod.bag;
|
|
682
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
683
|
-
if (def.value < curr) {
|
|
684
|
-
if (def.inclusive)
|
|
685
|
-
bag.maximum = def.value;
|
|
686
|
-
else
|
|
687
|
-
bag.exclusiveMaximum = def.value;
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
989
|
inst._zod.check = (payload) => {
|
|
691
990
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
692
991
|
return;
|
|
693
992
|
}
|
|
694
993
|
payload.issues.push({
|
|
695
|
-
origin,
|
|
994
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
696
995
|
code: "too_big",
|
|
697
996
|
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
698
997
|
input: payload.value,
|
|
@@ -705,22 +1004,12 @@ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (ins
|
|
|
705
1004
|
const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
706
1005
|
$ZodCheck.init(inst, def);
|
|
707
1006
|
const origin = numericOriginMap[typeof def.value];
|
|
708
|
-
inst._zod.onattach.push((inst2) => {
|
|
709
|
-
const bag = inst2._zod.bag;
|
|
710
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
711
|
-
if (def.value > curr) {
|
|
712
|
-
if (def.inclusive)
|
|
713
|
-
bag.minimum = def.value;
|
|
714
|
-
else
|
|
715
|
-
bag.exclusiveMinimum = def.value;
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
1007
|
inst._zod.check = (payload) => {
|
|
719
1008
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
720
1009
|
return;
|
|
721
1010
|
}
|
|
722
1011
|
payload.issues.push({
|
|
723
|
-
origin,
|
|
1012
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
724
1013
|
code: "too_small",
|
|
725
1014
|
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
726
1015
|
input: payload.value,
|
|
@@ -732,14 +1021,13 @@ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan"
|
|
|
732
1021
|
});
|
|
733
1022
|
const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
734
1023
|
$ZodCheck.init(inst, def);
|
|
735
|
-
inst._zod.onattach.push((inst2) => {
|
|
736
|
-
var _a2;
|
|
737
|
-
(_a2 = inst2._zod.bag).multipleOf ?? (_a2.multipleOf = def.value);
|
|
738
|
-
});
|
|
739
1024
|
inst._zod.check = (payload) => {
|
|
740
1025
|
if (typeof payload.value !== typeof def.value)
|
|
741
1026
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
742
|
-
const isMultiple = typeof payload.value === "bigint" ?
|
|
1027
|
+
const isMultiple = typeof payload.value === "bigint" ? (
|
|
1028
|
+
// `value % 0n` throws, and nothing is a multiple of zero — the number branch already fails this way via NaN
|
|
1029
|
+
def.value !== BigInt(0) && payload.value % def.value === BigInt(0)
|
|
1030
|
+
) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
743
1031
|
if (isMultiple)
|
|
744
1032
|
return;
|
|
745
1033
|
payload.issues.push({
|
|
@@ -758,14 +1046,6 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
|
|
|
758
1046
|
const isInt = def.format?.includes("int");
|
|
759
1047
|
const origin = isInt ? "int" : "number";
|
|
760
1048
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
761
|
-
inst._zod.onattach.push((inst2) => {
|
|
762
|
-
const bag = inst2._zod.bag;
|
|
763
|
-
bag.format = def.format;
|
|
764
|
-
bag.minimum = minimum;
|
|
765
|
-
bag.maximum = maximum;
|
|
766
|
-
if (isInt)
|
|
767
|
-
bag.pattern = integer;
|
|
768
|
-
});
|
|
769
1049
|
inst._zod.check = (payload) => {
|
|
770
1050
|
const input = payload.value;
|
|
771
1051
|
if (isInt) {
|
|
@@ -834,18 +1114,11 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
|
|
|
834
1114
|
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
835
1115
|
var _a2;
|
|
836
1116
|
$ZodCheck.init(inst, def);
|
|
837
|
-
(_a2 = inst._zod.def).when ?? (_a2.when =
|
|
838
|
-
const val = payload.value;
|
|
839
|
-
return !nullish(val) && val.length !== void 0;
|
|
840
|
-
});
|
|
841
|
-
inst._zod.onattach.push((inst2) => {
|
|
842
|
-
const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
843
|
-
if (def.maximum < curr)
|
|
844
|
-
inst2._zod.bag.maximum = def.maximum;
|
|
845
|
-
});
|
|
1117
|
+
(_a2 = inst._zod.def).when ?? (_a2.when = _whenHasLength);
|
|
846
1118
|
inst._zod.check = (payload) => {
|
|
847
1119
|
const input = payload.value;
|
|
848
|
-
const
|
|
1120
|
+
const units = input.length;
|
|
1121
|
+
const length = typeof input === "string" && units > def.maximum ? codePointLength(input) : units;
|
|
849
1122
|
if (length <= def.maximum)
|
|
850
1123
|
return;
|
|
851
1124
|
const origin = getLengthableOrigin(input);
|
|
@@ -863,18 +1136,11 @@ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (i
|
|
|
863
1136
|
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
864
1137
|
var _a2;
|
|
865
1138
|
$ZodCheck.init(inst, def);
|
|
866
|
-
(_a2 = inst._zod.def).when ?? (_a2.when =
|
|
867
|
-
const val = payload.value;
|
|
868
|
-
return !nullish(val) && val.length !== void 0;
|
|
869
|
-
});
|
|
870
|
-
inst._zod.onattach.push((inst2) => {
|
|
871
|
-
const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
872
|
-
if (def.minimum > curr)
|
|
873
|
-
inst2._zod.bag.minimum = def.minimum;
|
|
874
|
-
});
|
|
1139
|
+
(_a2 = inst._zod.def).when ?? (_a2.when = _whenHasLength);
|
|
875
1140
|
inst._zod.check = (payload) => {
|
|
876
1141
|
const input = payload.value;
|
|
877
|
-
const
|
|
1142
|
+
const units = input.length;
|
|
1143
|
+
const length = typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units;
|
|
878
1144
|
if (length >= def.minimum)
|
|
879
1145
|
return;
|
|
880
1146
|
const origin = getLengthableOrigin(input);
|
|
@@ -892,19 +1158,11 @@ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (i
|
|
|
892
1158
|
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
893
1159
|
var _a2;
|
|
894
1160
|
$ZodCheck.init(inst, def);
|
|
895
|
-
(_a2 = inst._zod.def).when ?? (_a2.when =
|
|
896
|
-
const val = payload.value;
|
|
897
|
-
return !nullish(val) && val.length !== void 0;
|
|
898
|
-
});
|
|
899
|
-
inst._zod.onattach.push((inst2) => {
|
|
900
|
-
const bag = inst2._zod.bag;
|
|
901
|
-
bag.minimum = def.length;
|
|
902
|
-
bag.maximum = def.length;
|
|
903
|
-
bag.length = def.length;
|
|
904
|
-
});
|
|
1161
|
+
(_a2 = inst._zod.def).when ?? (_a2.when = _whenHasLength);
|
|
905
1162
|
inst._zod.check = (payload) => {
|
|
906
1163
|
const input = payload.value;
|
|
907
|
-
const
|
|
1164
|
+
const units = input.length;
|
|
1165
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
908
1166
|
if (length === def.length)
|
|
909
1167
|
return;
|
|
910
1168
|
const origin = getLengthableOrigin(input);
|
|
@@ -923,14 +1181,6 @@ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEqual
|
|
|
923
1181
|
const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
924
1182
|
var _a2, _b;
|
|
925
1183
|
$ZodCheck.init(inst, def);
|
|
926
|
-
inst._zod.onattach.push((inst2) => {
|
|
927
|
-
const bag = inst2._zod.bag;
|
|
928
|
-
bag.format = def.format;
|
|
929
|
-
if (def.pattern) {
|
|
930
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
931
|
-
bag.patterns.add(def.pattern);
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
1184
|
if (def.pattern)
|
|
935
1185
|
(_a2 = inst._zod).check ?? (_a2.check = (payload) => {
|
|
936
1186
|
def.pattern.lastIndex = 0;
|
|
@@ -978,13 +1228,8 @@ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (i
|
|
|
978
1228
|
const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
979
1229
|
$ZodCheck.init(inst, def);
|
|
980
1230
|
const escapedRegex = escapeRegex(def.includes);
|
|
981
|
-
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
1231
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
982
1232
|
def.pattern = pattern;
|
|
983
|
-
inst._zod.onattach.push((inst2) => {
|
|
984
|
-
const bag = inst2._zod.bag;
|
|
985
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
986
|
-
bag.patterns.add(pattern);
|
|
987
|
-
});
|
|
988
1233
|
inst._zod.check = (payload) => {
|
|
989
1234
|
if (payload.value.includes(def.includes, def.position))
|
|
990
1235
|
return;
|
|
@@ -1003,11 +1248,6 @@ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith",
|
|
|
1003
1248
|
$ZodCheck.init(inst, def);
|
|
1004
1249
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1005
1250
|
def.pattern ?? (def.pattern = pattern);
|
|
1006
|
-
inst._zod.onattach.push((inst2) => {
|
|
1007
|
-
const bag = inst2._zod.bag;
|
|
1008
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1009
|
-
bag.patterns.add(pattern);
|
|
1010
|
-
});
|
|
1011
1251
|
inst._zod.check = (payload) => {
|
|
1012
1252
|
if (payload.value.startsWith(def.prefix))
|
|
1013
1253
|
return;
|
|
@@ -1026,11 +1266,6 @@ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (ins
|
|
|
1026
1266
|
$ZodCheck.init(inst, def);
|
|
1027
1267
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1028
1268
|
def.pattern ?? (def.pattern = pattern);
|
|
1029
|
-
inst._zod.onattach.push((inst2) => {
|
|
1030
|
-
const bag = inst2._zod.bag;
|
|
1031
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1032
|
-
bag.patterns.add(pattern);
|
|
1033
|
-
});
|
|
1034
1269
|
inst._zod.check = (payload) => {
|
|
1035
1270
|
if (payload.value.endsWith(def.suffix))
|
|
1036
1271
|
return;
|
|
@@ -1052,16 +1287,20 @@ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (i
|
|
|
1052
1287
|
};
|
|
1053
1288
|
});
|
|
1054
1289
|
class Doc {
|
|
1055
|
-
constructor(args = []) {
|
|
1290
|
+
constructor(args = [], closed = {}) {
|
|
1056
1291
|
this.content = [];
|
|
1057
1292
|
this.indent = 0;
|
|
1058
|
-
|
|
1059
|
-
|
|
1293
|
+
this.args = args;
|
|
1294
|
+
this.closed = closed;
|
|
1060
1295
|
}
|
|
1296
|
+
// the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it
|
|
1061
1297
|
indented(fn) {
|
|
1062
1298
|
this.indent += 1;
|
|
1063
|
-
|
|
1064
|
-
|
|
1299
|
+
try {
|
|
1300
|
+
fn(this);
|
|
1301
|
+
} finally {
|
|
1302
|
+
this.indent -= 1;
|
|
1303
|
+
}
|
|
1065
1304
|
}
|
|
1066
1305
|
write(arg) {
|
|
1067
1306
|
if (typeof arg === "function") {
|
|
@@ -1079,16 +1318,17 @@ class Doc {
|
|
|
1079
1318
|
}
|
|
1080
1319
|
compile() {
|
|
1081
1320
|
const F = Function;
|
|
1082
|
-
const args = this?.args;
|
|
1083
1321
|
const content = this?.content ?? [``];
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1322
|
+
const factory = new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {
|
|
1323
|
+
${content.join("\n")}
|
|
1324
|
+
};`);
|
|
1325
|
+
return factory(...Object.values(this.closed));
|
|
1086
1326
|
}
|
|
1087
1327
|
}
|
|
1088
1328
|
const version = {
|
|
1089
1329
|
major: 4,
|
|
1090
|
-
minor:
|
|
1091
|
-
patch:
|
|
1330
|
+
minor: 6,
|
|
1331
|
+
patch: 5
|
|
1092
1332
|
};
|
|
1093
1333
|
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1094
1334
|
var _a2;
|
|
@@ -1096,10 +1336,8 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1096
1336
|
inst._zod.def = def;
|
|
1097
1337
|
inst._zod.bag = inst._zod.bag || {};
|
|
1098
1338
|
inst._zod.version = version;
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
checks.unshift(inst);
|
|
1102
|
-
}
|
|
1339
|
+
const defChecks = inst._zod.def.checks;
|
|
1340
|
+
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
|
|
1103
1341
|
for (const ch of checks) {
|
|
1104
1342
|
for (const fn of ch._zod.onattach) {
|
|
1105
1343
|
fn(inst);
|
|
@@ -1112,6 +1350,8 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1112
1350
|
});
|
|
1113
1351
|
} else {
|
|
1114
1352
|
const runChecks = (payload, checks2, ctx) => {
|
|
1353
|
+
if (payload.memo)
|
|
1354
|
+
return payload;
|
|
1115
1355
|
let isAborted = aborted(payload);
|
|
1116
1356
|
let asyncResult;
|
|
1117
1357
|
for (const ch of checks2) {
|
|
@@ -1135,6 +1375,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1135
1375
|
const nextLen = payload.issues.length;
|
|
1136
1376
|
if (nextLen === currLen)
|
|
1137
1377
|
return;
|
|
1378
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1138
1379
|
if (!isAborted)
|
|
1139
1380
|
isAborted = aborted(payload, currLen);
|
|
1140
1381
|
});
|
|
@@ -1142,6 +1383,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1142
1383
|
const nextLen = payload.issues.length;
|
|
1143
1384
|
if (nextLen === currLen)
|
|
1144
1385
|
continue;
|
|
1386
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1145
1387
|
if (!isAborted)
|
|
1146
1388
|
isAborted = aborted(payload, currLen);
|
|
1147
1389
|
}
|
|
@@ -1188,22 +1430,39 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
1188
1430
|
return runChecks(result, checks, ctx);
|
|
1189
1431
|
};
|
|
1190
1432
|
}
|
|
1191
|
-
|
|
1433
|
+
}, {
|
|
1434
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
1435
|
+
get "~standard"() {
|
|
1436
|
+
return hide(this, "~standard", standardProps(this));
|
|
1437
|
+
},
|
|
1438
|
+
set "~standard"(value) {
|
|
1439
|
+
own(this, "~standard", value);
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1443
|
+
async function validateAsync(inst, value) {
|
|
1444
|
+
const ctx = { async: true };
|
|
1445
|
+
return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
|
|
1446
|
+
}
|
|
1447
|
+
function standardProps(inst) {
|
|
1448
|
+
return {
|
|
1192
1449
|
validate: (value) => {
|
|
1450
|
+
const ctx = { async: false };
|
|
1193
1451
|
try {
|
|
1194
|
-
const r =
|
|
1195
|
-
|
|
1452
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
1453
|
+
if (!(r instanceof Promise))
|
|
1454
|
+
return toStandardResult(r, ctx);
|
|
1196
1455
|
} catch (_) {
|
|
1197
|
-
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1198
1456
|
}
|
|
1457
|
+
return validateAsync(inst, value);
|
|
1199
1458
|
},
|
|
1200
1459
|
vendor: "zod",
|
|
1201
1460
|
version: 1
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1204
1463
|
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1205
1464
|
$ZodType.init(inst, def);
|
|
1206
|
-
inst._zod.pattern =
|
|
1465
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1207
1466
|
inst._zod.parse = (payload, _) => {
|
|
1208
1467
|
if (def.coerce)
|
|
1209
1468
|
try {
|
|
@@ -1253,58 +1512,105 @@ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
|
1253
1512
|
def.pattern ?? (def.pattern = email);
|
|
1254
1513
|
$ZodStringFormat.init(inst, def);
|
|
1255
1514
|
});
|
|
1515
|
+
const URL_BAD_FORMAT = 1;
|
|
1516
|
+
const URL_UNPARSEABLE = 2;
|
|
1517
|
+
function canParseURL(input) {
|
|
1518
|
+
try {
|
|
1519
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function")
|
|
1520
|
+
return URL.canParse(input);
|
|
1521
|
+
new URL(input);
|
|
1522
|
+
return true;
|
|
1523
|
+
} catch {
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
function validateURL(trimmed, def) {
|
|
1528
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
1529
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
1530
|
+
}
|
|
1531
|
+
return parseURLObject(trimmed, def);
|
|
1532
|
+
}
|
|
1533
|
+
function parseURLObject(trimmed, def) {
|
|
1534
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
1535
|
+
return URL_BAD_FORMAT;
|
|
1536
|
+
}
|
|
1537
|
+
try {
|
|
1538
|
+
if (typeof URL !== "undefined") {
|
|
1539
|
+
const URLStatic = URL;
|
|
1540
|
+
if (typeof URLStatic.parse === "function")
|
|
1541
|
+
return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
1542
|
+
}
|
|
1543
|
+
return new URL(trimmed);
|
|
1544
|
+
} catch {
|
|
1545
|
+
return URL_UNPARSEABLE;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
1549
|
+
function stripTabAndNewline(value) {
|
|
1550
|
+
return value.replace(asciiTabOrNewline, "");
|
|
1551
|
+
}
|
|
1552
|
+
function urlHostnameOk(url, hostname) {
|
|
1553
|
+
hostname.lastIndex = 0;
|
|
1554
|
+
return hostname.test(url.hostname);
|
|
1555
|
+
}
|
|
1556
|
+
function urlProtocolOk(url, protocol) {
|
|
1557
|
+
protocol.lastIndex = 0;
|
|
1558
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
1559
|
+
}
|
|
1256
1560
|
const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1257
1561
|
$ZodStringFormat.init(inst, def);
|
|
1258
1562
|
inst._zod.check = (payload) => {
|
|
1259
1563
|
try {
|
|
1260
1564
|
const trimmed = payload.value.trim();
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
}
|
|
1565
|
+
const url = validateURL(trimmed, def);
|
|
1566
|
+
if (url === URL_BAD_FORMAT) {
|
|
1567
|
+
payload.issues.push({
|
|
1568
|
+
code: "invalid_format",
|
|
1569
|
+
format: "url",
|
|
1570
|
+
note: "Invalid URL format",
|
|
1571
|
+
input: payload.value,
|
|
1572
|
+
inst,
|
|
1573
|
+
continue: !def.abort
|
|
1574
|
+
});
|
|
1575
|
+
return;
|
|
1273
1576
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
payload.
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
input: payload.value,
|
|
1284
|
-
inst,
|
|
1285
|
-
continue: !def.abort
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1577
|
+
if (url === URL_UNPARSEABLE) {
|
|
1578
|
+
payload.issues.push({
|
|
1579
|
+
code: "invalid_format",
|
|
1580
|
+
format: "url",
|
|
1581
|
+
input: payload.value,
|
|
1582
|
+
inst,
|
|
1583
|
+
continue: !def.abort
|
|
1584
|
+
});
|
|
1585
|
+
return;
|
|
1288
1586
|
}
|
|
1289
|
-
if (
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
payload.issues.push({
|
|
1293
|
-
code: "invalid_format",
|
|
1294
|
-
format: "url",
|
|
1295
|
-
note: "Invalid protocol",
|
|
1296
|
-
pattern: def.protocol.source,
|
|
1297
|
-
input: payload.value,
|
|
1298
|
-
inst,
|
|
1299
|
-
continue: !def.abort
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1587
|
+
if (url === true) {
|
|
1588
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1589
|
+
return;
|
|
1302
1590
|
}
|
|
1303
|
-
if (def.
|
|
1304
|
-
payload.
|
|
1305
|
-
|
|
1306
|
-
|
|
1591
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
1592
|
+
payload.issues.push({
|
|
1593
|
+
code: "invalid_format",
|
|
1594
|
+
format: "url",
|
|
1595
|
+
note: "Invalid hostname",
|
|
1596
|
+
pattern: def.hostname.source,
|
|
1597
|
+
input: payload.value,
|
|
1598
|
+
inst,
|
|
1599
|
+
continue: !def.abort
|
|
1600
|
+
});
|
|
1307
1601
|
}
|
|
1602
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
1603
|
+
payload.issues.push({
|
|
1604
|
+
code: "invalid_format",
|
|
1605
|
+
format: "url",
|
|
1606
|
+
note: "Invalid protocol",
|
|
1607
|
+
pattern: def.protocol.source,
|
|
1608
|
+
input: payload.value,
|
|
1609
|
+
inst,
|
|
1610
|
+
continue: !def.abort
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
1308
1614
|
return;
|
|
1309
1615
|
} catch (_) {
|
|
1310
1616
|
payload.issues.push({
|
|
@@ -1322,7 +1628,9 @@ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
|
1322
1628
|
$ZodStringFormat.init(inst, def);
|
|
1323
1629
|
});
|
|
1324
1630
|
const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1325
|
-
def.
|
|
1631
|
+
if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1))
|
|
1632
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
1633
|
+
def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
|
|
1326
1634
|
$ZodStringFormat.init(inst, def);
|
|
1327
1635
|
});
|
|
1328
1636
|
const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
@@ -1346,34 +1654,36 @@ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
1346
1654
|
$ZodStringFormat.init(inst, def);
|
|
1347
1655
|
});
|
|
1348
1656
|
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1349
|
-
def.pattern ?? (def.pattern = datetime
|
|
1657
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1350
1658
|
$ZodStringFormat.init(inst, def);
|
|
1351
1659
|
});
|
|
1352
1660
|
const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1353
|
-
def.pattern ?? (def.pattern = date
|
|
1661
|
+
def.pattern ?? (def.pattern = date);
|
|
1354
1662
|
$ZodStringFormat.init(inst, def);
|
|
1355
1663
|
});
|
|
1356
1664
|
const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1357
|
-
def.pattern ?? (def.pattern = time
|
|
1665
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1358
1666
|
$ZodStringFormat.init(inst, def);
|
|
1359
1667
|
});
|
|
1360
1668
|
const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1361
|
-
def.pattern ?? (def.pattern = duration
|
|
1669
|
+
def.pattern ?? (def.pattern = duration);
|
|
1362
1670
|
$ZodStringFormat.init(inst, def);
|
|
1363
1671
|
});
|
|
1364
1672
|
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1365
1673
|
def.pattern ?? (def.pattern = ipv4);
|
|
1366
1674
|
$ZodStringFormat.init(inst, def);
|
|
1367
|
-
inst._zod.bag.format = `ipv4`;
|
|
1368
1675
|
});
|
|
1676
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1677
|
+
function isValidIPv6(value) {
|
|
1678
|
+
if (!ipv6Alphabet.test(value))
|
|
1679
|
+
return false;
|
|
1680
|
+
return canParseURL(`http://[${value}]`);
|
|
1681
|
+
}
|
|
1369
1682
|
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1370
1683
|
def.pattern ?? (def.pattern = ipv6);
|
|
1371
1684
|
$ZodStringFormat.init(inst, def);
|
|
1372
|
-
inst._zod.bag.format = `ipv6`;
|
|
1373
1685
|
inst._zod.check = (payload) => {
|
|
1374
|
-
|
|
1375
|
-
new URL(`http://[${payload.value}]`);
|
|
1376
|
-
} catch {
|
|
1686
|
+
if (!isValidIPv6(payload.value)) {
|
|
1377
1687
|
payload.issues.push({
|
|
1378
1688
|
code: "invalid_format",
|
|
1379
1689
|
format: "ipv6",
|
|
@@ -1388,24 +1698,25 @@ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
|
1388
1698
|
def.pattern ?? (def.pattern = cidrv4);
|
|
1389
1699
|
$ZodStringFormat.init(inst, def);
|
|
1390
1700
|
});
|
|
1701
|
+
function isValidCIDRv6(value) {
|
|
1702
|
+
const parts = value.split("/");
|
|
1703
|
+
if (parts.length !== 2)
|
|
1704
|
+
return false;
|
|
1705
|
+
const [address, prefix] = parts;
|
|
1706
|
+
if (!prefix)
|
|
1707
|
+
return false;
|
|
1708
|
+
const prefixNum = Number(prefix);
|
|
1709
|
+
if (`${prefixNum}` !== prefix)
|
|
1710
|
+
return false;
|
|
1711
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
1712
|
+
return false;
|
|
1713
|
+
return isValidIPv6(address);
|
|
1714
|
+
}
|
|
1391
1715
|
const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1392
1716
|
def.pattern ?? (def.pattern = cidrv6);
|
|
1393
1717
|
$ZodStringFormat.init(inst, def);
|
|
1394
1718
|
inst._zod.check = (payload) => {
|
|
1395
|
-
|
|
1396
|
-
try {
|
|
1397
|
-
if (parts.length !== 2)
|
|
1398
|
-
throw new Error();
|
|
1399
|
-
const [address, prefix] = parts;
|
|
1400
|
-
if (!prefix)
|
|
1401
|
-
throw new Error();
|
|
1402
|
-
const prefixNum = Number(prefix);
|
|
1403
|
-
if (`${prefixNum}` !== prefix)
|
|
1404
|
-
throw new Error();
|
|
1405
|
-
if (prefixNum < 0 || prefixNum > 128)
|
|
1406
|
-
throw new Error();
|
|
1407
|
-
new URL(`http://[${address}]`);
|
|
1408
|
-
} catch {
|
|
1719
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
1409
1720
|
payload.issues.push({
|
|
1410
1721
|
code: "invalid_format",
|
|
1411
1722
|
format: "cidrv6",
|
|
@@ -1430,10 +1741,10 @@ function isValidBase64(data) {
|
|
|
1430
1741
|
return false;
|
|
1431
1742
|
}
|
|
1432
1743
|
}
|
|
1744
|
+
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1433
1745
|
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1434
|
-
def.pattern ?? (def.pattern =
|
|
1746
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1435
1747
|
$ZodStringFormat.init(inst, def);
|
|
1436
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1437
1748
|
inst._zod.check = (payload) => {
|
|
1438
1749
|
if (isValidBase64(payload.value))
|
|
1439
1750
|
return;
|
|
@@ -1446,17 +1757,17 @@ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
1446
1757
|
});
|
|
1447
1758
|
};
|
|
1448
1759
|
});
|
|
1760
|
+
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1449
1761
|
function isValidBase64URL(data) {
|
|
1450
|
-
if (!
|
|
1762
|
+
if (!base64urlCharset.test(data))
|
|
1451
1763
|
return false;
|
|
1452
1764
|
const base642 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1453
1765
|
const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
|
|
1454
1766
|
return isValidBase64(padded);
|
|
1455
1767
|
}
|
|
1456
1768
|
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1457
|
-
def.pattern ?? (def.pattern =
|
|
1769
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1458
1770
|
$ZodStringFormat.init(inst, def);
|
|
1459
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1460
1771
|
inst._zod.check = (payload) => {
|
|
1461
1772
|
if (isValidBase64URL(payload.value))
|
|
1462
1773
|
return;
|
|
@@ -1509,7 +1820,7 @@ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1509
1820
|
});
|
|
1510
1821
|
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1511
1822
|
$ZodType.init(inst, def);
|
|
1512
|
-
inst._zod.pattern =
|
|
1823
|
+
inst._zod.pattern = number$1;
|
|
1513
1824
|
inst._zod.parse = (payload, _ctx) => {
|
|
1514
1825
|
if (def.coerce)
|
|
1515
1826
|
try {
|
|
@@ -1520,7 +1831,7 @@ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
1520
1831
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
1521
1832
|
return payload;
|
|
1522
1833
|
}
|
|
1523
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ?
|
|
1834
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
|
|
1524
1835
|
payload.issues.push({
|
|
1525
1836
|
expected: "number",
|
|
1526
1837
|
code: "invalid_type",
|
|
@@ -1580,6 +1891,8 @@ function handleArrayResult(result, final, index) {
|
|
|
1580
1891
|
}
|
|
1581
1892
|
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1582
1893
|
$ZodType.init(inst, def);
|
|
1894
|
+
const memo2 = globalConfig.memoizer;
|
|
1895
|
+
memo2?.attach(inst);
|
|
1583
1896
|
inst._zod.parse = (payload, ctx) => {
|
|
1584
1897
|
const input = payload.value;
|
|
1585
1898
|
if (!Array.isArray(input)) {
|
|
@@ -1591,8 +1904,9 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1591
1904
|
});
|
|
1592
1905
|
return payload;
|
|
1593
1906
|
}
|
|
1594
|
-
payload.value = Array(input.length);
|
|
1907
|
+
payload.value = memo2 ? memo2.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1595
1908
|
const proms = [];
|
|
1909
|
+
const abortEarly = ctx?.abortEarly;
|
|
1596
1910
|
for (let i = 0; i < input.length; i++) {
|
|
1597
1911
|
const item = input[i];
|
|
1598
1912
|
const result = def.element._zod.run({
|
|
@@ -1603,6 +1917,8 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1603
1917
|
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
1604
1918
|
} else {
|
|
1605
1919
|
handleArrayResult(result, payload, i);
|
|
1920
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result))
|
|
1921
|
+
break;
|
|
1606
1922
|
}
|
|
1607
1923
|
}
|
|
1608
1924
|
if (proms.length) {
|
|
@@ -1611,15 +1927,19 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
1611
1927
|
return payload;
|
|
1612
1928
|
};
|
|
1613
1929
|
});
|
|
1614
|
-
function handlePropertyResult(result, final, key, input,
|
|
1930
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
1615
1931
|
const isPresent = key in input;
|
|
1932
|
+
const isOptionalOut = optout === "optional";
|
|
1933
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1616
1936
|
if (result.issues.length) {
|
|
1617
|
-
if (
|
|
1937
|
+
if (optin !== void 0 && isOptionalOut && !isPresent) {
|
|
1618
1938
|
return;
|
|
1619
1939
|
}
|
|
1620
1940
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1621
1941
|
}
|
|
1622
|
-
if (!isPresent &&
|
|
1942
|
+
if (!isPresent && optin === void 0) {
|
|
1623
1943
|
if (!result.issues.length) {
|
|
1624
1944
|
final.issues.push({
|
|
1625
1945
|
code: "invalid_type",
|
|
@@ -1631,50 +1951,65 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
1631
1951
|
return;
|
|
1632
1952
|
}
|
|
1633
1953
|
if (result.value === void 0) {
|
|
1634
|
-
if (isPresent) {
|
|
1954
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) {
|
|
1635
1955
|
final.value[key] = void 0;
|
|
1636
1956
|
}
|
|
1637
1957
|
} else {
|
|
1638
1958
|
final.value[key] = result.value;
|
|
1639
1959
|
}
|
|
1640
1960
|
}
|
|
1961
|
+
const NO_SYMBOL_KEYS = [];
|
|
1641
1962
|
function normalizeDef(def) {
|
|
1642
1963
|
const keys = Object.keys(def.shape);
|
|
1643
|
-
|
|
1964
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
1965
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
1966
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
1967
|
+
for (const k of allKeys) {
|
|
1644
1968
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
1645
|
-
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1969
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
1646
1970
|
}
|
|
1647
1971
|
}
|
|
1648
1972
|
const okeys = optionalKeys(def.shape);
|
|
1649
1973
|
return {
|
|
1650
1974
|
...def,
|
|
1651
|
-
|
|
1975
|
+
allKeys,
|
|
1976
|
+
symbolKeys,
|
|
1977
|
+
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
1652
1978
|
keySet: new Set(keys),
|
|
1653
1979
|
numKeys: keys.length,
|
|
1654
1980
|
optionalKeys: new Set(okeys)
|
|
1655
1981
|
};
|
|
1656
1982
|
}
|
|
1657
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1983
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
1658
1984
|
const unrecognized = [];
|
|
1659
1985
|
const keySet = def.keySet;
|
|
1660
1986
|
const _catchall = def.catchall._zod;
|
|
1661
1987
|
const t = _catchall.def.type;
|
|
1662
|
-
const
|
|
1663
|
-
const
|
|
1988
|
+
const optin = _catchall.optin;
|
|
1989
|
+
const optout = _catchall.optout;
|
|
1990
|
+
let seen = 0;
|
|
1664
1991
|
for (const key in input) {
|
|
1665
|
-
if (
|
|
1666
|
-
|
|
1992
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1993
|
+
if (aborted(payload, seen))
|
|
1994
|
+
break;
|
|
1995
|
+
seen = payload.issues.length;
|
|
1996
|
+
}
|
|
1667
1997
|
if (keySet.has(key))
|
|
1668
1998
|
continue;
|
|
1999
|
+
if (key === "__proto__") {
|
|
2000
|
+
if (t === "never")
|
|
2001
|
+
unrecognized.push(key);
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
1669
2004
|
if (t === "never") {
|
|
1670
2005
|
unrecognized.push(key);
|
|
1671
2006
|
continue;
|
|
1672
2007
|
}
|
|
1673
2008
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1674
2009
|
if (r instanceof Promise) {
|
|
1675
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input,
|
|
2010
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, optin, optout)));
|
|
1676
2011
|
} else {
|
|
1677
|
-
handlePropertyResult(r, payload, key, input,
|
|
2012
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1678
2013
|
}
|
|
1679
2014
|
}
|
|
1680
2015
|
if (unrecognized.length) {
|
|
@@ -1682,7 +2017,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1682
2017
|
code: "unrecognized_keys",
|
|
1683
2018
|
keys: unrecognized,
|
|
1684
2019
|
input,
|
|
1685
|
-
inst
|
|
2020
|
+
inst,
|
|
2021
|
+
// Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
|
|
2022
|
+
continue: true
|
|
1686
2023
|
});
|
|
1687
2024
|
}
|
|
1688
2025
|
if (!proms.length)
|
|
@@ -1694,28 +2031,31 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1694
2031
|
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1695
2032
|
$ZodType.init(inst, def);
|
|
1696
2033
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
});
|
|
2034
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
2035
|
+
if (sh) {
|
|
2036
|
+
const get = () => {
|
|
2037
|
+
const newSh = { ...sh };
|
|
2038
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
2039
|
+
get.raw = newSh;
|
|
2040
|
+
return newSh;
|
|
2041
|
+
};
|
|
2042
|
+
get.raw = sh;
|
|
2043
|
+
Object.defineProperty(def, "shape", { get });
|
|
1708
2044
|
}
|
|
1709
2045
|
const _normalized = cached(() => normalizeDef(def));
|
|
1710
|
-
|
|
1711
|
-
const shape = def.shape;
|
|
2046
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
2047
|
+
const shape = zod.def.shape;
|
|
1712
2048
|
const propValues = {};
|
|
1713
2049
|
for (const key in shape) {
|
|
1714
2050
|
const field = shape[key]._zod;
|
|
1715
2051
|
if (field.values) {
|
|
1716
|
-
|
|
2052
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
2053
|
+
assignProp(propValues, key, /* @__PURE__ */ new Set());
|
|
2054
|
+
}
|
|
1717
2055
|
for (const v of field.values)
|
|
1718
2056
|
propValues[key].add(v);
|
|
2057
|
+
if (field.optin !== void 0)
|
|
2058
|
+
propValues[key].add(void 0);
|
|
1719
2059
|
}
|
|
1720
2060
|
}
|
|
1721
2061
|
return propValues;
|
|
@@ -1723,6 +2063,8 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
1723
2063
|
const isObject$1 = isObject;
|
|
1724
2064
|
const catchall = def.catchall;
|
|
1725
2065
|
let value;
|
|
2066
|
+
const memo2 = globalConfig.memoizer;
|
|
2067
|
+
memo2?.attach(inst);
|
|
1726
2068
|
inst._zod.parse = (payload, ctx) => {
|
|
1727
2069
|
value ?? (value = _normalized.value);
|
|
1728
2070
|
const input = payload.value;
|
|
@@ -1735,79 +2077,93 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
1735
2077
|
});
|
|
1736
2078
|
return payload;
|
|
1737
2079
|
}
|
|
1738
|
-
payload.value = {};
|
|
2080
|
+
payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
|
|
1739
2081
|
const proms = [];
|
|
1740
2082
|
const shape = value.shape;
|
|
1741
|
-
|
|
2083
|
+
const abortEarly = ctx?.abortEarly;
|
|
2084
|
+
let seen = payload.issues.length;
|
|
2085
|
+
for (const key of value.allKeys) {
|
|
2086
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2087
|
+
if (aborted(payload, seen))
|
|
2088
|
+
break;
|
|
2089
|
+
seen = payload.issues.length;
|
|
2090
|
+
}
|
|
2091
|
+
if (key === "__proto__")
|
|
2092
|
+
continue;
|
|
1742
2093
|
const el = shape[key];
|
|
1743
|
-
const
|
|
1744
|
-
const
|
|
2094
|
+
const optin = el._zod.optin;
|
|
2095
|
+
const optout = el._zod.optout;
|
|
1745
2096
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1746
2097
|
if (r instanceof Promise) {
|
|
1747
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input,
|
|
2098
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, optin, optout)));
|
|
1748
2099
|
} else {
|
|
1749
|
-
handlePropertyResult(r, payload, key, input,
|
|
2100
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1750
2101
|
}
|
|
1751
2102
|
}
|
|
1752
2103
|
if (!catchall) {
|
|
1753
2104
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1754
2105
|
}
|
|
1755
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2106
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1756
2107
|
};
|
|
1757
2108
|
});
|
|
1758
2109
|
const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1759
2110
|
$ZodObject.init(inst, def);
|
|
1760
2111
|
const superParse = inst._zod.parse;
|
|
1761
2112
|
const _normalized = cached(() => normalizeDef(def));
|
|
2113
|
+
const memo2 = globalConfig.memoizer;
|
|
1762
2114
|
const generateFastpass = (shape) => {
|
|
1763
|
-
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
1764
2115
|
const normalized = _normalized.value;
|
|
1765
|
-
const
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2116
|
+
const syms = normalized.symbolKeys;
|
|
2117
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo: memo2, syms });
|
|
2118
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2119
|
+
const prefixStr = (id, k) => `
|
|
2120
|
+
let ${id}_ab = false;
|
|
2121
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2122
|
+
const iss = ${id}.issues[i];
|
|
2123
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2124
|
+
payload.issues.push(iss);
|
|
2125
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2126
|
+
}
|
|
2127
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2128
|
+
payload.value = newResult;
|
|
2129
|
+
return payload;
|
|
2130
|
+
}`;
|
|
1769
2131
|
doc.write(`const input = payload.value;`);
|
|
1770
2132
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
1771
2133
|
let counter = 0;
|
|
1772
|
-
for (const key of normalized.
|
|
2134
|
+
for (const key of normalized.allKeys) {
|
|
1773
2135
|
ids[key] = `key_${counter++}`;
|
|
1774
2136
|
}
|
|
1775
|
-
doc.write(`const newResult = {};`);
|
|
1776
|
-
for (const key of normalized.
|
|
2137
|
+
doc.write(memo2 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2138
|
+
for (const key of normalized.allKeys) {
|
|
2139
|
+
if (key === "__proto__")
|
|
2140
|
+
continue;
|
|
1777
2141
|
const id = ids[key];
|
|
1778
|
-
const k = esc(key);
|
|
2142
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
2143
|
+
const isPresent = `${k} in input`;
|
|
1779
2144
|
const schema = shape[key];
|
|
1780
|
-
const
|
|
2145
|
+
const optin = schema?._zod?.optin;
|
|
2146
|
+
const isOptionalIn = optin !== void 0;
|
|
1781
2147
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1782
|
-
doc.write(`const ${id} = ${parseStr(
|
|
2148
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
1783
2149
|
if (isOptionalIn && isOptionalOut) {
|
|
2150
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
1784
2151
|
doc.write(`
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
...iss,
|
|
1789
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1790
|
-
})));
|
|
2152
|
+
const ${id}_present = ${isPresent};
|
|
2153
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2154
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1791
2155
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
if (${k} in input) {
|
|
1796
|
-
newResult[${k}] = undefined;
|
|
2156
|
+
|
|
2157
|
+
if (${assign}) {
|
|
2158
|
+
newResult[${k}] = ${id}.value;
|
|
1797
2159
|
}
|
|
1798
|
-
} else {
|
|
1799
|
-
newResult[${k}] = ${id}.value;
|
|
1800
2160
|
}
|
|
1801
|
-
|
|
2161
|
+
|
|
1802
2162
|
`);
|
|
1803
2163
|
} else if (!isOptionalIn) {
|
|
1804
2164
|
doc.write(`
|
|
1805
|
-
const ${id}_present = ${
|
|
1806
|
-
if (${id}.issues.length) {
|
|
1807
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1808
|
-
...iss,
|
|
1809
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1810
|
-
})));
|
|
2165
|
+
const ${id}_present = ${isPresent};
|
|
2166
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1811
2167
|
}
|
|
1812
2168
|
if (!${id}_present && !${id}.issues.length) {
|
|
1813
2169
|
payload.issues.push({
|
|
@@ -1816,41 +2172,36 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1816
2172
|
input: undefined,
|
|
1817
2173
|
path: [${k}]
|
|
1818
2174
|
});
|
|
2175
|
+
if (ctx && ctx.abortEarly) {
|
|
2176
|
+
payload.value = newResult;
|
|
2177
|
+
return payload;
|
|
2178
|
+
}
|
|
1819
2179
|
}
|
|
1820
2180
|
|
|
1821
2181
|
if (${id}_present) {
|
|
1822
|
-
|
|
1823
|
-
newResult[${k}] = undefined;
|
|
1824
|
-
} else {
|
|
1825
|
-
newResult[${k}] = ${id}.value;
|
|
1826
|
-
}
|
|
2182
|
+
newResult[${k}] = ${id}.value;
|
|
1827
2183
|
}
|
|
1828
2184
|
|
|
1829
2185
|
`);
|
|
1830
2186
|
} else {
|
|
1831
2187
|
doc.write(`
|
|
1832
|
-
if (${id}.issues.length) {
|
|
1833
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1834
|
-
...iss,
|
|
1835
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1836
|
-
})));
|
|
2188
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1837
2189
|
}
|
|
1838
|
-
|
|
1839
|
-
if (
|
|
1840
|
-
|
|
1841
|
-
newResult[${k}] = undefined;
|
|
1842
|
-
}
|
|
2190
|
+
`);
|
|
2191
|
+
if (optin === "defaulted") {
|
|
2192
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
1843
2193
|
} else {
|
|
2194
|
+
doc.write(`
|
|
2195
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1844
2196
|
newResult[${k}] = ${id}.value;
|
|
1845
2197
|
}
|
|
1846
|
-
|
|
1847
2198
|
`);
|
|
2199
|
+
}
|
|
1848
2200
|
}
|
|
1849
2201
|
}
|
|
1850
2202
|
doc.write(`payload.value = newResult;`);
|
|
1851
2203
|
doc.write(`return payload;`);
|
|
1852
|
-
|
|
1853
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2204
|
+
return doc.compile();
|
|
1854
2205
|
};
|
|
1855
2206
|
let fastpass;
|
|
1856
2207
|
const isObject$1 = isObject;
|
|
@@ -1877,7 +2228,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
1877
2228
|
payload = fastpass(payload, ctx);
|
|
1878
2229
|
if (!catchall)
|
|
1879
2230
|
return payload;
|
|
1880
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2231
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
1881
2232
|
}
|
|
1882
2233
|
return superParse(payload, ctx);
|
|
1883
2234
|
};
|
|
@@ -1904,17 +2255,17 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
1904
2255
|
}
|
|
1905
2256
|
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1906
2257
|
$ZodType.init(inst, def);
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
if (def.options.every((o) => o._zod.values)) {
|
|
1911
|
-
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2258
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted") ? "defaulted" : zod.def.options.some((o) => o._zod.optin !== void 0) ? "optional" : void 0);
|
|
2259
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2260
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2261
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
2262
|
+
return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1912
2263
|
}
|
|
1913
2264
|
return void 0;
|
|
1914
2265
|
});
|
|
1915
|
-
|
|
1916
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1917
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2266
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2267
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2268
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
1918
2269
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1919
2270
|
}
|
|
1920
2271
|
return void 0;
|
|
@@ -1973,7 +2324,11 @@ function mergeValues(a, b) {
|
|
|
1973
2324
|
const bKeys = Object.keys(b);
|
|
1974
2325
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1975
2326
|
const newObj = { ...a, ...b };
|
|
2327
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
2328
|
+
delete newObj.__proto__;
|
|
1976
2329
|
for (const key of sharedKeys) {
|
|
2330
|
+
if (key === "__proto__")
|
|
2331
|
+
continue;
|
|
1977
2332
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1978
2333
|
if (!sharedValue.valid) {
|
|
1979
2334
|
return {
|
|
@@ -2009,37 +2364,49 @@ function mergeValues(a, b) {
|
|
|
2009
2364
|
function handleIntersectionResults(result, left, right) {
|
|
2010
2365
|
const unrecKeys = /* @__PURE__ */ new Map();
|
|
2011
2366
|
let unrecIssue;
|
|
2012
|
-
|
|
2013
|
-
|
|
2367
|
+
const keyIssues = /* @__PURE__ */ new Map();
|
|
2368
|
+
const collect = (iss, side) => {
|
|
2369
|
+
let keys;
|
|
2370
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2014
2371
|
unrecIssue ?? (unrecIssue = iss);
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2372
|
+
keys = iss.keys;
|
|
2373
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2374
|
+
const k = String(iss.path[0]);
|
|
2375
|
+
if (!keyIssues.has(k))
|
|
2376
|
+
keyIssues.set(k, iss);
|
|
2377
|
+
keys = [k];
|
|
2020
2378
|
} else {
|
|
2021
|
-
|
|
2379
|
+
return false;
|
|
2380
|
+
}
|
|
2381
|
+
for (const k of keys) {
|
|
2382
|
+
if (!unrecKeys.has(k))
|
|
2383
|
+
unrecKeys.set(k, {});
|
|
2384
|
+
unrecKeys.get(k)[side] = true;
|
|
2022
2385
|
}
|
|
2386
|
+
return true;
|
|
2387
|
+
};
|
|
2388
|
+
for (const iss of left.issues) {
|
|
2389
|
+
if (!collect(iss, "l"))
|
|
2390
|
+
result.issues.push(iss);
|
|
2023
2391
|
}
|
|
2024
2392
|
for (const iss of right.issues) {
|
|
2025
|
-
if (iss
|
|
2026
|
-
for (const k of iss.keys) {
|
|
2027
|
-
if (!unrecKeys.has(k))
|
|
2028
|
-
unrecKeys.set(k, {});
|
|
2029
|
-
unrecKeys.get(k).r = true;
|
|
2030
|
-
}
|
|
2031
|
-
} else {
|
|
2393
|
+
if (!collect(iss, "r"))
|
|
2032
2394
|
result.issues.push(iss);
|
|
2033
|
-
}
|
|
2034
2395
|
}
|
|
2035
2396
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2036
|
-
if (bothKeys.length
|
|
2037
|
-
|
|
2397
|
+
if (bothKeys.length) {
|
|
2398
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
2399
|
+
if (aggregated.length)
|
|
2400
|
+
result.issues.push({ ...unrecIssue, keys: aggregated });
|
|
2401
|
+
for (const k of bothKeys) {
|
|
2402
|
+
if (!aggregated.includes(k) && keyIssues.has(k))
|
|
2403
|
+
result.issues.push(keyIssues.get(k));
|
|
2404
|
+
}
|
|
2038
2405
|
}
|
|
2039
|
-
if (aborted(result))
|
|
2040
|
-
return result;
|
|
2041
2406
|
const merged = mergeValues(left.value, right.value);
|
|
2042
2407
|
if (!merged.valid) {
|
|
2408
|
+
if (aborted(result))
|
|
2409
|
+
return result;
|
|
2043
2410
|
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2044
2411
|
}
|
|
2045
2412
|
result.value = merged.data;
|
|
@@ -2050,7 +2417,10 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2050
2417
|
const values = getEnumValues(def.entries);
|
|
2051
2418
|
const valuesSet = new Set(values);
|
|
2052
2419
|
inst._zod.values = valuesSet;
|
|
2053
|
-
inst
|
|
2420
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2421
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2422
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2423
|
+
});
|
|
2054
2424
|
inst._zod.parse = (payload, _ctx) => {
|
|
2055
2425
|
const input = payload.value;
|
|
2056
2426
|
if (valuesSet.has(input)) {
|
|
@@ -2068,6 +2438,7 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2068
2438
|
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
2069
2439
|
$ZodType.init(inst, def);
|
|
2070
2440
|
inst._zod.optin = "optional";
|
|
2441
|
+
globalConfig.memoizer?.guard(inst);
|
|
2071
2442
|
inst._zod.parse = (payload, ctx) => {
|
|
2072
2443
|
if (ctx.direction === "backward") {
|
|
2073
2444
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -2077,7 +2448,6 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
|
|
|
2077
2448
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
2078
2449
|
return output.then((output2) => {
|
|
2079
2450
|
payload.value = output2;
|
|
2080
|
-
payload.fallback = true;
|
|
2081
2451
|
return payload;
|
|
2082
2452
|
});
|
|
2083
2453
|
}
|
|
@@ -2085,59 +2455,55 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
|
|
|
2085
2455
|
throw new $ZodAsyncError();
|
|
2086
2456
|
}
|
|
2087
2457
|
payload.value = _out;
|
|
2088
|
-
payload.fallback = true;
|
|
2089
2458
|
return payload;
|
|
2090
2459
|
};
|
|
2091
2460
|
});
|
|
2092
|
-
function handleOptionalResult(
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
}
|
|
2096
|
-
return result;
|
|
2461
|
+
function handleOptionalResult(payload, result) {
|
|
2462
|
+
payload.value = result.issues.length ? void 0 : result.value;
|
|
2463
|
+
return payload;
|
|
2097
2464
|
}
|
|
2098
2465
|
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
2099
2466
|
$ZodType.init(inst, def);
|
|
2100
|
-
inst._zod.optin
|
|
2467
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2101
2468
|
inst._zod.optout = "optional";
|
|
2102
|
-
|
|
2103
|
-
|
|
2469
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2470
|
+
const values = zod.def.innerType._zod.values;
|
|
2471
|
+
return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
|
|
2104
2472
|
});
|
|
2105
|
-
|
|
2106
|
-
const pattern = def.innerType._zod.pattern;
|
|
2473
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2474
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2107
2475
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2108
2476
|
});
|
|
2109
2477
|
inst._zod.parse = (payload, ctx) => {
|
|
2110
|
-
if (def.innerType._zod.optin === "optional") {
|
|
2111
|
-
const input = payload.value;
|
|
2112
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2113
|
-
if (result instanceof Promise)
|
|
2114
|
-
return result.then((r) => handleOptionalResult(r, input));
|
|
2115
|
-
return handleOptionalResult(result, input);
|
|
2116
|
-
}
|
|
2117
2478
|
if (payload.value === void 0) {
|
|
2118
|
-
|
|
2479
|
+
if (def.innerType._zod.optin !== "defaulted")
|
|
2480
|
+
return payload;
|
|
2481
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2482
|
+
if (result instanceof Promise)
|
|
2483
|
+
return result.then((result2) => handleOptionalResult(payload, result2));
|
|
2484
|
+
return handleOptionalResult(payload, result);
|
|
2119
2485
|
}
|
|
2120
2486
|
return def.innerType._zod.run(payload, ctx);
|
|
2121
2487
|
};
|
|
2122
2488
|
});
|
|
2123
2489
|
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
2124
2490
|
$ZodOptional.init(inst, def);
|
|
2125
|
-
|
|
2126
|
-
|
|
2491
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2492
|
+
defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2127
2493
|
inst._zod.parse = (payload, ctx) => {
|
|
2128
2494
|
return def.innerType._zod.run(payload, ctx);
|
|
2129
2495
|
};
|
|
2130
2496
|
});
|
|
2131
2497
|
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
2132
2498
|
$ZodType.init(inst, def);
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
const pattern = def.innerType._zod.pattern;
|
|
2499
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2500
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2501
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2502
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2137
2503
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2138
2504
|
});
|
|
2139
|
-
|
|
2140
|
-
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2505
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2506
|
+
return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
|
|
2141
2507
|
});
|
|
2142
2508
|
inst._zod.parse = (payload, ctx) => {
|
|
2143
2509
|
if (payload.value === null)
|
|
@@ -2147,8 +2513,8 @@ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) =>
|
|
|
2147
2513
|
});
|
|
2148
2514
|
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
2149
2515
|
$ZodType.init(inst, def);
|
|
2150
|
-
inst._zod.optin = "
|
|
2151
|
-
|
|
2516
|
+
inst._zod.optin = "defaulted";
|
|
2517
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2152
2518
|
inst._zod.parse = (payload, ctx) => {
|
|
2153
2519
|
if (ctx.direction === "backward") {
|
|
2154
2520
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2172,8 +2538,8 @@ function handleDefaultResult(payload, def) {
|
|
|
2172
2538
|
}
|
|
2173
2539
|
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
2174
2540
|
$ZodType.init(inst, def);
|
|
2175
|
-
inst._zod.optin = "
|
|
2176
|
-
|
|
2541
|
+
inst._zod.optin = "defaulted";
|
|
2542
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2177
2543
|
inst._zod.parse = (payload, ctx) => {
|
|
2178
2544
|
if (ctx.direction === "backward") {
|
|
2179
2545
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2186,8 +2552,8 @@ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) =>
|
|
|
2186
2552
|
});
|
|
2187
2553
|
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2188
2554
|
$ZodType.init(inst, def);
|
|
2189
|
-
|
|
2190
|
-
const v = def.innerType._zod.values;
|
|
2555
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2556
|
+
const v = zod.def.innerType._zod.values;
|
|
2191
2557
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2192
2558
|
});
|
|
2193
2559
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2209,54 +2575,45 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2209
2575
|
}
|
|
2210
2576
|
return payload;
|
|
2211
2577
|
}
|
|
2578
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2579
|
+
if (!result.issues.length) {
|
|
2580
|
+
payload.value = result.value;
|
|
2581
|
+
if (result.memo)
|
|
2582
|
+
payload.memo = true;
|
|
2583
|
+
return payload;
|
|
2584
|
+
}
|
|
2585
|
+
payload.value = def.catchValue({
|
|
2586
|
+
...result,
|
|
2587
|
+
value: payload.value,
|
|
2588
|
+
error: {
|
|
2589
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2590
|
+
},
|
|
2591
|
+
input: payload.value
|
|
2592
|
+
});
|
|
2593
|
+
return payload;
|
|
2594
|
+
}
|
|
2212
2595
|
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
2213
2596
|
$ZodType.init(inst, def);
|
|
2214
|
-
inst._zod.optin
|
|
2215
|
-
|
|
2216
|
-
|
|
2597
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2598
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2599
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2217
2600
|
inst._zod.parse = (payload, ctx) => {
|
|
2218
2601
|
if (ctx.direction === "backward") {
|
|
2219
2602
|
return def.innerType._zod.run(payload, ctx);
|
|
2220
2603
|
}
|
|
2221
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2604
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
2222
2605
|
if (result instanceof Promise) {
|
|
2223
|
-
return result.then((result2) =>
|
|
2224
|
-
payload.value = result2.value;
|
|
2225
|
-
if (result2.issues.length) {
|
|
2226
|
-
payload.value = def.catchValue({
|
|
2227
|
-
...payload,
|
|
2228
|
-
error: {
|
|
2229
|
-
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2230
|
-
},
|
|
2231
|
-
input: payload.value
|
|
2232
|
-
});
|
|
2233
|
-
payload.issues = [];
|
|
2234
|
-
payload.fallback = true;
|
|
2235
|
-
}
|
|
2236
|
-
return payload;
|
|
2237
|
-
});
|
|
2238
|
-
}
|
|
2239
|
-
payload.value = result.value;
|
|
2240
|
-
if (result.issues.length) {
|
|
2241
|
-
payload.value = def.catchValue({
|
|
2242
|
-
...payload,
|
|
2243
|
-
error: {
|
|
2244
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2245
|
-
},
|
|
2246
|
-
input: payload.value
|
|
2247
|
-
});
|
|
2248
|
-
payload.issues = [];
|
|
2249
|
-
payload.fallback = true;
|
|
2606
|
+
return result.then((result2) => handleCatchResult(payload, result2, def, ctx));
|
|
2250
2607
|
}
|
|
2251
|
-
return payload;
|
|
2608
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
2252
2609
|
};
|
|
2253
2610
|
});
|
|
2254
2611
|
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
2255
2612
|
$ZodType.init(inst, def);
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2613
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2614
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2615
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2616
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2260
2617
|
inst._zod.parse = (payload, ctx) => {
|
|
2261
2618
|
if (ctx.direction === "backward") {
|
|
2262
2619
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -2273,18 +2630,18 @@ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
|
2273
2630
|
};
|
|
2274
2631
|
});
|
|
2275
2632
|
function handlePipeResult(left, next, ctx) {
|
|
2276
|
-
if (left.issues.
|
|
2633
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2277
2634
|
left.aborted = true;
|
|
2278
2635
|
return left;
|
|
2279
2636
|
}
|
|
2280
|
-
return next._zod.run({ value: left.value, issues: left.issues
|
|
2637
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
2281
2638
|
}
|
|
2282
2639
|
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2283
2640
|
$ZodType.init(inst, def);
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2641
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2642
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2643
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2644
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2288
2645
|
inst._zod.parse = (payload, ctx) => {
|
|
2289
2646
|
if (ctx.direction === "backward") {
|
|
2290
2647
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2297,7 +2654,8 @@ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) =>
|
|
|
2297
2654
|
};
|
|
2298
2655
|
});
|
|
2299
2656
|
function handleReadonlyResult(payload) {
|
|
2300
|
-
|
|
2657
|
+
if (!payload.memo)
|
|
2658
|
+
payload.value = Object.freeze(payload.value);
|
|
2301
2659
|
return payload;
|
|
2302
2660
|
}
|
|
2303
2661
|
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -2333,6 +2691,400 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
2333
2691
|
payload.issues.push(issue(_iss));
|
|
2334
2692
|
}
|
|
2335
2693
|
}
|
|
2694
|
+
class $ZodCyclicError extends Error {
|
|
2695
|
+
constructor() {
|
|
2696
|
+
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
2697
|
+
this.name = "ZodCyclicError";
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
const STATE = "~memo";
|
|
2701
|
+
const NO_ISSUES = [];
|
|
2702
|
+
function isRef(value) {
|
|
2703
|
+
return value !== null && typeof value === "object";
|
|
2704
|
+
}
|
|
2705
|
+
function cloneIssues(issues) {
|
|
2706
|
+
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
2707
|
+
}
|
|
2708
|
+
const recursive = /* @__PURE__ */ new WeakMap();
|
|
2709
|
+
const NONE = 0;
|
|
2710
|
+
const ASSUMED = 1;
|
|
2711
|
+
const PROVEN = 2;
|
|
2712
|
+
function isRecursive(inst, stack, resolve) {
|
|
2713
|
+
const cached2 = recursive.get(inst);
|
|
2714
|
+
if (cached2 !== void 0)
|
|
2715
|
+
return cached2 ? PROVEN : NONE;
|
|
2716
|
+
if (stack.has(inst))
|
|
2717
|
+
return PROVEN;
|
|
2718
|
+
stack.add(inst);
|
|
2719
|
+
let result = NONE;
|
|
2720
|
+
const check = (child) => {
|
|
2721
|
+
if (result !== PROVEN && child?._zod) {
|
|
2722
|
+
const answer = isRecursive(child, stack);
|
|
2723
|
+
if (answer > result)
|
|
2724
|
+
result = answer;
|
|
2725
|
+
}
|
|
2726
|
+
};
|
|
2727
|
+
const shape = (sh, spread) => {
|
|
2728
|
+
let answer = NONE;
|
|
2729
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
2730
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
2731
|
+
if (!desc.enumerable)
|
|
2732
|
+
continue;
|
|
2733
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack) : NONE;
|
|
2734
|
+
if (child > answer)
|
|
2735
|
+
answer = child;
|
|
2736
|
+
}
|
|
2737
|
+
return answer;
|
|
2738
|
+
};
|
|
2739
|
+
const merge2 = (answer) => {
|
|
2740
|
+
if (answer > result)
|
|
2741
|
+
result = answer;
|
|
2742
|
+
};
|
|
2743
|
+
const def = inst._zod.def;
|
|
2744
|
+
const kind = def.type;
|
|
2745
|
+
switch (kind) {
|
|
2746
|
+
case "object": {
|
|
2747
|
+
const raw = rawShape(def);
|
|
2748
|
+
merge2(raw ? shape(raw) : ASSUMED);
|
|
2749
|
+
check(def.catchall);
|
|
2750
|
+
break;
|
|
2751
|
+
}
|
|
2752
|
+
case "array":
|
|
2753
|
+
check(def.element);
|
|
2754
|
+
break;
|
|
2755
|
+
case "tuple":
|
|
2756
|
+
for (const el of def.items)
|
|
2757
|
+
check(el);
|
|
2758
|
+
check(def.rest);
|
|
2759
|
+
break;
|
|
2760
|
+
case "record":
|
|
2761
|
+
case "map":
|
|
2762
|
+
check(def.keyType);
|
|
2763
|
+
check(def.valueType);
|
|
2764
|
+
break;
|
|
2765
|
+
case "set":
|
|
2766
|
+
check(def.valueType);
|
|
2767
|
+
break;
|
|
2768
|
+
case "union":
|
|
2769
|
+
for (const el of def.options)
|
|
2770
|
+
check(el);
|
|
2771
|
+
break;
|
|
2772
|
+
case "intersection":
|
|
2773
|
+
check(def.left);
|
|
2774
|
+
check(def.right);
|
|
2775
|
+
break;
|
|
2776
|
+
case "optional":
|
|
2777
|
+
case "nullable":
|
|
2778
|
+
case "default":
|
|
2779
|
+
case "prefault":
|
|
2780
|
+
case "catch":
|
|
2781
|
+
case "readonly":
|
|
2782
|
+
case "nonoptional":
|
|
2783
|
+
case "promise":
|
|
2784
|
+
case "success":
|
|
2785
|
+
check(def.innerType);
|
|
2786
|
+
break;
|
|
2787
|
+
case "pipe":
|
|
2788
|
+
check(def.in);
|
|
2789
|
+
check(def.out);
|
|
2790
|
+
break;
|
|
2791
|
+
case "function":
|
|
2792
|
+
check(def.input);
|
|
2793
|
+
check(def.output);
|
|
2794
|
+
break;
|
|
2795
|
+
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
2796
|
+
case "lazy": {
|
|
2797
|
+
const inner = def._cachedInner ?? void 0;
|
|
2798
|
+
merge2(inner ? isRecursive(inner, stack) : ASSUMED);
|
|
2799
|
+
break;
|
|
2800
|
+
}
|
|
2801
|
+
// a leaf by choice: `parts` are regex fragments, not data positions
|
|
2802
|
+
case "template_literal":
|
|
2803
|
+
// leaves
|
|
2804
|
+
case "string":
|
|
2805
|
+
case "number":
|
|
2806
|
+
case "int":
|
|
2807
|
+
case "boolean":
|
|
2808
|
+
case "bigint":
|
|
2809
|
+
case "symbol":
|
|
2810
|
+
case "undefined":
|
|
2811
|
+
case "null":
|
|
2812
|
+
case "void":
|
|
2813
|
+
case "never":
|
|
2814
|
+
case "any":
|
|
2815
|
+
case "unknown":
|
|
2816
|
+
case "date":
|
|
2817
|
+
case "nan":
|
|
2818
|
+
case "enum":
|
|
2819
|
+
case "literal":
|
|
2820
|
+
case "file":
|
|
2821
|
+
case "transform":
|
|
2822
|
+
case "custom":
|
|
2823
|
+
break;
|
|
2824
|
+
default: {
|
|
2825
|
+
for (const key in def) {
|
|
2826
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
2827
|
+
if (!desc || desc.get)
|
|
2828
|
+
continue;
|
|
2829
|
+
const value = desc.value;
|
|
2830
|
+
if (!value || typeof value !== "object")
|
|
2831
|
+
continue;
|
|
2832
|
+
if (value._zod)
|
|
2833
|
+
check(value);
|
|
2834
|
+
else if (Array.isArray(value))
|
|
2835
|
+
for (const el of value)
|
|
2836
|
+
check(el);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
stack.delete(inst);
|
|
2841
|
+
return settle(inst, result);
|
|
2842
|
+
}
|
|
2843
|
+
function settle(inst, answer) {
|
|
2844
|
+
if (answer !== ASSUMED)
|
|
2845
|
+
recursive.set(inst, answer === PROVEN);
|
|
2846
|
+
return answer;
|
|
2847
|
+
}
|
|
2848
|
+
function bucketFor(state, inst) {
|
|
2849
|
+
let bucket = state.buckets.get(inst);
|
|
2850
|
+
if (!bucket) {
|
|
2851
|
+
bucket = /* @__PURE__ */ new WeakMap();
|
|
2852
|
+
state.buckets.set(inst, bucket);
|
|
2853
|
+
}
|
|
2854
|
+
return bucket;
|
|
2855
|
+
}
|
|
2856
|
+
let handoff;
|
|
2857
|
+
const open = [];
|
|
2858
|
+
const memo = {
|
|
2859
|
+
alloc(_inst, payload, empty) {
|
|
2860
|
+
const bucket = handoff;
|
|
2861
|
+
if (!bucket)
|
|
2862
|
+
return empty;
|
|
2863
|
+
handoff = void 0;
|
|
2864
|
+
const entry = { value: empty, issues: null };
|
|
2865
|
+
bucket.set(payload.value, entry);
|
|
2866
|
+
open.push(entry);
|
|
2867
|
+
return empty;
|
|
2868
|
+
},
|
|
2869
|
+
guard(inst) {
|
|
2870
|
+
var _a2;
|
|
2871
|
+
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
2872
|
+
inst._zod.deferred.push(() => {
|
|
2873
|
+
const base = inst._zod.parse;
|
|
2874
|
+
const wrapped = (payload, ctx) => {
|
|
2875
|
+
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value))
|
|
2876
|
+
throw new $ZodCyclicError();
|
|
2877
|
+
return base(payload, ctx);
|
|
2878
|
+
};
|
|
2879
|
+
inst._zod.parse = wrapped;
|
|
2880
|
+
if (inst._zod.run === base)
|
|
2881
|
+
inst._zod.run = wrapped;
|
|
2882
|
+
});
|
|
2883
|
+
},
|
|
2884
|
+
attach(inst) {
|
|
2885
|
+
var _a2;
|
|
2886
|
+
let isRecursiveInst;
|
|
2887
|
+
let rechecked = false;
|
|
2888
|
+
let lastCtx;
|
|
2889
|
+
let lastBucket;
|
|
2890
|
+
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
2891
|
+
inst._zod.deferred.push(() => {
|
|
2892
|
+
const base = inst._zod.parse;
|
|
2893
|
+
const wrapped = (payload, ctx) => {
|
|
2894
|
+
if (isRecursiveInst === void 0) {
|
|
2895
|
+
const walked = isRecursive(inst, /* @__PURE__ */ new Set());
|
|
2896
|
+
if (walked === NONE) {
|
|
2897
|
+
inst._zod.parse = base;
|
|
2898
|
+
if (inst._zod.run === wrapped)
|
|
2899
|
+
inst._zod.run = base;
|
|
2900
|
+
return base(payload, ctx);
|
|
2901
|
+
}
|
|
2902
|
+
if (walked === PROVEN || rechecked)
|
|
2903
|
+
isRecursiveInst = true;
|
|
2904
|
+
else
|
|
2905
|
+
rechecked = true;
|
|
2906
|
+
}
|
|
2907
|
+
const input = payload.value;
|
|
2908
|
+
if (!isRef(input))
|
|
2909
|
+
return base(payload, ctx);
|
|
2910
|
+
let state = ctx[STATE];
|
|
2911
|
+
if (!state) {
|
|
2912
|
+
state = { buckets: /* @__PURE__ */ new WeakMap(), backEdges: void 0 };
|
|
2913
|
+
ctx[STATE] = state;
|
|
2914
|
+
}
|
|
2915
|
+
let bucket;
|
|
2916
|
+
if (lastCtx === ctx) {
|
|
2917
|
+
bucket = lastBucket;
|
|
2918
|
+
} else {
|
|
2919
|
+
bucket = bucketFor(state, inst);
|
|
2920
|
+
lastCtx = ctx;
|
|
2921
|
+
lastBucket = bucket;
|
|
2922
|
+
}
|
|
2923
|
+
const hit = bucket.get(input);
|
|
2924
|
+
if (hit) {
|
|
2925
|
+
payload.value = hit.value;
|
|
2926
|
+
if (hit.issues) {
|
|
2927
|
+
if (hit.issues.length)
|
|
2928
|
+
payload.issues.push(...cloneIssues(hit.issues));
|
|
2929
|
+
} else {
|
|
2930
|
+
payload.memo = true;
|
|
2931
|
+
state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
|
|
2932
|
+
state.backEdges.add(hit.value);
|
|
2933
|
+
}
|
|
2934
|
+
return payload;
|
|
2935
|
+
}
|
|
2936
|
+
handoff = bucket;
|
|
2937
|
+
const depth = open.length;
|
|
2938
|
+
const result = base(payload, ctx);
|
|
2939
|
+
handoff = void 0;
|
|
2940
|
+
const entry = open.length > depth ? open.pop() : void 0;
|
|
2941
|
+
if (result instanceof Promise) {
|
|
2942
|
+
return result.then((r) => {
|
|
2943
|
+
if (entry)
|
|
2944
|
+
entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
2945
|
+
return r;
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
if (entry)
|
|
2949
|
+
entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
2950
|
+
return result;
|
|
2951
|
+
};
|
|
2952
|
+
inst._zod.parse = wrapped;
|
|
2953
|
+
if (inst._zod.run === base)
|
|
2954
|
+
inst._zod.run = wrapped;
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
function memoizer() {
|
|
2959
|
+
return memo;
|
|
2960
|
+
}
|
|
2961
|
+
function isBackEdge(ctx, value) {
|
|
2962
|
+
const backEdges = ctx[STATE]?.backEdges;
|
|
2963
|
+
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
2964
|
+
}
|
|
2965
|
+
const error = () => {
|
|
2966
|
+
const Sizable = {
|
|
2967
|
+
string: { unit: "characters", verb: "to have" },
|
|
2968
|
+
file: { unit: "bytes", verb: "to have" },
|
|
2969
|
+
array: { unit: "items", verb: "to have" },
|
|
2970
|
+
set: { unit: "items", verb: "to have" },
|
|
2971
|
+
map: { unit: "entries", verb: "to have" }
|
|
2972
|
+
};
|
|
2973
|
+
function getSizing(origin) {
|
|
2974
|
+
return Sizable[origin] ?? null;
|
|
2975
|
+
}
|
|
2976
|
+
const FormatDictionary = {
|
|
2977
|
+
regex: "input",
|
|
2978
|
+
email: "email address",
|
|
2979
|
+
url: "URL",
|
|
2980
|
+
emoji: "emoji",
|
|
2981
|
+
uuid: "UUID",
|
|
2982
|
+
uuidv4: "UUIDv4",
|
|
2983
|
+
uuidv6: "UUIDv6",
|
|
2984
|
+
nanoid: "nanoid",
|
|
2985
|
+
guid: "GUID",
|
|
2986
|
+
cuid: "cuid",
|
|
2987
|
+
cuid2: "cuid2",
|
|
2988
|
+
ulid: "ULID",
|
|
2989
|
+
xid: "XID",
|
|
2990
|
+
ksuid: "KSUID",
|
|
2991
|
+
datetime: "ISO datetime",
|
|
2992
|
+
date: "ISO date",
|
|
2993
|
+
time: "ISO time",
|
|
2994
|
+
duration: "ISO duration",
|
|
2995
|
+
ipv4: "IPv4 address",
|
|
2996
|
+
ipv6: "IPv6 address",
|
|
2997
|
+
mac: "MAC address",
|
|
2998
|
+
cidrv4: "IPv4 range",
|
|
2999
|
+
cidrv6: "IPv6 range",
|
|
3000
|
+
base64: "base64-encoded string",
|
|
3001
|
+
base64url: "base64url-encoded string",
|
|
3002
|
+
json_string: "JSON string",
|
|
3003
|
+
e164: "E.164 number",
|
|
3004
|
+
currency_code: "currency code",
|
|
3005
|
+
credit_card: "credit card number",
|
|
3006
|
+
iban: "IBAN",
|
|
3007
|
+
jwt: "JWT",
|
|
3008
|
+
template_literal: "input"
|
|
3009
|
+
};
|
|
3010
|
+
const TypeDictionary = {
|
|
3011
|
+
// Compatibility: "nan" -> "NaN" for display
|
|
3012
|
+
nan: "NaN"
|
|
3013
|
+
// All other type names omitted - they fall back to raw values via ?? operator
|
|
3014
|
+
};
|
|
3015
|
+
function getTypeName(type, input) {
|
|
3016
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
|
|
3017
|
+
return String(input);
|
|
3018
|
+
}
|
|
3019
|
+
return TypeDictionary[type] ?? type;
|
|
3020
|
+
}
|
|
3021
|
+
return (issue2) => {
|
|
3022
|
+
switch (issue2.code) {
|
|
3023
|
+
case "invalid_type": {
|
|
3024
|
+
const expected = getTypeName(issue2.expected);
|
|
3025
|
+
const receivedType = parsedType(issue2.input);
|
|
3026
|
+
const received = getTypeName(receivedType, issue2.input);
|
|
3027
|
+
return `Invalid input: expected ${expected}, received ${received}`;
|
|
3028
|
+
}
|
|
3029
|
+
case "invalid_value":
|
|
3030
|
+
if (issue2.values.length === 1)
|
|
3031
|
+
return `Invalid input: expected ${stringifyPrimitive(issue2.values[0])}`;
|
|
3032
|
+
return `Invalid option: expected one of ${joinValues(issue2.values, "|")}`;
|
|
3033
|
+
case "too_big": {
|
|
3034
|
+
const adj = issue2.exact ? "exactly " : issue2.inclusive ? "<=" : "<";
|
|
3035
|
+
const sizing = getSizing(issue2.origin);
|
|
3036
|
+
if (sizing)
|
|
3037
|
+
return `Too big: expected ${issue2.origin ?? "value"} to have ${adj}${issue2.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
3038
|
+
return `Too big: expected ${issue2.origin ?? "value"} to be ${adj}${issue2.maximum.toString()}`;
|
|
3039
|
+
}
|
|
3040
|
+
case "too_small": {
|
|
3041
|
+
const adj = issue2.exact ? "exactly " : issue2.inclusive ? ">=" : ">";
|
|
3042
|
+
const sizing = getSizing(issue2.origin);
|
|
3043
|
+
if (sizing) {
|
|
3044
|
+
return `Too small: expected ${issue2.origin} to have ${adj}${issue2.minimum.toString()} ${sizing.unit}`;
|
|
3045
|
+
}
|
|
3046
|
+
return `Too small: expected ${issue2.origin} to be ${adj}${issue2.minimum.toString()}`;
|
|
3047
|
+
}
|
|
3048
|
+
case "invalid_format": {
|
|
3049
|
+
const _issue = issue2;
|
|
3050
|
+
if (_issue.format === "starts_with") {
|
|
3051
|
+
return `Invalid string: must start with "${_issue.prefix}"`;
|
|
3052
|
+
}
|
|
3053
|
+
if (_issue.format === "ends_with")
|
|
3054
|
+
return `Invalid string: must end with "${_issue.suffix}"`;
|
|
3055
|
+
if (_issue.format === "includes")
|
|
3056
|
+
return `Invalid string: must include "${_issue.includes}"`;
|
|
3057
|
+
if (_issue.format === "regex")
|
|
3058
|
+
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
3059
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
|
|
3060
|
+
}
|
|
3061
|
+
case "not_multiple_of":
|
|
3062
|
+
return `Invalid number: must be a multiple of ${issue2.divisor}`;
|
|
3063
|
+
case "unrecognized_keys":
|
|
3064
|
+
return `Unrecognized key${issue2.keys.length > 1 ? "s" : ""}: ${joinValues(issue2.keys, ", ")}`;
|
|
3065
|
+
case "invalid_key":
|
|
3066
|
+
return `Invalid key in ${issue2.origin}`;
|
|
3067
|
+
case "invalid_union":
|
|
3068
|
+
if (issue2.options && Array.isArray(issue2.options) && issue2.options.length > 0) {
|
|
3069
|
+
const opts = issue2.options.map((o) => `'${o}'`).join(" | ");
|
|
3070
|
+
return `Invalid discriminator value. Expected ${opts}`;
|
|
3071
|
+
}
|
|
3072
|
+
if (issue2.inclusive === false) {
|
|
3073
|
+
return "Invalid input: more than one option matched";
|
|
3074
|
+
}
|
|
3075
|
+
return "Invalid input";
|
|
3076
|
+
case "invalid_element":
|
|
3077
|
+
return `Invalid value in ${issue2.origin}`;
|
|
3078
|
+
default:
|
|
3079
|
+
return `Invalid input`;
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
};
|
|
3083
|
+
function en() {
|
|
3084
|
+
return {
|
|
3085
|
+
localeError: error()
|
|
3086
|
+
};
|
|
3087
|
+
}
|
|
2336
3088
|
var _a;
|
|
2337
3089
|
class $ZodRegistry {
|
|
2338
3090
|
constructor() {
|
|
@@ -2379,12 +3131,14 @@ function registry() {
|
|
|
2379
3131
|
}
|
|
2380
3132
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2381
3133
|
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
3134
|
+
function snapshotChecks(def) {
|
|
3135
|
+
if (def.checks)
|
|
3136
|
+
def.checks = [...def.checks];
|
|
3137
|
+
return def;
|
|
3138
|
+
}
|
|
2382
3139
|
// @__NO_SIDE_EFFECTS__
|
|
2383
3140
|
function _string(Class, params) {
|
|
2384
|
-
return new Class({
|
|
2385
|
-
type: "string",
|
|
2386
|
-
...normalizeParams(params)
|
|
2387
|
-
});
|
|
3141
|
+
return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
|
|
2388
3142
|
}
|
|
2389
3143
|
// @__NO_SIDE_EFFECTS__
|
|
2390
3144
|
function _email(Class, params) {
|
|
@@ -2651,11 +3405,7 @@ function _isoDuration(Class, params) {
|
|
|
2651
3405
|
}
|
|
2652
3406
|
// @__NO_SIDE_EFFECTS__
|
|
2653
3407
|
function _number(Class, params) {
|
|
2654
|
-
return new Class({
|
|
2655
|
-
type: "number",
|
|
2656
|
-
checks: [],
|
|
2657
|
-
...normalizeParams(params)
|
|
2658
|
-
});
|
|
3408
|
+
return new Class(snapshotChecks({ type: "number", checks: [], ...normalizeParams(params) }));
|
|
2659
3409
|
}
|
|
2660
3410
|
// @__NO_SIDE_EFFECTS__
|
|
2661
3411
|
function _int(Class, params) {
|
|
@@ -2867,7 +3617,8 @@ function _superRefine(fn, params) {
|
|
|
2867
3617
|
if (_issue.fatal)
|
|
2868
3618
|
_issue.continue = false;
|
|
2869
3619
|
_issue.code ?? (_issue.code = "custom");
|
|
2870
|
-
|
|
3620
|
+
if (!("input" in _issue))
|
|
3621
|
+
_issue.input = payload.value;
|
|
2871
3622
|
_issue.inst ?? (_issue.inst = ch);
|
|
2872
3623
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2873
3624
|
payload.issues.push(issue(_issue));
|
|
@@ -2886,6 +3637,16 @@ function _check(fn, params) {
|
|
|
2886
3637
|
ch._zod.check = fn;
|
|
2887
3638
|
return ch;
|
|
2888
3639
|
}
|
|
3640
|
+
function assignProps(target, ...sources) {
|
|
3641
|
+
for (const source of sources) {
|
|
3642
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
3643
|
+
if (Object.prototype.propertyIsEnumerable.call(source, key)) {
|
|
3644
|
+
assignProp(target, key, source[key]);
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
return target;
|
|
3649
|
+
}
|
|
2889
3650
|
function initializeContext(params) {
|
|
2890
3651
|
let target = params?.target ?? "draft-2020-12";
|
|
2891
3652
|
if (target === "draft-4")
|
|
@@ -2902,12 +3663,25 @@ function initializeContext(params) {
|
|
|
2902
3663
|
io: params?.io ?? "output",
|
|
2903
3664
|
counter: 0,
|
|
2904
3665
|
seen: /* @__PURE__ */ new Map(),
|
|
3666
|
+
sharedDefsExtractedFor: void 0,
|
|
3667
|
+
sharedEmitDoneFor: void 0,
|
|
2905
3668
|
cycles: params?.cycles ?? "ref",
|
|
2906
3669
|
reused: params?.reused ?? "inline",
|
|
3670
|
+
intersections: [],
|
|
3671
|
+
deferred: [],
|
|
2907
3672
|
external: params?.external ?? void 0
|
|
2908
3673
|
};
|
|
2909
3674
|
}
|
|
2910
|
-
function
|
|
3675
|
+
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
3676
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
3677
|
+
if (result === "any")
|
|
3678
|
+
return false;
|
|
3679
|
+
if (result === void 0 || result === "throw")
|
|
3680
|
+
throw new Error(message);
|
|
3681
|
+
Object.assign(json, result);
|
|
3682
|
+
return true;
|
|
3683
|
+
}
|
|
3684
|
+
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
2911
3685
|
var _a2;
|
|
2912
3686
|
const def = schema._zod.def;
|
|
2913
3687
|
const seen = ctx.seen.get(schema);
|
|
@@ -2921,6 +3695,8 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
2921
3695
|
}
|
|
2922
3696
|
const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
2923
3697
|
ctx.seen.set(schema, result);
|
|
3698
|
+
ctx.sharedDefsExtractedFor = void 0;
|
|
3699
|
+
ctx.sharedEmitDoneFor = void 0;
|
|
2924
3700
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2925
3701
|
if (overrideSchema) {
|
|
2926
3702
|
result.schema = overrideSchema;
|
|
@@ -2944,13 +3720,13 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
2944
3720
|
if (parent) {
|
|
2945
3721
|
if (!result.ref)
|
|
2946
3722
|
result.ref = parent;
|
|
2947
|
-
|
|
3723
|
+
processSchema(parent, ctx, params);
|
|
2948
3724
|
ctx.seen.get(parent).isParent = true;
|
|
2949
3725
|
}
|
|
2950
3726
|
}
|
|
2951
3727
|
const meta = ctx.metadataRegistry.get(schema);
|
|
2952
3728
|
if (meta)
|
|
2953
|
-
|
|
3729
|
+
assignProps(result.schema, meta);
|
|
2954
3730
|
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2955
3731
|
delete result.schema.examples;
|
|
2956
3732
|
delete result.schema.default;
|
|
@@ -2961,10 +3737,15 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
2961
3737
|
const _result = ctx.seen.get(schema);
|
|
2962
3738
|
return _result.schema;
|
|
2963
3739
|
}
|
|
3740
|
+
function encodeJSONPointerSegment(segment) {
|
|
3741
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3742
|
+
}
|
|
2964
3743
|
function extractDefs(ctx, schema) {
|
|
2965
3744
|
const root = ctx.seen.get(schema);
|
|
2966
3745
|
if (!root)
|
|
2967
3746
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3747
|
+
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external)
|
|
3748
|
+
return;
|
|
2968
3749
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
2969
3750
|
for (const entry of ctx.seen.entries()) {
|
|
2970
3751
|
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
@@ -2986,15 +3767,15 @@ function extractDefs(ctx, schema) {
|
|
|
2986
3767
|
}
|
|
2987
3768
|
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
2988
3769
|
entry[1].defId = id;
|
|
2989
|
-
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
2990
|
-
}
|
|
2991
|
-
if (entry[1] === root) {
|
|
2992
|
-
return { ref: "#" };
|
|
3770
|
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}` };
|
|
2993
3771
|
}
|
|
2994
3772
|
const uriPrefix = `#`;
|
|
2995
3773
|
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
3774
|
+
if (entry[1] === root && !entry[1].schema.id) {
|
|
3775
|
+
return { ref: uriPrefix };
|
|
3776
|
+
}
|
|
2996
3777
|
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2997
|
-
return { defId, ref: defUriPrefix + defId };
|
|
3778
|
+
return { defId, ref: defUriPrefix + encodeJSONPointerSegment(defId) };
|
|
2998
3779
|
};
|
|
2999
3780
|
const extractToDef = (entry) => {
|
|
3000
3781
|
if (entry[1].schema.$ref) {
|
|
@@ -3046,10 +3827,119 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3046
3827
|
if (seen.count > 1) {
|
|
3047
3828
|
if (ctx.reused === "ref") {
|
|
3048
3829
|
extractToDef(entry);
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
if (ctx.external)
|
|
3834
|
+
ctx.sharedDefsExtractedFor = ctx.external;
|
|
3835
|
+
}
|
|
3836
|
+
function compactTypeUnion(schema) {
|
|
3837
|
+
const options = schema.anyOf;
|
|
3838
|
+
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0)
|
|
3839
|
+
return;
|
|
3840
|
+
const types = [];
|
|
3841
|
+
for (const option of options) {
|
|
3842
|
+
if (!option || typeof option !== "object")
|
|
3843
|
+
return;
|
|
3844
|
+
compactTypeUnion(option);
|
|
3845
|
+
const keys = Object.keys(option);
|
|
3846
|
+
if (keys.length !== 1 || keys[0] !== "type")
|
|
3847
|
+
return;
|
|
3848
|
+
const type = option.type;
|
|
3849
|
+
for (const member of Array.isArray(type) ? type : [type]) {
|
|
3850
|
+
if (typeof member !== "string")
|
|
3851
|
+
return;
|
|
3852
|
+
if (!types.includes(member))
|
|
3853
|
+
types.push(member);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
delete schema.anyOf;
|
|
3857
|
+
schema.type = types.length === 1 ? types[0] : types;
|
|
3858
|
+
}
|
|
3859
|
+
const FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
|
|
3860
|
+
const UNION_KEYS = ["oneOf", "anyOf"];
|
|
3861
|
+
function undeclaredConstraint(member) {
|
|
3862
|
+
const extra = member.additionalProperties;
|
|
3863
|
+
if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null)
|
|
3864
|
+
return null;
|
|
3865
|
+
return Object.keys(extra).length ? extra : null;
|
|
3866
|
+
}
|
|
3867
|
+
function foldObjects(members2) {
|
|
3868
|
+
const objects = [];
|
|
3869
|
+
for (const member of members2) {
|
|
3870
|
+
if (typeof member !== "object" || member.type !== "object")
|
|
3871
|
+
return null;
|
|
3872
|
+
for (const key in member) {
|
|
3873
|
+
if (!FOLDABLE_KEYS.has(key))
|
|
3874
|
+
return null;
|
|
3875
|
+
}
|
|
3876
|
+
objects.push(member);
|
|
3877
|
+
}
|
|
3878
|
+
const properties = {};
|
|
3879
|
+
const required2 = /* @__PURE__ */ new Set();
|
|
3880
|
+
for (const object2 of objects) {
|
|
3881
|
+
for (const key in object2.properties) {
|
|
3882
|
+
if (Object.prototype.hasOwnProperty.call(properties, key))
|
|
3049
3883
|
continue;
|
|
3884
|
+
const parts = [];
|
|
3885
|
+
for (const other of objects) {
|
|
3886
|
+
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
3887
|
+
if (part === null || part === void 0)
|
|
3888
|
+
continue;
|
|
3889
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part)))
|
|
3890
|
+
parts.push(part);
|
|
3050
3891
|
}
|
|
3892
|
+
const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
|
|
3893
|
+
assignProp(properties, key, merged);
|
|
3894
|
+
}
|
|
3895
|
+
for (const key of object2.required ?? [])
|
|
3896
|
+
required2.add(key);
|
|
3897
|
+
}
|
|
3898
|
+
const folded = { type: "object", properties };
|
|
3899
|
+
if (required2.size)
|
|
3900
|
+
folded.required = [...required2];
|
|
3901
|
+
if (objects.every((object2) => object2.additionalProperties === false)) {
|
|
3902
|
+
folded.additionalProperties = false;
|
|
3903
|
+
} else {
|
|
3904
|
+
const constraints = [];
|
|
3905
|
+
for (const object2 of objects) {
|
|
3906
|
+
const constraint = undeclaredConstraint(object2);
|
|
3907
|
+
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint)))
|
|
3908
|
+
constraints.push(constraint);
|
|
3051
3909
|
}
|
|
3910
|
+
if (constraints.length === 1)
|
|
3911
|
+
folded.additionalProperties = constraints[0];
|
|
3912
|
+
else if (constraints.length > 1)
|
|
3913
|
+
folded.additionalProperties = { allOf: constraints };
|
|
3052
3914
|
}
|
|
3915
|
+
return folded;
|
|
3916
|
+
}
|
|
3917
|
+
function foldIntersection(json) {
|
|
3918
|
+
const allOf = json.allOf;
|
|
3919
|
+
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
3920
|
+
return;
|
|
3921
|
+
for (const key of FOLDABLE_KEYS)
|
|
3922
|
+
if (key in json)
|
|
3923
|
+
return;
|
|
3924
|
+
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
3925
|
+
let folded = null;
|
|
3926
|
+
if (!unions.length) {
|
|
3927
|
+
folded = foldObjects(allOf);
|
|
3928
|
+
} else {
|
|
3929
|
+
const union2 = unions[0];
|
|
3930
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union2[k]));
|
|
3931
|
+
if (Object.keys(union2).length !== 1)
|
|
3932
|
+
return;
|
|
3933
|
+
const rest = allOf.filter((m) => m !== union2);
|
|
3934
|
+
const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
3935
|
+
if (branches.some((b) => !b))
|
|
3936
|
+
return;
|
|
3937
|
+
folded = { [keyword]: branches };
|
|
3938
|
+
}
|
|
3939
|
+
if (!folded)
|
|
3940
|
+
return;
|
|
3941
|
+
delete json.allOf;
|
|
3942
|
+
assignProps(json, folded);
|
|
3053
3943
|
}
|
|
3054
3944
|
function finalize(ctx, schema) {
|
|
3055
3945
|
const root = ctx.seen.get(schema);
|
|
@@ -3071,9 +3961,9 @@ function finalize(ctx, schema) {
|
|
|
3071
3961
|
schema2.allOf = schema2.allOf ?? [];
|
|
3072
3962
|
schema2.allOf.push(refSchema);
|
|
3073
3963
|
} else {
|
|
3074
|
-
|
|
3964
|
+
assignProps(schema2, refSchema);
|
|
3075
3965
|
}
|
|
3076
|
-
|
|
3966
|
+
assignProps(schema2, _cached);
|
|
3077
3967
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
3078
3968
|
if (isParentRef) {
|
|
3079
3969
|
for (const key in schema2) {
|
|
@@ -3117,8 +4007,36 @@ function finalize(ctx, schema) {
|
|
|
3117
4007
|
path: seen.path ?? []
|
|
3118
4008
|
});
|
|
3119
4009
|
};
|
|
3120
|
-
|
|
3121
|
-
|
|
4010
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
4011
|
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
4012
|
+
flattenRef(entry[0]);
|
|
4013
|
+
}
|
|
4014
|
+
if (ctx.target !== "openapi-3.0") {
|
|
4015
|
+
for (const entry of ctx.seen.entries()) {
|
|
4016
|
+
compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
for (const rewrite of ctx.deferred)
|
|
4020
|
+
rewrite();
|
|
4021
|
+
if (ctx.intersections.length) {
|
|
4022
|
+
const carriers = /* @__PURE__ */ new Map();
|
|
4023
|
+
for (const seen of ctx.seen.values()) {
|
|
4024
|
+
for (const json of [seen.schema, seen.def]) {
|
|
4025
|
+
const allOf = json?.allOf;
|
|
4026
|
+
if (!Array.isArray(allOf))
|
|
4027
|
+
continue;
|
|
4028
|
+
const existing = carriers.get(allOf);
|
|
4029
|
+
if (existing)
|
|
4030
|
+
existing.push(json);
|
|
4031
|
+
else
|
|
4032
|
+
carriers.set(allOf, [json]);
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
for (const allOf of ctx.intersections) {
|
|
4036
|
+
for (const json of carriers.get(allOf) ?? [])
|
|
4037
|
+
foldIntersection(json);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
3122
4040
|
}
|
|
3123
4041
|
const result = {};
|
|
3124
4042
|
if (ctx.target === "draft-2020-12") {
|
|
@@ -3135,19 +4053,23 @@ function finalize(ctx, schema) {
|
|
|
3135
4053
|
throw new Error("Schema is missing an `id` property");
|
|
3136
4054
|
result.$id = ctx.external.uri(id);
|
|
3137
4055
|
}
|
|
3138
|
-
|
|
4056
|
+
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
3139
4057
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3140
4058
|
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
3141
4059
|
delete result.id;
|
|
3142
4060
|
const defs = ctx.external?.defs ?? {};
|
|
3143
|
-
|
|
3144
|
-
const seen
|
|
3145
|
-
|
|
3146
|
-
if (seen.def
|
|
3147
|
-
|
|
3148
|
-
|
|
4061
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
4062
|
+
for (const entry of ctx.seen.entries()) {
|
|
4063
|
+
const seen = entry[1];
|
|
4064
|
+
if (seen.def && seen.defId) {
|
|
4065
|
+
if (seen.def.id === seen.defId)
|
|
4066
|
+
delete seen.def.id;
|
|
4067
|
+
assignProp(defs, seen.defId, seen.def);
|
|
4068
|
+
}
|
|
3149
4069
|
}
|
|
3150
4070
|
}
|
|
4071
|
+
if (ctx.external)
|
|
4072
|
+
ctx.sharedEmitDoneFor = ctx.external;
|
|
3151
4073
|
if (ctx.external) ;
|
|
3152
4074
|
else {
|
|
3153
4075
|
if (Object.keys(defs).length > 0) {
|
|
@@ -3190,7 +4112,7 @@ function isTransforming(_schema, _ctx) {
|
|
|
3190
4112
|
return isTransforming(def.valueType, ctx);
|
|
3191
4113
|
if (def.type === "lazy")
|
|
3192
4114
|
return isTransforming(def.getter(), ctx);
|
|
3193
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
|
|
4115
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault" || def.type === "catch") {
|
|
3194
4116
|
return isTransforming(def.innerType, ctx);
|
|
3195
4117
|
}
|
|
3196
4118
|
if (def.type === "intersection") {
|
|
@@ -3231,17 +4153,105 @@ function isTransforming(_schema, _ctx) {
|
|
|
3231
4153
|
}
|
|
3232
4154
|
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
3233
4155
|
const ctx = initializeContext({ ...params, processors });
|
|
3234
|
-
|
|
4156
|
+
processSchema(schema, ctx);
|
|
3235
4157
|
extractDefs(ctx, schema);
|
|
3236
4158
|
return finalize(ctx, schema);
|
|
3237
4159
|
};
|
|
3238
4160
|
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
3239
4161
|
const { libraryOptions, target } = params ?? {};
|
|
3240
4162
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
3241
|
-
|
|
4163
|
+
processSchema(schema, ctx);
|
|
3242
4164
|
extractDefs(ctx, schema);
|
|
3243
4165
|
return finalize(ctx, schema);
|
|
3244
4166
|
};
|
|
4167
|
+
const narrowMin = (agg, key, value) => {
|
|
4168
|
+
if (agg[key] === void 0 || value > agg[key])
|
|
4169
|
+
agg[key] = value;
|
|
4170
|
+
};
|
|
4171
|
+
const narrowMax = (agg, key, value) => {
|
|
4172
|
+
if (agg[key] === void 0 || value < agg[key])
|
|
4173
|
+
agg[key] = value;
|
|
4174
|
+
};
|
|
4175
|
+
const narrowBoth = (agg, value) => {
|
|
4176
|
+
narrowMin(agg, "minimum", value);
|
|
4177
|
+
narrowMax(agg, "maximum", value);
|
|
4178
|
+
};
|
|
4179
|
+
const addDivisor = (agg, value) => {
|
|
4180
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
4181
|
+
if (!agg.multipleOf.includes(value))
|
|
4182
|
+
agg.multipleOf.push(value);
|
|
4183
|
+
};
|
|
4184
|
+
const addPattern = (agg, pattern) => {
|
|
4185
|
+
agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
|
|
4186
|
+
agg.patterns.add(pattern);
|
|
4187
|
+
};
|
|
4188
|
+
const intersectMime = (agg, mime) => {
|
|
4189
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
4190
|
+
};
|
|
4191
|
+
const setFormat = (agg, format) => {
|
|
4192
|
+
agg.format = format;
|
|
4193
|
+
if (format.includes("int"))
|
|
4194
|
+
agg.isInt = true;
|
|
4195
|
+
};
|
|
4196
|
+
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
4197
|
+
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
4198
|
+
const formatContributor = (ranges) => (agg, def) => {
|
|
4199
|
+
setFormat(agg, def.format);
|
|
4200
|
+
const [minimum, maximum] = ranges[def.format];
|
|
4201
|
+
narrowMin(agg, "minimum", minimum);
|
|
4202
|
+
narrowMax(agg, "maximum", maximum);
|
|
4203
|
+
};
|
|
4204
|
+
const contributors = {
|
|
4205
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
4206
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
4207
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
4208
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
4209
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
4210
|
+
min_length: minContributor,
|
|
4211
|
+
max_length: maxContributor,
|
|
4212
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
4213
|
+
min_size: minContributor,
|
|
4214
|
+
max_size: maxContributor,
|
|
4215
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
4216
|
+
string_format: (agg, def) => {
|
|
4217
|
+
setFormat(agg, def.format);
|
|
4218
|
+
if (def.pattern)
|
|
4219
|
+
addPattern(agg, def.pattern);
|
|
4220
|
+
if (def.format === "base64" || def.format === "base64url")
|
|
4221
|
+
agg.contentEncoding = def.format;
|
|
4222
|
+
if (def.local || def.precision === -1)
|
|
4223
|
+
agg.laxFormat = true;
|
|
4224
|
+
},
|
|
4225
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
4226
|
+
};
|
|
4227
|
+
function aggregateChecks(schema) {
|
|
4228
|
+
const agg = {};
|
|
4229
|
+
const def = schema._zod.def;
|
|
4230
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
4231
|
+
for (const ch of list)
|
|
4232
|
+
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
4233
|
+
const bag = schema._zod.bag;
|
|
4234
|
+
if (bag.minimum !== void 0)
|
|
4235
|
+
narrowMin(agg, "minimum", bag.minimum);
|
|
4236
|
+
if (bag.exclusiveMinimum !== void 0)
|
|
4237
|
+
narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
4238
|
+
if (bag.maximum !== void 0)
|
|
4239
|
+
narrowMax(agg, "maximum", bag.maximum);
|
|
4240
|
+
if (bag.exclusiveMaximum !== void 0)
|
|
4241
|
+
narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
4242
|
+
if (bag.multipleOf !== void 0)
|
|
4243
|
+
addDivisor(agg, bag.multipleOf);
|
|
4244
|
+
if (bag.format !== void 0) {
|
|
4245
|
+
agg.format ?? (agg.format = bag.format);
|
|
4246
|
+
if (bag.format.includes("int"))
|
|
4247
|
+
agg.isInt = true;
|
|
4248
|
+
}
|
|
4249
|
+
if (bag.mime)
|
|
4250
|
+
intersectMime(agg, bag.mime);
|
|
4251
|
+
for (const pattern of bag.patterns ?? [])
|
|
4252
|
+
addPattern(agg, pattern);
|
|
4253
|
+
return agg;
|
|
4254
|
+
}
|
|
3245
4255
|
const formatMap = {
|
|
3246
4256
|
guid: "uuid",
|
|
3247
4257
|
url: "uri",
|
|
@@ -3250,10 +4260,15 @@ const formatMap = {
|
|
|
3250
4260
|
regex: ""
|
|
3251
4261
|
// do not set
|
|
3252
4262
|
};
|
|
4263
|
+
const exactPatterns = /* @__PURE__ */ new Map([
|
|
4264
|
+
[base64Charset, base64],
|
|
4265
|
+
[base64urlCharset, base64url]
|
|
4266
|
+
]);
|
|
4267
|
+
const exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
3253
4268
|
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
3254
4269
|
const json = _json;
|
|
3255
4270
|
json.type = "string";
|
|
3256
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema
|
|
4271
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
3257
4272
|
if (typeof minimum === "number")
|
|
3258
4273
|
json.minLength = minimum;
|
|
3259
4274
|
if (typeof maximum === "number")
|
|
@@ -3262,19 +4277,19 @@ const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
3262
4277
|
json.format = formatMap[format] ?? format;
|
|
3263
4278
|
if (json.format === "")
|
|
3264
4279
|
delete json.format;
|
|
3265
|
-
if (format === "time") {
|
|
4280
|
+
if (format === "time" || laxFormat) {
|
|
3266
4281
|
delete json.format;
|
|
3267
4282
|
}
|
|
3268
4283
|
}
|
|
3269
4284
|
if (contentEncoding)
|
|
3270
4285
|
json.contentEncoding = contentEncoding;
|
|
3271
4286
|
if (patterns && patterns.size > 0) {
|
|
3272
|
-
const
|
|
3273
|
-
if (
|
|
3274
|
-
json.pattern =
|
|
3275
|
-
else if (
|
|
4287
|
+
const patternList = [...patterns].map(exactPattern);
|
|
4288
|
+
if (patternList.length === 1)
|
|
4289
|
+
json.pattern = patternList[0].source;
|
|
4290
|
+
else if (patternList.length > 1) {
|
|
3276
4291
|
json.allOf = [
|
|
3277
|
-
...
|
|
4292
|
+
...patternList.map((regex) => ({
|
|
3278
4293
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3279
4294
|
pattern: regex.source
|
|
3280
4295
|
}))
|
|
@@ -3282,13 +4297,10 @@ const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
3282
4297
|
}
|
|
3283
4298
|
}
|
|
3284
4299
|
};
|
|
3285
|
-
const numberProcessor = (schema, ctx, _json,
|
|
4300
|
+
const numberProcessor = (schema, ctx, _json, params) => {
|
|
3286
4301
|
const json = _json;
|
|
3287
|
-
const { minimum, maximum,
|
|
3288
|
-
|
|
3289
|
-
json.type = "integer";
|
|
3290
|
-
else
|
|
3291
|
-
json.type = "number";
|
|
4302
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
4303
|
+
json.type = isInt ? "integer" : "number";
|
|
3292
4304
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3293
4305
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3294
4306
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
@@ -3312,8 +4324,20 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
3312
4324
|
} else if (typeof maximum === "number") {
|
|
3313
4325
|
json.maximum = maximum;
|
|
3314
4326
|
}
|
|
3315
|
-
if (
|
|
3316
|
-
|
|
4327
|
+
if (multipleOf) {
|
|
4328
|
+
const divisors = /* @__PURE__ */ new Set();
|
|
4329
|
+
for (const divisor of multipleOf) {
|
|
4330
|
+
if (Number.isFinite(divisor) && divisor !== 0)
|
|
4331
|
+
divisors.add(Math.abs(divisor));
|
|
4332
|
+
else
|
|
4333
|
+
handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
4334
|
+
}
|
|
4335
|
+
const [first, ...rest] = divisors;
|
|
4336
|
+
if (first !== void 0)
|
|
4337
|
+
json.multipleOf = first;
|
|
4338
|
+
if (rest.length)
|
|
4339
|
+
json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
4340
|
+
}
|
|
3317
4341
|
};
|
|
3318
4342
|
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3319
4343
|
json.type = "boolean";
|
|
@@ -3326,59 +4350,71 @@ const unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
|
3326
4350
|
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
3327
4351
|
const def = schema._zod.def;
|
|
3328
4352
|
const values = getEnumValues(def.entries);
|
|
4353
|
+
if (values.length === 0) {
|
|
4354
|
+
json.not = {};
|
|
4355
|
+
return;
|
|
4356
|
+
}
|
|
3329
4357
|
if (values.every((v) => typeof v === "number"))
|
|
3330
4358
|
json.type = "number";
|
|
3331
4359
|
if (values.every((v) => typeof v === "string"))
|
|
3332
4360
|
json.type = "string";
|
|
3333
4361
|
json.enum = values;
|
|
3334
4362
|
};
|
|
3335
|
-
const customProcessor = (
|
|
3336
|
-
|
|
3337
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3338
|
-
}
|
|
4363
|
+
const customProcessor = (schema, ctx, json, params) => {
|
|
4364
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
3339
4365
|
};
|
|
3340
|
-
const transformProcessor = (
|
|
3341
|
-
|
|
3342
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3343
|
-
}
|
|
4366
|
+
const transformProcessor = (schema, ctx, json, params) => {
|
|
4367
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
3344
4368
|
};
|
|
3345
4369
|
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
3346
4370
|
const json = _json;
|
|
3347
4371
|
const def = schema._zod.def;
|
|
3348
|
-
const { minimum, maximum } = schema
|
|
4372
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
3349
4373
|
if (typeof minimum === "number")
|
|
3350
4374
|
json.minItems = minimum;
|
|
3351
4375
|
if (typeof maximum === "number")
|
|
3352
4376
|
json.maxItems = maximum;
|
|
3353
4377
|
json.type = "array";
|
|
3354
|
-
json.items =
|
|
4378
|
+
json.items = processSchema(def.element, ctx, {
|
|
3355
4379
|
...params,
|
|
3356
4380
|
path: [...params.path, "items"]
|
|
3357
4381
|
});
|
|
3358
4382
|
};
|
|
4383
|
+
function inputOptin(schema) {
|
|
4384
|
+
const def = schema._zod.def;
|
|
4385
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) {
|
|
4386
|
+
return inputOptin(def.out);
|
|
4387
|
+
}
|
|
4388
|
+
if (def.type === "catch") {
|
|
4389
|
+
return inputOptin(def.innerType);
|
|
4390
|
+
}
|
|
4391
|
+
return schema._zod.optin;
|
|
4392
|
+
}
|
|
3359
4393
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
3360
4394
|
const json = _json;
|
|
3361
4395
|
const def = schema._zod.def;
|
|
4396
|
+
const shape = def.shape;
|
|
4397
|
+
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
4398
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
4399
|
+
return;
|
|
4400
|
+
}
|
|
3362
4401
|
json.type = "object";
|
|
3363
4402
|
json.properties = {};
|
|
3364
|
-
const shape = def.shape;
|
|
3365
4403
|
for (const key in shape) {
|
|
3366
|
-
json.properties
|
|
4404
|
+
assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
3367
4405
|
...params,
|
|
3368
4406
|
path: [...params.path, "properties", key]
|
|
3369
|
-
});
|
|
4407
|
+
}));
|
|
3370
4408
|
}
|
|
3371
|
-
const
|
|
3372
|
-
const
|
|
3373
|
-
const
|
|
3374
|
-
if (ctx.io === "input") {
|
|
3375
|
-
|
|
3376
|
-
} else {
|
|
3377
|
-
return v.optout === void 0;
|
|
4409
|
+
const requiredKeys = [];
|
|
4410
|
+
for (const key of Object.keys(shape)) {
|
|
4411
|
+
const field = def.shape[key];
|
|
4412
|
+
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) {
|
|
4413
|
+
requiredKeys.push(key);
|
|
3378
4414
|
}
|
|
3379
|
-
}
|
|
3380
|
-
if (requiredKeys.
|
|
3381
|
-
json.required =
|
|
4415
|
+
}
|
|
4416
|
+
if (requiredKeys.length > 0) {
|
|
4417
|
+
json.required = requiredKeys;
|
|
3382
4418
|
}
|
|
3383
4419
|
if (def.catchall?._zod.def.type === "never") {
|
|
3384
4420
|
json.additionalProperties = false;
|
|
@@ -3386,7 +4422,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3386
4422
|
if (ctx.io === "output")
|
|
3387
4423
|
json.additionalProperties = false;
|
|
3388
4424
|
} else if (def.catchall) {
|
|
3389
|
-
json.additionalProperties =
|
|
4425
|
+
json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
3390
4426
|
...params,
|
|
3391
4427
|
path: [...params.path, "additionalProperties"]
|
|
3392
4428
|
});
|
|
@@ -3395,7 +4431,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3395
4431
|
const unionProcessor = (schema, ctx, json, params) => {
|
|
3396
4432
|
const def = schema._zod.def;
|
|
3397
4433
|
const isExclusive = def.inclusive === false;
|
|
3398
|
-
const options = def.options.map((x, i) =>
|
|
4434
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
3399
4435
|
...params,
|
|
3400
4436
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
3401
4437
|
}));
|
|
@@ -3407,11 +4443,11 @@ const unionProcessor = (schema, ctx, json, params) => {
|
|
|
3407
4443
|
};
|
|
3408
4444
|
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
3409
4445
|
const def = schema._zod.def;
|
|
3410
|
-
const a =
|
|
4446
|
+
const a = processSchema(def.left, ctx, {
|
|
3411
4447
|
...params,
|
|
3412
4448
|
path: [...params.path, "allOf", 0]
|
|
3413
4449
|
});
|
|
3414
|
-
const b =
|
|
4450
|
+
const b = processSchema(def.right, ctx, {
|
|
3415
4451
|
...params,
|
|
3416
4452
|
path: [...params.path, "allOf", 1]
|
|
3417
4453
|
});
|
|
@@ -3421,10 +4457,11 @@ const intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3421
4457
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
3422
4458
|
];
|
|
3423
4459
|
json.allOf = allOf;
|
|
4460
|
+
ctx.intersections.push(allOf);
|
|
3424
4461
|
};
|
|
3425
4462
|
const nullableProcessor = (schema, ctx, json, params) => {
|
|
3426
4463
|
const def = schema._zod.def;
|
|
3427
|
-
const inner =
|
|
4464
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
3428
4465
|
const seen = ctx.seen.get(schema);
|
|
3429
4466
|
if (ctx.target === "openapi-3.0") {
|
|
3430
4467
|
seen.ref = def.innerType;
|
|
@@ -3435,35 +4472,55 @@ const nullableProcessor = (schema, ctx, json, params) => {
|
|
|
3435
4472
|
};
|
|
3436
4473
|
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3437
4474
|
const def = schema._zod.def;
|
|
3438
|
-
|
|
4475
|
+
processSchema(def.innerType, ctx, params);
|
|
3439
4476
|
const seen = ctx.seen.get(schema);
|
|
3440
4477
|
seen.ref = def.innerType;
|
|
3441
4478
|
};
|
|
4479
|
+
const UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
4480
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
4481
|
+
let unrepresentable = false;
|
|
4482
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
4483
|
+
if (typeof val !== "bigint")
|
|
4484
|
+
return val;
|
|
4485
|
+
unrepresentable = true;
|
|
4486
|
+
return null;
|
|
4487
|
+
});
|
|
4488
|
+
if (!unrepresentable)
|
|
4489
|
+
return JSON.parse(serialized);
|
|
4490
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
4491
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
4492
|
+
}
|
|
3442
4493
|
const defaultProcessor = (schema, ctx, json, params) => {
|
|
3443
4494
|
const def = schema._zod.def;
|
|
3444
|
-
|
|
4495
|
+
processSchema(def.innerType, ctx, params);
|
|
3445
4496
|
const seen = ctx.seen.get(schema);
|
|
3446
4497
|
seen.ref = def.innerType;
|
|
3447
|
-
|
|
4498
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4499
|
+
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
4500
|
+
json.default = value;
|
|
3448
4501
|
};
|
|
3449
4502
|
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
3450
4503
|
const def = schema._zod.def;
|
|
3451
|
-
|
|
4504
|
+
processSchema(def.innerType, ctx, params);
|
|
3452
4505
|
const seen = ctx.seen.get(schema);
|
|
3453
4506
|
seen.ref = def.innerType;
|
|
3454
|
-
if (ctx.io
|
|
3455
|
-
|
|
4507
|
+
if (ctx.io !== "input")
|
|
4508
|
+
return;
|
|
4509
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4510
|
+
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
4511
|
+
json._prefault = value;
|
|
3456
4512
|
};
|
|
3457
4513
|
const catchProcessor = (schema, ctx, json, params) => {
|
|
3458
4514
|
const def = schema._zod.def;
|
|
3459
|
-
|
|
4515
|
+
processSchema(def.innerType, ctx, params);
|
|
3460
4516
|
const seen = ctx.seen.get(schema);
|
|
3461
4517
|
seen.ref = def.innerType;
|
|
3462
4518
|
let catchValue;
|
|
3463
4519
|
try {
|
|
3464
4520
|
catchValue = def.catchValue(void 0);
|
|
3465
4521
|
} catch {
|
|
3466
|
-
|
|
4522
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
4523
|
+
return;
|
|
3467
4524
|
}
|
|
3468
4525
|
json.default = catchValue;
|
|
3469
4526
|
};
|
|
@@ -3471,86 +4528,64 @@ const pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
3471
4528
|
const def = schema._zod.def;
|
|
3472
4529
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
3473
4530
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
3474
|
-
|
|
4531
|
+
processSchema(innerType, ctx, params);
|
|
3475
4532
|
const seen = ctx.seen.get(schema);
|
|
3476
4533
|
seen.ref = innerType;
|
|
3477
4534
|
};
|
|
3478
4535
|
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
3479
4536
|
const def = schema._zod.def;
|
|
3480
|
-
|
|
4537
|
+
processSchema(def.innerType, ctx, params);
|
|
3481
4538
|
const seen = ctx.seen.get(schema);
|
|
3482
4539
|
seen.ref = def.innerType;
|
|
3483
4540
|
json.readOnly = true;
|
|
3484
4541
|
};
|
|
3485
4542
|
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
3486
4543
|
const def = schema._zod.def;
|
|
3487
|
-
|
|
4544
|
+
processSchema(def.innerType, ctx, params);
|
|
3488
4545
|
const seen = ctx.seen.get(schema);
|
|
3489
4546
|
seen.ref = def.innerType;
|
|
3490
4547
|
};
|
|
3491
|
-
const
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
}
|
|
3505
|
-
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
3506
|
-
$ZodISOTime.init(inst, def);
|
|
3507
|
-
ZodStringFormat.init(inst, def);
|
|
3508
|
-
});
|
|
3509
|
-
function time(params) {
|
|
3510
|
-
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
|
|
3511
|
-
}
|
|
3512
|
-
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
3513
|
-
$ZodISODuration.init(inst, def);
|
|
3514
|
-
ZodStringFormat.init(inst, def);
|
|
3515
|
-
});
|
|
3516
|
-
function duration(params) {
|
|
3517
|
-
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
4548
|
+
const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
4549
|
+
function _lazyMethod(proto, key, make) {
|
|
4550
|
+
Object.defineProperty(proto, key, {
|
|
4551
|
+
configurable: true,
|
|
4552
|
+
enumerable: false,
|
|
4553
|
+
get() {
|
|
4554
|
+
const value = make(this);
|
|
4555
|
+
Object.defineProperty(this, key, { value, configurable: true, writable: true });
|
|
4556
|
+
return value;
|
|
4557
|
+
},
|
|
4558
|
+
set(value) {
|
|
4559
|
+
Object.defineProperty(this, key, { value, configurable: true, writable: true });
|
|
4560
|
+
}
|
|
4561
|
+
});
|
|
3518
4562
|
}
|
|
3519
4563
|
const initializer = (inst, issues) => {
|
|
3520
4564
|
$ZodError.init(inst, issues);
|
|
3521
4565
|
inst.name = "ZodError";
|
|
3522
|
-
Object.
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3542
|
-
}
|
|
3543
|
-
// enumerable: false,
|
|
3544
|
-
},
|
|
3545
|
-
isEmpty: {
|
|
3546
|
-
get() {
|
|
3547
|
-
return inst.issues.length === 0;
|
|
3548
|
-
}
|
|
3549
|
-
// enumerable: false,
|
|
4566
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4567
|
+
if (_installedErrorProtos.has(proto))
|
|
4568
|
+
return;
|
|
4569
|
+
_installedErrorProtos.add(proto);
|
|
4570
|
+
_lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
|
|
4571
|
+
_lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
|
|
4572
|
+
_lazyMethod(proto, "addIssue", (self) => (issue2) => {
|
|
4573
|
+
self.issues.push(issue2);
|
|
4574
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4575
|
+
});
|
|
4576
|
+
_lazyMethod(proto, "addIssues", (self) => (issues2) => {
|
|
4577
|
+
self.issues.push(...issues2);
|
|
4578
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4579
|
+
});
|
|
4580
|
+
Object.defineProperty(proto, "isEmpty", {
|
|
4581
|
+
configurable: true,
|
|
4582
|
+
enumerable: false,
|
|
4583
|
+
get() {
|
|
4584
|
+
return this.issues.length === 0;
|
|
3550
4585
|
}
|
|
3551
4586
|
});
|
|
3552
4587
|
};
|
|
3553
|
-
const ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, {
|
|
4588
|
+
const ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer, void 0, {
|
|
3554
4589
|
Parent: Error
|
|
3555
4590
|
});
|
|
3556
4591
|
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
@@ -3565,181 +4600,201 @@ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
|
3565
4600
|
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
3566
4601
|
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3567
4602
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
}
|
|
3576
|
-
if (installed.has(group))
|
|
3577
|
-
return;
|
|
3578
|
-
installed.add(group);
|
|
3579
|
-
for (const key in methods) {
|
|
3580
|
-
const fn = methods[key];
|
|
3581
|
-
Object.defineProperty(proto, key, {
|
|
3582
|
-
configurable: true,
|
|
3583
|
-
enumerable: false,
|
|
3584
|
-
get() {
|
|
3585
|
-
const bound = fn.bind(this);
|
|
3586
|
-
Object.defineProperty(this, key, {
|
|
3587
|
-
configurable: true,
|
|
3588
|
-
writable: true,
|
|
3589
|
-
enumerable: true,
|
|
3590
|
-
value: bound
|
|
3591
|
-
});
|
|
3592
|
-
return bound;
|
|
3593
|
-
},
|
|
3594
|
-
set(v) {
|
|
3595
|
-
Object.defineProperty(this, key, {
|
|
3596
|
-
configurable: true,
|
|
3597
|
-
writable: true,
|
|
3598
|
-
enumerable: true,
|
|
3599
|
-
value: v
|
|
3600
|
-
});
|
|
3601
|
-
}
|
|
3602
|
-
});
|
|
3603
|
-
}
|
|
4603
|
+
function _ensureDefaultLocale() {
|
|
4604
|
+
if (!globalConfig.localeError)
|
|
4605
|
+
config(en());
|
|
4606
|
+
}
|
|
4607
|
+
function _ensureDefaultMemoizer() {
|
|
4608
|
+
if (!globalConfig.memoizer)
|
|
4609
|
+
config({ memoizer: memoizer() });
|
|
3604
4610
|
}
|
|
3605
4611
|
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
4612
|
+
_ensureDefaultLocale();
|
|
3606
4613
|
$ZodType.init(inst, def);
|
|
3607
|
-
Object.assign(inst["~standard"], {
|
|
3608
|
-
jsonSchema: {
|
|
3609
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
3610
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
3611
|
-
}
|
|
3612
|
-
});
|
|
3613
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
3614
4614
|
inst.def = def;
|
|
3615
4615
|
inst.type = def.type;
|
|
3616
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
3617
|
-
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
3618
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
3619
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
3620
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
3621
|
-
inst.spa = inst.safeParseAsync;
|
|
3622
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
3623
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
3624
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
3625
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
3626
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
3627
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
3628
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
3629
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3630
|
-
_installLazyMethods(inst, "ZodType", {
|
|
3631
|
-
check(...chks) {
|
|
3632
|
-
const def2 = this.def;
|
|
3633
|
-
return this.clone(mergeDefs(def2, {
|
|
3634
|
-
checks: [
|
|
3635
|
-
...def2.checks ?? [],
|
|
3636
|
-
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
3637
|
-
]
|
|
3638
|
-
}), { parent: true });
|
|
3639
|
-
},
|
|
3640
|
-
with(...chks) {
|
|
3641
|
-
return this.check(...chks);
|
|
3642
|
-
},
|
|
3643
|
-
clone(def2, params) {
|
|
3644
|
-
return clone(this, def2, params);
|
|
3645
|
-
},
|
|
3646
|
-
brand() {
|
|
3647
|
-
return this;
|
|
3648
|
-
},
|
|
3649
|
-
register(reg, meta) {
|
|
3650
|
-
reg.add(this, meta);
|
|
3651
|
-
return this;
|
|
3652
|
-
},
|
|
3653
|
-
refine(check, params) {
|
|
3654
|
-
return this.check(refine(check, params));
|
|
3655
|
-
},
|
|
3656
|
-
superRefine(refinement, params) {
|
|
3657
|
-
return this.check(superRefine(refinement, params));
|
|
3658
|
-
},
|
|
3659
|
-
overwrite(fn) {
|
|
3660
|
-
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
3661
|
-
},
|
|
3662
|
-
optional() {
|
|
3663
|
-
return optional(this);
|
|
3664
|
-
},
|
|
3665
|
-
exactOptional() {
|
|
3666
|
-
return exactOptional(this);
|
|
3667
|
-
},
|
|
3668
|
-
nullable() {
|
|
3669
|
-
return nullable(this);
|
|
3670
|
-
},
|
|
3671
|
-
nullish() {
|
|
3672
|
-
return optional(nullable(this));
|
|
3673
|
-
},
|
|
3674
|
-
nonoptional(params) {
|
|
3675
|
-
return nonoptional(this, params);
|
|
3676
|
-
},
|
|
3677
|
-
array() {
|
|
3678
|
-
return array(this);
|
|
3679
|
-
},
|
|
3680
|
-
or(arg) {
|
|
3681
|
-
return union([this, arg]);
|
|
3682
|
-
},
|
|
3683
|
-
and(arg) {
|
|
3684
|
-
return intersection(this, arg);
|
|
3685
|
-
},
|
|
3686
|
-
transform(tx) {
|
|
3687
|
-
return pipe(this, transform(tx));
|
|
3688
|
-
},
|
|
3689
|
-
default(d) {
|
|
3690
|
-
return _default(this, d);
|
|
3691
|
-
},
|
|
3692
|
-
prefault(d) {
|
|
3693
|
-
return prefault(this, d);
|
|
3694
|
-
},
|
|
3695
|
-
catch(params) {
|
|
3696
|
-
return _catch(this, params);
|
|
3697
|
-
},
|
|
3698
|
-
pipe(target) {
|
|
3699
|
-
return pipe(this, target);
|
|
3700
|
-
},
|
|
3701
|
-
readonly() {
|
|
3702
|
-
return readonly(this);
|
|
3703
|
-
},
|
|
3704
|
-
describe(description) {
|
|
3705
|
-
const cl = this.clone();
|
|
3706
|
-
globalRegistry.add(cl, { description });
|
|
3707
|
-
return cl;
|
|
3708
|
-
},
|
|
3709
|
-
meta(...args) {
|
|
3710
|
-
if (args.length === 0)
|
|
3711
|
-
return globalRegistry.get(this);
|
|
3712
|
-
const cl = this.clone();
|
|
3713
|
-
globalRegistry.add(cl, args[0]);
|
|
3714
|
-
return cl;
|
|
3715
|
-
},
|
|
3716
|
-
isOptional() {
|
|
3717
|
-
return this.safeParse(void 0).success;
|
|
3718
|
-
},
|
|
3719
|
-
isNullable() {
|
|
3720
|
-
return this.safeParse(null).success;
|
|
3721
|
-
},
|
|
3722
|
-
apply(fn) {
|
|
3723
|
-
return fn(this);
|
|
3724
|
-
}
|
|
3725
|
-
});
|
|
3726
|
-
Object.defineProperty(inst, "description", {
|
|
3727
|
-
get() {
|
|
3728
|
-
return globalRegistry.get(inst)?.description;
|
|
3729
|
-
},
|
|
3730
|
-
configurable: true
|
|
3731
|
-
});
|
|
3732
4616
|
return inst;
|
|
4617
|
+
}, {
|
|
4618
|
+
check(...chks) {
|
|
4619
|
+
const def = this.def;
|
|
4620
|
+
return this.clone(mergeDefs(def, {
|
|
4621
|
+
checks: [
|
|
4622
|
+
...def.checks ?? [],
|
|
4623
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
4624
|
+
]
|
|
4625
|
+
}), { parent: true });
|
|
4626
|
+
},
|
|
4627
|
+
with(...chks) {
|
|
4628
|
+
return this.check(...chks);
|
|
4629
|
+
},
|
|
4630
|
+
clone(def, params) {
|
|
4631
|
+
return clone(this, def, params);
|
|
4632
|
+
},
|
|
4633
|
+
brand() {
|
|
4634
|
+
return this;
|
|
4635
|
+
},
|
|
4636
|
+
register(reg, meta) {
|
|
4637
|
+
reg.add(this, meta);
|
|
4638
|
+
return this;
|
|
4639
|
+
},
|
|
4640
|
+
refine(check, params) {
|
|
4641
|
+
return this.check(refine(check, params));
|
|
4642
|
+
},
|
|
4643
|
+
superRefine(refinement, params) {
|
|
4644
|
+
return this.check(superRefine(refinement, params));
|
|
4645
|
+
},
|
|
4646
|
+
overwrite(fn) {
|
|
4647
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4648
|
+
},
|
|
4649
|
+
optional() {
|
|
4650
|
+
return optional(this);
|
|
4651
|
+
},
|
|
4652
|
+
exactOptional() {
|
|
4653
|
+
return exactOptional(this);
|
|
4654
|
+
},
|
|
4655
|
+
nullable() {
|
|
4656
|
+
return nullable(this);
|
|
4657
|
+
},
|
|
4658
|
+
nullish() {
|
|
4659
|
+
return optional(nullable(this));
|
|
4660
|
+
},
|
|
4661
|
+
nonoptional(params) {
|
|
4662
|
+
return nonoptional(this, params);
|
|
4663
|
+
},
|
|
4664
|
+
array() {
|
|
4665
|
+
return array(this);
|
|
4666
|
+
},
|
|
4667
|
+
or(arg) {
|
|
4668
|
+
return union([this, arg]);
|
|
4669
|
+
},
|
|
4670
|
+
and(arg) {
|
|
4671
|
+
return intersection(this, arg);
|
|
4672
|
+
},
|
|
4673
|
+
transform(tx) {
|
|
4674
|
+
return pipe(this, transform(tx));
|
|
4675
|
+
},
|
|
4676
|
+
default(d) {
|
|
4677
|
+
return _default(this, d);
|
|
4678
|
+
},
|
|
4679
|
+
prefault(d) {
|
|
4680
|
+
return prefault(this, d);
|
|
4681
|
+
},
|
|
4682
|
+
catch(params) {
|
|
4683
|
+
return _catch(this, params);
|
|
4684
|
+
},
|
|
4685
|
+
pipe(target) {
|
|
4686
|
+
return pipe(this, target);
|
|
4687
|
+
},
|
|
4688
|
+
readonly() {
|
|
4689
|
+
return readonly(this);
|
|
4690
|
+
},
|
|
4691
|
+
describe(description) {
|
|
4692
|
+
const cl = this.clone();
|
|
4693
|
+
globalRegistry.add(cl, { description });
|
|
4694
|
+
return cl;
|
|
4695
|
+
},
|
|
4696
|
+
meta(...args) {
|
|
4697
|
+
if (args.length === 0)
|
|
4698
|
+
return globalRegistry.get(this);
|
|
4699
|
+
const cl = this.clone();
|
|
4700
|
+
globalRegistry.add(cl, args[0]);
|
|
4701
|
+
return cl;
|
|
4702
|
+
},
|
|
4703
|
+
isOptional() {
|
|
4704
|
+
return this.safeParse(void 0).success;
|
|
4705
|
+
},
|
|
4706
|
+
isNullable() {
|
|
4707
|
+
return this.safeParse(null).success;
|
|
4708
|
+
},
|
|
4709
|
+
apply(fn, ...args) {
|
|
4710
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
4711
|
+
},
|
|
4712
|
+
// Overrides core's `~standard` to add `jsonSchema`. Must stay a prototype entry: redefining it per instance demotes instances to dictionary mode.
|
|
4713
|
+
get "~standard"() {
|
|
4714
|
+
return hide(this, "~standard", {
|
|
4715
|
+
...standardProps(this),
|
|
4716
|
+
jsonSchema: {
|
|
4717
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
4718
|
+
output: createStandardJSONSchemaMethod(this, "output")
|
|
4719
|
+
}
|
|
4720
|
+
});
|
|
4721
|
+
},
|
|
4722
|
+
set "~standard"(value) {
|
|
4723
|
+
own(this, "~standard", value);
|
|
4724
|
+
},
|
|
4725
|
+
parse: function _parse2(data, params) {
|
|
4726
|
+
return parse(this, data, params, { callee: _parse2 });
|
|
4727
|
+
},
|
|
4728
|
+
parseAsync: async function _parseAsync2(data, params) {
|
|
4729
|
+
return await parseAsync(this, data, params, { callee: _parseAsync2 });
|
|
4730
|
+
},
|
|
4731
|
+
safeParse(data, params) {
|
|
4732
|
+
return safeParse(this, data, params);
|
|
4733
|
+
},
|
|
4734
|
+
async safeParseAsync(data, params) {
|
|
4735
|
+
return safeParseAsync(this, data, params);
|
|
4736
|
+
},
|
|
4737
|
+
// `spa` is an alias: same function object as `safeParseAsync`, as before.
|
|
4738
|
+
get spa() {
|
|
4739
|
+
return this?.safeParseAsync;
|
|
4740
|
+
},
|
|
4741
|
+
set spa(value) {
|
|
4742
|
+
own(this, "spa", value);
|
|
4743
|
+
},
|
|
4744
|
+
validate(data, params) {
|
|
4745
|
+
return validate(this, data, params);
|
|
4746
|
+
},
|
|
4747
|
+
validateAsync(data, params) {
|
|
4748
|
+
return validateAsync$1(this, data, params);
|
|
4749
|
+
},
|
|
4750
|
+
encode: function _encode2(data, params) {
|
|
4751
|
+
return encode(this, data, params, { callee: _encode2 });
|
|
4752
|
+
},
|
|
4753
|
+
decode: function _decode2(data, params) {
|
|
4754
|
+
return decode(this, data, params, { callee: _decode2 });
|
|
4755
|
+
},
|
|
4756
|
+
encodeAsync: async function _encodeAsync2(data, params) {
|
|
4757
|
+
return await encodeAsync(this, data, params, { callee: _encodeAsync2 });
|
|
4758
|
+
},
|
|
4759
|
+
decodeAsync: async function _decodeAsync2(data, params) {
|
|
4760
|
+
return await decodeAsync(this, data, params, { callee: _decodeAsync2 });
|
|
4761
|
+
},
|
|
4762
|
+
safeEncode(data, params) {
|
|
4763
|
+
return safeEncode(this, data, params);
|
|
4764
|
+
},
|
|
4765
|
+
safeDecode(data, params) {
|
|
4766
|
+
return safeDecode(this, data, params);
|
|
4767
|
+
},
|
|
4768
|
+
async safeEncodeAsync(data, params) {
|
|
4769
|
+
return safeEncodeAsync(this, data, params);
|
|
4770
|
+
},
|
|
4771
|
+
async safeDecodeAsync(data, params) {
|
|
4772
|
+
return safeDecodeAsync(this, data, params);
|
|
4773
|
+
},
|
|
4774
|
+
toJSONSchema(params) {
|
|
4775
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
4776
|
+
},
|
|
4777
|
+
// Reads through to the registry on every access, so it must not cache.
|
|
4778
|
+
get description() {
|
|
4779
|
+
return globalRegistry.get(this)?.description;
|
|
4780
|
+
},
|
|
4781
|
+
// No setter: `schema._def = x` throws, as it did when `_def` was a non-writable own property.
|
|
4782
|
+
get _def() {
|
|
4783
|
+
return this._zod.def;
|
|
4784
|
+
}
|
|
3733
4785
|
});
|
|
3734
|
-
const _ZodString = /* @__PURE__ */ $constructor(
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
4786
|
+
const _ZodString = /* @__PURE__ */ $constructor(
|
|
4787
|
+
"_ZodString",
|
|
4788
|
+
(inst, def) => {
|
|
4789
|
+
$ZodString.init(inst, def);
|
|
4790
|
+
ZodType.init(inst, def);
|
|
4791
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
|
|
4792
|
+
},
|
|
4793
|
+
/* @__PURE__ */ derived({
|
|
4794
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
4795
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
4796
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
4797
|
+
}, {
|
|
3743
4798
|
regex(...args) {
|
|
3744
4799
|
return this.check(/* @__PURE__ */ _regex(...args));
|
|
3745
4800
|
},
|
|
@@ -3785,38 +4840,90 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
3785
4840
|
slugify() {
|
|
3786
4841
|
return this.check(/* @__PURE__ */ _slugify());
|
|
3787
4842
|
}
|
|
3788
|
-
})
|
|
3789
|
-
|
|
4843
|
+
})
|
|
4844
|
+
);
|
|
3790
4845
|
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
3791
4846
|
$ZodString.init(inst, def);
|
|
3792
4847
|
_ZodString.init(inst, def);
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
4848
|
+
}, {
|
|
4849
|
+
email(params) {
|
|
4850
|
+
return this.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
4851
|
+
},
|
|
4852
|
+
url(params) {
|
|
4853
|
+
return this.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
4854
|
+
},
|
|
4855
|
+
jwt(params) {
|
|
4856
|
+
return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
4857
|
+
},
|
|
4858
|
+
emoji(params) {
|
|
4859
|
+
return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
4860
|
+
},
|
|
4861
|
+
guid(params) {
|
|
4862
|
+
return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4863
|
+
},
|
|
4864
|
+
uuid(params) {
|
|
4865
|
+
return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
4866
|
+
},
|
|
4867
|
+
uuidv4(params) {
|
|
4868
|
+
return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
4869
|
+
},
|
|
4870
|
+
uuidv6(params) {
|
|
4871
|
+
return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
4872
|
+
},
|
|
4873
|
+
uuidv7(params) {
|
|
4874
|
+
return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
4875
|
+
},
|
|
4876
|
+
nanoid(params) {
|
|
4877
|
+
return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
4878
|
+
},
|
|
4879
|
+
cuid(params) {
|
|
4880
|
+
return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
4881
|
+
},
|
|
4882
|
+
cuid2(params) {
|
|
4883
|
+
return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
4884
|
+
},
|
|
4885
|
+
ulid(params) {
|
|
4886
|
+
return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
4887
|
+
},
|
|
4888
|
+
base64(params) {
|
|
4889
|
+
return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
4890
|
+
},
|
|
4891
|
+
base64url(params) {
|
|
4892
|
+
return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
4893
|
+
},
|
|
4894
|
+
xid(params) {
|
|
4895
|
+
return this.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
4896
|
+
},
|
|
4897
|
+
ksuid(params) {
|
|
4898
|
+
return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
4899
|
+
},
|
|
4900
|
+
ipv4(params) {
|
|
4901
|
+
return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
4902
|
+
},
|
|
4903
|
+
ipv6(params) {
|
|
4904
|
+
return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
4905
|
+
},
|
|
4906
|
+
cidrv4(params) {
|
|
4907
|
+
return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
4908
|
+
},
|
|
4909
|
+
cidrv6(params) {
|
|
4910
|
+
return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
4911
|
+
},
|
|
4912
|
+
e164(params) {
|
|
4913
|
+
return this.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
4914
|
+
},
|
|
4915
|
+
datetime(params) {
|
|
4916
|
+
return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
|
|
4917
|
+
},
|
|
4918
|
+
date(params) {
|
|
4919
|
+
return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
|
|
4920
|
+
},
|
|
4921
|
+
time(params) {
|
|
4922
|
+
return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
|
|
4923
|
+
},
|
|
4924
|
+
duration(params) {
|
|
4925
|
+
return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
|
|
4926
|
+
}
|
|
3820
4927
|
});
|
|
3821
4928
|
function string(params) {
|
|
3822
4929
|
return /* @__PURE__ */ _string(ZodString, params);
|
|
@@ -3825,6 +4932,22 @@ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, d
|
|
|
3825
4932
|
$ZodStringFormat.init(inst, def);
|
|
3826
4933
|
_ZodString.init(inst, def);
|
|
3827
4934
|
});
|
|
4935
|
+
const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
4936
|
+
$ZodISODateTime.init(inst, def);
|
|
4937
|
+
ZodStringFormat.init(inst, def);
|
|
4938
|
+
});
|
|
4939
|
+
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
4940
|
+
$ZodISODate.init(inst, def);
|
|
4941
|
+
ZodStringFormat.init(inst, def);
|
|
4942
|
+
});
|
|
4943
|
+
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
4944
|
+
$ZodISOTime.init(inst, def);
|
|
4945
|
+
ZodStringFormat.init(inst, def);
|
|
4946
|
+
});
|
|
4947
|
+
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
4948
|
+
$ZodISODuration.init(inst, def);
|
|
4949
|
+
ZodStringFormat.init(inst, def);
|
|
4950
|
+
});
|
|
3828
4951
|
const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
3829
4952
|
$ZodEmail.init(inst, def);
|
|
3830
4953
|
ZodStringFormat.init(inst, def);
|
|
@@ -3901,11 +5024,29 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
|
3901
5024
|
$ZodJWT.init(inst, def);
|
|
3902
5025
|
ZodStringFormat.init(inst, def);
|
|
3903
5026
|
});
|
|
3904
|
-
const ZodNumber = /* @__PURE__ */ $constructor(
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
5027
|
+
const ZodNumber = /* @__PURE__ */ $constructor(
|
|
5028
|
+
"ZodNumber",
|
|
5029
|
+
(inst, def) => {
|
|
5030
|
+
$ZodNumber.init(inst, def);
|
|
5031
|
+
ZodType.init(inst, def);
|
|
5032
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
5033
|
+
inst.isFinite = true;
|
|
5034
|
+
},
|
|
5035
|
+
/* @__PURE__ */ derived({
|
|
5036
|
+
minValue: (inst) => {
|
|
5037
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
5038
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
5039
|
+
},
|
|
5040
|
+
maxValue: (inst) => {
|
|
5041
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
5042
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
5043
|
+
},
|
|
5044
|
+
isInt: (inst) => {
|
|
5045
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
5046
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
5047
|
+
},
|
|
5048
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
5049
|
+
}, {
|
|
3909
5050
|
gt(value, params) {
|
|
3910
5051
|
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
3911
5052
|
},
|
|
@@ -3951,14 +5092,8 @@ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
3951
5092
|
finite() {
|
|
3952
5093
|
return this;
|
|
3953
5094
|
}
|
|
3954
|
-
})
|
|
3955
|
-
|
|
3956
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
3957
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
3958
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
3959
|
-
inst.isFinite = true;
|
|
3960
|
-
inst.format = bag.format ?? null;
|
|
3961
|
-
});
|
|
5095
|
+
})
|
|
5096
|
+
);
|
|
3962
5097
|
function number(params) {
|
|
3963
5098
|
return /* @__PURE__ */ _number(ZodNumber, params);
|
|
3964
5099
|
}
|
|
@@ -3994,79 +5129,80 @@ function never(params) {
|
|
|
3994
5129
|
return /* @__PURE__ */ _never(ZodNever, params);
|
|
3995
5130
|
}
|
|
3996
5131
|
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
5132
|
+
_ensureDefaultMemoizer();
|
|
3997
5133
|
$ZodArray.init(inst, def);
|
|
3998
5134
|
ZodType.init(inst, def);
|
|
3999
5135
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4000
5136
|
inst.element = def.element;
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
});
|
|
5137
|
+
}, {
|
|
5138
|
+
min(n, params) {
|
|
5139
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
5140
|
+
},
|
|
5141
|
+
nonempty(params) {
|
|
5142
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
5143
|
+
},
|
|
5144
|
+
max(n, params) {
|
|
5145
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
5146
|
+
},
|
|
5147
|
+
length(n, params) {
|
|
5148
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
5149
|
+
},
|
|
5150
|
+
unwrap() {
|
|
5151
|
+
return this.element;
|
|
5152
|
+
}
|
|
4018
5153
|
});
|
|
4019
5154
|
function array(element, params) {
|
|
4020
5155
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
4021
5156
|
}
|
|
4022
5157
|
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
5158
|
+
_ensureDefaultMemoizer();
|
|
4023
5159
|
$ZodObjectJIT.init(inst, def);
|
|
4024
5160
|
ZodType.init(inst, def);
|
|
4025
5161
|
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
}
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
}
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
}
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
}
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
}
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
}
|
|
5162
|
+
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
5163
|
+
}, {
|
|
5164
|
+
keyof() {
|
|
5165
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
5166
|
+
},
|
|
5167
|
+
catchall(catchall) {
|
|
5168
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
5169
|
+
},
|
|
5170
|
+
passthrough() {
|
|
5171
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5172
|
+
},
|
|
5173
|
+
loose() {
|
|
5174
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5175
|
+
},
|
|
5176
|
+
strict() {
|
|
5177
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
5178
|
+
},
|
|
5179
|
+
strip() {
|
|
5180
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
|
|
5181
|
+
},
|
|
5182
|
+
extend(incoming) {
|
|
5183
|
+
return extend(this, incoming);
|
|
5184
|
+
},
|
|
5185
|
+
safeExtend(incoming) {
|
|
5186
|
+
return safeExtend(this, incoming);
|
|
5187
|
+
},
|
|
5188
|
+
merge(other) {
|
|
5189
|
+
return merge(this, other);
|
|
5190
|
+
},
|
|
5191
|
+
pick(mask) {
|
|
5192
|
+
return pick(this, mask);
|
|
5193
|
+
},
|
|
5194
|
+
omit(mask) {
|
|
5195
|
+
return omit(this, mask);
|
|
5196
|
+
},
|
|
5197
|
+
partial(...args) {
|
|
5198
|
+
return partial(ZodOptional, this, args[0]);
|
|
5199
|
+
},
|
|
5200
|
+
exactPartial(...args) {
|
|
5201
|
+
return partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
5202
|
+
},
|
|
5203
|
+
required(...args) {
|
|
5204
|
+
return required(ZodNonOptional, this, args[0]);
|
|
5205
|
+
}
|
|
4070
5206
|
});
|
|
4071
5207
|
function object(shape, params) {
|
|
4072
5208
|
const def = {
|
|
@@ -4106,7 +5242,7 @@ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
4106
5242
|
ZodType.init(inst, def);
|
|
4107
5243
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
|
|
4108
5244
|
inst.enum = def.entries;
|
|
4109
|
-
inst.options =
|
|
5245
|
+
inst.options = [...inst._zod.values];
|
|
4110
5246
|
const keys = new Set(Object.keys(def.entries));
|
|
4111
5247
|
inst.extract = (values, params) => {
|
|
4112
5248
|
const newEntries = {};
|
|
@@ -4148,9 +5284,10 @@ function _enum(values, params) {
|
|
|
4148
5284
|
});
|
|
4149
5285
|
}
|
|
4150
5286
|
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
5287
|
+
_ensureDefaultMemoizer();
|
|
4151
5288
|
$ZodTransform.init(inst, def);
|
|
4152
5289
|
ZodType.init(inst, def);
|
|
4153
|
-
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
|
|
5290
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
4154
5291
|
inst._zod.parse = (payload, _ctx) => {
|
|
4155
5292
|
if (_ctx.direction === "backward") {
|
|
4156
5293
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -4163,7 +5300,8 @@ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) =>
|
|
|
4163
5300
|
if (_issue.fatal)
|
|
4164
5301
|
_issue.continue = false;
|
|
4165
5302
|
_issue.code ?? (_issue.code = "custom");
|
|
4166
|
-
|
|
5303
|
+
if (!("input" in _issue))
|
|
5304
|
+
_issue.input = payload.value;
|
|
4167
5305
|
_issue.inst ?? (_issue.inst = inst);
|
|
4168
5306
|
payload.issues.push(issue(_issue));
|
|
4169
5307
|
}
|
|
@@ -4172,12 +5310,10 @@ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) =>
|
|
|
4172
5310
|
if (output instanceof Promise) {
|
|
4173
5311
|
return output.then((output2) => {
|
|
4174
5312
|
payload.value = output2;
|
|
4175
|
-
payload.fallback = true;
|
|
4176
5313
|
return payload;
|
|
4177
5314
|
});
|
|
4178
5315
|
}
|
|
4179
5316
|
payload.value = output;
|
|
4180
|
-
payload.fallback = true;
|
|
4181
5317
|
return payload;
|
|
4182
5318
|
};
|
|
4183
5319
|
});
|
|
@@ -4278,7 +5414,7 @@ function _catch(innerType, catchValue) {
|
|
|
4278
5414
|
return new ZodCatch({
|
|
4279
5415
|
type: "catch",
|
|
4280
5416
|
innerType,
|
|
4281
|
-
catchValue: typeof catchValue === "function" ? catchValue : ()
|
|
5417
|
+
catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
|
|
4282
5418
|
});
|
|
4283
5419
|
}
|
|
4284
5420
|
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
@@ -4311,7 +5447,7 @@ function readonly(innerType) {
|
|
|
4311
5447
|
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
4312
5448
|
$ZodCustom.init(inst, def);
|
|
4313
5449
|
ZodType.init(inst, def);
|
|
4314
|
-
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
|
|
5450
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
4315
5451
|
});
|
|
4316
5452
|
function refine(fn, _params = {}) {
|
|
4317
5453
|
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|