@farm.js/core 0.1.0-beta.6 → 0.1.0-beta.8
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/after.cjs +227 -0
- package/dist/after.cjs.map +1 -0
- package/dist/after.d.mts +25 -0
- package/dist/after.d.ts +25 -0
- package/dist/after.mjs +14 -0
- package/dist/after.mjs.map +1 -0
- package/dist/agent-runtime.cjs +2379 -0
- package/dist/agent-runtime.cjs.map +1 -0
- package/dist/agent-runtime.d.mts +94 -0
- package/dist/agent-runtime.d.ts +94 -0
- package/dist/agent-runtime.mjs +479 -0
- package/dist/agent-runtime.mjs.map +1 -0
- package/dist/api/route-manager.d.mts +66 -0
- package/dist/api/route-manager.d.ts +66 -0
- package/dist/api/runtime.d.mts +3 -0
- package/dist/api/runtime.d.ts +3 -0
- package/dist/api.cjs +4100 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.mts +48 -0
- package/dist/api.d.ts +48 -0
- package/dist/api.mjs +93 -0
- package/dist/api.mjs.map +1 -0
- package/dist/app-BWtqQu3R.d.mts +302 -0
- package/dist/app-markdown.cjs +244 -0
- package/dist/app-markdown.cjs.map +1 -0
- package/dist/app-markdown.d.mts +22 -0
- package/dist/app-markdown.d.ts +22 -0
- package/dist/app-markdown.mjs +27 -0
- package/dist/app-markdown.mjs.map +1 -0
- package/dist/app-xltejvLY.d.ts +302 -0
- package/dist/cache.cjs +945 -0
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.mts +192 -0
- package/dist/cache.d.ts +192 -0
- package/dist/cache.mjs +46 -0
- package/dist/cache.mjs.map +1 -0
- package/dist/chunk-2ED5Q2GH.mjs +422 -0
- package/dist/chunk-2ED5Q2GH.mjs.map +1 -0
- package/dist/chunk-32W4QEJP.mjs +158 -0
- package/dist/chunk-32W4QEJP.mjs.map +1 -0
- package/dist/chunk-3XNTL3FQ.mjs +452 -0
- package/dist/chunk-3XNTL3FQ.mjs.map +1 -0
- package/dist/chunk-44ZCFSKE.mjs +84 -0
- package/dist/chunk-44ZCFSKE.mjs.map +1 -0
- package/dist/chunk-4MGVSBRP.mjs +7787 -0
- package/dist/chunk-4MGVSBRP.mjs.map +1 -0
- package/dist/chunk-4S3ORGFA.mjs +44 -0
- package/dist/chunk-4S3ORGFA.mjs.map +1 -0
- package/dist/chunk-5BY76U2M.mjs +1 -0
- package/dist/chunk-5BY76U2M.mjs.map +1 -0
- package/dist/chunk-5ZGPRGWV.mjs +136 -0
- package/dist/chunk-5ZGPRGWV.mjs.map +1 -0
- package/dist/chunk-65A7QIKI.mjs +142 -0
- package/dist/chunk-65A7QIKI.mjs.map +1 -0
- package/dist/chunk-74YTBPTY.mjs +450 -0
- package/dist/chunk-74YTBPTY.mjs.map +1 -0
- package/dist/chunk-7FBJLMQH.mjs +338 -0
- package/dist/chunk-7FBJLMQH.mjs.map +1 -0
- package/dist/chunk-7HO6AEOP.mjs +74 -0
- package/dist/chunk-7HO6AEOP.mjs.map +1 -0
- package/dist/chunk-7MABZJIM.mjs +29 -0
- package/dist/chunk-7MABZJIM.mjs.map +1 -0
- package/dist/chunk-7N62DNSO.mjs +41 -0
- package/dist/chunk-7N62DNSO.mjs.map +1 -0
- package/dist/chunk-7ZY5AIJO.mjs +161 -0
- package/dist/chunk-7ZY5AIJO.mjs.map +1 -0
- package/dist/chunk-ALCLXXTY.mjs +187 -0
- package/dist/chunk-ALCLXXTY.mjs.map +1 -0
- package/dist/chunk-AZ7YUVNR.mjs +65 -0
- package/dist/chunk-AZ7YUVNR.mjs.map +1 -0
- package/dist/chunk-B232I2GP.mjs +163 -0
- package/dist/chunk-B232I2GP.mjs.map +1 -0
- package/dist/chunk-B4W3BNTL.mjs +483 -0
- package/dist/chunk-B4W3BNTL.mjs.map +1 -0
- package/dist/chunk-C2ROET2V.mjs +718 -0
- package/dist/chunk-C2ROET2V.mjs.map +1 -0
- package/dist/chunk-CGILA3WO.mjs +14 -0
- package/dist/chunk-CGILA3WO.mjs.map +1 -0
- package/dist/chunk-CGIXMLSY.mjs +184 -0
- package/dist/chunk-CGIXMLSY.mjs.map +1 -0
- package/dist/chunk-DJSGLHCN.mjs +597 -0
- package/dist/chunk-DJSGLHCN.mjs.map +1 -0
- package/dist/chunk-E2MPIBRE.mjs +149 -0
- package/dist/chunk-E2MPIBRE.mjs.map +1 -0
- package/dist/chunk-E6EPN5BT.mjs +203 -0
- package/dist/chunk-E6EPN5BT.mjs.map +1 -0
- package/dist/chunk-EI43C4RA.mjs +6277 -0
- package/dist/chunk-EI43C4RA.mjs.map +1 -0
- package/dist/chunk-EJ7T4TPB.mjs +622 -0
- package/dist/chunk-EJ7T4TPB.mjs.map +1 -0
- package/dist/chunk-FQYDHKKU.mjs +128 -0
- package/dist/chunk-FQYDHKKU.mjs.map +1 -0
- package/dist/chunk-FRPWCMMG.mjs +299 -0
- package/dist/chunk-FRPWCMMG.mjs.map +1 -0
- package/dist/chunk-GN72QAIH.mjs +146 -0
- package/dist/chunk-GN72QAIH.mjs.map +1 -0
- package/dist/chunk-GQVGIUSN.mjs +149 -0
- package/dist/chunk-GQVGIUSN.mjs.map +1 -0
- package/dist/chunk-GS6K5OCM.mjs +407 -0
- package/dist/chunk-GS6K5OCM.mjs.map +1 -0
- package/dist/chunk-GXASWWJU.mjs +364 -0
- package/dist/chunk-GXASWWJU.mjs.map +1 -0
- package/dist/chunk-GY2STC2S.mjs +180 -0
- package/dist/chunk-GY2STC2S.mjs.map +1 -0
- package/dist/chunk-H2FA2SBS.mjs +51 -0
- package/dist/chunk-H2FA2SBS.mjs.map +1 -0
- package/dist/chunk-I4CUBGVF.mjs +93 -0
- package/dist/chunk-I4CUBGVF.mjs.map +1 -0
- package/dist/chunk-ITN462YM.mjs +98 -0
- package/dist/chunk-ITN462YM.mjs.map +1 -0
- package/dist/chunk-J23HNLFY.mjs +72 -0
- package/dist/chunk-J23HNLFY.mjs.map +1 -0
- package/dist/chunk-J4FNJ5IU.mjs +179 -0
- package/dist/chunk-J4FNJ5IU.mjs.map +1 -0
- package/dist/chunk-J5YWQVI5.mjs +211 -0
- package/dist/chunk-J5YWQVI5.mjs.map +1 -0
- package/dist/chunk-JDEOUK5V.mjs +427 -0
- package/dist/chunk-JDEOUK5V.mjs.map +1 -0
- package/dist/chunk-JK25YEN6.mjs +219 -0
- package/dist/chunk-JK25YEN6.mjs.map +1 -0
- package/dist/chunk-K4667E2Q.mjs +1916 -0
- package/dist/chunk-K4667E2Q.mjs.map +1 -0
- package/dist/chunk-LGHEOHBU.mjs +218 -0
- package/dist/chunk-LGHEOHBU.mjs.map +1 -0
- package/dist/chunk-LM2YNO4U.mjs +24 -0
- package/dist/chunk-LM2YNO4U.mjs.map +1 -0
- package/dist/chunk-ME4MO2RJ.mjs +3540 -0
- package/dist/chunk-ME4MO2RJ.mjs.map +1 -0
- package/dist/chunk-MIUW47JX.mjs +639 -0
- package/dist/chunk-MIUW47JX.mjs.map +1 -0
- package/dist/chunk-NNLCAVB6.mjs +391 -0
- package/dist/chunk-NNLCAVB6.mjs.map +1 -0
- package/dist/chunk-P7QDS5AT.mjs +191 -0
- package/dist/chunk-P7QDS5AT.mjs.map +1 -0
- package/dist/chunk-PFE6GMNE.mjs +603 -0
- package/dist/chunk-PFE6GMNE.mjs.map +1 -0
- package/dist/chunk-QGOHVJ6J.mjs +63 -0
- package/dist/chunk-QGOHVJ6J.mjs.map +1 -0
- package/dist/chunk-QKVUNGAH.mjs +39 -0
- package/dist/chunk-QKVUNGAH.mjs.map +1 -0
- package/dist/chunk-QM746KUO.mjs +56 -0
- package/dist/chunk-QM746KUO.mjs.map +1 -0
- package/dist/chunk-QTZZ2ISQ.mjs +753 -0
- package/dist/chunk-QTZZ2ISQ.mjs.map +1 -0
- package/dist/chunk-RBRLLZL5.mjs +81 -0
- package/dist/chunk-RBRLLZL5.mjs.map +1 -0
- package/dist/chunk-RHIFZZUI.mjs +69 -0
- package/dist/chunk-RHIFZZUI.mjs.map +1 -0
- package/dist/chunk-RQ633A5I.mjs +187 -0
- package/dist/chunk-RQ633A5I.mjs.map +1 -0
- package/dist/chunk-SCFX4UTD.mjs +28 -0
- package/dist/chunk-SCFX4UTD.mjs.map +1 -0
- package/dist/chunk-SL6HTIOK.mjs +66 -0
- package/dist/chunk-SL6HTIOK.mjs.map +1 -0
- package/dist/chunk-SPBBQLXI.mjs +207 -0
- package/dist/chunk-SPBBQLXI.mjs.map +1 -0
- package/dist/chunk-SSA7THPX.mjs +10 -0
- package/dist/chunk-SSA7THPX.mjs.map +1 -0
- package/dist/chunk-T4QJQK76.mjs +459 -0
- package/dist/chunk-T4QJQK76.mjs.map +1 -0
- package/dist/chunk-TQAEEJB4.mjs +157 -0
- package/dist/chunk-TQAEEJB4.mjs.map +1 -0
- package/dist/chunk-UB5UOSHB.mjs +458 -0
- package/dist/chunk-UB5UOSHB.mjs.map +1 -0
- package/dist/chunk-USWZZUEH.mjs +25 -0
- package/dist/chunk-USWZZUEH.mjs.map +1 -0
- package/dist/chunk-UVCIEUJC.mjs +16 -0
- package/dist/chunk-UVCIEUJC.mjs.map +1 -0
- package/dist/chunk-UXUAWNO5.mjs +396 -0
- package/dist/chunk-UXUAWNO5.mjs.map +1 -0
- package/dist/chunk-V3XURYJO.mjs +756 -0
- package/dist/chunk-V3XURYJO.mjs.map +1 -0
- package/dist/chunk-V6WE6JSZ.mjs +352 -0
- package/dist/chunk-V6WE6JSZ.mjs.map +1 -0
- package/dist/chunk-V7RBCSDJ.mjs +170 -0
- package/dist/chunk-V7RBCSDJ.mjs.map +1 -0
- package/dist/chunk-VCANOYFI.mjs +588 -0
- package/dist/chunk-VCANOYFI.mjs.map +1 -0
- package/dist/chunk-VY2UYN5R.mjs +224 -0
- package/dist/chunk-VY2UYN5R.mjs.map +1 -0
- package/dist/chunk-W2CRQFF6.mjs +1352 -0
- package/dist/chunk-W2CRQFF6.mjs.map +1 -0
- package/dist/chunk-WDU6QXNK.mjs +872 -0
- package/dist/chunk-WDU6QXNK.mjs.map +1 -0
- package/dist/chunk-WZ5QFROO.mjs +23 -0
- package/dist/chunk-WZ5QFROO.mjs.map +1 -0
- package/dist/chunk-XIVV5IWN.mjs +541 -0
- package/dist/chunk-XIVV5IWN.mjs.map +1 -0
- package/dist/chunk-YW7OBE6Q.mjs +119 -0
- package/dist/chunk-YW7OBE6Q.mjs.map +1 -0
- package/dist/chunk-Z5CQMP54.mjs +365 -0
- package/dist/chunk-Z5CQMP54.mjs.map +1 -0
- package/dist/chunk-ZBE6MLHL.mjs +230 -0
- package/dist/chunk-ZBE6MLHL.mjs.map +1 -0
- package/dist/chunk-ZVWA4ZQ3.mjs +189 -0
- package/dist/chunk-ZVWA4ZQ3.mjs.map +1 -0
- package/dist/chunk-ZZ57EH5Z.mjs +173 -0
- package/dist/chunk-ZZ57EH5Z.mjs.map +1 -0
- package/dist/client-BT1mFQas.d.mts +447 -0
- package/dist/client-Nn0q4eO4.d.ts +447 -0
- package/dist/client-cache-CIlyBlmx.d.ts +6 -0
- package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
- package/dist/client-plugins-BI2R6Eae.d.mts +1926 -0
- package/dist/client-plugins-DU9oMspX.d.ts +1926 -0
- package/dist/client-plugins.cjs +415 -0
- package/dist/client-plugins.cjs.map +1 -0
- package/dist/client-plugins.d.mts +22 -0
- package/dist/client-plugins.d.ts +22 -0
- package/dist/client-plugins.mjs +10 -0
- package/dist/client-plugins.mjs.map +1 -0
- package/dist/client.cjs +5402 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.mts +447 -0
- package/dist/client.d.ts +447 -0
- package/dist/client.mjs +110 -0
- package/dist/client.mjs.map +1 -0
- package/dist/config.cjs +38 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.mts +29 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.mjs +10 -0
- package/dist/config.mjs.map +1 -0
- package/dist/cron.cjs +406 -0
- package/dist/cron.cjs.map +1 -0
- package/dist/cron.d.mts +78 -0
- package/dist/cron.d.ts +78 -0
- package/dist/cron.mjs +30 -0
- package/dist/cron.mjs.map +1 -0
- package/dist/deferred.cjs +438 -0
- package/dist/deferred.cjs.map +1 -0
- package/dist/deferred.d.mts +42 -0
- package/dist/deferred.d.ts +42 -0
- package/dist/deferred.mjs +28 -0
- package/dist/deferred.mjs.map +1 -0
- package/dist/deployment.cjs +199 -0
- package/dist/deployment.cjs.map +1 -0
- package/dist/deployment.d.mts +34 -0
- package/dist/deployment.d.ts +34 -0
- package/dist/deployment.mjs +38 -0
- package/dist/deployment.mjs.map +1 -0
- package/dist/devtools-REQTS3I7.mjs +371 -0
- package/dist/devtools-REQTS3I7.mjs.map +1 -0
- package/dist/devtools-client-3XRTBND5.mjs +216 -0
- package/dist/devtools-client-3XRTBND5.mjs.map +1 -0
- package/dist/devtools-ui-NJKFORTG.mjs +1349 -0
- package/dist/devtools-ui-NJKFORTG.mjs.map +1 -0
- package/dist/docs.cjs +5548 -0
- package/dist/docs.cjs.map +1 -0
- package/dist/docs.d.mts +69 -0
- package/dist/docs.d.ts +69 -0
- package/dist/docs.mjs +47 -0
- package/dist/docs.mjs.map +1 -0
- package/dist/env-types.cjs +232 -0
- package/dist/env-types.cjs.map +1 -0
- package/dist/env-types.d.mts +12 -0
- package/dist/env-types.d.ts +12 -0
- package/dist/env-types.mjs +11 -0
- package/dist/env-types.mjs.map +1 -0
- package/dist/env.cjs +215 -0
- package/dist/env.cjs.map +1 -0
- package/dist/env.d.mts +45 -0
- package/dist/env.d.ts +45 -0
- package/dist/env.mjs +22 -0
- package/dist/env.mjs.map +1 -0
- package/dist/environment/vite.d.mts +22 -0
- package/dist/environment/vite.d.ts +22 -0
- package/dist/environment.cjs +96 -0
- package/dist/environment.cjs.map +1 -0
- package/dist/environment.d.mts +18 -0
- package/dist/environment.d.ts +18 -0
- package/dist/environment.mjs +14 -0
- package/dist/environment.mjs.map +1 -0
- package/dist/headers.cjs +126 -0
- package/dist/headers.cjs.map +1 -0
- package/dist/headers.d.mts +22 -0
- package/dist/headers.d.ts +22 -0
- package/dist/headers.mjs +12 -0
- package/dist/headers.mjs.map +1 -0
- package/dist/i18n/client.d.mts +32 -0
- package/dist/i18n/client.d.ts +32 -0
- package/dist/i18n/index.d.mts +20 -0
- package/dist/i18n/index.d.ts +20 -0
- package/dist/i18n/server.d.mts +30 -0
- package/dist/i18n/server.d.ts +30 -0
- package/dist/image/server.d.mts +37 -0
- package/dist/image/server.d.ts +37 -0
- package/dist/image/sharp.d.mts +7 -0
- package/dist/image/sharp.d.ts +7 -0
- package/dist/image-config-Duob7wER.d.mts +50 -0
- package/dist/image-config-Duob7wER.d.ts +50 -0
- package/dist/image.cjs +209 -0
- package/dist/image.cjs.map +1 -0
- package/dist/image.d.mts +39 -0
- package/dist/image.d.ts +39 -0
- package/dist/image.mjs +165 -0
- package/dist/image.mjs.map +1 -0
- package/dist/index.cjs +42186 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +454 -0
- package/dist/index.d.ts +454 -0
- package/dist/index.mjs +980 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integration-api-CHT2OKAf.d.mts +93 -0
- package/dist/integration-api-CHT2OKAf.d.ts +93 -0
- package/dist/integration-orm-GQLGU66X.mjs +13 -0
- package/dist/integration-orm-GQLGU66X.mjs.map +1 -0
- package/dist/integrations.cjs +2820 -0
- package/dist/integrations.cjs.map +1 -0
- package/dist/integrations.d.mts +22 -0
- package/dist/integrations.d.ts +22 -0
- package/dist/integrations.mjs +51 -0
- package/dist/integrations.mjs.map +1 -0
- package/dist/internal/build-runtime.cjs +643 -322
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.d.mts +39 -0
- package/dist/internal/build-runtime.d.ts +39 -0
- package/dist/internal/build-runtime.mjs +11 -10
- package/dist/internal/client-runtime.d.mts +2 -0
- package/dist/internal/client-runtime.d.ts +2 -0
- package/dist/internal/config-runtime.cjs +135 -39
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.d.mts +39 -0
- package/dist/internal/config-runtime.d.ts +39 -0
- package/dist/internal/config-runtime.mjs +5 -4
- package/dist/internal/production-node-env.d.mts +12 -0
- package/dist/internal/production-node-env.d.ts +12 -0
- package/dist/internal/production-runtime.d.mts +39 -0
- package/dist/internal/production-runtime.d.ts +39 -0
- package/dist/layers-VWVDTPUZ.mjs +16 -0
- package/dist/layers-VWVDTPUZ.mjs.map +1 -0
- package/dist/manager-THKFTOFE.mjs +10 -0
- package/dist/manager-THKFTOFE.mjs.map +1 -0
- package/dist/markdown.cjs +364 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.mts +60 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/markdown.mjs +18 -0
- package/dist/markdown.mjs.map +1 -0
- package/dist/metadata-Cm9ujH4I.d.ts +22 -0
- package/dist/metadata-DacXbnLA.d.mts +22 -0
- package/dist/middleware.cjs +2148 -0
- package/dist/middleware.cjs.map +1 -0
- package/dist/middleware.d.mts +164 -0
- package/dist/middleware.d.ts +164 -0
- package/dist/middleware.mjs +49 -0
- package/dist/middleware.mjs.map +1 -0
- package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
- package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
- package/dist/navigation.cjs +1329 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.mts +14 -0
- package/dist/navigation.d.ts +14 -0
- package/dist/navigation.mjs +33 -0
- package/dist/navigation.mjs.map +1 -0
- package/dist/nitro-QO5LV6QK.mjs +689 -0
- package/dist/nitro-QO5LV6QK.mjs.map +1 -0
- package/dist/observability.cjs +186 -0
- package/dist/observability.cjs.map +1 -0
- package/dist/observability.d.mts +335 -0
- package/dist/observability.d.ts +335 -0
- package/dist/observability.mjs +16 -0
- package/dist/observability.mjs.map +1 -0
- package/dist/params-BALtrRim.d.ts +15 -0
- package/dist/params-ry-lxqmy.d.mts +15 -0
- package/dist/plugin-BJDf43dc.d.mts +165 -0
- package/dist/plugin-BJDf43dc.d.ts +165 -0
- package/dist/plugin.cjs +23470 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.mts +22 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.mjs +8 -7
- package/dist/production-runtime-4KKq1AVC.d.mts +79 -0
- package/dist/production-runtime-C_B79w2P.d.mts +28 -0
- package/dist/production-runtime-DDEM1D2q.d.ts +28 -0
- package/dist/production-runtime-DRsWDN2x.d.ts +79 -0
- package/dist/query/client.d.mts +61 -0
- package/dist/query/client.d.ts +61 -0
- package/dist/query/index.d.mts +90 -0
- package/dist/query/index.d.ts +90 -0
- package/dist/query/parsers.d.mts +25 -0
- package/dist/query/parsers.d.ts +25 -0
- package/dist/query/server.d.mts +55 -0
- package/dist/query/server.d.ts +55 -0
- package/dist/request-Dsq4kGW0.d.mts +6 -0
- package/dist/request-udtobOLv.d.ts +6 -0
- package/dist/request.d.mts +2 -0
- package/dist/request.d.ts +2 -0
- package/dist/resolver-DJqjLMg_.d.mts +14 -0
- package/dist/resolver-IH4RmPEl.d.ts +14 -0
- package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
- package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
- package/dist/router.d.mts +36 -0
- package/dist/router.d.ts +36 -0
- package/dist/routes.d.mts +224 -0
- package/dist/routes.d.ts +224 -0
- package/dist/runtime-9nQjVM7X.d.mts +206 -0
- package/dist/runtime-Cxpq6xZN.d.mts +27 -0
- package/dist/runtime-DgeS2skB.d.ts +206 -0
- package/dist/runtime-bv63eUiO.d.ts +27 -0
- package/dist/server-action-security.d.mts +43 -0
- package/dist/server-action-security.d.ts +43 -0
- package/dist/server-fn-client.d.mts +32 -0
- package/dist/server-fn-client.d.ts +32 -0
- package/dist/server-fn.d.mts +93 -0
- package/dist/server-fn.d.ts +93 -0
- package/dist/server-plugins.d.mts +55 -0
- package/dist/server-plugins.d.ts +55 -0
- package/dist/server-query-client.d.mts +50 -0
- package/dist/server-query-client.d.ts +50 -0
- package/dist/server-query.d.mts +36 -0
- package/dist/server-query.d.ts +36 -0
- package/dist/server.cjs +731 -447
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.mts +48 -0
- package/dist/server.d.ts +48 -0
- package/dist/server.mjs +9 -8
- package/dist/server.mjs.map +1 -1
- package/dist/storage.d.mts +52 -0
- package/dist/storage.d.ts +52 -0
- package/dist/testing.d.mts +101 -0
- package/dist/testing.d.ts +101 -0
- package/dist/transport-BmbGTXA5.d.mts +49 -0
- package/dist/transport-BmbGTXA5.d.ts +49 -0
- package/dist/types-BMxWr97v.d.mts +81 -0
- package/dist/types-BMxWr97v.d.ts +81 -0
- package/dist/types-C9N-nk5R.d.mts +53 -0
- package/dist/types-C9N-nk5R.d.ts +53 -0
- package/dist/types-D1A6-XvH.d.mts +73 -0
- package/dist/types-D1A6-XvH.d.ts +73 -0
- package/dist/utils-B-cUHwoK.d.ts +23 -0
- package/dist/utils-Cm41AefV.d.mts +23 -0
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +3 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +682 -437
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.mjs +6 -5
- package/dist/workflows.d.mts +110 -0
- package/dist/workflows.d.ts +110 -0
- package/package.json +3 -2
- package/types/client.d.ts +1 -1
- package/types/image.d.ts +4 -0
- package/types/images.d.ts +59 -0
|
@@ -0,0 +1,1916 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sendWebResponse
|
|
3
|
+
} from "./chunk-QGOHVJ6J.mjs";
|
|
4
|
+
import {
|
|
5
|
+
api,
|
|
6
|
+
defineIntegrationAPIOperation
|
|
7
|
+
} from "./chunk-JK25YEN6.mjs";
|
|
8
|
+
import {
|
|
9
|
+
__name
|
|
10
|
+
} from "./chunk-CGILA3WO.mjs";
|
|
11
|
+
|
|
12
|
+
// src/request-context.ts
|
|
13
|
+
var REQUEST_CONTEXT_STORE_KEY = /* @__PURE__ */ Symbol.for("farm.requestContextStore");
|
|
14
|
+
function getRequestContextStore() {
|
|
15
|
+
const globalState = globalThis;
|
|
16
|
+
if (!globalState[REQUEST_CONTEXT_STORE_KEY]) {
|
|
17
|
+
globalState[REQUEST_CONTEXT_STORE_KEY] = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
}
|
|
19
|
+
return globalState[REQUEST_CONTEXT_STORE_KEY];
|
|
20
|
+
}
|
|
21
|
+
__name(getRequestContextStore, "getRequestContextStore");
|
|
22
|
+
function getBucket(target) {
|
|
23
|
+
const requestContextStore = getRequestContextStore();
|
|
24
|
+
let bucket = requestContextStore.get(target);
|
|
25
|
+
if (!bucket) {
|
|
26
|
+
bucket = {
|
|
27
|
+
privateData: /* @__PURE__ */ new Map(),
|
|
28
|
+
exposedData: /* @__PURE__ */ new Map()
|
|
29
|
+
};
|
|
30
|
+
requestContextStore.set(target, bucket);
|
|
31
|
+
}
|
|
32
|
+
return bucket;
|
|
33
|
+
}
|
|
34
|
+
__name(getBucket, "getBucket");
|
|
35
|
+
function setRequestContext(target, key, value, options = {}) {
|
|
36
|
+
const bucket = getBucket(target);
|
|
37
|
+
bucket.privateData.set(key, value);
|
|
38
|
+
if (options.exposeToPage) {
|
|
39
|
+
bucket.exposedData.set(key, value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
__name(setRequestContext, "setRequestContext");
|
|
43
|
+
function getRequestContext(target, key) {
|
|
44
|
+
const requestContextStore = getRequestContextStore();
|
|
45
|
+
const bucket = requestContextStore.get(target);
|
|
46
|
+
return bucket?.privateData.get(key);
|
|
47
|
+
}
|
|
48
|
+
__name(getRequestContext, "getRequestContext");
|
|
49
|
+
function hasRequestContext(target, key) {
|
|
50
|
+
const requestContextStore = getRequestContextStore();
|
|
51
|
+
const bucket = requestContextStore.get(target);
|
|
52
|
+
return bucket?.privateData.has(key) ?? false;
|
|
53
|
+
}
|
|
54
|
+
__name(hasRequestContext, "hasRequestContext");
|
|
55
|
+
function deleteRequestContext(target, key) {
|
|
56
|
+
const requestContextStore = getRequestContextStore();
|
|
57
|
+
const bucket = requestContextStore.get(target);
|
|
58
|
+
if (!bucket) return false;
|
|
59
|
+
const removedPrivate = bucket.privateData.delete(key);
|
|
60
|
+
bucket.exposedData.delete(key);
|
|
61
|
+
return removedPrivate;
|
|
62
|
+
}
|
|
63
|
+
__name(deleteRequestContext, "deleteRequestContext");
|
|
64
|
+
function clearRequestContext(target) {
|
|
65
|
+
const requestContextStore = getRequestContextStore();
|
|
66
|
+
const bucket = requestContextStore.get(target);
|
|
67
|
+
if (!bucket) return;
|
|
68
|
+
bucket.privateData.clear();
|
|
69
|
+
bucket.exposedData.clear();
|
|
70
|
+
}
|
|
71
|
+
__name(clearRequestContext, "clearRequestContext");
|
|
72
|
+
function getRequestContextSnapshot(target, options = {}) {
|
|
73
|
+
const requestContextStore = getRequestContextStore();
|
|
74
|
+
const bucket = requestContextStore.get(target);
|
|
75
|
+
if (!bucket) return /* @__PURE__ */ new Map();
|
|
76
|
+
if (options.exposedOnly) {
|
|
77
|
+
return new Map(bucket.exposedData);
|
|
78
|
+
}
|
|
79
|
+
return new Map(bucket.privateData);
|
|
80
|
+
}
|
|
81
|
+
__name(getRequestContextSnapshot, "getRequestContextSnapshot");
|
|
82
|
+
|
|
83
|
+
// src/integrations.ts
|
|
84
|
+
var FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
|
|
85
|
+
function defineIntegrationSchema(schema) {
|
|
86
|
+
return schema;
|
|
87
|
+
}
|
|
88
|
+
__name(defineIntegrationSchema, "defineIntegrationSchema");
|
|
89
|
+
var FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME = /* @__PURE__ */ Symbol.for(
|
|
90
|
+
"@farm.js/core/integration-plugin-server-runtime"
|
|
91
|
+
);
|
|
92
|
+
function getFarmIntegrationPluginServerRuntime(plugin) {
|
|
93
|
+
const value = plugin[FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME];
|
|
94
|
+
return typeof value === "boolean" ? value : void 0;
|
|
95
|
+
}
|
|
96
|
+
__name(getFarmIntegrationPluginServerRuntime, "getFarmIntegrationPluginServerRuntime");
|
|
97
|
+
function defineTypedIntegrationRoute(method, path, input) {
|
|
98
|
+
return {
|
|
99
|
+
path,
|
|
100
|
+
method,
|
|
101
|
+
middleware: input.middleware,
|
|
102
|
+
before: input.before,
|
|
103
|
+
after: input.after,
|
|
104
|
+
rawBody: input.rawBody,
|
|
105
|
+
bodyFormat: input.bodyFormat,
|
|
106
|
+
input: normalizeIntegrationRouteInputSchemas(input),
|
|
107
|
+
handler: input.handler,
|
|
108
|
+
__operation: defineIntegrationAPIOperation({
|
|
109
|
+
path,
|
|
110
|
+
method,
|
|
111
|
+
bodyFormat: input.bodyFormat,
|
|
112
|
+
responseFormat: input.responseFormat,
|
|
113
|
+
headers: input.headers,
|
|
114
|
+
credentials: input.credentials,
|
|
115
|
+
isServer: input.isServer
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
__name(defineTypedIntegrationRoute, "defineTypedIntegrationRoute");
|
|
120
|
+
function createIntegrationRouteFactory() {
|
|
121
|
+
return {
|
|
122
|
+
get(path, input) {
|
|
123
|
+
return defineTypedIntegrationRoute(
|
|
124
|
+
"GET",
|
|
125
|
+
path,
|
|
126
|
+
input
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
post(path, input) {
|
|
130
|
+
return defineTypedIntegrationRoute(
|
|
131
|
+
"POST",
|
|
132
|
+
path,
|
|
133
|
+
{
|
|
134
|
+
bodyFormat: "json",
|
|
135
|
+
...input
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
put(path, input) {
|
|
140
|
+
return defineTypedIntegrationRoute(
|
|
141
|
+
"PUT",
|
|
142
|
+
path,
|
|
143
|
+
{
|
|
144
|
+
bodyFormat: "json",
|
|
145
|
+
...input
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
},
|
|
149
|
+
patch(path, input) {
|
|
150
|
+
return defineTypedIntegrationRoute("PATCH", path, {
|
|
151
|
+
bodyFormat: "json",
|
|
152
|
+
...input
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
delete(path, input) {
|
|
156
|
+
return defineTypedIntegrationRoute("DELETE", path, {
|
|
157
|
+
bodyFormat: "json",
|
|
158
|
+
...input
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
options(path, input) {
|
|
162
|
+
return defineTypedIntegrationRoute("OPTIONS", path, input);
|
|
163
|
+
},
|
|
164
|
+
head(path, input) {
|
|
165
|
+
return defineTypedIntegrationRoute(
|
|
166
|
+
"HEAD",
|
|
167
|
+
path,
|
|
168
|
+
input
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
__name(createIntegrationRouteFactory, "createIntegrationRouteFactory");
|
|
174
|
+
function createIntegrationRoute(_schema) {
|
|
175
|
+
return createIntegrationRouteFactory();
|
|
176
|
+
}
|
|
177
|
+
__name(createIntegrationRoute, "createIntegrationRoute");
|
|
178
|
+
var integrationRoute = createIntegrationRouteFactory();
|
|
179
|
+
var INTEGRATION_RUNTIME_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("farm.integrationRuntimeRegistry");
|
|
180
|
+
var INTEGRATION_REQUEST_DISPATCHER_KEY = /* @__PURE__ */ Symbol.for("farm.integrationRequestDispatcher");
|
|
181
|
+
function getIntegrationRuntimeRegistry() {
|
|
182
|
+
const globalState = globalThis;
|
|
183
|
+
if (!globalState[INTEGRATION_RUNTIME_REGISTRY_KEY]) {
|
|
184
|
+
globalState[INTEGRATION_RUNTIME_REGISTRY_KEY] = /* @__PURE__ */ new Map();
|
|
185
|
+
}
|
|
186
|
+
return globalState[INTEGRATION_RUNTIME_REGISTRY_KEY];
|
|
187
|
+
}
|
|
188
|
+
__name(getIntegrationRuntimeRegistry, "getIntegrationRuntimeRegistry");
|
|
189
|
+
function isIntegrationEndpointRoute(value) {
|
|
190
|
+
return !!value && typeof value === "object" && typeof value.path === "string" && typeof value.handler === "function";
|
|
191
|
+
}
|
|
192
|
+
__name(isIntegrationEndpointRoute, "isIntegrationEndpointRoute");
|
|
193
|
+
function flattenIntegrationEndpoints(endpoints) {
|
|
194
|
+
if (!endpoints) {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
197
|
+
if (Array.isArray(endpoints)) {
|
|
198
|
+
return endpoints.flatMap((endpoint) => flattenIntegrationEndpoints(endpoint));
|
|
199
|
+
}
|
|
200
|
+
if (isIntegrationEndpointRoute(endpoints)) {
|
|
201
|
+
return [endpoints];
|
|
202
|
+
}
|
|
203
|
+
if (typeof endpoints === "object") {
|
|
204
|
+
return Object.values(endpoints).flatMap((endpoint) => flattenIntegrationEndpoints(endpoint));
|
|
205
|
+
}
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
__name(flattenIntegrationEndpoints, "flattenIntegrationEndpoints");
|
|
209
|
+
function defineIntegration(integration) {
|
|
210
|
+
const category = integration.category ?? integration.slot;
|
|
211
|
+
if (!category) {
|
|
212
|
+
throw new Error("Integration category is required.");
|
|
213
|
+
}
|
|
214
|
+
if (integration.category && integration.slot && integration.category !== integration.slot) {
|
|
215
|
+
throw new Error("Integration category and slot must match when both are provided.");
|
|
216
|
+
}
|
|
217
|
+
const routeFactory = createIntegrationRoute(integration.schema);
|
|
218
|
+
const routes = typeof integration.routes === "function" ? integration.routes({
|
|
219
|
+
route: routeFactory,
|
|
220
|
+
integrationRoute: routeFactory
|
|
221
|
+
}) : integration.routes;
|
|
222
|
+
const endpoints = typeof integration.endpoints === "function" ? integration.endpoints({
|
|
223
|
+
endpoint: routeFactory,
|
|
224
|
+
route: routeFactory,
|
|
225
|
+
integrationRoute: routeFactory
|
|
226
|
+
}) : integration.endpoints;
|
|
227
|
+
const endpointRoutes = flattenIntegrationEndpoints(endpoints);
|
|
228
|
+
const allRoutes = routes?.length || endpointRoutes.length ? [...routes || [], ...endpointRoutes] : void 0;
|
|
229
|
+
const derivedApi = integration.api || (allRoutes?.length ? api.fromRoutes(
|
|
230
|
+
allRoutes
|
|
231
|
+
) : void 0);
|
|
232
|
+
return {
|
|
233
|
+
kind: "farm-integration",
|
|
234
|
+
...integration,
|
|
235
|
+
endpoints,
|
|
236
|
+
routes: allRoutes,
|
|
237
|
+
api: derivedApi,
|
|
238
|
+
category,
|
|
239
|
+
slot: category
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
__name(defineIntegration, "defineIntegration");
|
|
243
|
+
function isFarmIntegration(value) {
|
|
244
|
+
return !!value && typeof value === "object" && value.kind === "farm-integration";
|
|
245
|
+
}
|
|
246
|
+
__name(isFarmIntegration, "isFarmIntegration");
|
|
247
|
+
function resolveIntegrationPlugins(integrations) {
|
|
248
|
+
if (!integrations) {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
const plugins = [];
|
|
252
|
+
for (const [key, integration] of Object.entries(integrations)) {
|
|
253
|
+
if (!integration || !isFarmIntegration(integration)) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
plugins.push(createIntegrationPlugin(key, integration));
|
|
257
|
+
if (integration.plugins?.length) {
|
|
258
|
+
plugins.push(...integration.plugins);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return plugins;
|
|
262
|
+
}
|
|
263
|
+
__name(resolveIntegrationPlugins, "resolveIntegrationPlugins");
|
|
264
|
+
function getIntegrationProviders(integrations) {
|
|
265
|
+
if (!integrations) {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
const providers = [];
|
|
269
|
+
for (const integration of Object.values(integrations)) {
|
|
270
|
+
if (!integration || !isFarmIntegration(integration) || !integration.providers?.length) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
for (const provider of integration.providers) {
|
|
274
|
+
providers.push({
|
|
275
|
+
name: provider.name,
|
|
276
|
+
type: provider.type,
|
|
277
|
+
props: provider.props
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return providers;
|
|
282
|
+
}
|
|
283
|
+
__name(getIntegrationProviders, "getIntegrationProviders");
|
|
284
|
+
function getIntegrationDocumentNavigationMatchers(integrations) {
|
|
285
|
+
if (!integrations) {
|
|
286
|
+
return [];
|
|
287
|
+
}
|
|
288
|
+
const matchers = [];
|
|
289
|
+
for (const integration of Object.values(integrations)) {
|
|
290
|
+
if (!integration || !isFarmIntegration(integration) || !integration.documentNavigations?.length) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
for (const navigation of integration.documentNavigations) {
|
|
294
|
+
const items = Array.isArray(navigation.matcher) ? navigation.matcher : [navigation.matcher];
|
|
295
|
+
for (const item of items) {
|
|
296
|
+
matchers.push(item);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return matchers;
|
|
301
|
+
}
|
|
302
|
+
__name(getIntegrationDocumentNavigationMatchers, "getIntegrationDocumentNavigationMatchers");
|
|
303
|
+
function getIntegrationSchemas(integrations) {
|
|
304
|
+
if (!integrations) {
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
const schemaEntries = Object.entries(integrations).map(([key, integration]) => {
|
|
308
|
+
const schema = integration && isFarmIntegration(integration) ? integration.schema : void 0;
|
|
309
|
+
return schema ? [key, schema] : null;
|
|
310
|
+
}).filter((value) => value !== null);
|
|
311
|
+
return Object.fromEntries(schemaEntries);
|
|
312
|
+
}
|
|
313
|
+
__name(getIntegrationSchemas, "getIntegrationSchemas");
|
|
314
|
+
function getRegisteredIntegrationRuntime(key) {
|
|
315
|
+
return getIntegrationRuntimeRegistry().get(key);
|
|
316
|
+
}
|
|
317
|
+
__name(getRegisteredIntegrationRuntime, "getRegisteredIntegrationRuntime");
|
|
318
|
+
function getRegisteredIntegrations() {
|
|
319
|
+
return Object.fromEntries(
|
|
320
|
+
Array.from(getIntegrationRuntimeRegistry().entries()).map(([key, runtime]) => [
|
|
321
|
+
key,
|
|
322
|
+
runtime.integration
|
|
323
|
+
])
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
__name(getRegisteredIntegrations, "getRegisteredIntegrations");
|
|
327
|
+
function getRegisteredIntegrationSchemas() {
|
|
328
|
+
return getIntegrationSchemas(getRegisteredIntegrations());
|
|
329
|
+
}
|
|
330
|
+
__name(getRegisteredIntegrationSchemas, "getRegisteredIntegrationSchemas");
|
|
331
|
+
function matchIntegrationRoute(integrations, input) {
|
|
332
|
+
if (!integrations) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
for (const [key, integration] of Object.entries(integrations)) {
|
|
336
|
+
if (!integration || !isFarmIntegration(integration)) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const routes = normalizeIntegrationRoutes(integration.routes || []);
|
|
340
|
+
for (const route of routes) {
|
|
341
|
+
if (!matchesMethod(route.methods, input.method)) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const params = extractPathParams(route.path, input.pathname);
|
|
345
|
+
if (!params) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
key,
|
|
350
|
+
integration,
|
|
351
|
+
route: {
|
|
352
|
+
path: route.path,
|
|
353
|
+
methods: route.methods
|
|
354
|
+
},
|
|
355
|
+
params
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
__name(matchIntegrationRoute, "matchIntegrationRoute");
|
|
362
|
+
function matchRegisteredIntegrationRoute(input) {
|
|
363
|
+
return matchIntegrationRoute(getRegisteredIntegrations(), input);
|
|
364
|
+
}
|
|
365
|
+
__name(matchRegisteredIntegrationRoute, "matchRegisteredIntegrationRoute");
|
|
366
|
+
function createClientSafeIntegrationAPI(api2) {
|
|
367
|
+
if (!api2) {
|
|
368
|
+
return void 0;
|
|
369
|
+
}
|
|
370
|
+
const entries = Object.entries(api2).map(([key, value]) => {
|
|
371
|
+
if (value && typeof value === "object" && value.kind === "farm-integration-api-operation") {
|
|
372
|
+
const operation = value;
|
|
373
|
+
return [
|
|
374
|
+
key,
|
|
375
|
+
defineIntegrationAPIOperation({
|
|
376
|
+
path: operation.path,
|
|
377
|
+
method: operation.method,
|
|
378
|
+
bodyFormat: operation.bodyFormat,
|
|
379
|
+
responseFormat: operation.responseFormat,
|
|
380
|
+
credentials: operation.credentials,
|
|
381
|
+
isServer: operation.isServer
|
|
382
|
+
})
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
if (value && typeof value === "object") {
|
|
386
|
+
return [key, createClientSafeIntegrationAPI(value)];
|
|
387
|
+
}
|
|
388
|
+
return [key, value];
|
|
389
|
+
});
|
|
390
|
+
return Object.fromEntries(entries);
|
|
391
|
+
}
|
|
392
|
+
__name(createClientSafeIntegrationAPI, "createClientSafeIntegrationAPI");
|
|
393
|
+
function getRegisteredIntegrationAPIManifest() {
|
|
394
|
+
const manifestEntries = Object.entries(getRegisteredIntegrations()).map(([key, integration]) => {
|
|
395
|
+
const api2 = createClientSafeIntegrationAPI(integration.api);
|
|
396
|
+
return api2 ? [key, api2] : null;
|
|
397
|
+
}).filter((value) => value !== null);
|
|
398
|
+
return Object.fromEntries(manifestEntries);
|
|
399
|
+
}
|
|
400
|
+
__name(getRegisteredIntegrationAPIManifest, "getRegisteredIntegrationAPIManifest");
|
|
401
|
+
function getIntegrationRuntimeEnv() {
|
|
402
|
+
return typeof process !== "undefined" ? process.env : {};
|
|
403
|
+
}
|
|
404
|
+
__name(getIntegrationRuntimeEnv, "getIntegrationRuntimeEnv");
|
|
405
|
+
function isIntegrationConfigDefinition(value) {
|
|
406
|
+
return !!value && typeof value === "object" && ("schema" in value || "env" in value || "defaults" in value || "input" in value || "resolve" in value);
|
|
407
|
+
}
|
|
408
|
+
__name(isIntegrationConfigDefinition, "isIntegrationConfigDefinition");
|
|
409
|
+
function mergeIntegrationConfigValue(current, next) {
|
|
410
|
+
if (next === void 0) {
|
|
411
|
+
return current;
|
|
412
|
+
}
|
|
413
|
+
if (isPlainIntegrationConfigObject(current) && isPlainIntegrationConfigObject(next)) {
|
|
414
|
+
return {
|
|
415
|
+
...current,
|
|
416
|
+
...next
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return next;
|
|
420
|
+
}
|
|
421
|
+
__name(mergeIntegrationConfigValue, "mergeIntegrationConfigValue");
|
|
422
|
+
function isPlainIntegrationConfigObject(value) {
|
|
423
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
424
|
+
}
|
|
425
|
+
__name(isPlainIntegrationConfigObject, "isPlainIntegrationConfigObject");
|
|
426
|
+
async function resolveIntegrationConfigPart(value, context) {
|
|
427
|
+
if (typeof value === "function") {
|
|
428
|
+
return value(context);
|
|
429
|
+
}
|
|
430
|
+
return value;
|
|
431
|
+
}
|
|
432
|
+
__name(resolveIntegrationConfigPart, "resolveIntegrationConfigPart");
|
|
433
|
+
function resolveIntegrationEnvConfig(env) {
|
|
434
|
+
if (!env) {
|
|
435
|
+
return void 0;
|
|
436
|
+
}
|
|
437
|
+
const runtimeEnv = getIntegrationRuntimeEnv();
|
|
438
|
+
const config = {};
|
|
439
|
+
for (const [key, names] of Object.entries(env)) {
|
|
440
|
+
const envNames = Array.isArray(names) ? names : [names];
|
|
441
|
+
const value = envNames.map((name) => runtimeEnv[name]).find((entry) => entry !== void 0);
|
|
442
|
+
if (value !== void 0) {
|
|
443
|
+
config[key] = value;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return config;
|
|
447
|
+
}
|
|
448
|
+
__name(resolveIntegrationEnvConfig, "resolveIntegrationEnvConfig");
|
|
449
|
+
async function parseIntegrationConfigSchema(integration, schema, value) {
|
|
450
|
+
const parser = schema.safeParseAsync || schema.safeParse;
|
|
451
|
+
if (parser) {
|
|
452
|
+
const result = await parser.call(schema, value);
|
|
453
|
+
if (result.success) {
|
|
454
|
+
return result.data;
|
|
455
|
+
}
|
|
456
|
+
throw createIntegrationConfigValidationError(integration, result.error);
|
|
457
|
+
}
|
|
458
|
+
if (schema["~standard"]?.validate) {
|
|
459
|
+
const result = await schema["~standard"].validate(value);
|
|
460
|
+
if ("value" in result) {
|
|
461
|
+
return result.value;
|
|
462
|
+
}
|
|
463
|
+
throw createIntegrationConfigValidationError(integration, {
|
|
464
|
+
issues: result.issues
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
if (schema.parse) {
|
|
468
|
+
try {
|
|
469
|
+
return await schema.parse(value);
|
|
470
|
+
} catch (error) {
|
|
471
|
+
throw createIntegrationConfigValidationError(
|
|
472
|
+
integration,
|
|
473
|
+
normalizeIntegrationValidationError(error)
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
throw new Error(
|
|
478
|
+
`Integration "${integration.type}" config schema must expose safeParse, safeParseAsync, parse, or ~standard.validate.`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
__name(parseIntegrationConfigSchema, "parseIntegrationConfigSchema");
|
|
482
|
+
function createIntegrationConfigValidationError(integration, error) {
|
|
483
|
+
const issues = Array.isArray(error.issues) && error.issues.length > 0 ? error.issues.map((issue) => {
|
|
484
|
+
const normalizedPath = normalizeIntegrationValidationPath(issue.path);
|
|
485
|
+
const path = normalizedPath.length ? `${normalizedPath.join(".")}: ` : "";
|
|
486
|
+
return `${path}${issue.message || "Invalid config"}`;
|
|
487
|
+
}).join("; ") : error.message || "Invalid config";
|
|
488
|
+
return new Error(`Integration "${integration.type}" config validation failed: ${issues}`);
|
|
489
|
+
}
|
|
490
|
+
__name(createIntegrationConfigValidationError, "createIntegrationConfigValidationError");
|
|
491
|
+
async function resolveIntegrationConfig(integration, context) {
|
|
492
|
+
const config = integration.config;
|
|
493
|
+
if (!config) {
|
|
494
|
+
return void 0;
|
|
495
|
+
}
|
|
496
|
+
if (!isIntegrationConfigDefinition(config)) {
|
|
497
|
+
return parseIntegrationConfigSchema(integration, config, {});
|
|
498
|
+
}
|
|
499
|
+
let value = {};
|
|
500
|
+
value = mergeIntegrationConfigValue(
|
|
501
|
+
value,
|
|
502
|
+
await resolveIntegrationConfigPart(config.defaults, context)
|
|
503
|
+
);
|
|
504
|
+
value = mergeIntegrationConfigValue(value, resolveIntegrationEnvConfig(config.env));
|
|
505
|
+
value = mergeIntegrationConfigValue(
|
|
506
|
+
value,
|
|
507
|
+
await resolveIntegrationConfigPart(config.input, context)
|
|
508
|
+
);
|
|
509
|
+
value = mergeIntegrationConfigValue(value, await config.resolve?.(context));
|
|
510
|
+
return config.schema ? parseIntegrationConfigSchema(integration, config.schema, value) : value;
|
|
511
|
+
}
|
|
512
|
+
__name(resolveIntegrationConfig, "resolveIntegrationConfig");
|
|
513
|
+
function createIntegrationLifecycleLogger(integration, phase) {
|
|
514
|
+
const write = /* @__PURE__ */ __name((level, message, meta) => {
|
|
515
|
+
if (!integration.log) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
void Promise.resolve(
|
|
519
|
+
integration.log({
|
|
520
|
+
category: integration.category,
|
|
521
|
+
slot: integration.category,
|
|
522
|
+
type: integration.type,
|
|
523
|
+
phase,
|
|
524
|
+
level,
|
|
525
|
+
message,
|
|
526
|
+
meta,
|
|
527
|
+
context: /* @__PURE__ */ new Map()
|
|
528
|
+
})
|
|
529
|
+
).catch(() => {
|
|
530
|
+
});
|
|
531
|
+
}, "write");
|
|
532
|
+
return {
|
|
533
|
+
info(message, meta) {
|
|
534
|
+
write("info", message, meta);
|
|
535
|
+
},
|
|
536
|
+
warn(message, meta) {
|
|
537
|
+
write("warn", message, meta);
|
|
538
|
+
},
|
|
539
|
+
error(message, meta) {
|
|
540
|
+
write("error", message, meta);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
__name(createIntegrationLifecycleLogger, "createIntegrationLifecycleLogger");
|
|
545
|
+
var INTEGRATION_DATA_HEADER = "x-farm-integration-data";
|
|
546
|
+
var INTEGRATION_DATA_HEADER_MAX_LENGTH = 16 * 1024;
|
|
547
|
+
var BLOCKED_INTEGRATION_DATA_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
548
|
+
function isFarmIntegrationData(value) {
|
|
549
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
550
|
+
}
|
|
551
|
+
__name(isFarmIntegrationData, "isFarmIntegrationData");
|
|
552
|
+
function isPlainIntegrationDataObject(value) {
|
|
553
|
+
if (!isFarmIntegrationData(value)) {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
const prototype = Object.getPrototypeOf(value);
|
|
557
|
+
return prototype === Object.prototype || prototype === null;
|
|
558
|
+
}
|
|
559
|
+
__name(isPlainIntegrationDataObject, "isPlainIntegrationDataObject");
|
|
560
|
+
function sanitizeIntegrationDataValue(value) {
|
|
561
|
+
if (Array.isArray(value)) {
|
|
562
|
+
return value.map((item) => sanitizeIntegrationDataValue(item));
|
|
563
|
+
}
|
|
564
|
+
if (!isPlainIntegrationDataObject(value)) {
|
|
565
|
+
return value;
|
|
566
|
+
}
|
|
567
|
+
const sanitized = {};
|
|
568
|
+
for (const [key, item] of Object.entries(value)) {
|
|
569
|
+
if (BLOCKED_INTEGRATION_DATA_KEYS.has(key)) {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
sanitized[key] = sanitizeIntegrationDataValue(item);
|
|
573
|
+
}
|
|
574
|
+
return sanitized;
|
|
575
|
+
}
|
|
576
|
+
__name(sanitizeIntegrationDataValue, "sanitizeIntegrationDataValue");
|
|
577
|
+
function normalizeIntegrationData(value) {
|
|
578
|
+
if (!isFarmIntegrationData(value)) {
|
|
579
|
+
return {};
|
|
580
|
+
}
|
|
581
|
+
const sanitized = sanitizeIntegrationDataValue(value);
|
|
582
|
+
return isFarmIntegrationData(sanitized) ? sanitized : {};
|
|
583
|
+
}
|
|
584
|
+
__name(normalizeIntegrationData, "normalizeIntegrationData");
|
|
585
|
+
function getIntegrationDataHeaderByteLength(value) {
|
|
586
|
+
return new TextEncoder().encode(value).byteLength;
|
|
587
|
+
}
|
|
588
|
+
__name(getIntegrationDataHeaderByteLength, "getIntegrationDataHeaderByteLength");
|
|
589
|
+
function parseIntegrationDataHeader(request) {
|
|
590
|
+
const raw = request.headers.get(INTEGRATION_DATA_HEADER);
|
|
591
|
+
if (!raw) {
|
|
592
|
+
return {};
|
|
593
|
+
}
|
|
594
|
+
if (getIntegrationDataHeaderByteLength(raw) > INTEGRATION_DATA_HEADER_MAX_LENGTH) {
|
|
595
|
+
return {};
|
|
596
|
+
}
|
|
597
|
+
try {
|
|
598
|
+
const value = JSON.parse(raw);
|
|
599
|
+
return normalizeIntegrationData(value);
|
|
600
|
+
} catch {
|
|
601
|
+
return {};
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
__name(parseIntegrationDataHeader, "parseIntegrationDataHeader");
|
|
605
|
+
function resolveIntegrationData(request, data) {
|
|
606
|
+
return {
|
|
607
|
+
...parseIntegrationDataHeader(request),
|
|
608
|
+
...normalizeIntegrationData(data)
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
__name(resolveIntegrationData, "resolveIntegrationData");
|
|
612
|
+
function createIntegrationPlugin(integrationKey, integration) {
|
|
613
|
+
const routes = normalizeIntegrationRoutes(integration.routes || []);
|
|
614
|
+
const middleware = [...integration.middleware || []];
|
|
615
|
+
const cleanupCallbacks = [];
|
|
616
|
+
let integrationConfigPromise;
|
|
617
|
+
const runCleanup = /* @__PURE__ */ __name(async () => {
|
|
618
|
+
const callbacks = cleanupCallbacks.splice(0).reverse();
|
|
619
|
+
for (const callback of callbacks) {
|
|
620
|
+
await callback();
|
|
621
|
+
}
|
|
622
|
+
}, "runCleanup");
|
|
623
|
+
const createLifecycleContext = /* @__PURE__ */ __name(async (context, phase, options = {}) => {
|
|
624
|
+
const args = createIntegrationRouteArgs({
|
|
625
|
+
integration,
|
|
626
|
+
config: context.config
|
|
627
|
+
});
|
|
628
|
+
const configContext = {
|
|
629
|
+
key: integrationKey,
|
|
630
|
+
integration,
|
|
631
|
+
appConfig: context.config,
|
|
632
|
+
config: context.config,
|
|
633
|
+
args,
|
|
634
|
+
env: getIntegrationRuntimeEnv(),
|
|
635
|
+
isDev: context.isDev,
|
|
636
|
+
isProd: context.isProd
|
|
637
|
+
};
|
|
638
|
+
integrationConfigPromise ?? (integrationConfigPromise = resolveIntegrationConfig(integration, configContext));
|
|
639
|
+
return {
|
|
640
|
+
...configContext,
|
|
641
|
+
integrationConfig: await integrationConfigPromise,
|
|
642
|
+
log: createIntegrationLifecycleLogger(integration, phase),
|
|
643
|
+
reason: options.reason,
|
|
644
|
+
async cleanup(callback) {
|
|
645
|
+
if (callback) {
|
|
646
|
+
cleanupCallbacks.push(callback);
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
await runCleanup();
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}, "createLifecycleContext");
|
|
653
|
+
const plugin = {
|
|
654
|
+
name: `farm:integration:${integration.category}:${integration.type}`,
|
|
655
|
+
enforce: "pre",
|
|
656
|
+
async init(context) {
|
|
657
|
+
getIntegrationRuntimeRegistry().set(integrationKey, {
|
|
658
|
+
integration,
|
|
659
|
+
config: context.config,
|
|
660
|
+
isDev: context.isDev,
|
|
661
|
+
isProd: context.isProd
|
|
662
|
+
});
|
|
663
|
+
await createLifecycleContext(context, "validate");
|
|
664
|
+
if (integration.validate) {
|
|
665
|
+
await integration.validate(await createLifecycleContext(context, "validate"));
|
|
666
|
+
}
|
|
667
|
+
if (integration.setup) {
|
|
668
|
+
await integration.setup(await createLifecycleContext(context, "setup"));
|
|
669
|
+
}
|
|
670
|
+
if (!integration.log) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
for (const route of routes) {
|
|
674
|
+
await integration.log({
|
|
675
|
+
category: integration.category,
|
|
676
|
+
slot: integration.category,
|
|
677
|
+
type: integration.type,
|
|
678
|
+
phase: "registered",
|
|
679
|
+
route: {
|
|
680
|
+
kind: "route",
|
|
681
|
+
path: route.path,
|
|
682
|
+
methods: route.methods
|
|
683
|
+
},
|
|
684
|
+
context: /* @__PURE__ */ new Map()
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
for (const entry of middleware) {
|
|
688
|
+
await integration.log({
|
|
689
|
+
category: integration.category,
|
|
690
|
+
slot: integration.category,
|
|
691
|
+
type: integration.type,
|
|
692
|
+
phase: "registered",
|
|
693
|
+
route: {
|
|
694
|
+
kind: "middleware",
|
|
695
|
+
path: normalizeMatcher(entry.matcher),
|
|
696
|
+
methods: ["ALL"]
|
|
697
|
+
},
|
|
698
|
+
context: /* @__PURE__ */ new Map()
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
async ready(context) {
|
|
703
|
+
if (integration.ready) {
|
|
704
|
+
await integration.ready(await createLifecycleContext(context, "ready"));
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
async shutdown(payload, context) {
|
|
708
|
+
try {
|
|
709
|
+
if (integration.dispose) {
|
|
710
|
+
await integration.dispose(
|
|
711
|
+
await createLifecycleContext(context, "dispose", {
|
|
712
|
+
reason: payload.reason
|
|
713
|
+
})
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
} finally {
|
|
717
|
+
await runCleanup();
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
async beforeRequest(req, res, context) {
|
|
721
|
+
const fullUrl = `http://${req.headers.host || "localhost"}${req.url || "/"}`;
|
|
722
|
+
const url = new URL(fullUrl);
|
|
723
|
+
const pathname = url.pathname;
|
|
724
|
+
const requestId = getRequestId(req);
|
|
725
|
+
let bodyLoaded = false;
|
|
726
|
+
let requestBody;
|
|
727
|
+
const getRequestBody = /* @__PURE__ */ __name(async () => {
|
|
728
|
+
if (!bodyLoaded) {
|
|
729
|
+
bodyLoaded = true;
|
|
730
|
+
if (req.method && req.method !== "GET" && req.method !== "HEAD") {
|
|
731
|
+
requestBody = await readRequestBody(req);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return requestBody;
|
|
735
|
+
}, "getRequestBody");
|
|
736
|
+
const createHandlerRequest = /* @__PURE__ */ __name(async () => {
|
|
737
|
+
return createWebRequest(req, fullUrl, await getRequestBody());
|
|
738
|
+
}, "createHandlerRequest");
|
|
739
|
+
for (const entry of middleware) {
|
|
740
|
+
const params = resolveMatcherParams(entry.matcher, pathname);
|
|
741
|
+
if (!params) {
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
const request = await createHandlerRequest();
|
|
745
|
+
const handlerContext = createIntegrationHandlerContext({
|
|
746
|
+
integration,
|
|
747
|
+
route: {
|
|
748
|
+
kind: "middleware",
|
|
749
|
+
path: normalizeMatcher(entry.matcher),
|
|
750
|
+
methods: ["ALL"]
|
|
751
|
+
},
|
|
752
|
+
request,
|
|
753
|
+
rawRequest: req,
|
|
754
|
+
params,
|
|
755
|
+
pathname,
|
|
756
|
+
requestId,
|
|
757
|
+
pluginContext: context
|
|
758
|
+
});
|
|
759
|
+
const startedAt = Date.now();
|
|
760
|
+
await integration.log?.({
|
|
761
|
+
category: integration.category,
|
|
762
|
+
slot: integration.category,
|
|
763
|
+
type: integration.type,
|
|
764
|
+
phase: "request:start",
|
|
765
|
+
route: {
|
|
766
|
+
kind: "middleware",
|
|
767
|
+
path: normalizeMatcher(entry.matcher),
|
|
768
|
+
methods: ["ALL"]
|
|
769
|
+
},
|
|
770
|
+
request,
|
|
771
|
+
requestId,
|
|
772
|
+
context: handlerContext.req.snapshot()
|
|
773
|
+
});
|
|
774
|
+
try {
|
|
775
|
+
const response = await entry.handler(request, handlerContext);
|
|
776
|
+
if (response) {
|
|
777
|
+
await sendWebResponse(res, response);
|
|
778
|
+
await integration.log?.({
|
|
779
|
+
category: integration.category,
|
|
780
|
+
slot: integration.category,
|
|
781
|
+
type: integration.type,
|
|
782
|
+
phase: "request:end",
|
|
783
|
+
route: {
|
|
784
|
+
kind: "middleware",
|
|
785
|
+
path: normalizeMatcher(entry.matcher),
|
|
786
|
+
methods: ["ALL"]
|
|
787
|
+
},
|
|
788
|
+
request,
|
|
789
|
+
response,
|
|
790
|
+
requestId,
|
|
791
|
+
durationMs: Date.now() - startedAt,
|
|
792
|
+
context: handlerContext.req.snapshot()
|
|
793
|
+
});
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
await integration.log?.({
|
|
797
|
+
category: integration.category,
|
|
798
|
+
slot: integration.category,
|
|
799
|
+
type: integration.type,
|
|
800
|
+
phase: "request:end",
|
|
801
|
+
route: {
|
|
802
|
+
kind: "middleware",
|
|
803
|
+
path: normalizeMatcher(entry.matcher),
|
|
804
|
+
methods: ["ALL"]
|
|
805
|
+
},
|
|
806
|
+
request,
|
|
807
|
+
requestId,
|
|
808
|
+
durationMs: Date.now() - startedAt,
|
|
809
|
+
context: handlerContext.req.snapshot()
|
|
810
|
+
});
|
|
811
|
+
} catch (error) {
|
|
812
|
+
await integration.log?.({
|
|
813
|
+
category: integration.category,
|
|
814
|
+
slot: integration.category,
|
|
815
|
+
type: integration.type,
|
|
816
|
+
phase: "request:error",
|
|
817
|
+
route: {
|
|
818
|
+
kind: "middleware",
|
|
819
|
+
path: normalizeMatcher(entry.matcher),
|
|
820
|
+
methods: ["ALL"]
|
|
821
|
+
},
|
|
822
|
+
request,
|
|
823
|
+
requestId,
|
|
824
|
+
durationMs: Date.now() - startedAt,
|
|
825
|
+
error,
|
|
826
|
+
context: handlerContext.req.snapshot()
|
|
827
|
+
});
|
|
828
|
+
throw error;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
for (const route of routes) {
|
|
832
|
+
const params = matchesMethod(route.methods, req.method) ? extractPathParams(route.path, pathname) : null;
|
|
833
|
+
if (!params) {
|
|
834
|
+
continue;
|
|
835
|
+
}
|
|
836
|
+
const request = await createHandlerRequest();
|
|
837
|
+
const handlerContext = createIntegrationHandlerContext({
|
|
838
|
+
integration,
|
|
839
|
+
route: {
|
|
840
|
+
kind: "route",
|
|
841
|
+
path: route.path,
|
|
842
|
+
methods: route.methods
|
|
843
|
+
},
|
|
844
|
+
request,
|
|
845
|
+
rawRequest: req,
|
|
846
|
+
params,
|
|
847
|
+
pathname,
|
|
848
|
+
requestId,
|
|
849
|
+
pluginContext: context
|
|
850
|
+
});
|
|
851
|
+
const startedAt = Date.now();
|
|
852
|
+
await integration.log?.({
|
|
853
|
+
category: integration.category,
|
|
854
|
+
slot: integration.category,
|
|
855
|
+
type: integration.type,
|
|
856
|
+
phase: "request:start",
|
|
857
|
+
route: {
|
|
858
|
+
kind: "route",
|
|
859
|
+
path: route.path,
|
|
860
|
+
methods: route.methods
|
|
861
|
+
},
|
|
862
|
+
request,
|
|
863
|
+
requestId,
|
|
864
|
+
context: handlerContext.req.snapshot()
|
|
865
|
+
});
|
|
866
|
+
try {
|
|
867
|
+
const validation = await validateIntegrationRouteInput(route, request, url);
|
|
868
|
+
if (!validation.success) {
|
|
869
|
+
await sendWebResponse(res, validation.response);
|
|
870
|
+
await integration.log?.({
|
|
871
|
+
category: integration.category,
|
|
872
|
+
slot: integration.category,
|
|
873
|
+
type: integration.type,
|
|
874
|
+
phase: "request:end",
|
|
875
|
+
route: {
|
|
876
|
+
kind: "route",
|
|
877
|
+
path: route.path,
|
|
878
|
+
methods: route.methods
|
|
879
|
+
},
|
|
880
|
+
request,
|
|
881
|
+
response: validation.response,
|
|
882
|
+
requestId,
|
|
883
|
+
durationMs: Date.now() - startedAt,
|
|
884
|
+
context: handlerContext.req.snapshot()
|
|
885
|
+
});
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
handlerContext.input = validation.input;
|
|
889
|
+
for (const middlewareEntry of route.middleware || []) {
|
|
890
|
+
const middlewareResponse = await middlewareEntry.handler(request, handlerContext);
|
|
891
|
+
if (middlewareResponse) {
|
|
892
|
+
await sendWebResponse(res, middlewareResponse);
|
|
893
|
+
await integration.log?.({
|
|
894
|
+
category: integration.category,
|
|
895
|
+
slot: integration.category,
|
|
896
|
+
type: integration.type,
|
|
897
|
+
phase: "request:end",
|
|
898
|
+
route: {
|
|
899
|
+
kind: "route",
|
|
900
|
+
path: route.path,
|
|
901
|
+
methods: route.methods
|
|
902
|
+
},
|
|
903
|
+
request,
|
|
904
|
+
response: middlewareResponse,
|
|
905
|
+
requestId,
|
|
906
|
+
durationMs: Date.now() - startedAt,
|
|
907
|
+
context: handlerContext.req.snapshot()
|
|
908
|
+
});
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const beforeResponse = await runIntegrationRouteBeforeHooks(
|
|
913
|
+
route,
|
|
914
|
+
request,
|
|
915
|
+
handlerContext
|
|
916
|
+
);
|
|
917
|
+
if (beforeResponse) {
|
|
918
|
+
const response2 = await runIntegrationRouteAfterHooks(
|
|
919
|
+
route,
|
|
920
|
+
request,
|
|
921
|
+
handlerContext,
|
|
922
|
+
beforeResponse
|
|
923
|
+
);
|
|
924
|
+
await sendWebResponse(res, response2);
|
|
925
|
+
await integration.log?.({
|
|
926
|
+
category: integration.category,
|
|
927
|
+
slot: integration.category,
|
|
928
|
+
type: integration.type,
|
|
929
|
+
phase: "request:end",
|
|
930
|
+
route: {
|
|
931
|
+
kind: "route",
|
|
932
|
+
path: route.path,
|
|
933
|
+
methods: route.methods
|
|
934
|
+
},
|
|
935
|
+
request,
|
|
936
|
+
response: response2,
|
|
937
|
+
requestId,
|
|
938
|
+
durationMs: Date.now() - startedAt,
|
|
939
|
+
context: handlerContext.req.snapshot()
|
|
940
|
+
});
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
const handlerResponse = await route.handler(request, handlerContext);
|
|
944
|
+
const response = await runIntegrationRouteAfterHooks(
|
|
945
|
+
route,
|
|
946
|
+
request,
|
|
947
|
+
handlerContext,
|
|
948
|
+
handlerResponse
|
|
949
|
+
);
|
|
950
|
+
await sendWebResponse(res, response);
|
|
951
|
+
await integration.log?.({
|
|
952
|
+
category: integration.category,
|
|
953
|
+
slot: integration.category,
|
|
954
|
+
type: integration.type,
|
|
955
|
+
phase: "request:end",
|
|
956
|
+
route: {
|
|
957
|
+
kind: "route",
|
|
958
|
+
path: route.path,
|
|
959
|
+
methods: route.methods
|
|
960
|
+
},
|
|
961
|
+
request,
|
|
962
|
+
response,
|
|
963
|
+
requestId,
|
|
964
|
+
durationMs: Date.now() - startedAt,
|
|
965
|
+
context: handlerContext.req.snapshot()
|
|
966
|
+
});
|
|
967
|
+
return;
|
|
968
|
+
} catch (error) {
|
|
969
|
+
await integration.log?.({
|
|
970
|
+
category: integration.category,
|
|
971
|
+
slot: integration.category,
|
|
972
|
+
type: integration.type,
|
|
973
|
+
phase: "request:error",
|
|
974
|
+
route: {
|
|
975
|
+
kind: "route",
|
|
976
|
+
path: route.path,
|
|
977
|
+
methods: route.methods
|
|
978
|
+
},
|
|
979
|
+
request,
|
|
980
|
+
requestId,
|
|
981
|
+
durationMs: Date.now() - startedAt,
|
|
982
|
+
error,
|
|
983
|
+
context: handlerContext.req.snapshot()
|
|
984
|
+
});
|
|
985
|
+
throw error;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
Object.defineProperty(plugin, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME, {
|
|
991
|
+
value: integration.serverRuntime !== false
|
|
992
|
+
});
|
|
993
|
+
return plugin;
|
|
994
|
+
}
|
|
995
|
+
__name(createIntegrationPlugin, "createIntegrationPlugin");
|
|
996
|
+
function createIntegrationHandlerContext(input) {
|
|
997
|
+
const req = createIntegrationRequestContextStore(
|
|
998
|
+
input.rawRequest,
|
|
999
|
+
input.request,
|
|
1000
|
+
input.pluginContext
|
|
1001
|
+
);
|
|
1002
|
+
return {
|
|
1003
|
+
request: input.request,
|
|
1004
|
+
requestId: input.requestId,
|
|
1005
|
+
url: new URL(input.request.url),
|
|
1006
|
+
pathname: input.pathname,
|
|
1007
|
+
method: input.request.method,
|
|
1008
|
+
params: input.params,
|
|
1009
|
+
input: {},
|
|
1010
|
+
args: createIntegrationRouteArgs({
|
|
1011
|
+
integration: input.integration,
|
|
1012
|
+
config: input.pluginContext.config
|
|
1013
|
+
}),
|
|
1014
|
+
data: resolveIntegrationData(input.request),
|
|
1015
|
+
integration: {
|
|
1016
|
+
category: input.integration.category,
|
|
1017
|
+
slot: input.integration.category,
|
|
1018
|
+
type: input.integration.type,
|
|
1019
|
+
instance: input.integration.instance
|
|
1020
|
+
},
|
|
1021
|
+
route: input.route,
|
|
1022
|
+
req,
|
|
1023
|
+
requestContext: req,
|
|
1024
|
+
config: input.pluginContext.config,
|
|
1025
|
+
isDev: input.pluginContext.isDev,
|
|
1026
|
+
isProd: input.pluginContext.isProd
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
__name(createIntegrationHandlerContext, "createIntegrationHandlerContext");
|
|
1030
|
+
function normalizeIntegrationRoutes(routes) {
|
|
1031
|
+
return routes.map((route) => ({
|
|
1032
|
+
...route,
|
|
1033
|
+
methods: normalizeIntegrationRouteMethods(route),
|
|
1034
|
+
input: normalizeIntegrationRouteInputSchemas(route)
|
|
1035
|
+
}));
|
|
1036
|
+
}
|
|
1037
|
+
__name(normalizeIntegrationRoutes, "normalizeIntegrationRoutes");
|
|
1038
|
+
function normalizeIntegrationRouteMethods(route) {
|
|
1039
|
+
const input = route.methods && route.methods.length > 0 ? [...route.methods] : route.method ? [route.method] : ["ALL"];
|
|
1040
|
+
return input.map((method) => String(method).toUpperCase());
|
|
1041
|
+
}
|
|
1042
|
+
__name(normalizeIntegrationRouteMethods, "normalizeIntegrationRouteMethods");
|
|
1043
|
+
function normalizeIntegrationRouteInputSchemas(route) {
|
|
1044
|
+
const input = {
|
|
1045
|
+
...route.input
|
|
1046
|
+
};
|
|
1047
|
+
if (route.body) {
|
|
1048
|
+
input.body = route.body;
|
|
1049
|
+
}
|
|
1050
|
+
if (route.query) {
|
|
1051
|
+
input.query = route.query;
|
|
1052
|
+
}
|
|
1053
|
+
return input.body || input.query ? input : void 0;
|
|
1054
|
+
}
|
|
1055
|
+
__name(normalizeIntegrationRouteInputSchemas, "normalizeIntegrationRouteInputSchemas");
|
|
1056
|
+
async function validateIntegrationRouteInput(route, request, url) {
|
|
1057
|
+
const schemas = route.input;
|
|
1058
|
+
if (!schemas?.body && !schemas?.query) {
|
|
1059
|
+
return {
|
|
1060
|
+
success: true,
|
|
1061
|
+
input: {}
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
const input = {};
|
|
1065
|
+
const issues = [];
|
|
1066
|
+
if (schemas.query) {
|
|
1067
|
+
const queryResult = await parseIntegrationInputSchema(
|
|
1068
|
+
"query",
|
|
1069
|
+
schemas.query,
|
|
1070
|
+
createQueryInput(url.searchParams)
|
|
1071
|
+
);
|
|
1072
|
+
if (queryResult.success) {
|
|
1073
|
+
input.query = queryResult.data;
|
|
1074
|
+
} else {
|
|
1075
|
+
issues.push(...queryResult.issues);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
if (schemas.body) {
|
|
1079
|
+
const bodyInput = await readIntegrationValidationBody(
|
|
1080
|
+
request,
|
|
1081
|
+
getIntegrationRouteBodyFormat(route)
|
|
1082
|
+
);
|
|
1083
|
+
if (bodyInput.success) {
|
|
1084
|
+
const bodyResult = await parseIntegrationInputSchema("body", schemas.body, bodyInput.data);
|
|
1085
|
+
if (bodyResult.success) {
|
|
1086
|
+
input.body = bodyResult.data;
|
|
1087
|
+
} else {
|
|
1088
|
+
issues.push(...bodyResult.issues);
|
|
1089
|
+
}
|
|
1090
|
+
} else {
|
|
1091
|
+
issues.push(bodyInput.issue);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
if (issues.length > 0) {
|
|
1095
|
+
return {
|
|
1096
|
+
success: false,
|
|
1097
|
+
response: createIntegrationValidationResponse(issues)
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
return {
|
|
1101
|
+
success: true,
|
|
1102
|
+
input
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
__name(validateIntegrationRouteInput, "validateIntegrationRouteInput");
|
|
1106
|
+
async function parseIntegrationInputSchema(source, schema, value) {
|
|
1107
|
+
const parser = schema.safeParseAsync || schema.safeParse;
|
|
1108
|
+
if (parser) {
|
|
1109
|
+
const result = await parser.call(schema, value);
|
|
1110
|
+
if (result.success) {
|
|
1111
|
+
return {
|
|
1112
|
+
success: true,
|
|
1113
|
+
data: result.data
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
return {
|
|
1117
|
+
success: false,
|
|
1118
|
+
issues: normalizeIntegrationValidationIssues(source, result.error)
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
if (schema["~standard"]?.validate) {
|
|
1122
|
+
const result = await schema["~standard"].validate(value);
|
|
1123
|
+
if ("value" in result) {
|
|
1124
|
+
return {
|
|
1125
|
+
success: true,
|
|
1126
|
+
data: result.value
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
return {
|
|
1130
|
+
success: false,
|
|
1131
|
+
issues: normalizeIntegrationValidationIssues(source, {
|
|
1132
|
+
issues: result.issues
|
|
1133
|
+
})
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
if (schema.parse) {
|
|
1137
|
+
try {
|
|
1138
|
+
return {
|
|
1139
|
+
success: true,
|
|
1140
|
+
data: await schema.parse(value)
|
|
1141
|
+
};
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
return {
|
|
1144
|
+
success: false,
|
|
1145
|
+
issues: normalizeIntegrationValidationIssues(
|
|
1146
|
+
source,
|
|
1147
|
+
normalizeIntegrationValidationError(error)
|
|
1148
|
+
)
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return {
|
|
1153
|
+
success: false,
|
|
1154
|
+
issues: [
|
|
1155
|
+
{
|
|
1156
|
+
source,
|
|
1157
|
+
message: "Input schema must expose safeParse, safeParseAsync, parse, or ~standard.validate."
|
|
1158
|
+
}
|
|
1159
|
+
]
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
__name(parseIntegrationInputSchema, "parseIntegrationInputSchema");
|
|
1163
|
+
function createIntegrationValidationResponse(issues) {
|
|
1164
|
+
return Response.json(
|
|
1165
|
+
{
|
|
1166
|
+
error: "Integration route input validation failed",
|
|
1167
|
+
issues
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
status: 400
|
|
1171
|
+
}
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
__name(createIntegrationValidationResponse, "createIntegrationValidationResponse");
|
|
1175
|
+
function normalizeIntegrationValidationIssues(source, error) {
|
|
1176
|
+
if (Array.isArray(error.issues) && error.issues.length > 0) {
|
|
1177
|
+
return error.issues.map((issue) => ({
|
|
1178
|
+
source,
|
|
1179
|
+
path: normalizeIntegrationValidationPath(issue.path),
|
|
1180
|
+
code: issue.code,
|
|
1181
|
+
message: issue.message || "Invalid input"
|
|
1182
|
+
}));
|
|
1183
|
+
}
|
|
1184
|
+
return [
|
|
1185
|
+
{
|
|
1186
|
+
source,
|
|
1187
|
+
path: [],
|
|
1188
|
+
message: error.message || "Invalid input"
|
|
1189
|
+
}
|
|
1190
|
+
];
|
|
1191
|
+
}
|
|
1192
|
+
__name(normalizeIntegrationValidationIssues, "normalizeIntegrationValidationIssues");
|
|
1193
|
+
function normalizeIntegrationValidationPath(path) {
|
|
1194
|
+
return (path || []).map((segment) => {
|
|
1195
|
+
const key = typeof segment === "object" && segment !== null && "key" in segment ? segment.key : segment;
|
|
1196
|
+
return typeof key === "symbol" ? key.description || key.toString() : key;
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
__name(normalizeIntegrationValidationPath, "normalizeIntegrationValidationPath");
|
|
1200
|
+
function normalizeIntegrationValidationError(error) {
|
|
1201
|
+
if (error && typeof error === "object") {
|
|
1202
|
+
return error;
|
|
1203
|
+
}
|
|
1204
|
+
return {
|
|
1205
|
+
message: error instanceof Error ? error.message : String(error || "Invalid input")
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
__name(normalizeIntegrationValidationError, "normalizeIntegrationValidationError");
|
|
1209
|
+
async function readIntegrationValidationBody(request, format) {
|
|
1210
|
+
if (request.method === "GET" || request.method === "HEAD" || format === "none") {
|
|
1211
|
+
return {
|
|
1212
|
+
success: true,
|
|
1213
|
+
data: void 0
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
try {
|
|
1217
|
+
if (format === "form") {
|
|
1218
|
+
return {
|
|
1219
|
+
success: true,
|
|
1220
|
+
data: createFormInput(await request.clone().formData())
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
const text = await request.clone().text();
|
|
1224
|
+
if (text.trim().length === 0) {
|
|
1225
|
+
return {
|
|
1226
|
+
success: true,
|
|
1227
|
+
data: void 0
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
return {
|
|
1231
|
+
success: true,
|
|
1232
|
+
data: JSON.parse(text)
|
|
1233
|
+
};
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
return {
|
|
1236
|
+
success: false,
|
|
1237
|
+
issue: {
|
|
1238
|
+
source: "body",
|
|
1239
|
+
path: [],
|
|
1240
|
+
message: format === "json" ? "Expected a valid JSON request body." : error instanceof Error && error.message ? error.message : "Could not parse request body."
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
__name(readIntegrationValidationBody, "readIntegrationValidationBody");
|
|
1246
|
+
function getIntegrationRouteBodyFormat(route) {
|
|
1247
|
+
return route.bodyFormat || route.__operation?.bodyFormat || "json";
|
|
1248
|
+
}
|
|
1249
|
+
__name(getIntegrationRouteBodyFormat, "getIntegrationRouteBodyFormat");
|
|
1250
|
+
function createIntegrationRouteArgs(input) {
|
|
1251
|
+
let clientPromise;
|
|
1252
|
+
let ormPromise;
|
|
1253
|
+
const getClient = /* @__PURE__ */ __name(() => {
|
|
1254
|
+
clientPromise ?? (clientPromise = import("./storage.mjs").then(
|
|
1255
|
+
({ resolveStorageRuntimeClient }) => resolveStorageRuntimeClient(input.config.storage)
|
|
1256
|
+
));
|
|
1257
|
+
return clientPromise;
|
|
1258
|
+
}, "getClient");
|
|
1259
|
+
const getOrm = /* @__PURE__ */ __name(() => {
|
|
1260
|
+
if (!input.integration.schema) {
|
|
1261
|
+
throw new Error(
|
|
1262
|
+
`Integration "${input.integration.type}" does not define a schema for ctx.args.db.`
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
ormPromise ?? (ormPromise = import("./integration-orm-GQLGU66X.mjs").then(
|
|
1266
|
+
({ createIntegrationOrm }) => createIntegrationOrm({
|
|
1267
|
+
schema: input.integration.schema,
|
|
1268
|
+
config: input.config
|
|
1269
|
+
})
|
|
1270
|
+
));
|
|
1271
|
+
return ormPromise;
|
|
1272
|
+
}, "getOrm");
|
|
1273
|
+
return {
|
|
1274
|
+
db: createLazyIntegrationOrmClient(getOrm),
|
|
1275
|
+
getDb: getOrm,
|
|
1276
|
+
storage: {
|
|
1277
|
+
getClient,
|
|
1278
|
+
getOrm
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
__name(createIntegrationRouteArgs, "createIntegrationRouteArgs");
|
|
1283
|
+
function createLazyIntegrationOrmClient(resolveOrm) {
|
|
1284
|
+
const modelProxyCache = /* @__PURE__ */ new Map();
|
|
1285
|
+
return new Proxy(
|
|
1286
|
+
{},
|
|
1287
|
+
{
|
|
1288
|
+
get(_target, prop) {
|
|
1289
|
+
if (prop === "then") {
|
|
1290
|
+
return void 0;
|
|
1291
|
+
}
|
|
1292
|
+
if (prop === "transaction" || prop === "batch") {
|
|
1293
|
+
return async (...args) => {
|
|
1294
|
+
const orm = await resolveOrm();
|
|
1295
|
+
const member = orm[prop];
|
|
1296
|
+
if (typeof member !== "function") {
|
|
1297
|
+
throw new Error(`Integration ORM does not expose "${String(prop)}".`);
|
|
1298
|
+
}
|
|
1299
|
+
return member.apply(orm, args);
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
if (prop === "$driver") {
|
|
1303
|
+
return void 0;
|
|
1304
|
+
}
|
|
1305
|
+
if (!modelProxyCache.has(prop)) {
|
|
1306
|
+
modelProxyCache.set(prop, createLazyIntegrationOrmModel(resolveOrm, prop));
|
|
1307
|
+
}
|
|
1308
|
+
return modelProxyCache.get(prop);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
__name(createLazyIntegrationOrmClient, "createLazyIntegrationOrmClient");
|
|
1314
|
+
function createLazyIntegrationOrmModel(resolveOrm, modelName) {
|
|
1315
|
+
return new Proxy(
|
|
1316
|
+
{},
|
|
1317
|
+
{
|
|
1318
|
+
get(_target, prop) {
|
|
1319
|
+
if (prop === "then") {
|
|
1320
|
+
return void 0;
|
|
1321
|
+
}
|
|
1322
|
+
return async (...args) => {
|
|
1323
|
+
const orm = await resolveOrm();
|
|
1324
|
+
const model = orm[modelName];
|
|
1325
|
+
const member = model?.[prop];
|
|
1326
|
+
if (typeof member !== "function") {
|
|
1327
|
+
throw new Error(
|
|
1328
|
+
`Integration ORM model "${String(modelName)}" does not expose "${String(prop)}".`
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
return member.apply(model, args);
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
__name(createLazyIntegrationOrmModel, "createLazyIntegrationOrmModel");
|
|
1338
|
+
async function runIntegrationRouteBeforeHooks(route, request, context) {
|
|
1339
|
+
const hookContext = context;
|
|
1340
|
+
hookContext.response = void 0;
|
|
1341
|
+
for (const hook of route.before || []) {
|
|
1342
|
+
const response = await hook(request, hookContext);
|
|
1343
|
+
if (response) {
|
|
1344
|
+
hookContext.response = response;
|
|
1345
|
+
return response;
|
|
1346
|
+
}
|
|
1347
|
+
if (hookContext.response) {
|
|
1348
|
+
return hookContext.response;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
return void 0;
|
|
1352
|
+
}
|
|
1353
|
+
__name(runIntegrationRouteBeforeHooks, "runIntegrationRouteBeforeHooks");
|
|
1354
|
+
async function runIntegrationRouteAfterHooks(route, request, context, response) {
|
|
1355
|
+
const hookContext = context;
|
|
1356
|
+
let currentResponse = response;
|
|
1357
|
+
for (const hook of route.after || []) {
|
|
1358
|
+
hookContext.response = currentResponse;
|
|
1359
|
+
const nextResponse = await hook(request, hookContext);
|
|
1360
|
+
currentResponse = nextResponse || hookContext.response || currentResponse;
|
|
1361
|
+
}
|
|
1362
|
+
hookContext.response = currentResponse;
|
|
1363
|
+
return currentResponse;
|
|
1364
|
+
}
|
|
1365
|
+
__name(runIntegrationRouteAfterHooks, "runIntegrationRouteAfterHooks");
|
|
1366
|
+
function createQueryInput(searchParams) {
|
|
1367
|
+
const input = {};
|
|
1368
|
+
searchParams.forEach((value, key) => {
|
|
1369
|
+
const existing = input[key];
|
|
1370
|
+
if (existing === void 0) {
|
|
1371
|
+
input[key] = value;
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
input[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
|
|
1375
|
+
});
|
|
1376
|
+
return input;
|
|
1377
|
+
}
|
|
1378
|
+
__name(createQueryInput, "createQueryInput");
|
|
1379
|
+
function createFormInput(formData) {
|
|
1380
|
+
const input = {};
|
|
1381
|
+
formData.forEach((value, key) => {
|
|
1382
|
+
const existing = input[key];
|
|
1383
|
+
if (existing === void 0) {
|
|
1384
|
+
input[key] = value;
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
input[key] = Array.isArray(existing) ? [...existing, value] : [existing, value];
|
|
1388
|
+
});
|
|
1389
|
+
return input;
|
|
1390
|
+
}
|
|
1391
|
+
__name(createFormInput, "createFormInput");
|
|
1392
|
+
async function dispatchIntegrationRequest(runtime, request, options = {}) {
|
|
1393
|
+
const integration = runtime.integration;
|
|
1394
|
+
const url = new URL(request.url);
|
|
1395
|
+
const pathname = url.pathname;
|
|
1396
|
+
const requestId = request.headers.get("x-request-id") || options.currentRequest?.headers.get("x-request-id") || String(Date.now());
|
|
1397
|
+
const routes = normalizeIntegrationRoutes(integration.routes || []);
|
|
1398
|
+
const middleware = [...integration.middleware || []];
|
|
1399
|
+
for (const entry of middleware) {
|
|
1400
|
+
const params = resolveMatcherParams(entry.matcher, pathname);
|
|
1401
|
+
if (!params) {
|
|
1402
|
+
continue;
|
|
1403
|
+
}
|
|
1404
|
+
const handlerContext = createServerIntegrationHandlerContext({
|
|
1405
|
+
runtime,
|
|
1406
|
+
route: {
|
|
1407
|
+
kind: "middleware",
|
|
1408
|
+
path: normalizeMatcher(entry.matcher),
|
|
1409
|
+
methods: ["ALL"]
|
|
1410
|
+
},
|
|
1411
|
+
request,
|
|
1412
|
+
params,
|
|
1413
|
+
pathname,
|
|
1414
|
+
requestId,
|
|
1415
|
+
currentRequest: options.currentRequest,
|
|
1416
|
+
data: options.data,
|
|
1417
|
+
internal: options.internal === true
|
|
1418
|
+
});
|
|
1419
|
+
const startedAt = Date.now();
|
|
1420
|
+
await integration.log?.({
|
|
1421
|
+
category: integration.category,
|
|
1422
|
+
slot: integration.category,
|
|
1423
|
+
type: integration.type,
|
|
1424
|
+
phase: "request:start",
|
|
1425
|
+
route: {
|
|
1426
|
+
kind: "middleware",
|
|
1427
|
+
path: normalizeMatcher(entry.matcher),
|
|
1428
|
+
methods: ["ALL"]
|
|
1429
|
+
},
|
|
1430
|
+
request,
|
|
1431
|
+
requestId,
|
|
1432
|
+
context: handlerContext.req.snapshot()
|
|
1433
|
+
});
|
|
1434
|
+
try {
|
|
1435
|
+
const response = await entry.handler(request, handlerContext);
|
|
1436
|
+
if (response) {
|
|
1437
|
+
await integration.log?.({
|
|
1438
|
+
category: integration.category,
|
|
1439
|
+
slot: integration.category,
|
|
1440
|
+
type: integration.type,
|
|
1441
|
+
phase: "request:end",
|
|
1442
|
+
route: {
|
|
1443
|
+
kind: "middleware",
|
|
1444
|
+
path: normalizeMatcher(entry.matcher),
|
|
1445
|
+
methods: ["ALL"]
|
|
1446
|
+
},
|
|
1447
|
+
request,
|
|
1448
|
+
response,
|
|
1449
|
+
requestId,
|
|
1450
|
+
durationMs: Date.now() - startedAt,
|
|
1451
|
+
context: handlerContext.req.snapshot()
|
|
1452
|
+
});
|
|
1453
|
+
return response;
|
|
1454
|
+
}
|
|
1455
|
+
await integration.log?.({
|
|
1456
|
+
category: integration.category,
|
|
1457
|
+
slot: integration.category,
|
|
1458
|
+
type: integration.type,
|
|
1459
|
+
phase: "request:end",
|
|
1460
|
+
route: {
|
|
1461
|
+
kind: "middleware",
|
|
1462
|
+
path: normalizeMatcher(entry.matcher),
|
|
1463
|
+
methods: ["ALL"]
|
|
1464
|
+
},
|
|
1465
|
+
request,
|
|
1466
|
+
requestId,
|
|
1467
|
+
durationMs: Date.now() - startedAt,
|
|
1468
|
+
context: handlerContext.req.snapshot()
|
|
1469
|
+
});
|
|
1470
|
+
} catch (error) {
|
|
1471
|
+
await integration.log?.({
|
|
1472
|
+
category: integration.category,
|
|
1473
|
+
slot: integration.category,
|
|
1474
|
+
type: integration.type,
|
|
1475
|
+
phase: "request:error",
|
|
1476
|
+
route: {
|
|
1477
|
+
kind: "middleware",
|
|
1478
|
+
path: normalizeMatcher(entry.matcher),
|
|
1479
|
+
methods: ["ALL"]
|
|
1480
|
+
},
|
|
1481
|
+
request,
|
|
1482
|
+
requestId,
|
|
1483
|
+
durationMs: Date.now() - startedAt,
|
|
1484
|
+
error,
|
|
1485
|
+
context: handlerContext.req.snapshot()
|
|
1486
|
+
});
|
|
1487
|
+
throw error;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
for (const route of routes) {
|
|
1491
|
+
const params = matchesMethod(route.methods, request.method) ? extractPathParams(route.path, pathname) : null;
|
|
1492
|
+
if (!params) {
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
const handlerContext = createServerIntegrationHandlerContext({
|
|
1496
|
+
runtime,
|
|
1497
|
+
route: {
|
|
1498
|
+
kind: "route",
|
|
1499
|
+
path: route.path,
|
|
1500
|
+
methods: route.methods
|
|
1501
|
+
},
|
|
1502
|
+
request,
|
|
1503
|
+
params,
|
|
1504
|
+
pathname,
|
|
1505
|
+
requestId,
|
|
1506
|
+
currentRequest: options.currentRequest,
|
|
1507
|
+
data: options.data,
|
|
1508
|
+
internal: options.internal === true
|
|
1509
|
+
});
|
|
1510
|
+
const startedAt = Date.now();
|
|
1511
|
+
await integration.log?.({
|
|
1512
|
+
category: integration.category,
|
|
1513
|
+
slot: integration.category,
|
|
1514
|
+
type: integration.type,
|
|
1515
|
+
phase: "request:start",
|
|
1516
|
+
route: {
|
|
1517
|
+
kind: "route",
|
|
1518
|
+
path: route.path,
|
|
1519
|
+
methods: route.methods
|
|
1520
|
+
},
|
|
1521
|
+
request,
|
|
1522
|
+
requestId,
|
|
1523
|
+
context: handlerContext.req.snapshot()
|
|
1524
|
+
});
|
|
1525
|
+
try {
|
|
1526
|
+
const validation = await validateIntegrationRouteInput(route, request, url);
|
|
1527
|
+
if (!validation.success) {
|
|
1528
|
+
await integration.log?.({
|
|
1529
|
+
category: integration.category,
|
|
1530
|
+
slot: integration.category,
|
|
1531
|
+
type: integration.type,
|
|
1532
|
+
phase: "request:end",
|
|
1533
|
+
route: {
|
|
1534
|
+
kind: "route",
|
|
1535
|
+
path: route.path,
|
|
1536
|
+
methods: route.methods
|
|
1537
|
+
},
|
|
1538
|
+
request,
|
|
1539
|
+
response: validation.response,
|
|
1540
|
+
requestId,
|
|
1541
|
+
durationMs: Date.now() - startedAt,
|
|
1542
|
+
context: handlerContext.req.snapshot()
|
|
1543
|
+
});
|
|
1544
|
+
return validation.response;
|
|
1545
|
+
}
|
|
1546
|
+
handlerContext.input = validation.input;
|
|
1547
|
+
for (const middlewareEntry of route.middleware || []) {
|
|
1548
|
+
const middlewareResponse = await middlewareEntry.handler(request, handlerContext);
|
|
1549
|
+
if (middlewareResponse) {
|
|
1550
|
+
await integration.log?.({
|
|
1551
|
+
category: integration.category,
|
|
1552
|
+
slot: integration.category,
|
|
1553
|
+
type: integration.type,
|
|
1554
|
+
phase: "request:end",
|
|
1555
|
+
route: {
|
|
1556
|
+
kind: "route",
|
|
1557
|
+
path: route.path,
|
|
1558
|
+
methods: route.methods
|
|
1559
|
+
},
|
|
1560
|
+
request,
|
|
1561
|
+
response: middlewareResponse,
|
|
1562
|
+
requestId,
|
|
1563
|
+
durationMs: Date.now() - startedAt,
|
|
1564
|
+
context: handlerContext.req.snapshot()
|
|
1565
|
+
});
|
|
1566
|
+
return middlewareResponse;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
const beforeResponse = await runIntegrationRouteBeforeHooks(route, request, handlerContext);
|
|
1570
|
+
if (beforeResponse) {
|
|
1571
|
+
const response2 = await runIntegrationRouteAfterHooks(
|
|
1572
|
+
route,
|
|
1573
|
+
request,
|
|
1574
|
+
handlerContext,
|
|
1575
|
+
beforeResponse
|
|
1576
|
+
);
|
|
1577
|
+
await integration.log?.({
|
|
1578
|
+
category: integration.category,
|
|
1579
|
+
slot: integration.category,
|
|
1580
|
+
type: integration.type,
|
|
1581
|
+
phase: "request:end",
|
|
1582
|
+
route: {
|
|
1583
|
+
kind: "route",
|
|
1584
|
+
path: route.path,
|
|
1585
|
+
methods: route.methods
|
|
1586
|
+
},
|
|
1587
|
+
request,
|
|
1588
|
+
response: response2,
|
|
1589
|
+
requestId,
|
|
1590
|
+
durationMs: Date.now() - startedAt,
|
|
1591
|
+
context: handlerContext.req.snapshot()
|
|
1592
|
+
});
|
|
1593
|
+
return response2;
|
|
1594
|
+
}
|
|
1595
|
+
const handlerResponse = await route.handler(request, handlerContext);
|
|
1596
|
+
const response = await runIntegrationRouteAfterHooks(
|
|
1597
|
+
route,
|
|
1598
|
+
request,
|
|
1599
|
+
handlerContext,
|
|
1600
|
+
handlerResponse
|
|
1601
|
+
);
|
|
1602
|
+
await integration.log?.({
|
|
1603
|
+
category: integration.category,
|
|
1604
|
+
slot: integration.category,
|
|
1605
|
+
type: integration.type,
|
|
1606
|
+
phase: "request:end",
|
|
1607
|
+
route: {
|
|
1608
|
+
kind: "route",
|
|
1609
|
+
path: route.path,
|
|
1610
|
+
methods: route.methods
|
|
1611
|
+
},
|
|
1612
|
+
request,
|
|
1613
|
+
response,
|
|
1614
|
+
requestId,
|
|
1615
|
+
durationMs: Date.now() - startedAt,
|
|
1616
|
+
context: handlerContext.req.snapshot()
|
|
1617
|
+
});
|
|
1618
|
+
return response;
|
|
1619
|
+
} catch (error) {
|
|
1620
|
+
await integration.log?.({
|
|
1621
|
+
category: integration.category,
|
|
1622
|
+
slot: integration.category,
|
|
1623
|
+
type: integration.type,
|
|
1624
|
+
phase: "request:error",
|
|
1625
|
+
route: {
|
|
1626
|
+
kind: "route",
|
|
1627
|
+
path: route.path,
|
|
1628
|
+
methods: route.methods
|
|
1629
|
+
},
|
|
1630
|
+
request,
|
|
1631
|
+
requestId,
|
|
1632
|
+
durationMs: Date.now() - startedAt,
|
|
1633
|
+
error,
|
|
1634
|
+
context: handlerContext.req.snapshot()
|
|
1635
|
+
});
|
|
1636
|
+
throw error;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
__name(dispatchIntegrationRequest, "dispatchIntegrationRequest");
|
|
1642
|
+
globalThis[INTEGRATION_REQUEST_DISPATCHER_KEY] = dispatchIntegrationRequest;
|
|
1643
|
+
function createIntegrationRequestContextStore(rawRequest, request, pluginContext) {
|
|
1644
|
+
return {
|
|
1645
|
+
get(key) {
|
|
1646
|
+
const requestValue = pluginContext.requestContext.get(request, key);
|
|
1647
|
+
if (requestValue !== void 0) {
|
|
1648
|
+
return requestValue;
|
|
1649
|
+
}
|
|
1650
|
+
return pluginContext.requestContext.get(rawRequest, key);
|
|
1651
|
+
},
|
|
1652
|
+
set(key, value, options) {
|
|
1653
|
+
pluginContext.requestContext.set(rawRequest, key, value, options);
|
|
1654
|
+
pluginContext.requestContext.set(request, key, value, options);
|
|
1655
|
+
},
|
|
1656
|
+
has(key) {
|
|
1657
|
+
return pluginContext.requestContext.has(request, key) || pluginContext.requestContext.has(rawRequest, key);
|
|
1658
|
+
},
|
|
1659
|
+
delete(key) {
|
|
1660
|
+
const deletedRequest = pluginContext.requestContext.delete(request, key);
|
|
1661
|
+
const deletedRaw = pluginContext.requestContext.delete(rawRequest, key);
|
|
1662
|
+
return deletedRequest || deletedRaw;
|
|
1663
|
+
},
|
|
1664
|
+
clear() {
|
|
1665
|
+
pluginContext.requestContext.clear(rawRequest);
|
|
1666
|
+
pluginContext.requestContext.clear(request);
|
|
1667
|
+
},
|
|
1668
|
+
snapshot(options) {
|
|
1669
|
+
const merged = pluginContext.requestContext.getAll(rawRequest, options);
|
|
1670
|
+
const requestSnapshot = pluginContext.requestContext.getAll(request, options);
|
|
1671
|
+
for (const [key, value] of requestSnapshot) {
|
|
1672
|
+
merged.set(key, value);
|
|
1673
|
+
}
|
|
1674
|
+
return merged;
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
__name(createIntegrationRequestContextStore, "createIntegrationRequestContextStore");
|
|
1679
|
+
function createServerIntegrationHandlerContext(input) {
|
|
1680
|
+
const req = createServerIntegrationRequestContextStore(input.request, input.currentRequest);
|
|
1681
|
+
if (input.internal) {
|
|
1682
|
+
req.set(FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY, true);
|
|
1683
|
+
}
|
|
1684
|
+
return {
|
|
1685
|
+
request: input.request,
|
|
1686
|
+
requestId: input.requestId,
|
|
1687
|
+
url: new URL(input.request.url),
|
|
1688
|
+
pathname: input.pathname,
|
|
1689
|
+
method: input.request.method,
|
|
1690
|
+
params: input.params,
|
|
1691
|
+
input: {},
|
|
1692
|
+
args: createIntegrationRouteArgs({
|
|
1693
|
+
integration: input.runtime.integration,
|
|
1694
|
+
config: input.runtime.config
|
|
1695
|
+
}),
|
|
1696
|
+
data: resolveIntegrationData(input.request, input.data),
|
|
1697
|
+
integration: {
|
|
1698
|
+
category: input.runtime.integration.category,
|
|
1699
|
+
slot: input.runtime.integration.category,
|
|
1700
|
+
type: input.runtime.integration.type,
|
|
1701
|
+
instance: input.runtime.integration.instance
|
|
1702
|
+
},
|
|
1703
|
+
route: input.route,
|
|
1704
|
+
req,
|
|
1705
|
+
requestContext: req,
|
|
1706
|
+
config: input.runtime.config,
|
|
1707
|
+
isDev: input.runtime.isDev,
|
|
1708
|
+
isProd: input.runtime.isProd
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
__name(createServerIntegrationHandlerContext, "createServerIntegrationHandlerContext");
|
|
1712
|
+
function createServerIntegrationRequestContextStore(request, currentRequest) {
|
|
1713
|
+
return {
|
|
1714
|
+
get(key) {
|
|
1715
|
+
const requestValue = getRequestContext(request, key);
|
|
1716
|
+
if (requestValue !== void 0) {
|
|
1717
|
+
return requestValue;
|
|
1718
|
+
}
|
|
1719
|
+
if (currentRequest) {
|
|
1720
|
+
return getRequestContext(currentRequest, key);
|
|
1721
|
+
}
|
|
1722
|
+
return void 0;
|
|
1723
|
+
},
|
|
1724
|
+
set(key, value, options) {
|
|
1725
|
+
setRequestContext(request, key, value, options);
|
|
1726
|
+
if (currentRequest) {
|
|
1727
|
+
setRequestContext(currentRequest, key, value, options);
|
|
1728
|
+
}
|
|
1729
|
+
},
|
|
1730
|
+
has(key) {
|
|
1731
|
+
return hasRequestContext(request, key) || !!currentRequest && hasRequestContext(currentRequest, key);
|
|
1732
|
+
},
|
|
1733
|
+
delete(key) {
|
|
1734
|
+
const deletedRequest = deleteRequestContext(request, key);
|
|
1735
|
+
const deletedCurrent = currentRequest ? deleteRequestContext(currentRequest, key) : false;
|
|
1736
|
+
return deletedRequest || deletedCurrent;
|
|
1737
|
+
},
|
|
1738
|
+
clear() {
|
|
1739
|
+
clearRequestContext(request);
|
|
1740
|
+
if (currentRequest) {
|
|
1741
|
+
clearRequestContext(currentRequest);
|
|
1742
|
+
}
|
|
1743
|
+
},
|
|
1744
|
+
snapshot(options) {
|
|
1745
|
+
const merged = currentRequest ? getRequestContextSnapshot(currentRequest, options) : /* @__PURE__ */ new Map();
|
|
1746
|
+
const requestSnapshot = getRequestContextSnapshot(request, options);
|
|
1747
|
+
for (const [key, value] of requestSnapshot) {
|
|
1748
|
+
merged.set(key, value);
|
|
1749
|
+
}
|
|
1750
|
+
return merged;
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
__name(createServerIntegrationRequestContextStore, "createServerIntegrationRequestContextStore");
|
|
1755
|
+
function createWebRequest(req, fullUrl, body) {
|
|
1756
|
+
const headers = new Headers();
|
|
1757
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
1758
|
+
if (value == null) {
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
if (Array.isArray(value)) {
|
|
1762
|
+
for (const item of value) {
|
|
1763
|
+
headers.append(key, item);
|
|
1764
|
+
}
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
headers.set(key, value);
|
|
1768
|
+
}
|
|
1769
|
+
return new Request(fullUrl, {
|
|
1770
|
+
method: req.method,
|
|
1771
|
+
headers,
|
|
1772
|
+
body
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
__name(createWebRequest, "createWebRequest");
|
|
1776
|
+
function matchesMethod(methods, method) {
|
|
1777
|
+
if (!method) {
|
|
1778
|
+
return false;
|
|
1779
|
+
}
|
|
1780
|
+
return methods.some((item) => item.toUpperCase() === method.toUpperCase());
|
|
1781
|
+
}
|
|
1782
|
+
__name(matchesMethod, "matchesMethod");
|
|
1783
|
+
function resolveMatcherParams(matcher, pathname) {
|
|
1784
|
+
if (!matcher) {
|
|
1785
|
+
return {};
|
|
1786
|
+
}
|
|
1787
|
+
const list = Array.isArray(matcher) ? matcher : [matcher];
|
|
1788
|
+
for (const item of list) {
|
|
1789
|
+
if (item === "/(.*)" || item === "*") {
|
|
1790
|
+
return {};
|
|
1791
|
+
}
|
|
1792
|
+
if (item.endsWith("(.*)")) {
|
|
1793
|
+
const prefix = item.slice(0, -4);
|
|
1794
|
+
if (pathname === prefix || pathname.startsWith(`${prefix}/`)) {
|
|
1795
|
+
return {};
|
|
1796
|
+
}
|
|
1797
|
+
continue;
|
|
1798
|
+
}
|
|
1799
|
+
const params = extractPathParams(item, pathname);
|
|
1800
|
+
if (params) {
|
|
1801
|
+
return params;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return null;
|
|
1805
|
+
}
|
|
1806
|
+
__name(resolveMatcherParams, "resolveMatcherParams");
|
|
1807
|
+
function extractPathParams(pattern, pathname) {
|
|
1808
|
+
const routeSegments = splitPath(pattern);
|
|
1809
|
+
const pathSegments = splitPath(pathname);
|
|
1810
|
+
const params = {};
|
|
1811
|
+
let routeIndex = 0;
|
|
1812
|
+
let pathIndex = 0;
|
|
1813
|
+
while (routeIndex < routeSegments.length && pathIndex < pathSegments.length) {
|
|
1814
|
+
const routeSegment = routeSegments[routeIndex];
|
|
1815
|
+
const pathSegment = pathSegments[pathIndex];
|
|
1816
|
+
if (isCatchAllSegment(routeSegment)) {
|
|
1817
|
+
params[getSegmentParamName(routeSegment)] = pathSegments.slice(pathIndex).map((segment) => decodeURIComponent(segment));
|
|
1818
|
+
return params;
|
|
1819
|
+
}
|
|
1820
|
+
if (isDynamicSegment(routeSegment)) {
|
|
1821
|
+
params[getSegmentParamName(routeSegment)] = decodeURIComponent(pathSegment);
|
|
1822
|
+
routeIndex += 1;
|
|
1823
|
+
pathIndex += 1;
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
if (routeSegment !== pathSegment) {
|
|
1827
|
+
return null;
|
|
1828
|
+
}
|
|
1829
|
+
routeIndex += 1;
|
|
1830
|
+
pathIndex += 1;
|
|
1831
|
+
}
|
|
1832
|
+
if (routeIndex === routeSegments.length && pathIndex === pathSegments.length) {
|
|
1833
|
+
return params;
|
|
1834
|
+
}
|
|
1835
|
+
if (routeIndex === routeSegments.length - 1 && isCatchAllSegment(routeSegments[routeIndex])) {
|
|
1836
|
+
params[getSegmentParamName(routeSegments[routeIndex])] = [];
|
|
1837
|
+
return params;
|
|
1838
|
+
}
|
|
1839
|
+
return null;
|
|
1840
|
+
}
|
|
1841
|
+
__name(extractPathParams, "extractPathParams");
|
|
1842
|
+
function splitPath(value) {
|
|
1843
|
+
return value.split("/").filter(Boolean);
|
|
1844
|
+
}
|
|
1845
|
+
__name(splitPath, "splitPath");
|
|
1846
|
+
function isDynamicSegment(segment) {
|
|
1847
|
+
return segment.startsWith("[") && segment.endsWith("]");
|
|
1848
|
+
}
|
|
1849
|
+
__name(isDynamicSegment, "isDynamicSegment");
|
|
1850
|
+
function isCatchAllSegment(segment) {
|
|
1851
|
+
return segment.startsWith("[...") && segment.endsWith("]");
|
|
1852
|
+
}
|
|
1853
|
+
__name(isCatchAllSegment, "isCatchAllSegment");
|
|
1854
|
+
function getSegmentParamName(segment) {
|
|
1855
|
+
if (isCatchAllSegment(segment)) {
|
|
1856
|
+
return segment.slice(4, -1);
|
|
1857
|
+
}
|
|
1858
|
+
return segment.slice(1, -1);
|
|
1859
|
+
}
|
|
1860
|
+
__name(getSegmentParamName, "getSegmentParamName");
|
|
1861
|
+
function getRequestId(req) {
|
|
1862
|
+
const headerValue = req.headers["x-request-id"];
|
|
1863
|
+
if (Array.isArray(headerValue)) {
|
|
1864
|
+
return headerValue[0] || String(Date.now());
|
|
1865
|
+
}
|
|
1866
|
+
return headerValue || String(Date.now());
|
|
1867
|
+
}
|
|
1868
|
+
__name(getRequestId, "getRequestId");
|
|
1869
|
+
async function readRequestBody(req) {
|
|
1870
|
+
return await new Promise((resolve, reject) => {
|
|
1871
|
+
const chunks = [];
|
|
1872
|
+
req.on("data", (chunk) => {
|
|
1873
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1874
|
+
});
|
|
1875
|
+
req.on("end", () => {
|
|
1876
|
+
resolve(Buffer.concat(chunks));
|
|
1877
|
+
});
|
|
1878
|
+
req.on("error", reject);
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
__name(readRequestBody, "readRequestBody");
|
|
1882
|
+
function normalizeMatcher(matcher) {
|
|
1883
|
+
if (!matcher) {
|
|
1884
|
+
return "/(.*)";
|
|
1885
|
+
}
|
|
1886
|
+
return typeof matcher === "string" ? matcher : matcher.join(", ");
|
|
1887
|
+
}
|
|
1888
|
+
__name(normalizeMatcher, "normalizeMatcher");
|
|
1889
|
+
|
|
1890
|
+
export {
|
|
1891
|
+
setRequestContext,
|
|
1892
|
+
getRequestContext,
|
|
1893
|
+
hasRequestContext,
|
|
1894
|
+
deleteRequestContext,
|
|
1895
|
+
clearRequestContext,
|
|
1896
|
+
getRequestContextSnapshot,
|
|
1897
|
+
FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY,
|
|
1898
|
+
defineIntegrationSchema,
|
|
1899
|
+
getFarmIntegrationPluginServerRuntime,
|
|
1900
|
+
createIntegrationRoute,
|
|
1901
|
+
integrationRoute,
|
|
1902
|
+
defineIntegration,
|
|
1903
|
+
isFarmIntegration,
|
|
1904
|
+
resolveIntegrationPlugins,
|
|
1905
|
+
getIntegrationProviders,
|
|
1906
|
+
getIntegrationDocumentNavigationMatchers,
|
|
1907
|
+
getIntegrationSchemas,
|
|
1908
|
+
getRegisteredIntegrationRuntime,
|
|
1909
|
+
getRegisteredIntegrations,
|
|
1910
|
+
getRegisteredIntegrationSchemas,
|
|
1911
|
+
matchIntegrationRoute,
|
|
1912
|
+
matchRegisteredIntegrationRoute,
|
|
1913
|
+
getRegisteredIntegrationAPIManifest,
|
|
1914
|
+
dispatchIntegrationRequest
|
|
1915
|
+
};
|
|
1916
|
+
//# sourceMappingURL=chunk-K4667E2Q.mjs.map
|