@farm.js/core 0.1.38 → 0.1.40
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/dist/{agent-mcp-BwKlpnc7.d.mts → agent-mcp-DRlXq3lM.d.ts} +1 -1
- package/dist/{agent-mcp-De1imoMS.d.ts → agent-mcp-XNF4JqHw.d.mts} +1 -1
- package/dist/{agent-mcp-handler-OLRMZONF.mjs → agent-mcp-handler-HVV5LNXF.mjs} +6 -6
- package/dist/{agent-mcp-handler-MRGP3WJ3.cjs → agent-mcp-handler-YKG7KVCY.cjs} +7 -7
- package/dist/agent-runtime.cjs +10 -6
- package/dist/agent-runtime.d.mts +5 -7
- package/dist/agent-runtime.d.ts +5 -7
- package/dist/agent-runtime.mjs +9 -5
- package/dist/api/client.cjs +3 -3
- package/dist/api/client.d.mts +3 -3
- package/dist/api/client.d.ts +3 -3
- package/dist/api/client.mjs +2 -2
- package/dist/api/route-manager.cjs +15 -13
- package/dist/api/route-manager.d.mts +7 -9
- package/dist/api/route-manager.d.ts +7 -9
- package/dist/api/route-manager.mjs +14 -12
- package/dist/api/runtime.cjs +12 -10
- package/dist/api/runtime.d.mts +6 -8
- package/dist/api/runtime.d.ts +6 -8
- package/dist/api/runtime.mjs +11 -9
- package/dist/{api-client-CyFtZFJ4.d.ts → api-client-BJv9mTbO.d.ts} +2 -2
- package/dist/{api-client-BjMmY8OD.d.mts → api-client-Dk9QOLwr.d.mts} +2 -2
- package/dist/api.cjs +17 -15
- package/dist/api.d.mts +9 -11
- package/dist/api.d.ts +9 -11
- package/dist/api.mjs +16 -14
- package/dist/{app-kT_QXTdx.d.ts → app-CDJHPqZn.d.ts} +11 -4
- package/dist/{app-CFZt-srr.d.mts → app-CWjCklhF.d.mts} +11 -4
- package/dist/app-markdown.cjs +7 -6
- package/dist/app-markdown.d.mts +6 -8
- package/dist/app-markdown.d.ts +6 -8
- package/dist/app-markdown.mjs +6 -5
- package/dist/cache.cjs +6 -3
- package/dist/cache.d.mts +23 -2
- package/dist/cache.d.ts +23 -2
- package/dist/cache.mjs +5 -2
- package/dist/{chunk-3UEVPCGW.mjs → chunk-2DMWQWNJ.mjs} +6 -1
- package/dist/{chunk-ZXH4TS3F.cjs → chunk-2JG2LJDI.cjs} +3 -64
- package/dist/{chunk-QTXBII4Z.cjs → chunk-3TB5QGUW.cjs} +5 -5
- package/dist/chunk-45QJHGZM.cjs +1063 -0
- package/dist/{chunk-JCKYH4LG.mjs → chunk-45UZKX2J.mjs} +12 -44
- package/dist/{chunk-FUCSUGDM.cjs → chunk-4A3YUB4D.cjs} +3 -3
- package/dist/{chunk-FUZEBRP3.mjs → chunk-4GP3XZ4Z.mjs} +5 -3
- package/dist/chunk-4TLUFAIP.cjs +92 -0
- package/dist/chunk-4U5XZDLG.cjs +80 -0
- package/dist/{chunk-VXEEATVD.cjs → chunk-4XO5GSD6.cjs} +2 -2
- package/dist/{chunk-P664ZVTV.mjs → chunk-4ZZNPK25.mjs} +2 -2
- package/dist/{chunk-TGFQVLLF.cjs → chunk-54QWHSNR.cjs} +697 -422
- package/dist/{chunk-W36M2BQ4.mjs → chunk-5E65AL7P.mjs} +3 -3
- package/dist/{chunk-3LOLJTFV.cjs → chunk-5JEC43MQ.cjs} +11 -11
- package/dist/{chunk-INL3THCU.mjs → chunk-5LL6TKII.mjs} +1 -1
- package/dist/{chunk-KIIMAWOJ.cjs → chunk-5NAVKJCZ.cjs} +35 -105
- package/dist/{chunk-PGZDEPTM.cjs → chunk-5XS5NCVM.cjs} +10 -10
- package/dist/{chunk-HXRYZWTA.mjs → chunk-62DY5GKS.mjs} +3 -3
- package/dist/{chunk-LSKZMJMP.cjs → chunk-64SBBZDU.cjs} +38 -1
- package/dist/chunk-6BWKJ6QS.cjs +43 -0
- package/dist/{chunk-JSROZYYO.cjs → chunk-6D24SDKO.cjs} +1 -20
- package/dist/{chunk-EIPC3FDA.cjs → chunk-6ILGLCXF.cjs} +9 -5
- package/dist/chunk-6QOLZITB.cjs +22 -0
- package/dist/{chunk-CXEN47J3.mjs → chunk-73WX6PRY.mjs} +25 -0
- package/dist/{chunk-RW63BOV7.cjs → chunk-7FHZ3E6D.cjs} +2 -2
- package/dist/chunk-7GNWGLWB.mjs +14 -0
- package/dist/{chunk-34UCJRQO.cjs → chunk-7RNAKBWF.cjs} +2 -2
- package/dist/{chunk-MSSFIQGM.mjs → chunk-7VAJSSPG.mjs} +41 -10
- package/dist/{chunk-KHKLMNI5.mjs → chunk-ACLPN56I.mjs} +43 -25
- package/dist/{chunk-JCYYXBAJ.cjs → chunk-AGR7F3LA.cjs} +3 -3
- package/dist/{chunk-4GWRFP22.cjs → chunk-ALPWLT27.cjs} +35 -3
- package/dist/{chunk-IBUQWVYA.mjs → chunk-AX7S67YV.mjs} +43 -40
- package/dist/{chunk-CUM5NYL5.mjs → chunk-AXB5P7BK.mjs} +1 -1
- package/dist/{chunk-2ZYGC6SS.cjs → chunk-B6IMBBOS.cjs} +3 -3
- package/dist/{chunk-472NCAZ7.cjs → chunk-B77AUCBV.cjs} +3 -3
- package/dist/{chunk-FWE7LEQC.cjs → chunk-BD3D7EZV.cjs} +4 -4
- package/dist/{chunk-H5CLOUZS.cjs → chunk-BMOBTMDR.cjs} +5 -5
- package/dist/{chunk-CQMVIOYP.mjs → chunk-BPGO2IEP.mjs} +7 -7
- package/dist/{chunk-E2ROOWQC.cjs → chunk-BPOTSHDO.cjs} +24 -87
- package/dist/chunk-BRYPZIMB.mjs +6 -0
- package/dist/{chunk-WFRT7JPX.mjs → chunk-BYQVROIP.mjs} +2 -2
- package/dist/{chunk-HALDNTIV.mjs → chunk-BYR3RQPB.mjs} +10 -73
- package/dist/{chunk-IWZKTWHZ.cjs → chunk-CA62IQY3.cjs} +7 -2
- package/dist/chunk-CALY6QG6.mjs +963 -0
- package/dist/{chunk-WC5UV2HQ.cjs → chunk-CBXBGM72.cjs} +2 -2
- package/dist/{chunk-WW46B6HA.cjs → chunk-CGR525MJ.cjs} +84 -45
- package/dist/{chunk-6V4TDWEC.cjs → chunk-CGVPXIRN.cjs} +18 -1
- package/dist/{chunk-TYMMBFN2.mjs → chunk-CKFK3Z2V.mjs} +1 -1
- package/dist/chunk-CZS6OACQ.mjs +63 -0
- package/dist/{chunk-SGBJ247Q.cjs → chunk-D4ROBNTK.cjs} +2 -2
- package/dist/{chunk-WEW2JVA4.cjs → chunk-D5IHNDHI.cjs} +6 -6
- package/dist/{chunk-ULASELLA.cjs → chunk-DATEWH3W.cjs} +13 -1
- package/dist/{chunk-KKSTAEMY.cjs → chunk-DKU6NXRK.cjs} +1 -1
- package/dist/{chunk-NBBEQLOK.cjs → chunk-E55H6UKH.cjs} +9 -9
- package/dist/{chunk-YR2VBEMO.cjs → chunk-EGCT3AHF.cjs} +1455 -8187
- package/dist/{chunk-SDOTRX3V.cjs → chunk-EORXKFLR.cjs} +7 -7
- package/dist/{chunk-HD5CF3OE.mjs → chunk-ETPEZLS3.mjs} +2 -2
- package/dist/{chunk-2DD4JMQC.cjs → chunk-EW4MEVLE.cjs} +30 -30
- package/dist/{chunk-TUBTR2OP.mjs → chunk-FCOLU5P6.mjs} +1173 -7905
- package/dist/chunk-FGH3ZXTP.mjs +1063 -0
- package/dist/{chunk-Q3NXS4MU.cjs → chunk-FLZ4H25A.cjs} +44 -32
- package/dist/chunk-FVPXT2JR.cjs +63 -0
- package/dist/{chunk-D2ULAULS.cjs → chunk-FXFKIJDA.cjs} +9 -7
- package/dist/chunk-GC3EM6H4.mjs +80 -0
- package/dist/chunk-GKQL726H.cjs +6096 -0
- package/dist/{chunk-5PWXMJOH.cjs → chunk-GNVEJUT5.cjs} +36 -36
- package/dist/{chunk-E3UK5IIB.cjs → chunk-GS3WR5HX.cjs} +5 -3
- package/dist/{chunk-QFW2IH5E.mjs → chunk-GZTUT75U.mjs} +5 -2
- package/dist/chunk-H3EGVQE5.mjs +22 -0
- package/dist/{chunk-KCQBAKIY.cjs → chunk-H44XGLFU.cjs} +36 -68
- package/dist/{chunk-LI2F57NI.mjs → chunk-H56MQYEG.mjs} +1 -1
- package/dist/chunk-HANGSYMB.mjs +67 -0
- package/dist/{chunk-5BWWFHR2.mjs → chunk-HBEBV7OZ.mjs} +3 -3
- package/dist/{chunk-RSOJ7DRT.mjs → chunk-HCSVR4YZ.mjs} +1 -58
- package/dist/{chunk-HZFM2LWQ.mjs → chunk-HKFBMHCD.mjs} +34 -2
- package/dist/{chunk-MLY2RP5R.mjs → chunk-I63UCMXW.mjs} +6 -2
- package/dist/{chunk-TO4GJ56K.cjs → chunk-I64GEPOB.cjs} +58 -18
- package/dist/{chunk-VNGH5MLF.mjs → chunk-I6UVKUYK.mjs} +1 -1
- package/dist/{chunk-EPYU2EBL.mjs → chunk-IF4NU2NG.mjs} +1 -1
- package/dist/{chunk-IVLZZZEI.mjs → chunk-IM7DY3ED.mjs} +1 -1
- package/dist/{chunk-A3EAIURZ.mjs → chunk-IMQO6ZUU.mjs} +2 -2
- package/dist/{chunk-F5QO4FNE.mjs → chunk-INQ64HTJ.mjs} +43 -11
- package/dist/{chunk-XKVVMZP5.cjs → chunk-IRYK4Z5M.cjs} +4 -4
- package/dist/{chunk-UWPLULNK.mjs → chunk-JGHCKIRI.mjs} +84 -24
- package/dist/{chunk-7FPTZLKH.mjs → chunk-JIYYX7WU.mjs} +10 -8
- package/dist/{chunk-6MVFL3R5.cjs → chunk-JR4QCLJY.cjs} +1 -58
- package/dist/{chunk-Q2KB32T4.mjs → chunk-JXB6DVCO.mjs} +5 -5
- package/dist/{chunk-CGBDNNSM.cjs → chunk-KEXK442I.cjs} +44 -12
- package/dist/{chunk-5D2JIPLH.cjs → chunk-KK22JPQM.cjs} +10 -10
- package/dist/{chunk-EA5K5BKU.mjs → chunk-KNHBTJP6.mjs} +18 -1
- package/dist/{chunk-MVL2RAJW.mjs → chunk-KYN5ODF6.mjs} +1 -1
- package/dist/{chunk-TYJALEHQ.cjs → chunk-LDPKAYVS.cjs} +16 -16
- package/dist/chunk-LFHCG2DU.mjs +43 -0
- package/dist/{chunk-EK4QAEFZ.cjs → chunk-LZESP4IR.cjs} +25 -0
- package/dist/{chunk-FZ6YYU2W.mjs → chunk-MGMF4VP7.mjs} +38 -1
- package/dist/{chunk-EKF7KDFD.mjs → chunk-MNUSIXGS.mjs} +2 -2
- package/dist/{chunk-MYIZXDZA.mjs → chunk-MOSYH4CY.mjs} +1 -1
- package/dist/{chunk-4ZFL5GFN.cjs → chunk-OILHPMFX.cjs} +86 -26
- package/dist/{chunk-AJQTP4OO.mjs → chunk-OJ7JP7RJ.mjs} +1 -1
- package/dist/{chunk-7PEP3BUT.mjs → chunk-OLQ73ZO5.mjs} +2 -2
- package/dist/{chunk-5OKBARDN.cjs → chunk-OZN4XL6L.cjs} +10 -10
- package/dist/{chunk-T5OJPTVN.cjs → chunk-P4TYB4SF.cjs} +2 -2
- package/dist/chunk-P7XDC7UJ.mjs +92 -0
- package/dist/{chunk-4E5QXOCL.cjs → chunk-PGW7HZE2.cjs} +6 -6
- package/dist/{chunk-SHLXACIO.cjs → chunk-PJ42JESY.cjs} +1 -9
- package/dist/{chunk-U6QLDL3G.mjs → chunk-PNCM5MFD.mjs} +1 -1
- package/dist/{chunk-OAHTRMIC.mjs → chunk-PYQ3ZG4Z.mjs} +11 -11
- package/dist/{chunk-KMTGADN3.mjs → chunk-QCVIRVHE.mjs} +1 -9
- package/dist/{chunk-RWFLWR5J.cjs → chunk-QJM7A4CR.cjs} +17 -15
- package/dist/{chunk-VU6AAZVY.cjs → chunk-RHGK2JEN.cjs} +65 -62
- package/dist/{chunk-QV4VE2OW.mjs → chunk-S6ENKNNG.mjs} +5 -3
- package/dist/{chunk-EMO6K4YY.cjs → chunk-SHFXCE5A.cjs} +7 -7
- package/dist/{chunk-EKN7NSZO.cjs → chunk-SZLNU3GJ.cjs} +8 -5
- package/dist/{chunk-WLL43JMO.mjs → chunk-T36UJS3X.mjs} +7 -5
- package/dist/{chunk-CNNOLE4O.mjs → chunk-T4II4MMW.mjs} +1 -1
- package/dist/{chunk-B6G5CKMC.mjs → chunk-T6DLMX5V.mjs} +11 -11
- package/dist/{chunk-4IE345DM.cjs → chunk-TAKG7ZCD.cjs} +14 -14
- package/dist/{chunk-SKVTP5PR.mjs → chunk-TFX4RTH2.mjs} +1 -62
- package/dist/chunk-TI7UANHI.cjs +77 -0
- package/dist/{chunk-ND2CWPOD.mjs → chunk-TS4JHGUJ.mjs} +1 -1
- package/dist/{chunk-6BK3K2GB.mjs → chunk-UIDWEU7M.mjs} +83 -44
- package/dist/{chunk-DRLKAXDM.mjs → chunk-UM3ZV5EP.mjs} +2 -2
- package/dist/{chunk-YWN746US.cjs → chunk-UMQAK3KP.cjs} +85 -54
- package/dist/chunk-UNJZGVPU.cjs +6 -0
- package/dist/{chunk-XKG2BLFN.cjs → chunk-UXMIFB44.cjs} +18 -35
- package/dist/{chunk-DMEPTZTI.mjs → chunk-VBN3UAPQ.mjs} +47 -7
- package/dist/chunk-VDRM36QB.cjs +963 -0
- package/dist/{chunk-RG4A6LB2.cjs → chunk-VNPXKF3G.cjs} +7 -7
- package/dist/chunk-VQDBNVOO.cjs +14 -0
- package/dist/chunk-VQGKD7RV.mjs +25 -0
- package/dist/{chunk-6HB6V3R7.mjs → chunk-WCWV25PG.mjs} +10 -27
- package/dist/{chunk-ZMSZZXOR.mjs → chunk-WDMIW6Q6.mjs} +0 -19
- package/dist/{chunk-4WVJLURN.mjs → chunk-WMHG64DA.mjs} +1 -1
- package/dist/{chunk-L4DD7ODZ.cjs → chunk-WSOBCAYO.cjs} +37 -35
- package/dist/{chunk-ARC7I3O2.mjs → chunk-WW374SGU.mjs} +1 -1
- package/dist/{chunk-J63ZH5OQ.cjs → chunk-X3GMHKO3.cjs} +2 -2
- package/dist/{chunk-VT4WFRHA.mjs → chunk-XJAEZCT6.mjs} +1 -1
- package/dist/{chunk-OCIEZME4.mjs → chunk-XKIUHXHW.mjs} +618 -343
- package/dist/{chunk-6XWDE2P2.cjs → chunk-XVIEGKTT.cjs} +30 -5
- package/dist/{chunk-N32CC42M.cjs → chunk-Y2GNNXGV.cjs} +72 -54
- package/dist/{chunk-ZJD2PN6Z.mjs → chunk-Y4QVEU67.mjs} +30 -18
- package/dist/chunk-Y5RG6B7S.mjs +77 -0
- package/dist/{chunk-QRKIMN7T.mjs → chunk-Y6LRPO2K.mjs} +13 -1
- package/dist/{chunk-BZHXGVMA.mjs → chunk-YJBWB6GF.mjs} +5 -3
- package/dist/{chunk-WXJLNP33.cjs → chunk-YR2P74F7.cjs} +9 -7
- package/dist/chunk-YZAKIXRL.cjs +67 -0
- package/dist/chunk-ZKVJYQPO.mjs +6095 -0
- package/dist/{chunk-POSPE3IO.mjs → chunk-ZOABCQGT.mjs} +27 -2
- package/dist/chunk-ZQRCSUSB.cjs +25 -0
- package/dist/{chunk-ZMMBIVQM.mjs → chunk-ZZGQD7A4.mjs} +16 -86
- package/dist/{client-plugins-DUrIYX9B.d.mts → client-plugins-B_5QbNrp.d.mts} +2551 -2653
- package/dist/{client-plugins-BvlNhGEB.d.ts → client-plugins-DgSfIWIF.d.ts} +2551 -2653
- package/dist/client-plugins.d.mts +5 -7
- package/dist/client-plugins.d.ts +5 -7
- package/dist/client.cjs +7 -7
- package/dist/client.d.mts +11 -12
- package/dist/client.d.ts +11 -12
- package/dist/client.mjs +6 -6
- package/dist/config.d.mts +5 -7
- package/dist/config.d.ts +5 -7
- package/dist/{devtools-VQWJANJV.cjs → devtools-ANJ7JAPQ.cjs} +21 -18
- package/dist/{devtools-JYJNOLPQ.mjs → devtools-VEQQDVHE.mjs} +20 -17
- package/dist/docs.cjs +23 -20
- package/dist/docs.d.mts +6 -8
- package/dist/docs.d.ts +6 -8
- package/dist/docs.mjs +22 -19
- package/dist/{endpoint-CA-TNX60.d.ts → endpoint-BOE0IAaG.d.ts} +6 -3
- package/dist/{endpoint-CCHFqyTE.d.mts → endpoint-DGZRZHux.d.mts} +6 -3
- package/dist/environment/vite.cjs +6 -2
- package/dist/environment/vite.d.mts +11 -2
- package/dist/environment/vite.d.ts +11 -2
- package/dist/environment/vite.mjs +5 -1
- package/dist/headers.cjs +4 -4
- package/dist/headers.mjs +3 -3
- package/dist/image/server.cjs +7 -3
- package/dist/image/server.d.mts +9 -1
- package/dist/image/server.d.ts +9 -1
- package/dist/image/server.mjs +6 -2
- package/dist/image/sharp.cjs +12 -10
- package/dist/image/sharp.mjs +4 -2
- package/dist/index.cjs +89 -69
- package/dist/index.d.mts +27 -24
- package/dist/index.d.ts +27 -24
- package/dist/index.mjs +102 -82
- package/dist/{integration-api-BPJo5oXb.d.ts → integration-api-BuPHMeKz.d.ts} +2 -2
- package/dist/{integration-api-0y4FXJpC.d.mts → integration-api-DWyMmvrR.d.mts} +2 -2
- package/dist/integration-orm-P2II2EBK.cjs +14 -0
- package/dist/{integration-orm-KV5B3BGZ.mjs → integration-orm-RBKCIQYZ.mjs} +4 -3
- package/dist/integrations.cjs +7 -5
- package/dist/integrations.d.mts +7 -9
- package/dist/integrations.d.ts +7 -9
- package/dist/integrations.mjs +6 -4
- package/dist/internal/app-markdown-runtime.cjs +6 -5
- package/dist/internal/app-markdown-runtime.d.mts +6 -8
- package/dist/internal/app-markdown-runtime.d.ts +6 -8
- package/dist/internal/app-markdown-runtime.mjs +5 -4
- package/dist/internal/build-runtime.cjs +57 -56
- package/dist/internal/build-runtime.d.mts +7 -9
- package/dist/internal/build-runtime.d.ts +7 -9
- package/dist/internal/build-runtime.mjs +56 -55
- package/dist/internal/cli-runtime.cjs +36 -30
- package/dist/internal/cli-runtime.mjs +36 -30
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +5 -7
- package/dist/internal/compression-runtime.d.ts +5 -7
- package/dist/internal/config-runtime.cjs +21 -18
- package/dist/internal/config-runtime.d.mts +6 -8
- package/dist/internal/config-runtime.d.ts +6 -8
- package/dist/internal/config-runtime.mjs +20 -17
- package/dist/internal/docs-precompiled-runtime.cjs +3 -3
- package/dist/internal/docs-precompiled-runtime.mjs +2 -2
- package/dist/internal/infra-analytics-runtime.cjs +7 -7
- package/dist/internal/infra-analytics-runtime.mjs +5 -5
- package/dist/internal/metadata-image-runtime.cjs +4 -3
- package/dist/internal/metadata-image-runtime.mjs +3 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +2 -2
- package/dist/internal/production-node-env.mjs +1 -1
- package/dist/internal/production-runtime.cjs +47 -28
- package/dist/internal/production-runtime.d.mts +25 -14
- package/dist/internal/production-runtime.d.ts +25 -14
- package/dist/internal/production-runtime.mjs +50 -31
- package/dist/layers-CM5i6T7z.d.mts +55 -0
- package/dist/layers-CM5i6T7z.d.ts +55 -0
- package/dist/markdown.cjs +4 -4
- package/dist/markdown.d.mts +5 -7
- package/dist/markdown.d.ts +5 -7
- package/dist/markdown.mjs +3 -3
- package/dist/middleware.cjs +16 -10
- package/dist/middleware.d.mts +7 -9
- package/dist/middleware.d.ts +7 -9
- package/dist/middleware.mjs +19 -13
- package/dist/navigation.cjs +6 -6
- package/dist/navigation.d.mts +8 -9
- package/dist/navigation.d.ts +8 -9
- package/dist/navigation.mjs +5 -5
- package/dist/{nitro-MPZJGPXK.mjs → nitro-NFG2LBRC.mjs} +3 -2
- package/dist/{nitro-7F65EZZS.cjs → nitro-S2QABUFA.cjs} +4 -3
- package/dist/observability.cjs +2 -2
- package/dist/observability.mjs +1 -1
- package/dist/plugin-DBBZ4JI2.cjs +32 -0
- package/dist/plugin-SYMK7PQ2.mjs +32 -0
- package/dist/plugin.cjs +56 -43
- package/dist/plugin.d.mts +23 -7
- package/dist/plugin.d.ts +23 -7
- package/dist/plugin.mjs +57 -44
- package/dist/{production-runtime-D2aMyzjr.d.ts → production-runtime-DfknD3g_.d.ts} +17 -3
- package/dist/{production-runtime-BQ4_WLwQ.d.mts → production-runtime-j_WCfuwB.d.mts} +17 -3
- package/dist/programmatic-routes-client-DcoxEaLe.d.mts +55 -0
- package/dist/programmatic-routes-client-DcoxEaLe.d.ts +55 -0
- package/dist/query/client.cjs +8 -8
- package/dist/query/client.mjs +3 -3
- package/dist/{render-plan-25p4hrj4.d.ts → render-plan-CFIhcYYS.d.ts} +1 -1
- package/dist/{render-plan-DtkXMN8D.d.mts → render-plan-ChUtsymc.d.mts} +1 -1
- package/dist/renderer-client.cjs +5 -5
- package/dist/renderer-client.d.mts +7 -8
- package/dist/renderer-client.d.ts +7 -8
- package/dist/renderer-client.mjs +2 -2
- package/dist/{request-DgCkIdcn.d.mts → request-F4HRwzSd.d.mts} +1 -1
- package/dist/{request-jF4jwx8f.d.ts → request-RJvelT8L.d.ts} +1 -1
- package/dist/request.cjs +3 -3
- package/dist/request.d.mts +6 -8
- package/dist/request.d.ts +6 -8
- package/dist/request.mjs +2 -2
- package/dist/{route-rendering-Bji6S6a_.d.ts → route-rendering-3a4fbNyC.d.mts} +1 -1
- package/dist/{route-rendering-CSBF78Ya.d.mts → route-rendering-D4coJ-kw.d.ts} +1 -1
- package/dist/{router-B09Ui3Qm.d.mts → router-DqIssGRO.d.mts} +1 -1
- package/dist/{router-CPB9cXtG.d.ts → router-WLEW3Te1.d.ts} +1 -1
- package/dist/routes.cjs +6 -5
- package/dist/routes.d.mts +5 -7
- package/dist/routes.d.ts +5 -7
- package/dist/routes.mjs +5 -4
- package/dist/{runtime-EDMwLdjv.d.ts → runtime-BrNdLOq9.d.ts} +3 -3
- package/dist/{runtime-CM6E6yuI.d.mts → runtime-CmE_j-js.d.mts} +3 -3
- package/dist/{schema-dev-notice-Y7MQEFGN.cjs → schema-dev-notice-5JPE67AI.cjs} +6 -4
- package/dist/{schema-dev-notice-O67CPXJ6.mjs → schema-dev-notice-WLPZ6WKU.mjs} +4 -2
- package/dist/server-action-security.cjs +4 -3
- package/dist/server-action-security.mjs +3 -2
- package/dist/server-client-bridge-DKWDl5NB.d.mts +7 -0
- package/dist/server-client-bridge-DKWDl5NB.d.ts +7 -0
- package/dist/server-fn-client.d.mts +3 -3
- package/dist/server-fn-client.d.ts +3 -3
- package/dist/server-fn.cjs +8 -7
- package/dist/server-fn.d.mts +1 -1
- package/dist/server-fn.d.ts +1 -1
- package/dist/server-fn.mjs +7 -6
- package/dist/server-plugins.cjs +5 -5
- package/dist/server-plugins.d.mts +6 -8
- package/dist/server-plugins.d.ts +6 -8
- package/dist/server-plugins.mjs +4 -4
- package/dist/server-query-client.d.mts +1 -1
- package/dist/server-query-client.d.ts +1 -1
- package/dist/server-query.cjs +9 -8
- package/dist/server-query.d.mts +1 -1
- package/dist/server-query.d.ts +1 -1
- package/dist/server-query.mjs +8 -7
- package/dist/server.cjs +97 -73
- package/dist/server.d.mts +16 -12
- package/dist/server.d.ts +16 -12
- package/dist/server.mjs +82 -58
- package/dist/{spa-router-Cgimzfbi.d.mts → spa-router-C41zjnFl.d.mts} +2 -2
- package/dist/{spa-router-B_N8XgVu.d.ts → spa-router-D_0VXqPC.d.ts} +2 -2
- package/dist/storage.cjs +6 -2
- package/dist/storage.d.mts +9 -1
- package/dist/storage.d.ts +9 -1
- package/dist/storage.mjs +5 -1
- package/dist/testing.cjs +20 -18
- package/dist/testing.d.mts +6 -8
- package/dist/testing.d.ts +6 -8
- package/dist/testing.mjs +16 -14
- package/dist/theme/server.cjs +4 -4
- package/dist/theme/server.mjs +3 -3
- package/dist/{utils-DZciYXYl.d.mts → utils-BKWSe3S7.d.mts} +1 -1
- package/dist/{utils-BNxAKAuT.d.ts → utils-YYcWsOJp.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +58 -45
- package/dist/vite.d.mts +92 -10
- package/dist/vite.d.ts +92 -10
- package/dist/vite.mjs +59 -46
- package/dist/{workflows-jZ4BcdoZ.d.ts → workflows-IWP1ddBm.d.mts} +5 -2
- package/dist/{workflows-jZ4BcdoZ.d.mts → workflows-IWP1ddBm.d.ts} +5 -2
- package/dist/workflows.cjs +4 -3
- package/dist/workflows.d.mts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.mjs +3 -2
- package/package.json +2 -1
- package/dist/chunk-3SDFA7UF.cjs +0 -701
- package/dist/chunk-E5GNDG5F.mjs +0 -701
- package/dist/integration-orm-55F7CII5.cjs +0 -13
|
@@ -0,0 +1,1063 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk4U5XZDLGcjs = require('./chunk-4U5XZDLG.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk6D24SDKOcjs = require('./chunk-6D24SDKO.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkTI7UANHIcjs = require('./chunk-TI7UANHI.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkFVPXT2JRcjs = require('./chunk-FVPXT2JR.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunk6QOLZITBcjs = require('./chunk-6QOLZITB.cjs');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunk4TLUFAIPcjs = require('./chunk-4TLUFAIP.cjs');
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
38
|
+
|
|
39
|
+
// src/schema-step-types.ts
|
|
40
|
+
function validateSchemaSteps(owner, schema, steps) {
|
|
41
|
+
if (steps === void 0) return;
|
|
42
|
+
if (!Array.isArray(steps)) {
|
|
43
|
+
throw new TypeError(`${owner}: \`migrations\` must be a list of steps.`);
|
|
44
|
+
}
|
|
45
|
+
const models = _chunk6D24SDKOcjs.resolveSchemaModels.call(void 0, owner, schema);
|
|
46
|
+
const ids = /* @__PURE__ */ new Set();
|
|
47
|
+
for (const step of steps) {
|
|
48
|
+
const where = `${owner} migration "${_optionalChain([step, 'optionalAccess', _ => _.id])}"`;
|
|
49
|
+
if (!step || typeof step.id !== "string" || step.id.trim() === "") {
|
|
50
|
+
throw new TypeError(`${owner}: every migration step needs a non-empty \`id\`.`);
|
|
51
|
+
}
|
|
52
|
+
if (ids.has(step.id))
|
|
53
|
+
throw new Error(`${owner}: two migration steps share the id "${step.id}".`);
|
|
54
|
+
ids.add(step.id);
|
|
55
|
+
const kinds = ["renameColumn", "renameTable", "dropColumn", "dropTable", "sql"].filter(
|
|
56
|
+
(kind) => kind in step
|
|
57
|
+
);
|
|
58
|
+
if (kinds.length !== 1) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`${where} must be exactly one of renameColumn, renameTable, dropColumn, dropTable, or sql.`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if ("renameColumn" in step) {
|
|
64
|
+
const { model, from, to } = step.renameColumn;
|
|
65
|
+
const target = Object.prototype.hasOwnProperty.call(models, model) ? models[model] : void 0;
|
|
66
|
+
if (!target)
|
|
67
|
+
throw new Error(`${where} renames a column of "${model}", which is not a model.`);
|
|
68
|
+
if (!Object.prototype.hasOwnProperty.call(target.fields, to)) {
|
|
69
|
+
throw new Error(`${where} renames to "${model}.${to}", which is not a field.`);
|
|
70
|
+
}
|
|
71
|
+
if (typeof from !== "string" || from.trim() === "") {
|
|
72
|
+
throw new Error(`${where} needs the old column name in \`from\`.`);
|
|
73
|
+
}
|
|
74
|
+
} else if ("renameTable" in step) {
|
|
75
|
+
const { from, to } = step.renameTable;
|
|
76
|
+
if (!Object.prototype.hasOwnProperty.call(models, to)) {
|
|
77
|
+
throw new Error(`${where} renames a table to "${to}", which is not a model.`);
|
|
78
|
+
}
|
|
79
|
+
if (typeof from !== "string" || from.trim() === "") {
|
|
80
|
+
throw new Error(`${where} needs the old table name in \`from\`.`);
|
|
81
|
+
}
|
|
82
|
+
} else if ("dropColumn" in step) {
|
|
83
|
+
const { model, column } = step.dropColumn;
|
|
84
|
+
const target = Object.prototype.hasOwnProperty.call(models, model) ? models[model] : void 0;
|
|
85
|
+
if (!target) {
|
|
86
|
+
throw new Error(`${where} drops a column of "${model}", which is not a model.`);
|
|
87
|
+
}
|
|
88
|
+
if (typeof column !== "string" || column.trim() === "") {
|
|
89
|
+
throw new Error(`${where} needs the column to drop in \`column\`.`);
|
|
90
|
+
}
|
|
91
|
+
const current = Object.entries(target.fields).find(
|
|
92
|
+
([key, field]) => key === column || field.name === column
|
|
93
|
+
);
|
|
94
|
+
if (current) {
|
|
95
|
+
throw new Error(`${where} drops "${model}.${column}", which is still in the schema.`);
|
|
96
|
+
}
|
|
97
|
+
} else if ("dropTable" in step) {
|
|
98
|
+
const { table } = step.dropTable;
|
|
99
|
+
if (typeof table !== "string" || table.trim() === "") {
|
|
100
|
+
throw new Error(`${where} needs the table to drop in \`table\`.`);
|
|
101
|
+
}
|
|
102
|
+
const current = Object.entries(models).find(
|
|
103
|
+
([key, model]) => key === table || model.name === table
|
|
104
|
+
);
|
|
105
|
+
if (current) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`${where} drops "${table}", which is still in the schema${current[1].external ? " as a table the plugin does not own" : ""}.`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
const sql = step.sql;
|
|
112
|
+
const dialects = Object.keys(_nullishCoalesce(sql, () => ( {})));
|
|
113
|
+
if (!sql || typeof sql !== "object" || dialects.length === 0) {
|
|
114
|
+
throw new Error(`${where} needs SQL for at least one of postgres, mysql, or sqlite.`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateSchemaSteps, "validateSchemaSteps");
|
|
120
|
+
|
|
121
|
+
// src/plugin-options.ts
|
|
122
|
+
var _FarmPluginOptionsError = class _FarmPluginOptionsError extends TypeError {
|
|
123
|
+
constructor(issues) {
|
|
124
|
+
const lines = issues.map((issue) => {
|
|
125
|
+
const path = formatIssuePath(issue.path);
|
|
126
|
+
return ` - ${path ? `${path}: ` : ""}${issue.message}`;
|
|
127
|
+
});
|
|
128
|
+
super(`Invalid plugin options:
|
|
129
|
+
${lines.join("\n")}`);
|
|
130
|
+
this.name = "FarmPluginOptionsError";
|
|
131
|
+
this.issues = issues;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _FarmPluginOptionsError, "FarmPluginOptionsError");
|
|
135
|
+
var FarmPluginOptionsError = _FarmPluginOptionsError;
|
|
136
|
+
function formatIssuePath(path) {
|
|
137
|
+
if (!_optionalChain([path, 'optionalAccess', _2 => _2.length])) return "";
|
|
138
|
+
return path.map((segment) => {
|
|
139
|
+
const key = typeof segment === "object" && segment !== null ? segment.key : segment;
|
|
140
|
+
return typeof key === "symbol" ? key.toString() : String(key);
|
|
141
|
+
}).join(".");
|
|
142
|
+
}
|
|
143
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, formatIssuePath, "formatIssuePath");
|
|
144
|
+
function isPromiseLike(value) {
|
|
145
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
146
|
+
}
|
|
147
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPromiseLike, "isPromiseLike");
|
|
148
|
+
function isPluginOptionsSchema(value) {
|
|
149
|
+
if (typeof value !== "object" && typeof value !== "function" || value === null) return false;
|
|
150
|
+
const standard = value["~standard"];
|
|
151
|
+
return typeof _optionalChain([standard, 'optionalAccess', _3 => _3.validate]) === "function";
|
|
152
|
+
}
|
|
153
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPluginOptionsSchema, "isPluginOptionsSchema");
|
|
154
|
+
function parsePluginOptions(schema, options) {
|
|
155
|
+
const standard = _optionalChain([schema, 'optionalAccess', _4 => _4["~standard"]]);
|
|
156
|
+
if (!standard || typeof standard.validate !== "function") {
|
|
157
|
+
throw new TypeError(
|
|
158
|
+
"A plugin's `options` needs a Standard Schema, such as a Zod, Valibot, or ArkType schema."
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const result = standard.validate(options === void 0 ? {} : options);
|
|
162
|
+
if (isPromiseLike(result)) {
|
|
163
|
+
throw new TypeError(
|
|
164
|
+
"Plugin option schemas must validate synchronously: plugins are created while the config loads. Remove asynchronous refinements or transforms from the schema."
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
if (result.issues) throw new FarmPluginOptionsError(result.issues);
|
|
168
|
+
return result.value;
|
|
169
|
+
}
|
|
170
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, parsePluginOptions, "parsePluginOptions");
|
|
171
|
+
|
|
172
|
+
// src/plugin.ts
|
|
173
|
+
var FARM_NODE_RESPONSE_END_PENDING = /* @__PURE__ */ Symbol.for("farm.nodeResponseEndPending");
|
|
174
|
+
var _FarmRuntimeShutdownError = class _FarmRuntimeShutdownError extends Error {
|
|
175
|
+
constructor(message, errors) {
|
|
176
|
+
super(message);
|
|
177
|
+
this.name = "FarmRuntimeShutdownError";
|
|
178
|
+
this.errors = errors;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _FarmRuntimeShutdownError, "FarmRuntimeShutdownError");
|
|
182
|
+
var FarmRuntimeShutdownError = _FarmRuntimeShutdownError;
|
|
183
|
+
var _PluginManager = class _PluginManager {
|
|
184
|
+
constructor(context) {
|
|
185
|
+
this.plugins = [];
|
|
186
|
+
this.hookPresence = /* @__PURE__ */ new Map();
|
|
187
|
+
this.runtimeHookPresence = /* @__PURE__ */ new Map();
|
|
188
|
+
this.pluginStates = /* @__PURE__ */ new Map();
|
|
189
|
+
this.setupComplete = false;
|
|
190
|
+
this.initialized = false;
|
|
191
|
+
this.runtimeReady = false;
|
|
192
|
+
this.runtimeClosed = false;
|
|
193
|
+
this.runtimeShutdownHooksRunning = false;
|
|
194
|
+
this.runtimeDisposers = [];
|
|
195
|
+
this.runtimeRequestContexts = /* @__PURE__ */ new WeakMap();
|
|
196
|
+
this.failedRuntimeSessions = /* @__PURE__ */ new WeakSet();
|
|
197
|
+
this.context = {
|
|
198
|
+
...context,
|
|
199
|
+
lifecycle: {
|
|
200
|
+
onShutdown: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (dispose) => {
|
|
201
|
+
if (typeof dispose !== "function") {
|
|
202
|
+
throw new TypeError("Farm lifecycle.onShutdown requires a cleanup function");
|
|
203
|
+
}
|
|
204
|
+
if (this.runtimeClosed) {
|
|
205
|
+
void (async () => {
|
|
206
|
+
try {
|
|
207
|
+
await dispose();
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error("Farm runtime cleanup registered after shutdown failed:", error);
|
|
210
|
+
}
|
|
211
|
+
})();
|
|
212
|
+
return () => {
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
this.runtimeDisposers.push(dispose);
|
|
216
|
+
let registered = true;
|
|
217
|
+
return () => {
|
|
218
|
+
if (!registered) return;
|
|
219
|
+
registered = false;
|
|
220
|
+
const index = this.runtimeDisposers.indexOf(dispose);
|
|
221
|
+
if (index >= 0) this.runtimeDisposers.splice(index, 1);
|
|
222
|
+
};
|
|
223
|
+
}, "onShutdown")
|
|
224
|
+
},
|
|
225
|
+
requestContext: {
|
|
226
|
+
set(target, key, value, options) {
|
|
227
|
+
_chunk4TLUFAIPcjs.setRequestContext.call(void 0, target, key, value, options);
|
|
228
|
+
},
|
|
229
|
+
get(target, key) {
|
|
230
|
+
return _chunk4TLUFAIPcjs.getRequestContext.call(void 0, target, key);
|
|
231
|
+
},
|
|
232
|
+
has(target, key) {
|
|
233
|
+
return _chunk4TLUFAIPcjs.hasRequestContext.call(void 0, target, key);
|
|
234
|
+
},
|
|
235
|
+
delete(target, key) {
|
|
236
|
+
return _chunk4TLUFAIPcjs.deleteRequestContext.call(void 0, target, key);
|
|
237
|
+
},
|
|
238
|
+
clear(target) {
|
|
239
|
+
_chunk4TLUFAIPcjs.clearRequestContext.call(void 0, target);
|
|
240
|
+
},
|
|
241
|
+
getAll(target, options) {
|
|
242
|
+
return _chunk4TLUFAIPcjs.getRequestContextSnapshot.call(void 0, target, options);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
createPluginHookContext(plugin, context = this.context) {
|
|
248
|
+
const integration = _chunk6QOLZITBcjs.getFarmPluginIntegrationContext.call(void 0, plugin);
|
|
249
|
+
return integration ? { ...context, integration } : context;
|
|
250
|
+
}
|
|
251
|
+
createRequestHookContext(target, plugin) {
|
|
252
|
+
const requestContext = this.context.requestContext;
|
|
253
|
+
return {
|
|
254
|
+
...this.createPluginHookContext(plugin),
|
|
255
|
+
req: {
|
|
256
|
+
set(key, value, options) {
|
|
257
|
+
requestContext.set(target, key, value, options);
|
|
258
|
+
},
|
|
259
|
+
get(key) {
|
|
260
|
+
return requestContext.get(target, key);
|
|
261
|
+
},
|
|
262
|
+
has(key) {
|
|
263
|
+
return requestContext.has(target, key);
|
|
264
|
+
},
|
|
265
|
+
delete(key) {
|
|
266
|
+
return requestContext.delete(target, key);
|
|
267
|
+
},
|
|
268
|
+
clear() {
|
|
269
|
+
requestContext.clear(target);
|
|
270
|
+
},
|
|
271
|
+
snapshot(options) {
|
|
272
|
+
return requestContext.getAll(target, options);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
copyRequestStore(source, target) {
|
|
278
|
+
_chunk4TLUFAIPcjs.copyRequestContext.call(void 0, source, target);
|
|
279
|
+
}
|
|
280
|
+
copyRuntimeRequestContext(source, target) {
|
|
281
|
+
const runtimeContext = this.runtimeRequestContexts.get(source);
|
|
282
|
+
if (runtimeContext) {
|
|
283
|
+
this.runtimeRequestContexts.set(target, runtimeContext);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
createRuntimeBaseEvent(plugin, request, options, waitUntil) {
|
|
287
|
+
return {
|
|
288
|
+
...this.createStateHookContext(plugin),
|
|
289
|
+
request,
|
|
290
|
+
req: this.createRequestHookContext(request, plugin).req,
|
|
291
|
+
kind: _nullishCoalesce(options.kind, () => ( "request")),
|
|
292
|
+
route: options.route,
|
|
293
|
+
signal: request.signal,
|
|
294
|
+
waitUntil
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
getRuntimeEndpoints() {
|
|
298
|
+
if (this.runtimeEndpoints) return this.runtimeEndpoints;
|
|
299
|
+
const endpoints = [];
|
|
300
|
+
const owners = /* @__PURE__ */ new Map();
|
|
301
|
+
for (const plugin of this.getSortedPlugins()) {
|
|
302
|
+
const configured = _optionalChain([plugin, 'access', _5 => _5.runtime, 'optionalAccess', _6 => _6.endpoints]);
|
|
303
|
+
if (configured === void 0) continue;
|
|
304
|
+
if (!Array.isArray(configured)) {
|
|
305
|
+
throw new TypeError(`Farm plugin "${plugin.name}" runtime.endpoints must be an array`);
|
|
306
|
+
}
|
|
307
|
+
for (const endpoint of configured) {
|
|
308
|
+
if (!endpoint || typeof endpoint !== "object") {
|
|
309
|
+
throw new TypeError(
|
|
310
|
+
`Farm plugin "${plugin.name}" runtime.endpoints must contain endpoint objects`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
const path = _chunkTI7UANHIcjs.normalizeFarmPluginRuntimeEndpointPath.call(void 0,
|
|
314
|
+
endpoint.path,
|
|
315
|
+
`Farm plugin "${plugin.name}" runtime endpoint`
|
|
316
|
+
);
|
|
317
|
+
if (typeof endpoint.handler !== "function") {
|
|
318
|
+
throw new TypeError(
|
|
319
|
+
`Farm plugin "${plugin.name}" runtime endpoint ${path} requires a handler`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
const owner = owners.get(path);
|
|
323
|
+
if (owner) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`Farm plugin runtime endpoint ${path} from "${plugin.name}" conflicts with "${owner}"`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
owners.set(path, plugin.name);
|
|
329
|
+
endpoints.push({ plugin, endpoint, path });
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
this.runtimeEndpoints = endpoints;
|
|
333
|
+
return endpoints;
|
|
334
|
+
}
|
|
335
|
+
async runRuntimeEndpoint(request, options, waitUntil, onMatch) {
|
|
336
|
+
const endpoints = this.getRuntimeEndpoints();
|
|
337
|
+
if (endpoints.length === 0) return void 0;
|
|
338
|
+
const requestPathname = new URL(request.url).pathname;
|
|
339
|
+
const basePath = _chunkI57LW5VZcjs.normalizeFarmBasePath.call(void 0, this.context.config.basePath);
|
|
340
|
+
if (basePath && requestPathname !== basePath && !requestPathname.startsWith(`${basePath}/`)) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const pathname = _chunkTI7UANHIcjs.normalizeRuntimeEndpointRequestPath.call(void 0,
|
|
344
|
+
_chunkI57LW5VZcjs.stripFarmBasePath.call(void 0, requestPathname, basePath)
|
|
345
|
+
);
|
|
346
|
+
const match = endpoints.find((entry) => entry.path === pathname);
|
|
347
|
+
if (!match) return void 0;
|
|
348
|
+
const endpointOptions = {
|
|
349
|
+
...options,
|
|
350
|
+
kind: "endpoint",
|
|
351
|
+
route: {
|
|
352
|
+
pathname: requestPathname,
|
|
353
|
+
pattern: match.path,
|
|
354
|
+
params: {}
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
onMatch(endpointOptions);
|
|
358
|
+
const response = await match.endpoint.handler({
|
|
359
|
+
...this.createRuntimeBaseEvent(match.plugin, request, endpointOptions, waitUntil),
|
|
360
|
+
path: match.path
|
|
361
|
+
});
|
|
362
|
+
if (!(response instanceof Response)) {
|
|
363
|
+
throw new TypeError(
|
|
364
|
+
`Farm plugin "${match.plugin.name}" runtime endpoint ${match.path} must return a Response`
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
return response;
|
|
368
|
+
}
|
|
369
|
+
async createRuntimeRequestContext(request, options, waitUntil) {
|
|
370
|
+
const values = {};
|
|
371
|
+
const owners = /* @__PURE__ */ new Map();
|
|
372
|
+
for (const plugin of this.getSortedPlugins()) {
|
|
373
|
+
const createContext = _optionalChain([plugin, 'access', _7 => _7.runtime, 'optionalAccess', _8 => _8.context]);
|
|
374
|
+
if (!createContext) continue;
|
|
375
|
+
const result = await createContext(
|
|
376
|
+
this.createRuntimeBaseEvent(plugin, request, options, waitUntil)
|
|
377
|
+
);
|
|
378
|
+
if (result === void 0) continue;
|
|
379
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) {
|
|
380
|
+
throw new TypeError(`Farm plugin "${plugin.name}" runtime.context must return an object`);
|
|
381
|
+
}
|
|
382
|
+
for (const [key, value] of Object.entries(result)) {
|
|
383
|
+
const owner = owners.get(key);
|
|
384
|
+
if (owner) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
`Farm plugin context key "${key}" from "${plugin.name}" conflicts with "${owner}"`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
owners.set(key, plugin.name);
|
|
390
|
+
values[key] = value;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const runtimeContext = Object.freeze(values);
|
|
394
|
+
this.runtimeRequestContexts.set(request, runtimeContext);
|
|
395
|
+
return runtimeContext;
|
|
396
|
+
}
|
|
397
|
+
async runRuntimeErrorHooks(request, error, ctx, durationMs, options, waitUntil) {
|
|
398
|
+
for (const plugin of this.getSortedPlugins()) {
|
|
399
|
+
const onError = _optionalChain([plugin, 'access', _9 => _9.runtime, 'optionalAccess', _10 => _10.error]);
|
|
400
|
+
if (!onError) continue;
|
|
401
|
+
try {
|
|
402
|
+
await onError({
|
|
403
|
+
...this.createRuntimeBaseEvent(plugin, request, options, waitUntil),
|
|
404
|
+
ctx,
|
|
405
|
+
error,
|
|
406
|
+
durationMs
|
|
407
|
+
});
|
|
408
|
+
} catch (hookError) {
|
|
409
|
+
console.error(`Farm plugin "${plugin.name}" runtime.error failed:`, hookError);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
await this.runHookParallel("onError", {
|
|
414
|
+
phase: "runtime",
|
|
415
|
+
error,
|
|
416
|
+
meta: {
|
|
417
|
+
kind: _nullishCoalesce(options.kind, () => ( "request")),
|
|
418
|
+
pathname: new URL(request.url).pathname,
|
|
419
|
+
durationMs
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
} catch (hookError) {
|
|
423
|
+
console.error("Farm plugin onError hook failed:", hookError);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
createStateHookContext(plugin, context = this.context) {
|
|
427
|
+
return {
|
|
428
|
+
...this.createPluginHookContext(plugin, context),
|
|
429
|
+
state: this.pluginStates.get(plugin)
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
getPluginHooks(plugin, hookName) {
|
|
433
|
+
const hooks = [];
|
|
434
|
+
const legacyHook = plugin[hookName];
|
|
435
|
+
if (typeof legacyHook === "function") {
|
|
436
|
+
hooks.push(legacyHook);
|
|
437
|
+
}
|
|
438
|
+
const withState = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (context) => this.createStateHookContext(plugin, context), "withState");
|
|
439
|
+
switch (hookName) {
|
|
440
|
+
case "config":
|
|
441
|
+
if (plugin.configure) {
|
|
442
|
+
hooks.push(
|
|
443
|
+
(config, context) => _optionalChain([plugin, 'access', _11 => _11.configure, 'optionalCall', _12 => _12(config, context)])
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
break;
|
|
447
|
+
case "ready":
|
|
448
|
+
if (_optionalChain([plugin, 'access', _13 => _13.runtime, 'optionalAccess', _14 => _14.start])) {
|
|
449
|
+
hooks.push((context) => _optionalChain([plugin, 'access', _15 => _15.runtime, 'optionalAccess', _16 => _16.start, 'optionalCall', _17 => _17(withState(context))]));
|
|
450
|
+
}
|
|
451
|
+
break;
|
|
452
|
+
case "shutdown":
|
|
453
|
+
if (_optionalChain([plugin, 'access', _18 => _18.runtime, 'optionalAccess', _19 => _19.close])) {
|
|
454
|
+
hooks.push(
|
|
455
|
+
(payload, context) => _optionalChain([plugin, 'access', _20 => _20.runtime, 'optionalAccess', _21 => _21.close, 'optionalCall', _22 => _22({
|
|
456
|
+
...withState(context),
|
|
457
|
+
reason: payload.reason
|
|
458
|
+
})])
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
break;
|
|
462
|
+
case "routeDiscovered":
|
|
463
|
+
if (_optionalChain([plugin, 'access', _23 => _23.router, 'optionalAccess', _24 => _24.discovered])) {
|
|
464
|
+
hooks.push(
|
|
465
|
+
(route, context) => _optionalChain([plugin, 'access', _25 => _25.router, 'optionalAccess', _26 => _26.discovered, 'optionalCall', _27 => _27(route, withState(context))])
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
break;
|
|
469
|
+
case "middlewareDiscovered":
|
|
470
|
+
if (_optionalChain([plugin, 'access', _28 => _28.router, 'optionalAccess', _29 => _29.discovered])) {
|
|
471
|
+
hooks.push(
|
|
472
|
+
(route, context) => _optionalChain([plugin, 'access', _30 => _30.router, 'optionalAccess', _31 => _31.discovered, 'optionalCall', _32 => _32({ kind: "middleware", ...route }, withState(context))])
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
break;
|
|
476
|
+
case "apiRouteDiscovered":
|
|
477
|
+
if (_optionalChain([plugin, 'access', _33 => _33.router, 'optionalAccess', _34 => _34.discovered])) {
|
|
478
|
+
hooks.push(
|
|
479
|
+
(route, context) => _optionalChain([plugin, 'access', _35 => _35.router, 'optionalAccess', _36 => _36.discovered, 'optionalCall', _37 => _37({ kind: "api", ...route }, withState(context))])
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
case "routesGenerated":
|
|
484
|
+
if (_optionalChain([plugin, 'access', _38 => _38.router, 'optionalAccess', _39 => _39.generated])) {
|
|
485
|
+
hooks.push(
|
|
486
|
+
(routes, context) => _optionalChain([plugin, 'access', _40 => _40.router, 'optionalAccess', _41 => _41.generated, 'optionalCall', _42 => _42(routes, withState(context))])
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
break;
|
|
490
|
+
case "beforeRouteMatch":
|
|
491
|
+
if (_optionalChain([plugin, 'access', _43 => _43.router, 'optionalAccess', _44 => _44.before])) {
|
|
492
|
+
hooks.push(
|
|
493
|
+
(route, context) => _optionalChain([plugin, 'access', _45 => _45.router, 'optionalAccess', _46 => _46.before, 'optionalCall', _47 => _47(route, withState(context))])
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
break;
|
|
497
|
+
case "afterRouteMatch":
|
|
498
|
+
if (_optionalChain([plugin, 'access', _48 => _48.router, 'optionalAccess', _49 => _49.after])) {
|
|
499
|
+
hooks.push(
|
|
500
|
+
(result, context) => _optionalChain([plugin, 'access', _50 => _50.router, 'optionalAccess', _51 => _51.after, 'optionalCall', _52 => _52(result, withState(context))])
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
break;
|
|
504
|
+
case "beforeRender":
|
|
505
|
+
if (_optionalChain([plugin, 'access', _53 => _53.render, 'optionalAccess', _54 => _54.before])) {
|
|
506
|
+
hooks.push(
|
|
507
|
+
(render, context) => _optionalChain([plugin, 'access', _55 => _55.render, 'optionalAccess', _56 => _56.before, 'optionalCall', _57 => _57(render, withState(context))])
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
break;
|
|
511
|
+
case "afterRender":
|
|
512
|
+
if (_optionalChain([plugin, 'access', _58 => _58.render, 'optionalAccess', _59 => _59.html])) {
|
|
513
|
+
hooks.push(
|
|
514
|
+
(html, render, context) => _optionalChain([plugin, 'access', _60 => _60.render, 'optionalAccess', _61 => _61.html, 'optionalCall', _62 => _62(html, render, withState(context))])
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
break;
|
|
518
|
+
case "beforeBundle":
|
|
519
|
+
if (_optionalChain([plugin, 'access', _63 => _63.build, 'optionalAccess', _64 => _64.before])) {
|
|
520
|
+
hooks.push(
|
|
521
|
+
(bundle, context) => _optionalChain([plugin, 'access', _65 => _65.build, 'optionalAccess', _66 => _66.before, 'optionalCall', _67 => _67(bundle, withState(context))])
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
case "beforeNitroBuild":
|
|
526
|
+
if (_optionalChain([plugin, 'access', _68 => _68.build, 'optionalAccess', _69 => _69.configure])) {
|
|
527
|
+
hooks.push(
|
|
528
|
+
(buildConfig, context) => _optionalChain([plugin, 'access', _70 => _70.build, 'optionalAccess', _71 => _71.configure, 'optionalCall', _72 => _72(buildConfig, withState(context))])
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
break;
|
|
532
|
+
case "afterBundle":
|
|
533
|
+
if (_optionalChain([plugin, 'access', _73 => _73.build, 'optionalAccess', _74 => _74.after])) {
|
|
534
|
+
hooks.push(
|
|
535
|
+
(result, context) => _optionalChain([plugin, 'access', _75 => _75.build, 'optionalAccess', _76 => _76.after, 'optionalCall', _77 => _77(result, withState(context))])
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
break;
|
|
539
|
+
case "devServerCreated":
|
|
540
|
+
if (_optionalChain([plugin, 'access', _78 => _78.dev, 'optionalAccess', _79 => _79.server])) {
|
|
541
|
+
hooks.push(
|
|
542
|
+
(server, context) => _optionalChain([plugin, 'access', _80 => _80.dev, 'optionalAccess', _81 => _81.server, 'optionalCall', _82 => _82(server, withState(context))])
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
break;
|
|
546
|
+
case "hmrUpdate":
|
|
547
|
+
if (_optionalChain([plugin, 'access', _83 => _83.dev, 'optionalAccess', _84 => _84.update])) {
|
|
548
|
+
hooks.push(
|
|
549
|
+
(update, context) => _optionalChain([plugin, 'access', _85 => _85.dev, 'optionalAccess', _86 => _86.update, 'optionalCall', _87 => _87(update, withState(context))])
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
return hooks;
|
|
555
|
+
}
|
|
556
|
+
getHookContext(plugin, hookName, args) {
|
|
557
|
+
if (hookName === "beforeRequest" || hookName === "afterResponse" || hookName === "beforeApiHandler") {
|
|
558
|
+
const target = args[0];
|
|
559
|
+
if (target && typeof target === "object") {
|
|
560
|
+
return this.createRequestHookContext(target, plugin);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return this.createPluginHookContext(plugin);
|
|
564
|
+
}
|
|
565
|
+
addPlugin(plugin) {
|
|
566
|
+
this.plugins.push(plugin);
|
|
567
|
+
this.hookPresence.clear();
|
|
568
|
+
this.runtimeHookPresence.clear();
|
|
569
|
+
this.runtimeEndpoints = void 0;
|
|
570
|
+
}
|
|
571
|
+
addPlugins(plugins) {
|
|
572
|
+
for (const plugin of plugins) {
|
|
573
|
+
this.addPlugin(plugin);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
getPlugins() {
|
|
577
|
+
return [...this.plugins];
|
|
578
|
+
}
|
|
579
|
+
getSortedPlugins() {
|
|
580
|
+
const pre = this.plugins.filter((p) => p.enforce === "pre");
|
|
581
|
+
const normal = this.plugins.filter((p) => !p.enforce);
|
|
582
|
+
const post = this.plugins.filter((p) => p.enforce === "post");
|
|
583
|
+
return [...pre, ...normal, ...post];
|
|
584
|
+
}
|
|
585
|
+
hasHook(hookName) {
|
|
586
|
+
const cached = this.hookPresence.get(hookName);
|
|
587
|
+
if (cached !== void 0) return cached;
|
|
588
|
+
const present = this.plugins.some((plugin) => this.getPluginHooks(plugin, hookName).length > 0);
|
|
589
|
+
this.hookPresence.set(hookName, present);
|
|
590
|
+
return present;
|
|
591
|
+
}
|
|
592
|
+
hasRuntimeHook(hookName) {
|
|
593
|
+
const cached = this.runtimeHookPresence.get(hookName);
|
|
594
|
+
if (cached !== void 0) return cached;
|
|
595
|
+
const present = this.plugins.some((plugin) => typeof _optionalChain([plugin, 'access', _88 => _88.runtime, 'optionalAccess', _89 => _89[hookName]]) === "function");
|
|
596
|
+
this.runtimeHookPresence.set(hookName, present);
|
|
597
|
+
return present;
|
|
598
|
+
}
|
|
599
|
+
hasRuntimeRequestHooks() {
|
|
600
|
+
return this.getRuntimeEndpoints().length > 0 || this.hasRuntimeHook("context") || this.hasRuntimeHook("before") || this.hasRuntimeHook("after") || this.hasRuntimeHook("error");
|
|
601
|
+
}
|
|
602
|
+
copyRequestContext(source, target) {
|
|
603
|
+
this.copyRequestStore(source, target);
|
|
604
|
+
if (source instanceof Request && target instanceof Request) {
|
|
605
|
+
this.copyRuntimeRequestContext(source, target);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
async setupPlugins() {
|
|
609
|
+
if (this.setupComplete) return;
|
|
610
|
+
for (const plugin of this.getSortedPlugins()) {
|
|
611
|
+
if (!plugin.setup) continue;
|
|
612
|
+
const state = await plugin.setup({
|
|
613
|
+
...this.createPluginHookContext(plugin),
|
|
614
|
+
env: _chunkVEKFLAQMcjs.getResolvedEnv.call(void 0, )
|
|
615
|
+
});
|
|
616
|
+
this.pluginStates.set(plugin, state);
|
|
617
|
+
}
|
|
618
|
+
this.setupComplete = true;
|
|
619
|
+
}
|
|
620
|
+
async startRuntime() {
|
|
621
|
+
if (this.runtimeReady) return;
|
|
622
|
+
if (this.runtimeStartPromise) return this.runtimeStartPromise;
|
|
623
|
+
this.runtimeStartPromise = (async () => {
|
|
624
|
+
this.getRuntimeEndpoints();
|
|
625
|
+
if (!this.initialized) {
|
|
626
|
+
await this.runHookParallel("init");
|
|
627
|
+
}
|
|
628
|
+
await this.setupPlugins();
|
|
629
|
+
if (!this.runtimeReady) {
|
|
630
|
+
await this.runHookParallel("ready");
|
|
631
|
+
}
|
|
632
|
+
})();
|
|
633
|
+
try {
|
|
634
|
+
await this.runtimeStartPromise;
|
|
635
|
+
} catch (error) {
|
|
636
|
+
this.runtimeStartPromise = void 0;
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async closeRuntime(reason = "runtime-closed") {
|
|
641
|
+
if (this.runtimeClosePromise) return this.runtimeClosePromise;
|
|
642
|
+
if (this.runtimeClosed) return;
|
|
643
|
+
this.runtimeClosePromise = (async () => {
|
|
644
|
+
const errors = [];
|
|
645
|
+
this.runtimeShutdownHooksRunning = true;
|
|
646
|
+
try {
|
|
647
|
+
await this.runHookParallel("shutdown", { reason });
|
|
648
|
+
} catch (error) {
|
|
649
|
+
if (error instanceof FarmRuntimeShutdownError) errors.push(...error.errors);
|
|
650
|
+
else errors.push(error);
|
|
651
|
+
} finally {
|
|
652
|
+
this.runtimeShutdownHooksRunning = false;
|
|
653
|
+
}
|
|
654
|
+
while (this.runtimeDisposers.length > 0) {
|
|
655
|
+
const batch = this.runtimeDisposers.splice(0).reverse();
|
|
656
|
+
for (const dispose of batch) {
|
|
657
|
+
try {
|
|
658
|
+
await dispose();
|
|
659
|
+
} catch (error) {
|
|
660
|
+
errors.push(error);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
this.runtimeClosed = true;
|
|
665
|
+
if (errors.length > 0) {
|
|
666
|
+
throw new FarmRuntimeShutdownError("Farm runtime shutdown failed", errors);
|
|
667
|
+
}
|
|
668
|
+
})();
|
|
669
|
+
return this.runtimeClosePromise;
|
|
670
|
+
}
|
|
671
|
+
async runBeforeHooks(request, options, waitUntil, ctx) {
|
|
672
|
+
let activeRequest = request;
|
|
673
|
+
for (const plugin of this.getSortedPlugins()) {
|
|
674
|
+
const before = _optionalChain([plugin, 'access', _90 => _90.runtime, 'optionalAccess', _91 => _91.before]);
|
|
675
|
+
if (!before) continue;
|
|
676
|
+
const result = await before({
|
|
677
|
+
...this.createRuntimeBaseEvent(plugin, activeRequest, options, waitUntil),
|
|
678
|
+
ctx
|
|
679
|
+
});
|
|
680
|
+
if (result instanceof Request) {
|
|
681
|
+
this.copyRequestStore(activeRequest, result);
|
|
682
|
+
this.copyRuntimeRequestContext(activeRequest, result);
|
|
683
|
+
activeRequest = result;
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
if (result instanceof Response) {
|
|
687
|
+
return { request: activeRequest, response: result };
|
|
688
|
+
}
|
|
689
|
+
if (result !== void 0) {
|
|
690
|
+
throw new TypeError(
|
|
691
|
+
`Farm plugin "${plugin.name}" runtime.before must return a Request, Response, or undefined`
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return { request: activeRequest };
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Runs only `runtime.before` for a request Farm re-routed internally, such as
|
|
699
|
+
* a configured rewrite, so guards also see the destination URL. The session
|
|
700
|
+
* opened for `source` keeps its context; context and after hooks don't rerun.
|
|
701
|
+
*/
|
|
702
|
+
async runRuntimeBeforeForRewrite(source, request, options = {}) {
|
|
703
|
+
if (!this.hasRuntimeHook("before")) return request;
|
|
704
|
+
this.copyRequestContext(source, request);
|
|
705
|
+
const waitUntil = options.waitUntil ? (promise) => _optionalChain([options, 'access', _92 => _92.waitUntil, 'optionalCall', _93 => _93(Promise.resolve(promise))]) : (promise) => {
|
|
706
|
+
void Promise.resolve(promise).catch(() => {
|
|
707
|
+
});
|
|
708
|
+
};
|
|
709
|
+
const result = await this.runBeforeHooks(
|
|
710
|
+
request,
|
|
711
|
+
options,
|
|
712
|
+
waitUntil,
|
|
713
|
+
_nullishCoalesce(this.runtimeRequestContexts.get(request), () => ( Object.freeze({})))
|
|
714
|
+
);
|
|
715
|
+
return _nullishCoalesce(result.response, () => ( result.request));
|
|
716
|
+
}
|
|
717
|
+
async beginRuntimeRequest(request, options = {}) {
|
|
718
|
+
await this.startRuntime();
|
|
719
|
+
const startedAt = Date.now();
|
|
720
|
+
const waitUntil = options.waitUntil ? (promise) => _optionalChain([options, 'access', _94 => _94.waitUntil, 'optionalCall', _95 => _95(Promise.resolve(promise))]) : (promise) => {
|
|
721
|
+
void Promise.resolve(promise).catch(() => {
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
let activeRequest = request;
|
|
725
|
+
let activeOptions = options;
|
|
726
|
+
let runtimeContext = Object.freeze({});
|
|
727
|
+
try {
|
|
728
|
+
const endpoint = await this.runRuntimeEndpoint(
|
|
729
|
+
activeRequest,
|
|
730
|
+
activeOptions,
|
|
731
|
+
waitUntil,
|
|
732
|
+
(nextOptions) => {
|
|
733
|
+
activeOptions = nextOptions;
|
|
734
|
+
}
|
|
735
|
+
);
|
|
736
|
+
if (endpoint) {
|
|
737
|
+
return {
|
|
738
|
+
request: activeRequest,
|
|
739
|
+
response: endpoint,
|
|
740
|
+
ctx: runtimeContext,
|
|
741
|
+
startedAt,
|
|
742
|
+
options: activeOptions,
|
|
743
|
+
waitUntil
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
runtimeContext = await this.createRuntimeRequestContext(
|
|
747
|
+
activeRequest,
|
|
748
|
+
activeOptions,
|
|
749
|
+
waitUntil
|
|
750
|
+
);
|
|
751
|
+
const before = await this.runBeforeHooks(
|
|
752
|
+
activeRequest,
|
|
753
|
+
activeOptions,
|
|
754
|
+
waitUntil,
|
|
755
|
+
runtimeContext
|
|
756
|
+
);
|
|
757
|
+
activeRequest = before.request;
|
|
758
|
+
return {
|
|
759
|
+
request: activeRequest,
|
|
760
|
+
response: before.response,
|
|
761
|
+
ctx: runtimeContext,
|
|
762
|
+
startedAt,
|
|
763
|
+
options: activeOptions,
|
|
764
|
+
waitUntil
|
|
765
|
+
};
|
|
766
|
+
} catch (error) {
|
|
767
|
+
await this.runRuntimeErrorHooks(
|
|
768
|
+
activeRequest,
|
|
769
|
+
error,
|
|
770
|
+
runtimeContext,
|
|
771
|
+
Date.now() - startedAt,
|
|
772
|
+
activeOptions,
|
|
773
|
+
waitUntil
|
|
774
|
+
);
|
|
775
|
+
throw error;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
async endRuntimeRequest(session, initialResponse) {
|
|
779
|
+
let response = initialResponse;
|
|
780
|
+
try {
|
|
781
|
+
for (const plugin of this.getSortedPlugins()) {
|
|
782
|
+
const after = _optionalChain([plugin, 'access', _96 => _96.runtime, 'optionalAccess', _97 => _97.after]);
|
|
783
|
+
if (!after) continue;
|
|
784
|
+
const result = await after({
|
|
785
|
+
...this.createRuntimeBaseEvent(
|
|
786
|
+
plugin,
|
|
787
|
+
session.request,
|
|
788
|
+
session.options,
|
|
789
|
+
session.waitUntil
|
|
790
|
+
),
|
|
791
|
+
ctx: session.ctx,
|
|
792
|
+
response,
|
|
793
|
+
durationMs: Date.now() - session.startedAt
|
|
794
|
+
});
|
|
795
|
+
if (result !== void 0) {
|
|
796
|
+
if (!(result instanceof Response)) {
|
|
797
|
+
throw new TypeError(
|
|
798
|
+
`Farm plugin "${plugin.name}" runtime.after must return a Response or undefined`
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
response = result;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return response;
|
|
805
|
+
} catch (error) {
|
|
806
|
+
await this.failRuntimeRequest(session, error);
|
|
807
|
+
throw error;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
async failRuntimeRequest(session, error) {
|
|
811
|
+
if (this.failedRuntimeSessions.has(session)) return;
|
|
812
|
+
this.failedRuntimeSessions.add(session);
|
|
813
|
+
await this.runRuntimeErrorHooks(
|
|
814
|
+
session.request,
|
|
815
|
+
error,
|
|
816
|
+
session.ctx,
|
|
817
|
+
Date.now() - session.startedAt,
|
|
818
|
+
session.options,
|
|
819
|
+
session.waitUntil
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
async runRuntimeRequest(request, handler, options = {}) {
|
|
823
|
+
const session = await this.beginRuntimeRequest(request, options);
|
|
824
|
+
try {
|
|
825
|
+
const response = await _asyncNullishCoalesce(session.response, async () => ( await handler(session.request)));
|
|
826
|
+
if (!(response instanceof Response)) {
|
|
827
|
+
throw new TypeError("Farm plugin runtime handlers must return a Response");
|
|
828
|
+
}
|
|
829
|
+
return await this.endRuntimeRequest(session, response);
|
|
830
|
+
} catch (error) {
|
|
831
|
+
await this.failRuntimeRequest(session, error);
|
|
832
|
+
throw error;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
async runHook(hookName, ...args) {
|
|
836
|
+
const plugins = this.getSortedPlugins();
|
|
837
|
+
for (const plugin of plugins) {
|
|
838
|
+
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
839
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
840
|
+
const result = await hook.apply(plugin, [...args, hookContext]);
|
|
841
|
+
if (result !== void 0) {
|
|
842
|
+
return result;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
async runHookSerial(hookName, initialValue, ...args) {
|
|
848
|
+
const plugins = this.getSortedPlugins();
|
|
849
|
+
let value = initialValue;
|
|
850
|
+
for (const plugin of plugins) {
|
|
851
|
+
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
852
|
+
const hookArgs = [value, ...args];
|
|
853
|
+
const hookContext = this.getHookContext(plugin, hookName, hookArgs);
|
|
854
|
+
const result = await hook.apply(plugin, [...hookArgs, hookContext]);
|
|
855
|
+
if (result !== void 0) {
|
|
856
|
+
if (hookName === "beforeApiHandler" && result !== value && value && result && typeof value === "object" && typeof result === "object") {
|
|
857
|
+
this.copyRequestStore(value, result);
|
|
858
|
+
}
|
|
859
|
+
value = result;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return value;
|
|
864
|
+
}
|
|
865
|
+
async runHookParallel(hookName, ...args) {
|
|
866
|
+
return this.runHookParallelFiltered(hookName, () => true, ...args);
|
|
867
|
+
}
|
|
868
|
+
/** @internal Runs hooks for only the plugins selected by the runtime adapter. */
|
|
869
|
+
async runHookParallelFiltered(hookName, include, ...args) {
|
|
870
|
+
if (hookName === "shutdown" && !this.runtimeShutdownHooksRunning) {
|
|
871
|
+
await this.closeRuntime(_optionalChain([args, 'access', _98 => _98[0], 'optionalAccess', _99 => _99.reason]));
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
const plugins = this.getSortedPlugins().filter(include);
|
|
875
|
+
if (hookName === "onError") {
|
|
876
|
+
const failures = [];
|
|
877
|
+
const reports = [];
|
|
878
|
+
for (const plugin of plugins) {
|
|
879
|
+
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
880
|
+
reports.push(
|
|
881
|
+
(async () => {
|
|
882
|
+
try {
|
|
883
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
884
|
+
await hook.apply(plugin, [...args, hookContext]);
|
|
885
|
+
} catch (error) {
|
|
886
|
+
failures.push(error);
|
|
887
|
+
}
|
|
888
|
+
})()
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
await Promise.all(reports);
|
|
893
|
+
if (failures.length > 0) throw failures[0];
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
const sequentialHooks = /* @__PURE__ */ new Set([
|
|
897
|
+
"ready",
|
|
898
|
+
"shutdown",
|
|
899
|
+
"beforeRequest",
|
|
900
|
+
"afterResponse",
|
|
901
|
+
"beforeApiHandler",
|
|
902
|
+
"afterApiHandler",
|
|
903
|
+
"beforeRouteMatch",
|
|
904
|
+
"afterRouteMatch",
|
|
905
|
+
"beforeRender",
|
|
906
|
+
"afterRender"
|
|
907
|
+
]);
|
|
908
|
+
if (sequentialHooks.has(hookName)) {
|
|
909
|
+
const shutdownErrors = [];
|
|
910
|
+
for (const plugin of plugins) {
|
|
911
|
+
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
912
|
+
if (hookName === "beforeRequest") {
|
|
913
|
+
const res = args[1];
|
|
914
|
+
if (res && (res.writableEnded || res[FARM_NODE_RESPONSE_END_PENDING])) {
|
|
915
|
+
return true;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
919
|
+
try {
|
|
920
|
+
await hook.apply(plugin, [...args, hookContext]);
|
|
921
|
+
} catch (error) {
|
|
922
|
+
if (hookName !== "shutdown") throw error;
|
|
923
|
+
shutdownErrors.push(error);
|
|
924
|
+
}
|
|
925
|
+
if (hookName === "beforeRequest") {
|
|
926
|
+
const res = args[1];
|
|
927
|
+
if (res && res.writableEnded) {
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (hookName === "shutdown" && shutdownErrors.length > 0) {
|
|
934
|
+
throw new FarmRuntimeShutdownError("Farm plugin shutdown hooks failed", shutdownErrors);
|
|
935
|
+
}
|
|
936
|
+
} else {
|
|
937
|
+
const promises = [];
|
|
938
|
+
try {
|
|
939
|
+
for (const plugin of plugins) {
|
|
940
|
+
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
941
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
942
|
+
promises.push(hook.apply(plugin, [...args, hookContext]));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
} catch (error) {
|
|
946
|
+
void Promise.all(promises).catch(() => {
|
|
947
|
+
});
|
|
948
|
+
throw error;
|
|
949
|
+
}
|
|
950
|
+
await Promise.all(promises);
|
|
951
|
+
}
|
|
952
|
+
if (hookName === "init") this.initialized = true;
|
|
953
|
+
if (hookName === "ready") this.runtimeReady = true;
|
|
954
|
+
return false;
|
|
955
|
+
}
|
|
956
|
+
updateContext(updates) {
|
|
957
|
+
this.context = {
|
|
958
|
+
...this.context,
|
|
959
|
+
...updates,
|
|
960
|
+
requestContext: this.context.requestContext
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, _PluginManager, "PluginManager");
|
|
965
|
+
var PluginManager = _PluginManager;
|
|
966
|
+
function definePlugin(plugin) {
|
|
967
|
+
if (!isPluginOptionsSchema(plugin.options)) return declarePluginSchema(plugin);
|
|
968
|
+
return createPluginFactory(
|
|
969
|
+
plugin
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, definePlugin, "definePlugin");
|
|
973
|
+
function createPluginFactory(definition) {
|
|
974
|
+
const { options: schema, configure, setup, ...plugin } = definition;
|
|
975
|
+
return (input) => {
|
|
976
|
+
const options = parsePluginOptions(schema, input);
|
|
977
|
+
const resolveState = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (state) => state === void 0 ? options : state, "resolveState");
|
|
978
|
+
return declarePluginSchema({
|
|
979
|
+
...plugin,
|
|
980
|
+
...configure ? {
|
|
981
|
+
configure: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (config, context) => configure(config, { ...context, options }), "configure")
|
|
982
|
+
} : {},
|
|
983
|
+
setup(context) {
|
|
984
|
+
const state = _optionalChain([setup, 'optionalCall', _100 => _100({ ...context, options })]);
|
|
985
|
+
return state instanceof Promise ? state.then(resolveState) : resolveState(state);
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createPluginFactory, "createPluginFactory");
|
|
991
|
+
function pluginSchemaName(pluginName) {
|
|
992
|
+
const name = _chunkFVPXT2JRcjs.pluginShortName.call(void 0, pluginName);
|
|
993
|
+
if (!/^[a-z0-9][a-z0-9_-]*$/iu.test(name)) {
|
|
994
|
+
throw new Error(
|
|
995
|
+
`Plugin "${pluginName}" declares a schema, so its name must end in a word made of letters, numbers, "-" or "_": that word becomes \`farm <name> migrate\`.`
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
return name;
|
|
999
|
+
}
|
|
1000
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, pluginSchemaName, "pluginSchemaName");
|
|
1001
|
+
function declarePluginSchema(plugin) {
|
|
1002
|
+
if (plugin.migrations && !plugin.schema) {
|
|
1003
|
+
throw new Error(
|
|
1004
|
+
`Plugin "${plugin.name}" sets \`migrations\` without a \`schema\`: its steps change the schema's tables.`
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
if (plugin.database && !plugin.schema) {
|
|
1008
|
+
throw new Error(
|
|
1009
|
+
`Plugin "${plugin.name}" sets \`database\` without a \`schema\`: it only says where the schema's tables live.`
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
if (!plugin.schema || _chunk4U5XZDLGcjs.readSchemaTables.call(void 0, plugin)) return plugin;
|
|
1013
|
+
const name = pluginSchemaName(plugin.name);
|
|
1014
|
+
const models = _chunk6D24SDKOcjs.resolveSchemaModels.call(void 0, name, plugin.schema);
|
|
1015
|
+
_chunk4U5XZDLGcjs.collectSchemaExtensions.call(void 0, name, plugin.schema);
|
|
1016
|
+
validateSchemaSteps(name, plugin.schema, plugin.migrations);
|
|
1017
|
+
const database = plugin.database;
|
|
1018
|
+
return _chunk4U5XZDLGcjs.declareSchemaTables.call(void 0, plugin, {
|
|
1019
|
+
name,
|
|
1020
|
+
schema: plugin.schema,
|
|
1021
|
+
// Also listed by key, which tooling from before `external` existed reads.
|
|
1022
|
+
models: Object.keys(models).filter((key) => !models[key].external),
|
|
1023
|
+
...plugin.dependsOn ? { dependsOn: plugin.dependsOn.map(_chunkFVPXT2JRcjs.pluginShortName) } : {},
|
|
1024
|
+
...plugin.version ? { version: plugin.version } : {},
|
|
1025
|
+
..._optionalChain([plugin, 'access', _101 => _101.migrations, 'optionalAccess', _102 => _102.length]) ? { migrations: plugin.migrations } : {},
|
|
1026
|
+
dialect: _optionalChain([database, 'optionalAccess', _103 => _103.dialect]),
|
|
1027
|
+
resolveClient: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (config) => {
|
|
1028
|
+
if (_optionalChain([database, 'optionalAccess', _104 => _104.client]) !== void 0 && database.client !== null) {
|
|
1029
|
+
const client2 = typeof database.client === "function" ? await database.client() : database.client;
|
|
1030
|
+
if (client2 === void 0 || client2 === null) {
|
|
1031
|
+
throw new Error(`The ${name} plugin's \`database.client\` returned no connection.`);
|
|
1032
|
+
}
|
|
1033
|
+
return client2;
|
|
1034
|
+
}
|
|
1035
|
+
const { resolveIntegrationOrmRuntimeClient } = await import("./integration-orm-P2II2EBK.cjs");
|
|
1036
|
+
const client = await resolveIntegrationOrmRuntimeClient({ config });
|
|
1037
|
+
if (client === void 0 || client === null) {
|
|
1038
|
+
throw new Error(
|
|
1039
|
+
`The ${name} plugin keeps its tables in the app's database: set \`storage.client\` in farm.config.`
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
return client;
|
|
1043
|
+
}, "resolveClient")
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, declarePluginSchema, "declarePluginSchema");
|
|
1047
|
+
((definePlugin2) => {
|
|
1048
|
+
function forIntegration() {
|
|
1049
|
+
return /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, function defineBoundPlugin(plugin) {
|
|
1050
|
+
return declarePluginSchema(plugin);
|
|
1051
|
+
}, "defineBoundPlugin");
|
|
1052
|
+
}
|
|
1053
|
+
definePlugin2.forIntegration = forIntegration;
|
|
1054
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, forIntegration, "forIntegration");
|
|
1055
|
+
})(definePlugin || (definePlugin = exports.definePlugin = {}));
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
exports.FarmPluginOptionsError = FarmPluginOptionsError; exports.FARM_NODE_RESPONSE_END_PENDING = FARM_NODE_RESPONSE_END_PENDING; exports.FarmRuntimeShutdownError = FarmRuntimeShutdownError; exports.PluginManager = PluginManager; exports.definePlugin = definePlugin;
|