@farm.js/core 0.1.35 → 0.1.36
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/{metadata-WGpBYcGn.d.mts → agent-mcp-BVExL8rZ.d.mts} +45 -2
- package/dist/agent-mcp-handler-LPJ2CADR.mjs +19 -0
- package/dist/agent-mcp-handler-SJAHFSPI.cjs +19 -0
- package/dist/{metadata-BnLDsUOS.d.ts → agent-mcp-luzfXK-P.d.ts} +45 -2
- package/dist/agent-runtime.cjs +5 -3
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +4 -2
- package/dist/api/route-manager.cjs +6 -6
- package/dist/api/route-manager.d.mts +10 -4
- package/dist/api/route-manager.d.ts +10 -4
- package/dist/api/route-manager.mjs +5 -5
- package/dist/api/runtime.cjs +4 -4
- package/dist/api/runtime.d.mts +4 -62
- package/dist/api/runtime.d.ts +4 -62
- package/dist/api/runtime.mjs +3 -3
- package/dist/api.cjs +8 -8
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +7 -7
- package/dist/{app-D_j9AAVL.d.mts → app-BukwkFIu.d.mts} +17 -3
- package/dist/{app-BXB3JZYc.d.ts → app-Yfa2dsFy.d.ts} +17 -3
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +3 -3
- package/dist/{chunk-4KU5Q7C2.mjs → chunk-276VJSM6.mjs} +221 -48
- package/dist/{chunk-PFQKNERH.cjs → chunk-2YTDKNH3.cjs} +364 -197
- package/dist/{chunk-UAORZ7QA.mjs → chunk-35GKZR22.mjs} +2 -2
- package/dist/{chunk-QAU5JD57.mjs → chunk-35WV46VL.mjs} +203 -36
- package/dist/{chunk-EFCQPQMG.cjs → chunk-42NHY7HW.cjs} +54 -4
- package/dist/{chunk-SOMHP6GF.mjs → chunk-4E5AEDKY.mjs} +2 -2
- package/dist/{chunk-UJD4PHYB.mjs → chunk-4E5WBPEG.mjs} +72 -354
- package/dist/{chunk-2G2NNLE2.mjs → chunk-4GLOOWKE.mjs} +4 -4
- package/dist/{chunk-62XKI4Z3.cjs → chunk-4NU4GGTC.cjs} +2 -2
- package/dist/{chunk-4JHOT46A.mjs → chunk-4WCZJQUO.mjs} +54 -4
- package/dist/chunk-4WQ6PGSJ.cjs +367 -0
- package/dist/{chunk-SMHH4VDG.mjs → chunk-4WVJLURN.mjs} +1 -1
- package/dist/chunk-6SJ2KJTA.mjs +314 -0
- package/dist/{chunk-IPXLADVO.cjs → chunk-ADEA7PN3.cjs} +122 -61
- package/dist/{chunk-CP6X4AEU.mjs → chunk-AJQTP4OO.mjs} +1 -1
- package/dist/{chunk-4MMGO7YW.cjs → chunk-AO6RYU5N.cjs} +31 -28
- package/dist/{chunk-GFHLGIYC.cjs → chunk-BO36SELV.cjs} +6 -6
- package/dist/{chunk-6TJOML4E.mjs → chunk-BPOF5U4N.mjs} +4 -4
- package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
- package/dist/{chunk-FTFYRMQQ.cjs → chunk-CBJJH36A.cjs} +50 -25
- package/dist/{chunk-7GLPRTTF.cjs → chunk-CGBDNNSM.cjs} +2 -2
- package/dist/chunk-CI6E3UOH.cjs +314 -0
- package/dist/{chunk-X6W5FFH6.cjs → chunk-D2BB47NB.cjs} +8 -8
- package/dist/chunk-DTSROJ5J.mjs +367 -0
- package/dist/{chunk-YC6V7PWE.cjs → chunk-DZ5ZVB2K.cjs} +1 -1
- package/dist/{chunk-DBNKI4NF.cjs → chunk-ECKF2BAM.cjs} +6 -2
- package/dist/{chunk-Q3VLETLE.mjs → chunk-EWET4D2Y.mjs} +1 -1
- package/dist/{chunk-HUMR6LSU.mjs → chunk-F5QO4FNE.mjs} +1 -1
- package/dist/{chunk-XBML5KMG.cjs → chunk-FO427P6I.cjs} +22 -12
- package/dist/{chunk-SAZVVAJH.mjs → chunk-GQRWBCWK.mjs} +8 -5
- package/dist/{chunk-F6Z3Y5KL.mjs → chunk-HOXTWRGB.mjs} +1 -1
- package/dist/{chunk-3BHT4WMP.cjs → chunk-JNUWCDTF.cjs} +6 -6
- package/dist/{chunk-73MC7ZL6.cjs → chunk-JZVADIOD.cjs} +2 -2
- package/dist/{chunk-OMVAU7NT.cjs → chunk-KIIMAWOJ.cjs} +11 -1
- package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
- package/dist/{chunk-6ETPZTJI.mjs → chunk-LSZAVSGY.mjs} +116 -55
- package/dist/{chunk-HMIJDL7S.mjs → chunk-MKYBIIAQ.mjs} +30 -5
- package/dist/{chunk-RU3M2FIK.cjs → chunk-MRMI32SN.cjs} +87 -369
- package/dist/{chunk-7L5V3KQO.cjs → chunk-N2NAS2AM.cjs} +2 -2
- package/dist/{chunk-ICUQICNC.cjs → chunk-NMHWYWDR.cjs} +654 -481
- package/dist/{chunk-G5RT7EXW.mjs → chunk-O6I6VWKK.mjs} +20 -5
- package/dist/{chunk-PDOCJ6RY.mjs → chunk-O6WAEAX3.mjs} +1 -1
- package/dist/{chunk-6DU6UFUE.mjs → chunk-OHLSEQ57.mjs} +16 -8
- package/dist/{chunk-3PXS2MHU.mjs → chunk-OO7GXVSR.mjs} +1 -1
- package/dist/chunk-PTZ2TVNE.cjs +178 -0
- package/dist/{chunk-6WCPV6G2.mjs → chunk-Q2KB32T4.mjs} +1 -1
- package/dist/{chunk-XCACDAZZ.cjs → chunk-S6VYG6XU.cjs} +23 -8
- package/dist/{chunk-VFQT3LAO.cjs → chunk-SDOTRX3V.cjs} +5 -5
- package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
- package/dist/{chunk-22LTEMGQ.mjs → chunk-T4OGRVNS.mjs} +13 -3
- package/dist/{chunk-ZXGAFZDO.cjs → chunk-T5OJPTVN.cjs} +2 -2
- package/dist/{chunk-VZJR7UTG.cjs → chunk-TE2G5ION.cjs} +2 -2
- package/dist/chunk-UH6QN5NL.mjs +178 -0
- package/dist/{chunk-F7JZENPF.cjs → chunk-UVW64BCB.cjs} +38 -30
- package/dist/{chunk-OKZUAXHF.mjs → chunk-VILIPRS6.mjs} +1 -1
- package/dist/{chunk-3UH7MRCP.cjs → chunk-VQLJWDVW.cjs} +13 -13
- package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
- package/dist/{chunk-EJQT6KZN.cjs → chunk-WC5UV2HQ.cjs} +2 -2
- package/dist/{chunk-YULD7ICZ.mjs → chunk-WZ77PUAM.mjs} +1 -1
- package/dist/{chunk-C35ZBVRD.mjs → chunk-YWMZUGIS.mjs} +6 -2
- package/dist/{chunk-Y7RKTKYI.mjs → chunk-ZMMBIVQM.mjs} +10 -0
- package/dist/{chunk-ULAWS2PA.cjs → chunk-ZWM5KGAA.cjs} +6 -6
- package/dist/{client-plugins-CvIslxWi.d.mts → client-plugins-C3mK9Pol.d.mts} +98 -5
- package/dist/{client-plugins-HIyulDym.d.ts → client-plugins-r1mOtSC1.d.ts} +98 -5
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-EE5RIBTH.mjs → devtools-ERIKFEXX.mjs} +9 -8
- package/dist/{devtools-EAUY43BS.cjs → devtools-JZJJY5CK.cjs} +10 -9
- package/dist/docs.cjs +12 -11
- package/dist/docs.d.mts +2 -2
- package/dist/docs.d.ts +2 -2
- package/dist/docs.mjs +11 -10
- package/dist/image/server.cjs +3 -3
- package/dist/image/server.mjs +2 -2
- package/dist/image/sharp.cjs +10 -10
- package/dist/image/sharp.mjs +2 -2
- package/dist/index.cjs +39 -35
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.mjs +38 -34
- package/dist/integrations.cjs +7 -3
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +6 -2
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +27 -25
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +26 -24
- package/dist/internal/cli-runtime.cjs +14 -13
- package/dist/internal/cli-runtime.mjs +13 -12
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +10 -9
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +9 -8
- package/dist/internal/isolated-boundary.cjs +2 -2
- package/dist/internal/isolated-boundary.d.mts +0 -1
- package/dist/internal/isolated-boundary.d.ts +0 -1
- package/dist/internal/isolated-boundary.mjs +1 -1
- package/dist/internal/metadata-image-runtime.cjs +3 -3
- package/dist/internal/metadata-image-runtime.mjs +2 -2
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-runtime.cjs +23 -9
- package/dist/internal/production-runtime.d.mts +67 -27
- package/dist/internal/production-runtime.d.ts +67 -27
- package/dist/internal/production-runtime.mjs +26 -12
- package/dist/{layers-BRQF5ETU.mjs → layers-UTB43B7A.mjs} +1 -1
- package/dist/layers-VUWIOFEO.cjs +18 -0
- package/dist/markdown.cjs +1 -1
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/middleware.cjs +6 -6
- package/dist/middleware.d.mts +3 -3
- package/dist/middleware.d.ts +3 -3
- package/dist/middleware.mjs +5 -5
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/{nitro-OVPLKPE2.cjs → nitro-7F65EZZS.cjs} +3 -3
- package/dist/{nitro-MXRDCXWZ.mjs → nitro-MPZJGPXK.mjs} +2 -2
- package/dist/plugin.cjs +23 -21
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +22 -20
- package/dist/{production-runtime-0sRnuYc-.d.mts → production-runtime-CCeVZXst.d.mts} +1 -1
- package/dist/{production-runtime-Crq6CJ-2.d.ts → production-runtime-DPnsggY3.d.ts} +1 -1
- package/dist/{render-plan-gs9GGPzw.d.mts → render-plan-BuGaPFe6.d.mts} +1 -1
- package/dist/{render-plan-8ozZh2Qv.d.ts → render-plan-Cw4f5E_R.d.ts} +1 -1
- package/dist/renderer/react/server.cjs +3 -3
- package/dist/renderer/react/server.mjs +1 -1
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/{request-B5G8rLBH.d.ts → request-Bkg-hERy.d.ts} +1 -1
- package/dist/{request-fkhiynXe.d.mts → request-CsGARcAw.d.mts} +1 -1
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/{route-rendering-lS5nUMua.d.ts → route-rendering-BUZMH_64.d.ts} +1 -1
- package/dist/{route-rendering-CLnS7AZj.d.mts → route-rendering-f11yh5dp.d.mts} +1 -1
- package/dist/{router-4iuiYnOW.d.ts → router-B8CR9GbD.d.ts} +1 -1
- package/dist/{router-ifU8Dui1.d.mts → router-Cp6yRE8A.d.mts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/runtime-CAEv36S_.d.mts +69 -0
- package/dist/runtime-CQVsT330.d.ts +69 -0
- package/dist/server-action-security.cjs +3 -3
- package/dist/server-action-security.mjs +2 -2
- package/dist/server-fn.cjs +4 -4
- package/dist/server-fn.mjs +3 -3
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-query.cjs +5 -5
- package/dist/server-query.mjs +4 -4
- package/dist/server.cjs +42 -40
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +25 -23
- package/dist/{spa-router-DaJk5Re4.d.ts → spa-router-BuciWGCZ.d.ts} +2 -2
- package/dist/{spa-router-Bq7VCOwx.d.mts → spa-router-DwbqGkGj.d.mts} +2 -2
- package/dist/testing.cjs +8 -8
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +6 -6
- package/dist/{utils-XJn0c9bj.d.mts → utils-B9V0S_yL.d.mts} +1 -1
- package/dist/{utils-BXLmFsVR.d.ts → utils-CaoWKtYM.d.ts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +23 -21
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +22 -20
- package/dist/workflows.cjs +3 -3
- package/dist/workflows.mjs +2 -2
- package/package.json +1 -1
- package/dist/layers-4PNE2HOY.cjs +0 -18
- package/dist/{chunk-2F2ER724.cjs → chunk-BPMATOP2.cjs} +2 -2
- package/dist/{chunk-IHNMMXHV.mjs → chunk-OTC5BDGO.mjs} +3 -3
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
+
var _chunkPTZ2TVNEcjs = require('./chunk-PTZ2TVNE.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkOWOUTKIJcjs = require('./chunk-OWOUTKIJ.cjs');
|
|
4
7
|
|
|
5
8
|
|
|
6
|
-
var
|
|
9
|
+
var _chunk4WQ6PGSJcjs = require('./chunk-4WQ6PGSJ.cjs');
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
var _chunkJ63ZH5OQcjs = require('./chunk-J63ZH5OQ.cjs');
|
|
@@ -19,14 +22,15 @@ var _chunkTKJZFIMLcjs = require('./chunk-TKJZFIML.cjs');
|
|
|
19
22
|
var _chunk75RZHGLScjs = require('./chunk-75RZHGLS.cjs');
|
|
20
23
|
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
|
|
26
|
+
var _chunkKIIMAWOJcjs = require('./chunk-KIIMAWOJ.cjs');
|
|
23
27
|
|
|
24
28
|
|
|
25
29
|
|
|
26
30
|
var _chunkKNBBQHO2cjs = require('./chunk-KNBBQHO2.cjs');
|
|
27
31
|
|
|
28
32
|
|
|
29
|
-
var
|
|
33
|
+
var _chunkDZ5ZVB2Kcjs = require('./chunk-DZ5ZVB2K.cjs');
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
var _chunkBIDYX3SLcjs = require('./chunk-BIDYX3SL.cjs');
|
|
@@ -153,7 +157,7 @@ function ensureFarmDocumentHead(markup) {
|
|
|
153
157
|
}
|
|
154
158
|
_chunkS3JO3N4Hcjs.__name.call(void 0, ensureFarmDocumentHead, "ensureFarmDocumentHead");
|
|
155
159
|
function ensureFarmDocumentRoot(markup) {
|
|
156
|
-
if (
|
|
160
|
+
if (/<body\b[^>]*>\s*<div\b[^>]*\sid=["']root["']/i.test(markup)) return markup;
|
|
157
161
|
return markup.replace(
|
|
158
162
|
/<body\b([^>]*)>/i,
|
|
159
163
|
(_match, attributes) => `<body${attributes}><div id="root">`
|
|
@@ -398,7 +402,7 @@ function createFarmMetadataRouteResponse(kind, value, routeModule = {}, options
|
|
|
398
402
|
if (isResponse(value)) {
|
|
399
403
|
return method === "HEAD" ? _chunkTKJZFIMLcjs.omitFarmResponseBody.call(void 0, value) : value;
|
|
400
404
|
}
|
|
401
|
-
const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ?
|
|
405
|
+
const body = kind === "sitemap" ? serializeSitemap(value) : kind === "robots" ? serializeRobots(value) : kind === "llms" || kind === "llms-full" ? _chunk4WQ6PGSJcjs.serializeFarmLlmsTxt.call(void 0, value) : serializeManifest(value);
|
|
402
406
|
const contentType = kind === "sitemap" ? "application/xml; charset=utf-8" : kind === "robots" || kind === "llms" || kind === "llms-full" ? "text/plain; charset=utf-8" : "application/manifest+json; charset=utf-8";
|
|
403
407
|
return new Response(method === "HEAD" ? null : body, {
|
|
404
408
|
headers: {
|
|
@@ -436,6 +440,13 @@ function listFarmMCPServerSources(input) {
|
|
|
436
440
|
if (sources.has(endpoint)) continue;
|
|
437
441
|
sources.set(endpoint, { ...server, endpoint, local: Boolean(server.path) });
|
|
438
442
|
}
|
|
443
|
+
if (sources.size === 0 && input.defaultMCP) {
|
|
444
|
+
const server = input.defaultMCP();
|
|
445
|
+
if (server) {
|
|
446
|
+
const endpoint = _chunkI57LW5VZcjs.applyFarmBasePath.call(void 0, server.path, input.basePath);
|
|
447
|
+
sources.set(endpoint, { ...server, endpoint, local: true });
|
|
448
|
+
}
|
|
449
|
+
}
|
|
439
450
|
return [...sources.values()];
|
|
440
451
|
}
|
|
441
452
|
_chunkS3JO3N4Hcjs.__name.call(void 0, listFarmMCPServerSources, "listFarmMCPServerSources");
|
|
@@ -526,7 +537,7 @@ function createFarmAiCatalogResponse(request, input = {}, requestUrl) {
|
|
|
526
537
|
const body = JSON.stringify(
|
|
527
538
|
card ? card.card : { specVersion: "1.0", entries: servers.map(({ entry }) => entry) }
|
|
528
539
|
);
|
|
529
|
-
const etag =
|
|
540
|
+
const etag = _chunkKIIMAWOJcjs.createFarmWeakETag.call(void 0, body);
|
|
530
541
|
const headers = {
|
|
531
542
|
...corsHeaders(),
|
|
532
543
|
"Content-Type": card ? `${SERVER_CARD_TYPE}; charset=utf-8` : ard ? "application/json; charset=utf-8" : `${AI_CATALOG_TYPE}; charset=utf-8`,
|
|
@@ -535,7 +546,7 @@ function createFarmAiCatalogResponse(request, input = {}, requestUrl) {
|
|
|
535
546
|
ETag: etag,
|
|
536
547
|
"X-Content-Type-Options": "nosniff"
|
|
537
548
|
};
|
|
538
|
-
if (
|
|
549
|
+
if (_chunkKIIMAWOJcjs.matchesFarmIfNoneMatch.call(void 0, request.headers.get("if-none-match"), etag)) {
|
|
539
550
|
return new Response(null, { status: 304, headers });
|
|
540
551
|
}
|
|
541
552
|
_chunkJ63ZH5OQcjs.emitFarmAgentRead.call(void 0, request, card ? "mcp-server-card" : "ai-catalog", 200);
|
|
@@ -565,15 +576,6 @@ function truncate(text) {
|
|
|
565
576
|
return text.length <= CARD_DESCRIPTION_MAX ? text : `${text.slice(0, CARD_DESCRIPTION_MAX - 1).trimEnd()}\u2026`;
|
|
566
577
|
}
|
|
567
578
|
_chunkS3JO3N4Hcjs.__name.call(void 0, truncate, "truncate");
|
|
568
|
-
function fnv1a(value) {
|
|
569
|
-
let hash = 2166136261;
|
|
570
|
-
for (let index = 0; index < value.length; index++) {
|
|
571
|
-
hash ^= value.charCodeAt(index);
|
|
572
|
-
hash = Math.imul(hash, 16777619);
|
|
573
|
-
}
|
|
574
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
575
|
-
}
|
|
576
|
-
_chunkS3JO3N4Hcjs.__name.call(void 0, fnv1a, "fnv1a");
|
|
577
579
|
|
|
578
580
|
// src/components/error-page.ts
|
|
579
581
|
var ERROR_STATUS_TEXT = {
|
|
@@ -868,7 +870,12 @@ function createFarmApiCatalogResponse(method, input, request) {
|
|
|
868
870
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmApiCatalogResponse, "createFarmApiCatalogResponse");
|
|
869
871
|
|
|
870
872
|
// src/app-manifest.ts
|
|
871
|
-
var FARM_APP_MANIFEST_PATH = "/.well-known/farmjs";
|
|
873
|
+
var FARM_APP_MANIFEST_PATH = "/.well-known/farmjs.json";
|
|
874
|
+
var FARM_APP_MANIFEST_LEGACY_PATH = "/.well-known/farmjs";
|
|
875
|
+
function isFarmAppManifestPath(pathname) {
|
|
876
|
+
return pathname === FARM_APP_MANIFEST_PATH || pathname === FARM_APP_MANIFEST_LEGACY_PATH;
|
|
877
|
+
}
|
|
878
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isFarmAppManifestPath, "isFarmAppManifestPath");
|
|
872
879
|
var FARM_INFRA_SIGNATURE_HEADER = "farmjs-infra-signature";
|
|
873
880
|
var SIGNED_PURPOSE = "farmjs-manifest-v1";
|
|
874
881
|
var SIGNATURE_WINDOW_SECONDS = 300;
|
|
@@ -901,48 +908,80 @@ var SOURCES = {
|
|
|
901
908
|
standalone: "defineTool",
|
|
902
909
|
serverFunction: "serverFunction"
|
|
903
910
|
};
|
|
904
|
-
function createFarmAppManifest(input) {
|
|
905
|
-
|
|
911
|
+
function createFarmAppManifest(input, { full = false } = {}) {
|
|
912
|
+
const manifest = {
|
|
906
913
|
schemaVersion: 1,
|
|
907
914
|
app: {
|
|
908
|
-
farm:
|
|
915
|
+
farm: _chunkDZ5ZVB2Kcjs.FARM_VERSION,
|
|
909
916
|
renderer: input.renderer,
|
|
910
917
|
basePath: input.basePath,
|
|
911
918
|
build: input.build
|
|
912
919
|
},
|
|
913
920
|
packages: input.packages,
|
|
914
921
|
mcp: {
|
|
915
|
-
servers: _chunk75RZHGLScjs._listFarmMCPCatalogs.call(void 0, ).map(({ server, tools, details }) =>
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
922
|
+
servers: _chunk75RZHGLScjs._listFarmMCPCatalogs.call(void 0, ).map(({ server, tools, details }) => {
|
|
923
|
+
const listed = full || _optionalChain([details, 'optionalAccess', _37 => _37.public]) === true;
|
|
924
|
+
return {
|
|
925
|
+
name: server.name,
|
|
926
|
+
version: server.version,
|
|
927
|
+
path: server.path,
|
|
928
|
+
authorization: _optionalChain([details, 'optionalAccess', _38 => _38.public]) === true ? "none" : "required",
|
|
929
|
+
resources: listed ? [..._nullishCoalesce(_optionalChain([details, 'optionalAccess', _39 => _39.resources]), () => ( []))] : [],
|
|
930
|
+
prompts: listed ? [..._nullishCoalesce(_optionalChain([details, 'optionalAccess', _40 => _40.prompts]), () => ( []))] : [],
|
|
931
|
+
tools: (listed ? tools : []).map((tool) => {
|
|
932
|
+
const schemas = _optionalChain([details, 'optionalAccess', _41 => _41.schemas, 'optionalAccess', _42 => _42[tool.name]]);
|
|
933
|
+
const hints = Object.fromEntries(
|
|
934
|
+
["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
|
|
935
|
+
);
|
|
936
|
+
return {
|
|
937
|
+
name: tool.name,
|
|
938
|
+
...tool.title ? { title: tool.title } : {},
|
|
939
|
+
...tool.description ? { description: tool.description } : {},
|
|
940
|
+
source: SOURCES[tool.kind],
|
|
941
|
+
// MCP clients never see the route behind a tool; only Infra's view names it.
|
|
942
|
+
...full && tool.kind === "endpoint" ? { method: tool.method, path: tool.path } : {},
|
|
943
|
+
...hints,
|
|
944
|
+
...schemas ? { inputSchema: schemas.input } : {},
|
|
945
|
+
..._optionalChain([schemas, 'optionalAccess', _43 => _43.output]) ? { outputSchema: schemas.output } : {}
|
|
946
|
+
};
|
|
947
|
+
})
|
|
948
|
+
};
|
|
949
|
+
})
|
|
938
950
|
},
|
|
939
951
|
webmcp: input.webmcp,
|
|
940
952
|
integrations: input.integrations,
|
|
941
953
|
agent: input.agent,
|
|
942
954
|
plugins: input.plugins
|
|
943
955
|
};
|
|
956
|
+
manifest.mcp.servers.push(...listDefaultServer(input));
|
|
957
|
+
return manifest;
|
|
944
958
|
}
|
|
945
959
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmAppManifest, "createFarmAppManifest");
|
|
960
|
+
function listDefaultServer(input) {
|
|
961
|
+
const server = _optionalChain([input, 'access', _44 => _44.defaultMCP, 'optionalCall', _45 => _45()]);
|
|
962
|
+
if (!server) return [];
|
|
963
|
+
return [
|
|
964
|
+
{
|
|
965
|
+
name: server.name,
|
|
966
|
+
version: server.version,
|
|
967
|
+
path: server.path,
|
|
968
|
+
authorization: "none",
|
|
969
|
+
resources: [],
|
|
970
|
+
prompts: [],
|
|
971
|
+
tools: _chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_TOOLS.map((tool) => ({
|
|
972
|
+
name: tool.name,
|
|
973
|
+
title: tool.title,
|
|
974
|
+
description: tool.description,
|
|
975
|
+
// Standalone tools with no endpoint behind them, like defineTool's.
|
|
976
|
+
source: "defineTool",
|
|
977
|
+
...tool.annotations,
|
|
978
|
+
inputSchema: tool.inputSchema,
|
|
979
|
+
..."outputSchema" in tool ? { outputSchema: tool.outputSchema } : {}
|
|
980
|
+
}))
|
|
981
|
+
}
|
|
982
|
+
];
|
|
983
|
+
}
|
|
984
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, listDefaultServer, "listDefaultServer");
|
|
946
985
|
var encoder = new TextEncoder();
|
|
947
986
|
var hex = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (bytes) => [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join(""), "hex");
|
|
948
987
|
async function sha256Hex(value) {
|
|
@@ -972,7 +1011,7 @@ async function verifyFarmInfraManifestSignature(header, key, now = Date.now()) {
|
|
|
972
1011
|
if (!header || header.length > 2048) return false;
|
|
973
1012
|
const parts = header.split(",").map((part) => part.trim());
|
|
974
1013
|
const timestamp = Number(
|
|
975
|
-
_optionalChain([/^t=(\d{1,12})$/, 'access',
|
|
1014
|
+
_optionalChain([/^t=(\d{1,12})$/, 'access', _46 => _46.exec, 'call', _47 => _47(_nullishCoalesce(parts.find((part) => part.startsWith("t=")), () => ( ""))), 'optionalAccess', _48 => _48[1]])
|
|
976
1015
|
);
|
|
977
1016
|
if (!Number.isSafeInteger(timestamp)) return false;
|
|
978
1017
|
if (Math.abs(now / 1e3 - timestamp) > SIGNATURE_WINDOW_SECONDS) return false;
|
|
@@ -984,25 +1023,44 @@ ${timestamp}`);
|
|
|
984
1023
|
}
|
|
985
1024
|
_chunkS3JO3N4Hcjs.__name.call(void 0, verifyFarmInfraManifestSignature, "verifyFarmInfraManifestSignature");
|
|
986
1025
|
function processEnv() {
|
|
987
|
-
return _nullishCoalesce(_optionalChain([globalThis, 'access',
|
|
1026
|
+
return _nullishCoalesce(_optionalChain([globalThis, 'access', _49 => _49.process, 'optionalAccess', _50 => _50.env]), () => ( {}));
|
|
988
1027
|
}
|
|
989
1028
|
_chunkS3JO3N4Hcjs.__name.call(void 0, processEnv, "processEnv");
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1029
|
+
var CORS_HEADERS = {
|
|
1030
|
+
"access-control-allow-origin": "*",
|
|
1031
|
+
"access-control-allow-methods": "GET, HEAD, OPTIONS",
|
|
1032
|
+
"access-control-allow-headers": `If-None-Match, ${FARM_INFRA_SIGNATURE_HEADER}`,
|
|
1033
|
+
"access-control-expose-headers": "ETag"
|
|
1034
|
+
};
|
|
1035
|
+
async function createFarmAppManifestResponse(request, input, options = {}) {
|
|
1036
|
+
const method = request.method.toUpperCase();
|
|
1037
|
+
if (method === "OPTIONS") return new Response(null, { status: 204, headers: CORS_HEADERS });
|
|
1038
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
1039
|
+
return new Response("Method Not Allowed", {
|
|
1040
|
+
status: 405,
|
|
1041
|
+
headers: { ...CORS_HEADERS, allow: "GET, HEAD, OPTIONS", "content-type": "text/plain" }
|
|
1042
|
+
});
|
|
1001
1043
|
}
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1044
|
+
const signature = request.headers.get(FARM_INFRA_SIGNATURE_HEADER);
|
|
1045
|
+
const key = input.analytics ? _optionalChain([(_nullishCoalesce(options.env, () => ( processEnv()))), 'access', _51 => _51.FARMJS_API_KEY, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()]) : void 0;
|
|
1046
|
+
const full = Boolean(
|
|
1047
|
+
signature && key && await verifyFarmInfraManifestSignature(signature, key)
|
|
1048
|
+
);
|
|
1049
|
+
const body = JSON.stringify(createFarmAppManifest(input, { full }));
|
|
1050
|
+
const etag = _chunkKIIMAWOJcjs.createFarmWeakETag.call(void 0, body);
|
|
1051
|
+
const headers = {
|
|
1052
|
+
...CORS_HEADERS,
|
|
1053
|
+
"content-type": "application/json; charset=utf-8",
|
|
1054
|
+
// The full view is for Infra alone; shared caches keep the two views apart.
|
|
1055
|
+
"cache-control": full ? "private, no-store" : "public, max-age=0, must-revalidate",
|
|
1056
|
+
vary: FARM_INFRA_SIGNATURE_HEADER,
|
|
1057
|
+
etag,
|
|
1058
|
+
"x-content-type-options": "nosniff"
|
|
1059
|
+
};
|
|
1060
|
+
if (!full && _chunkKIIMAWOJcjs.matchesFarmIfNoneMatch.call(void 0, request.headers.get("if-none-match"), etag)) {
|
|
1061
|
+
return new Response(null, { status: 304, headers });
|
|
1062
|
+
}
|
|
1063
|
+
return new Response(method === "HEAD" ? null : body, { status: 200, headers });
|
|
1006
1064
|
}
|
|
1007
1065
|
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmAppManifestResponse, "createFarmAppManifestResponse");
|
|
1008
1066
|
|
|
@@ -1037,4 +1095,7 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmAppManifestResponse, "createFarm
|
|
|
1037
1095
|
|
|
1038
1096
|
|
|
1039
1097
|
|
|
1040
|
-
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
exports.formatRouteSegment = formatRouteSegment; exports.createRouteDirectoryPattern = createRouteDirectoryPattern; exports.stripRouteGroups = stripRouteGroups; exports.getRouteGroupScope = getRouteGroupScope; exports.isInRouteGroupScope = isInRouteGroupScope; exports.getRouteDirectoryDepth = getRouteDirectoryDepth; exports.routeBoundaryCoversDirectory = routeBoundaryCoversDirectory; exports.HOISTED_HEAD_ELEMENT = HOISTED_HEAD_ELEMENT; exports.extractFarmFullDocument = extractFarmFullDocument; exports.classifyFarmDocumentPrefix = classifyFarmDocumentPrefix; exports.removeFarmDocumentTitles = removeFarmDocumentTitles; exports.ensureFarmDocumentMeta = ensureFarmDocumentMeta; exports.composeFarmFullDocument = composeFarmFullDocument; exports.renderFarmLocaleAlternateLinks = renderFarmLocaleAlternateLinks; exports.createLateRedirectRecovery = createLateRedirectRecovery; exports.createLateNotFoundRecovery = createLateNotFoundRecovery; exports.createFarmMetadataRouteResponse = createFarmMetadataRouteResponse; exports.listFarmMCPLlmsTxtLinks = listFarmMCPLlmsTxtLinks; exports.createFarmAiCatalogResponse = createFarmAiCatalogResponse; exports.resolveDefaultErrorStatus = resolveDefaultErrorStatus; exports.getDefaultErrorStatusText = getDefaultErrorStatusText; exports.createDefaultErrorMarkup = createDefaultErrorMarkup; exports.createFarmThemeDocumentParts = createFarmThemeDocumentParts; exports.applyFarmThemeDocument = applyFarmThemeDocument; exports.FARM_API_CATALOG_PATH = FARM_API_CATALOG_PATH; exports.resolveFarmApiCatalogInput = resolveFarmApiCatalogInput; exports.createFarmApiCatalogResponse = createFarmApiCatalogResponse; exports.FARM_APP_MANIFEST_PATH = FARM_APP_MANIFEST_PATH; exports.FARM_APP_MANIFEST_LEGACY_PATH = FARM_APP_MANIFEST_LEGACY_PATH; exports.isFarmAppManifestPath = isFarmAppManifestPath; exports.FARM_INFRA_SIGNATURE_HEADER = FARM_INFRA_SIGNATURE_HEADER; exports.resolveFarmAppManifestInput = resolveFarmAppManifestInput; exports.createFarmAppManifestResponse = createFarmAppManifestResponse;
|
|
@@ -6,7 +6,7 @@ var _chunk4PPEPOZZcjs = require('./chunk-4PPEPOZZ.cjs');
|
|
|
6
6
|
var _chunkMQ3H6LT5cjs = require('./chunk-MQ3H6LT5.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkFO427P6Icjs = require('./chunk-FO427P6I.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkSJNMVDDFcjs = require('./chunk-SJNMVDDF.cjs');
|
|
@@ -20,7 +20,7 @@ var _chunk2CQ74SP6cjs = require('./chunk-2CQ74SP6.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkS6VYG6XUcjs = require('./chunk-S6VYG6XU.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
|
|
@@ -28,13 +28,13 @@ var _chunk6V4TDWECcjs = require('./chunk-6V4TDWEC.cjs');
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var _chunkKIIMAWOJcjs = require('./chunk-KIIMAWOJ.cjs');
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
var _chunkM2L4MYDQcjs = require('./chunk-M2L4MYDQ.cjs');
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
var
|
|
37
|
+
var _chunkSHLXACIOcjs = require('./chunk-SHLXACIO.cjs');
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
@@ -58,7 +58,7 @@ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
|
58
58
|
function farmApiPlugin(options = {}) {
|
|
59
59
|
const srcDir = _nullishCoalesce(options.srcDir, () => ( "src"));
|
|
60
60
|
const debug = _nullishCoalesce(options.debug, () => ( false));
|
|
61
|
-
const bodySizeLimit =
|
|
61
|
+
const bodySizeLimit = _chunkKIIMAWOJcjs.resolveFarmServerConfig.call(void 0, {
|
|
62
62
|
bodySizeLimit: options.bodySizeLimit
|
|
63
63
|
}).bodySizeLimit;
|
|
64
64
|
const basePath = options.basePath;
|
|
@@ -110,7 +110,7 @@ function farmApiPlugin(options = {}) {
|
|
|
110
110
|
const existing = apiRoutesCache.get(routePath);
|
|
111
111
|
const existingFile = _optionalChain([endpointSources, 'access', _ => _.get, 'call', _2 => _2(routePath), 'optionalAccess', _3 => _3.get, 'call', _4 => _4(normalizedMethod)]);
|
|
112
112
|
if (existingFile) {
|
|
113
|
-
throw new (0,
|
|
113
|
+
throw new (0, _chunkFO427P6Icjs.APIRouteConflictError)(routePath, normalizedMethod, existingFile, filePath);
|
|
114
114
|
}
|
|
115
115
|
if (existing) {
|
|
116
116
|
if (!existing.methods.includes(normalizedMethod)) {
|
|
@@ -186,8 +186,11 @@ function farmApiPlugin(options = {}) {
|
|
|
186
186
|
const createRouter = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
|
|
187
187
|
const plugins = options.plugins ? await (_nullishCoalesce(routePlugins, () => ( (routePlugins = Promise.resolve(options.plugins({ root: projectRoot })))))) : [];
|
|
188
188
|
pluginMergedRoutes = plugins.length ? new Map(
|
|
189
|
-
|
|
190
|
-
bodySizeLimit
|
|
189
|
+
_chunkS6VYG6XUcjs.mergePluginAPIRoutes.call(void 0, [...apiRoutesCache.values()], plugins, void 0, {
|
|
190
|
+
bodySizeLimit,
|
|
191
|
+
// A plugin calling an app endpoint (an MCP tool, say) goes back through this server,
|
|
192
|
+
// so the middleware that guards the endpoint's path runs for it.
|
|
193
|
+
dispatch: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (request) => fetch(request, { redirect: "manual" }), "dispatch")
|
|
191
194
|
}).map((route) => [route.path, route])
|
|
192
195
|
) : null;
|
|
193
196
|
const totalEndpoints = Array.from(servedRoutes().values()).reduce(
|
|
@@ -200,7 +203,7 @@ function farmApiPlugin(options = {}) {
|
|
|
200
203
|
const url = new URL(request.url);
|
|
201
204
|
const method = request.method.toUpperCase();
|
|
202
205
|
const pathname = url.pathname;
|
|
203
|
-
const match =
|
|
206
|
+
const match = _chunkS6VYG6XUcjs.matchAPIRouteAtBasePath.call(void 0, servedRoutes(), pathname, basePath);
|
|
204
207
|
if (!match) {
|
|
205
208
|
return new Response(JSON.stringify({ error: "Not Found" }), {
|
|
206
209
|
status: 404,
|
|
@@ -208,18 +211,18 @@ function farmApiPlugin(options = {}) {
|
|
|
208
211
|
});
|
|
209
212
|
}
|
|
210
213
|
const { route, params } = match;
|
|
211
|
-
const endpoint =
|
|
214
|
+
const endpoint = _chunkS6VYG6XUcjs.resolveAPIRouteEndpoint.call(void 0, route, method);
|
|
212
215
|
if (!endpoint) {
|
|
213
216
|
return new Response(JSON.stringify({ error: "Method Not Allowed" }), {
|
|
214
217
|
status: 405,
|
|
215
218
|
headers: {
|
|
216
|
-
Allow:
|
|
219
|
+
Allow: _chunkS6VYG6XUcjs.getAllowedAPIRouteMethods.call(void 0, route).join(", "),
|
|
217
220
|
"Content-Type": "application/json"
|
|
218
221
|
}
|
|
219
222
|
});
|
|
220
223
|
}
|
|
221
224
|
try {
|
|
222
|
-
return await
|
|
225
|
+
return await _chunkS6VYG6XUcjs.invokeAPIRouteEndpoint.call(void 0, endpoint, request, params, bodySizeLimit);
|
|
223
226
|
} catch (error) {
|
|
224
227
|
return new Response(JSON.stringify({ error: error.message || "Internal Server Error" }), {
|
|
225
228
|
status: 500,
|
|
@@ -264,10 +267,10 @@ function farmApiPlugin(options = {}) {
|
|
|
264
267
|
try {
|
|
265
268
|
const relativePath = path.relative(apiDir, path.dirname(filePath));
|
|
266
269
|
const routePath = "/api/" + (relativePath === "." ? "" : relativePath.replace(/\\/g, "/"));
|
|
267
|
-
const routeModule = await
|
|
270
|
+
const routeModule = await _chunkSHLXACIOcjs.loadFarmDevModule.call(void 0, server, filePath);
|
|
268
271
|
const endpoints = {};
|
|
269
272
|
const availableMethods = [];
|
|
270
|
-
for (const method of
|
|
273
|
+
for (const method of _chunkS6VYG6XUcjs.API_ROUTE_METHODS) {
|
|
271
274
|
if (routeModule[method]) {
|
|
272
275
|
availableMethods.push(method);
|
|
273
276
|
endpoints[method] = routeModule[method];
|
|
@@ -280,7 +283,7 @@ function farmApiPlugin(options = {}) {
|
|
|
280
283
|
log(`API route discovered: ${availableMethods.join(", ")} ${routePath}`);
|
|
281
284
|
}
|
|
282
285
|
} catch (e) {
|
|
283
|
-
if (e instanceof
|
|
286
|
+
if (e instanceof _chunkFO427P6Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
284
287
|
log(`API route load failed at ${filePath}: ${e.message}`);
|
|
285
288
|
}
|
|
286
289
|
}
|
|
@@ -296,7 +299,7 @@ function farmApiPlugin(options = {}) {
|
|
|
296
299
|
for (const routesFile of routesFiles) {
|
|
297
300
|
if (fs.existsSync(routesFile)) {
|
|
298
301
|
try {
|
|
299
|
-
const routesModule = await
|
|
302
|
+
const routesModule = await _chunkSHLXACIOcjs.loadFarmDevModule.call(void 0, server, routesFile);
|
|
300
303
|
for (const [exportName, exportValue] of Object.entries(routesModule)) {
|
|
301
304
|
const endpoint = exportValue;
|
|
302
305
|
if (endpoint && endpoint.__path) {
|
|
@@ -307,7 +310,7 @@ function farmApiPlugin(options = {}) {
|
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
312
|
} catch (e) {
|
|
310
|
-
if (e instanceof
|
|
313
|
+
if (e instanceof _chunkFO427P6Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
311
314
|
log(`Root routes.ts load failed: ${e.message}`);
|
|
312
315
|
}
|
|
313
316
|
break;
|
|
@@ -322,7 +325,7 @@ function farmApiPlugin(options = {}) {
|
|
|
322
325
|
const { getProgrammaticRouteManifest } = await import("./routes.cjs");
|
|
323
326
|
for (const routeFile of routeFiles) {
|
|
324
327
|
try {
|
|
325
|
-
const routesModule = await
|
|
328
|
+
const routesModule = await _chunkSHLXACIOcjs.loadFarmDevModule.call(void 0,
|
|
326
329
|
server,
|
|
327
330
|
_chunk5QIKR7RRcjs.toViteModuleId.call(void 0, routeFile, server.config.root)
|
|
328
331
|
);
|
|
@@ -338,7 +341,7 @@ function farmApiPlugin(options = {}) {
|
|
|
338
341
|
}
|
|
339
342
|
}
|
|
340
343
|
} catch (e) {
|
|
341
|
-
if (e instanceof
|
|
344
|
+
if (e instanceof _chunkFO427P6Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
342
345
|
log(`Programmatic routes file load failed at ${routeFile}: ${e.message}`);
|
|
343
346
|
}
|
|
344
347
|
}
|
|
@@ -390,7 +393,7 @@ function farmApiPlugin(options = {}) {
|
|
|
390
393
|
const pathname = url.split("?")[0];
|
|
391
394
|
const method = req.method || "GET";
|
|
392
395
|
if (discoveryPromise) await waitForDiscovery();
|
|
393
|
-
if (!
|
|
396
|
+
if (!_chunkS6VYG6XUcjs.matchAPIRouteAtBasePath.call(void 0, servedRoutes(), pathname, basePath)) {
|
|
394
397
|
return next();
|
|
395
398
|
}
|
|
396
399
|
if (!apiRouterHandler) {
|
|
@@ -411,7 +414,7 @@ function farmApiPlugin(options = {}) {
|
|
|
411
414
|
}
|
|
412
415
|
const currentUrl = req.url || url;
|
|
413
416
|
const currentPathname = currentUrl.split("?")[0];
|
|
414
|
-
if (currentPathname !== pathname && !
|
|
417
|
+
if (currentPathname !== pathname && !_chunkS6VYG6XUcjs.matchAPIRouteAtBasePath.call(void 0, servedRoutes(), currentPathname, basePath)) {
|
|
415
418
|
return next();
|
|
416
419
|
}
|
|
417
420
|
const fullUrl = _chunkUXFQ3UDAcjs.resolveFarmRequestURL.call(void 0, req);
|
|
@@ -423,7 +426,7 @@ function farmApiPlugin(options = {}) {
|
|
|
423
426
|
}
|
|
424
427
|
let body;
|
|
425
428
|
if (method !== "GET" && method !== "HEAD") {
|
|
426
|
-
body = await
|
|
429
|
+
body = await _chunkKIIMAWOJcjs.readNodeRequestBody.call(void 0, req, bodySizeLimit);
|
|
427
430
|
}
|
|
428
431
|
const request = new Request(fullUrl, {
|
|
429
432
|
method,
|
|
@@ -438,7 +441,7 @@ function farmApiPlugin(options = {}) {
|
|
|
438
441
|
logResponse(method, currentPathname, response.status, duration);
|
|
439
442
|
await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, response);
|
|
440
443
|
} catch (error) {
|
|
441
|
-
const bodyErrorResponse =
|
|
444
|
+
const bodyErrorResponse = _chunkKIIMAWOJcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
|
|
442
445
|
if (bodyErrorResponse) {
|
|
443
446
|
await _chunkUQZ4AYTHcjs.sendWebResponse.call(void 0, res, bodyErrorResponse);
|
|
444
447
|
return;
|
|
@@ -487,7 +490,7 @@ function farmApiPlugin(options = {}) {
|
|
|
487
490
|
if (await _optionalChain([recoverFailedDiscovery, 'optionalCall', _9 => _9()])) return [];
|
|
488
491
|
const previousState = snapshotRouteState();
|
|
489
492
|
try {
|
|
490
|
-
const routesModule = await
|
|
493
|
+
const routesModule = await _chunkSHLXACIOcjs.loadFarmDevModule.call(void 0, server, file);
|
|
491
494
|
removeEndpointsFromFile(file);
|
|
492
495
|
for (const [exportName, exportValue] of Object.entries(routesModule)) {
|
|
493
496
|
const endpoint = exportValue;
|
|
@@ -515,7 +518,7 @@ function farmApiPlugin(options = {}) {
|
|
|
515
518
|
log(`API router recreated`);
|
|
516
519
|
} catch (e) {
|
|
517
520
|
restoreRouteState(previousState);
|
|
518
|
-
if (e instanceof
|
|
521
|
+
if (e instanceof _chunkFO427P6Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
519
522
|
log(`Root routes.ts HMR failed: ${e.message}`);
|
|
520
523
|
}
|
|
521
524
|
return [];
|
|
@@ -540,10 +543,10 @@ function farmApiPlugin(options = {}) {
|
|
|
540
543
|
log(`API route file removed: ${routePath}`);
|
|
541
544
|
return [];
|
|
542
545
|
}
|
|
543
|
-
const routeModule = await
|
|
546
|
+
const routeModule = await _chunkSHLXACIOcjs.loadFarmDevModule.call(void 0, server, file);
|
|
544
547
|
removeEndpointsFromFile(file);
|
|
545
548
|
const availableMethods = [];
|
|
546
|
-
for (const method of
|
|
549
|
+
for (const method of _chunkS6VYG6XUcjs.API_ROUTE_METHODS) {
|
|
547
550
|
if (!routeModule[method]) continue;
|
|
548
551
|
availableMethods.push(method);
|
|
549
552
|
addEndpoint(routePath, file, method, routeModule[method]);
|
|
@@ -553,7 +556,7 @@ function farmApiPlugin(options = {}) {
|
|
|
553
556
|
log(`API router recreated`);
|
|
554
557
|
} catch (e) {
|
|
555
558
|
restoreRouteState(previousState);
|
|
556
|
-
if (e instanceof
|
|
559
|
+
if (e instanceof _chunkFO427P6Icjs.APIRouteConflictError || e instanceof _chunkNO3WWW3Ncjs.AmbiguousRouteError) throw e;
|
|
557
560
|
log(`API route HMR failed: ${e.message}`);
|
|
558
561
|
}
|
|
559
562
|
return [];
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkT5OJPTVNcjs = require('./chunk-T5OJPTVN.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkYWN746UScjs = require('./chunk-YWN746US.cjs');
|
|
@@ -70,13 +70,13 @@ async function _invokeServerFunction(value, input, request) {
|
|
|
70
70
|
throw new TypeError("Expected a function created with createServerFn or createServerQuery");
|
|
71
71
|
}
|
|
72
72
|
try {
|
|
73
|
-
const data = await
|
|
73
|
+
const data = await _chunkT5OJPTVNcjs.runWithServerActionRequest.call(void 0, request, () => runner.run(input));
|
|
74
74
|
return { ok: true, data };
|
|
75
75
|
} catch (error) {
|
|
76
76
|
if (error instanceof ServerFnInputError) {
|
|
77
77
|
return { ok: false, reason: "input", error: error.cause };
|
|
78
78
|
}
|
|
79
|
-
if (
|
|
79
|
+
if (_chunkT5OJPTVNcjs.isServerFnFailure.call(void 0, error)) return { ok: false, reason: "failure", failure: error };
|
|
80
80
|
const redirect = _chunkOX6O6WVAcjs.getFarmRedirectError.call(void 0, error);
|
|
81
81
|
if (redirect) {
|
|
82
82
|
return { ok: false, reason: "redirect", url: redirect.url, status: redirect.status };
|
|
@@ -117,9 +117,9 @@ function createServerFn(options) {
|
|
|
117
117
|
} catch (cause) {
|
|
118
118
|
throw labelInputErrors && isSchemaValidationFailure(cause) ? new ServerFnInputError(cause) : cause;
|
|
119
119
|
}
|
|
120
|
-
const executionContext =
|
|
120
|
+
const executionContext = _chunkT5OJPTVNcjs.getServerActionExecutionContext.call(void 0, );
|
|
121
121
|
const request = _nullishCoalesce(_optionalChain([executionContext, 'optionalAccess', _ => _.request]), () => ( _chunkU4KT7QP3cjs._resolveCurrentRequest.call(void 0, )));
|
|
122
|
-
const signal = _nullishCoalesce(_nullishCoalesce(_optionalChain([executionContext, 'optionalAccess', _2 => _2.signal]), () => ( _optionalChain([request, 'optionalAccess', _3 => _3.signal]))), () => (
|
|
122
|
+
const signal = _nullishCoalesce(_nullishCoalesce(_optionalChain([executionContext, 'optionalAccess', _2 => _2.signal]), () => ( _optionalChain([request, 'optionalAccess', _3 => _3.signal]))), () => ( _chunkT5OJPTVNcjs.getServerActionSignal.call(void 0, )));
|
|
123
123
|
const handlerContext = {
|
|
124
124
|
input,
|
|
125
125
|
rawInput,
|
|
@@ -245,7 +245,7 @@ function createServerFnErrorHandler(definitions) {
|
|
|
245
245
|
throw new TypeError(`Server function error "${code}" is not declared`);
|
|
246
246
|
}
|
|
247
247
|
const parsed = parseServerFnFailureData(code, definition.data, data);
|
|
248
|
-
throw new (0,
|
|
248
|
+
throw new (0, _chunkT5OJPTVNcjs.ServerFnFailure)(code, parsed, {
|
|
249
249
|
status: definition.status,
|
|
250
250
|
message: _nullishCoalesce(definition.message, () => ( "Server function failed"))
|
|
251
251
|
});
|
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
loadFarmDevModule,
|
|
22
22
|
toFileModuleUrl
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-KMTGADN3.mjs";
|
|
24
24
|
import {
|
|
25
25
|
logger
|
|
26
26
|
} from "./chunk-KI3MESHB.mjs";
|
|
27
|
-
import {
|
|
28
|
-
createFarmAPIMiddlewarePathnames
|
|
29
|
-
} from "./chunk-BTHHUD7Q.mjs";
|
|
30
27
|
import {
|
|
31
28
|
emitFarmEvent
|
|
32
29
|
} from "./chunk-FUZEBRP3.mjs";
|
|
33
30
|
import {
|
|
34
31
|
sendWebResponse
|
|
35
32
|
} from "./chunk-Z2RZJZIZ.mjs";
|
|
33
|
+
import {
|
|
34
|
+
createFarmAPIMiddlewarePathnames
|
|
35
|
+
} from "./chunk-BTHHUD7Q.mjs";
|
|
36
36
|
import {
|
|
37
37
|
getFarmRedirectError,
|
|
38
38
|
isFarmNotFoundError,
|
|
@@ -190,6 +190,7 @@ function createFarmConfigResolutionPlugin(options) {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
__name(createFarmConfigResolutionPlugin, "createFarmConfigResolutionPlugin");
|
|
193
|
+
var FARM_CONFIG_ROOT = /* @__PURE__ */ Symbol.for("farm.configRoot");
|
|
193
194
|
async function loadFarmConfigFile(configPath, options) {
|
|
194
195
|
const { transform } = await import("rolldown/utils");
|
|
195
196
|
const cacheRoot = path.resolve(options.cacheRoot || options.root);
|
|
@@ -207,6 +208,9 @@ async function loadFarmConfigFile(configPath, options) {
|
|
|
207
208
|
plugins: [createFarmConfigResolutionPlugin({ transform })]
|
|
208
209
|
});
|
|
209
210
|
const moduleUrl = `${pathToFileURL(modulePath).href}?t=${Date.now()}`;
|
|
211
|
+
const configRootState = globalThis;
|
|
212
|
+
const previousConfigRoot = configRootState[FARM_CONFIG_ROOT];
|
|
213
|
+
configRootState[FARM_CONFIG_ROOT] = cacheRoot;
|
|
210
214
|
try {
|
|
211
215
|
const loaded = await import(
|
|
212
216
|
/* @vite-ignore */
|
|
@@ -218,6 +222,7 @@ async function loadFarmConfigFile(configPath, options) {
|
|
|
218
222
|
}
|
|
219
223
|
return config;
|
|
220
224
|
} finally {
|
|
225
|
+
configRootState[FARM_CONFIG_ROOT] = previousConfigRoot;
|
|
221
226
|
await unlink(modulePath).catch(() => void 0);
|
|
222
227
|
}
|
|
223
228
|
}
|