@farm.js/core 0.1.25 → 0.1.27

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.
Files changed (181) hide show
  1. package/dist/agent-runtime.d.mts +8 -10
  2. package/dist/agent-runtime.d.ts +8 -10
  3. package/dist/api/client.cjs +3 -3
  4. package/dist/api/client.d.mts +4 -5
  5. package/dist/api/client.d.ts +4 -5
  6. package/dist/api/client.mjs +2 -2
  7. package/dist/api/route-manager.cjs +6 -5
  8. package/dist/api/route-manager.d.mts +7 -9
  9. package/dist/api/route-manager.d.ts +7 -9
  10. package/dist/api/route-manager.mjs +5 -4
  11. package/dist/api/runtime.cjs +10 -4
  12. package/dist/api/runtime.d.mts +35 -3
  13. package/dist/api/runtime.d.ts +35 -3
  14. package/dist/api/runtime.mjs +9 -3
  15. package/dist/{api-client-Cx54IR5g.d.mts → api-client-BjMmY8OD.d.mts} +2 -3
  16. package/dist/{api-client-DykpaKcY.d.ts → api-client-CyFtZFJ4.d.ts} +2 -3
  17. package/dist/api.cjs +9 -8
  18. package/dist/api.d.mts +9 -11
  19. package/dist/api.d.ts +9 -11
  20. package/dist/api.mjs +9 -8
  21. package/dist/{app-ZuWrAMc_.d.mts → app-BfzZdjgX.d.mts} +3 -4
  22. package/dist/{app-BF-ctoxh.d.ts → app-CXK7Prrt.d.ts} +3 -4
  23. package/dist/app-markdown.cjs +12 -4
  24. package/dist/app-markdown.d.mts +9 -11
  25. package/dist/app-markdown.d.ts +9 -11
  26. package/dist/app-markdown.mjs +11 -3
  27. package/dist/{chunk-2BIJGZR3.mjs → chunk-3PTVHMLD.mjs} +1 -1
  28. package/dist/{chunk-XME4TCLB.mjs → chunk-4FHDV7VM.mjs} +2 -2
  29. package/dist/{chunk-KLSSO6YD.mjs → chunk-4UNKCNSL.mjs} +1 -1
  30. package/dist/chunk-5MKEDGLD.cjs +53 -0
  31. package/dist/{chunk-E3RDL2DA.cjs → chunk-DQMTHWPI.cjs} +61 -31
  32. package/dist/{chunk-TTVHACQV.cjs → chunk-FOT7LZEO.cjs} +1 -1
  33. package/dist/{chunk-2KI3CL3N.mjs → chunk-FPW4W3VW.mjs} +1 -1
  34. package/dist/{chunk-6K4SPQWL.cjs → chunk-HF5SIACK.cjs} +3 -3
  35. package/dist/{chunk-T2OPSH6S.mjs → chunk-HG237IEY.mjs} +12 -5
  36. package/dist/chunk-J63ZH5OQ.cjs +62 -0
  37. package/dist/{chunk-BD2U4ZL6.cjs → chunk-JQGDQO2I.cjs} +8 -8
  38. package/dist/{chunk-RR6UGYUT.mjs → chunk-JT25KHDI.mjs} +39 -9
  39. package/dist/{chunk-O5DVPF3R.cjs → chunk-KAERLFD3.cjs} +16 -11
  40. package/dist/{chunk-H7CJRJ4L.cjs → chunk-LAHZ7LZA.cjs} +16 -16
  41. package/dist/{chunk-XM4ZDVD7.mjs → chunk-MBFURXAC.mjs} +1 -1
  42. package/dist/{chunk-6VEHUKZ2.mjs → chunk-MM5D6VLP.mjs} +4 -20
  43. package/dist/chunk-MVL2RAJW.mjs +62 -0
  44. package/dist/{chunk-YA6LLTIJ.cjs → chunk-ND224OE2.cjs} +4 -20
  45. package/dist/{chunk-RYDW7GPR.cjs → chunk-NPFGGBM5.cjs} +13 -13
  46. package/dist/{chunk-VZWO3XVL.mjs → chunk-O2LV5XDG.mjs} +2 -2
  47. package/dist/chunk-O6XNAMBV.mjs +53 -0
  48. package/dist/{chunk-N2Z4ZFDE.mjs → chunk-OGHTEYXS.mjs} +22 -14
  49. package/dist/{chunk-U4MP7XTD.mjs → chunk-POXI72VV.mjs} +180 -16
  50. package/dist/{chunk-QGG336NI.mjs → chunk-Q4BHBO6V.mjs} +1 -1
  51. package/dist/{chunk-AXYTGLF3.cjs → chunk-QI7WQSMI.cjs} +4 -4
  52. package/dist/{chunk-WOI2HOGA.mjs → chunk-QQQNJS2E.mjs} +1 -1
  53. package/dist/{chunk-CFNOGDUS.cjs → chunk-TDWFCC2T.cjs} +2 -2
  54. package/dist/{chunk-R7LCG3BT.cjs → chunk-UNSKL6BI.cjs} +89 -81
  55. package/dist/{chunk-WJYCI56T.mjs → chunk-UWTQTZFN.mjs} +52 -33
  56. package/dist/{chunk-5YYJ6Q2L.mjs → chunk-WIVTGKLY.mjs} +7 -2
  57. package/dist/{chunk-65P6OGYN.cjs → chunk-WJKVTJJR.cjs} +12 -5
  58. package/dist/{chunk-OAVTUMJP.cjs → chunk-YXM74XOW.cjs} +9 -9
  59. package/dist/{chunk-QYMRIVG6.cjs → chunk-YZBV7733.cjs} +120 -101
  60. package/dist/{chunk-2ITKVAIF.cjs → chunk-ZSO5GWGD.cjs} +203 -39
  61. package/dist/{client-plugins-DPG0NeZN.d.mts → client-plugins-1GS4zubE.d.mts} +1940 -1677
  62. package/dist/{client-plugins-Fgni-_25.d.ts → client-plugins-B1Za6F5x.d.ts} +1940 -1677
  63. package/dist/client-plugins.d.mts +8 -10
  64. package/dist/client-plugins.d.ts +8 -10
  65. package/dist/client.cjs +4 -4
  66. package/dist/client.d.mts +10 -12
  67. package/dist/client.d.ts +10 -12
  68. package/dist/client.mjs +3 -3
  69. package/dist/config.d.mts +8 -10
  70. package/dist/config.d.ts +8 -10
  71. package/dist/{devtools-I7TBFOKD.mjs → devtools-6RN6KHTW.mjs} +8 -3
  72. package/dist/{devtools-6OA7FEF6.cjs → devtools-CQJ3H6MX.cjs} +9 -4
  73. package/dist/docs.cjs +11 -6
  74. package/dist/docs.mjs +10 -5
  75. package/dist/{endpoint-1zA994xL.d.ts → endpoint-CA-TNX60.d.ts} +1 -1
  76. package/dist/{endpoint-DAc96i93.d.mts → endpoint-CCHFqyTE.d.mts} +1 -1
  77. package/dist/index.cjs +26 -21
  78. package/dist/index.d.mts +16 -18
  79. package/dist/index.d.ts +16 -18
  80. package/dist/index.mjs +26 -21
  81. package/dist/{integration-api-BbaiokCC.d.ts → integration-api-0y4FXJpC.d.mts} +128 -1
  82. package/dist/{integration-api-BbaiokCC.d.mts → integration-api-BPJo5oXb.d.ts} +128 -1
  83. package/dist/integrations.d.mts +8 -10
  84. package/dist/integrations.d.ts +8 -10
  85. package/dist/internal/app-markdown-runtime.cjs +11 -3
  86. package/dist/internal/app-markdown-runtime.d.mts +9 -10
  87. package/dist/internal/app-markdown-runtime.d.ts +9 -10
  88. package/dist/internal/app-markdown-runtime.mjs +10 -2
  89. package/dist/internal/build-runtime.cjs +19 -17
  90. package/dist/internal/build-runtime.d.mts +10 -12
  91. package/dist/internal/build-runtime.d.ts +10 -12
  92. package/dist/internal/build-runtime.mjs +18 -16
  93. package/dist/internal/cli-runtime.cjs +9 -5
  94. package/dist/internal/cli-runtime.mjs +8 -4
  95. package/dist/internal/client-error-overlay.cjs +4 -4
  96. package/dist/internal/client-error-overlay.mjs +1 -1
  97. package/dist/internal/compression-runtime.d.mts +8 -10
  98. package/dist/internal/compression-runtime.d.ts +8 -10
  99. package/dist/internal/config-runtime.cjs +9 -4
  100. package/dist/internal/config-runtime.d.mts +9 -11
  101. package/dist/internal/config-runtime.d.ts +9 -11
  102. package/dist/internal/config-runtime.mjs +8 -3
  103. package/dist/internal/infra-analytics-runtime.cjs +4 -3
  104. package/dist/internal/infra-analytics-runtime.mjs +2 -1
  105. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  106. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  107. package/dist/internal/production-runtime.cjs +8 -5
  108. package/dist/internal/production-runtime.d.mts +16 -16
  109. package/dist/internal/production-runtime.d.ts +16 -16
  110. package/dist/internal/production-runtime.mjs +7 -4
  111. package/dist/markdown.cjs +10 -2
  112. package/dist/markdown.d.mts +35 -153
  113. package/dist/markdown.d.ts +35 -153
  114. package/dist/markdown.mjs +9 -1
  115. package/dist/{metadata-CDnRHKVq.d.ts → metadata-7LKgQEWF.d.ts} +1 -1
  116. package/dist/{metadata-D0EF7esB.d.mts → metadata-B9mCxKgp.d.mts} +1 -1
  117. package/dist/middleware.d.mts +9 -11
  118. package/dist/middleware.d.ts +9 -11
  119. package/dist/navigation.d.mts +10 -12
  120. package/dist/navigation.d.ts +10 -12
  121. package/dist/{nitro-ZKLGOTVY.mjs → nitro-NAKCRVHX.mjs} +4 -3
  122. package/dist/{nitro-KQDU7CFE.cjs → nitro-VYDZGYFY.cjs} +4 -3
  123. package/dist/observability-BupkiN0m.d.mts +447 -0
  124. package/dist/observability-BupkiN0m.d.ts +447 -0
  125. package/dist/observability.d.mts +2 -417
  126. package/dist/observability.d.ts +2 -417
  127. package/dist/plugin.cjs +14 -12
  128. package/dist/plugin.d.mts +9 -11
  129. package/dist/plugin.d.ts +9 -11
  130. package/dist/plugin.mjs +13 -11
  131. package/dist/{production-runtime-DpCt0opU.d.ts → production-runtime-B3xnY6fI.d.ts} +1 -1
  132. package/dist/{production-runtime-x3W4wVqx.d.mts → production-runtime-DramhI0c.d.mts} +1 -1
  133. package/dist/{render-plan-D5oFRVBV.d.ts → render-plan-CpW32tOL.d.ts} +1 -1
  134. package/dist/{render-plan-tazUJalK.d.mts → render-plan-CtQB-zHS.d.mts} +1 -1
  135. package/dist/renderer-client.d.mts +6 -8
  136. package/dist/renderer-client.d.ts +6 -8
  137. package/dist/{request-CzZX0Aew.d.ts → request-BVGGeQv4.d.ts} +1 -1
  138. package/dist/{request-CXmQy5ks.d.mts → request-DlLVBKe3.d.mts} +1 -1
  139. package/dist/request.d.mts +9 -11
  140. package/dist/request.d.ts +9 -11
  141. package/dist/{route-rendering-Dw3C362T.d.ts → route-rendering-BdEldajn.d.ts} +1 -1
  142. package/dist/{route-rendering-B-qpe32B.d.mts → route-rendering-DChYLNdh.d.mts} +1 -1
  143. package/dist/{router-CLl3xHwl.d.ts → router-D0Az-1Nu.d.ts} +1 -1
  144. package/dist/{router-CafM2jlw.d.mts → router-D5htHn_M.d.mts} +1 -1
  145. package/dist/routes.d.mts +6 -8
  146. package/dist/routes.d.ts +6 -8
  147. package/dist/server-fn-client.d.mts +3 -4
  148. package/dist/server-fn-client.d.ts +3 -4
  149. package/dist/server-fn.d.mts +1 -1
  150. package/dist/server-fn.d.ts +1 -1
  151. package/dist/server-plugins.d.mts +8 -10
  152. package/dist/server-plugins.d.ts +8 -10
  153. package/dist/server-query-client.d.mts +1 -1
  154. package/dist/server-query-client.d.ts +1 -1
  155. package/dist/server-query.d.mts +1 -1
  156. package/dist/server-query.d.ts +1 -1
  157. package/dist/server.cjs +292 -141
  158. package/dist/server.d.mts +13 -15
  159. package/dist/server.d.ts +13 -15
  160. package/dist/server.mjs +278 -127
  161. package/dist/{spa-router-6sJfsMlQ.d.mts → spa-router-DVfSJZ5o.d.mts} +2 -2
  162. package/dist/{spa-router-DePr2aZ6.d.ts → spa-router-DmwP_7QL.d.ts} +2 -2
  163. package/dist/testing.cjs +6 -5
  164. package/dist/testing.d.mts +7 -9
  165. package/dist/testing.d.ts +7 -9
  166. package/dist/testing.mjs +5 -4
  167. package/dist/{utils-BPHr-1mP.d.mts → utils-B_Rmr0-n.d.mts} +1 -1
  168. package/dist/{utils-BBKC3cf3.d.ts → utils-Dv0OuLtF.d.ts} +1 -1
  169. package/dist/version.cjs +2 -2
  170. package/dist/version.mjs +1 -1
  171. package/dist/vite.cjs +14 -12
  172. package/dist/vite.d.mts +8 -10
  173. package/dist/vite.d.ts +8 -10
  174. package/dist/vite.mjs +13 -11
  175. package/package.json +1 -1
  176. package/dist/route-B0XrsrFk.d.mts +0 -128
  177. package/dist/route-DOEpbyWZ.d.ts +0 -128
  178. package/dist/{chunk-GDUYXFIS.mjs → chunk-6EG7U4NF.mjs} +3 -3
  179. package/dist/{chunk-YAOX43YI.cjs → chunk-C7OUJ6JI.cjs} +2 -2
  180. package/dist/{chunk-IXTFU4PL.cjs → chunk-NL3ZSMZB.cjs} +2 -2
  181. package/dist/{chunk-L6V3P73N.mjs → chunk-UOXGA6TO.mjs} +4 -4
@@ -1,16 +1,17 @@
1
1
  import { n as FarmClientPlugin } from './lifecycle-DK06VuKP.mjs';
2
- import { R as RouteMethod, g as PluginRoutes, P as PluginRoutesFactory } from './route-B0XrsrFk.mjs';
3
- import { T as TypedEndpoint, d as EndpointMCPMetadata, R as RouteSchema, a as RouteSchemaOutput, c as RouteSchemaInput, Y as OpenAPISecurityMode } from './endpoint-DAc96i93.mjs';
2
+ import { F as FarmIntegrationAPI, e as FarmIntegrationAPIMethod, c as FarmIntegrationAPIBodyFormat, f as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, h as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes, p as PluginRoutes, P as PluginRoutesFactory, R as RouteMethod } from './integration-api-0y4FXJpC.mjs';
3
+ import { Y as OpenAPISecurityMode, T as TypedEndpoint, E as EndpointMCPMetadata, R as RouteSchema, b as RouteSchemaOutput, d as RouteSchemaInput } from './endpoint-CCHFqyTE.mjs';
4
4
  import { FarmRenderer } from './renderer.mjs';
5
5
  import { IncomingMessage, ServerResponse } from 'http';
6
- import { FarmMarkdownResolvedConfig, FarmMarkdownUserConfig } from './markdown.mjs';
6
+ import { ServerFn } from './server-fn.mjs';
7
+ import { ServerQuery } from './server-query.mjs';
8
+ import { g as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.mjs';
7
9
  import { d as FarmStorageUserConfig } from './types-Cc8l9IqS.mjs';
8
10
  import { FarmSchemaField, FarmSchema, FarmSchemaModel, FarmSchemaReference, FarmSchemaFieldType, FarmSchemaConstraint, FarmSchemaModelExtension, FarmSchemaModelOverride, defineSchema, FarmSchemaConfig } from './schema.mjs';
9
11
  import React__default, { ComponentType, ReactNode } from 'react';
10
- import { F as FarmIntegrationAPI, e as FarmIntegrationAPIMethod, c as FarmIntegrationAPIBodyFormat, f as FarmIntegrationAPIOperation, g as FarmIntegrationAPIResponseFormat, h as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes } from './integration-api-BbaiokCC.mjs';
11
12
  import { OrmClient, SchemaDefinition, ModelDefinition, FieldBuilder, JsonValue, AnyModelDefinition, SchemaModels } from '@farming-labs/orm';
12
13
  import { a as FarmDocsUserConfig, F as FarmDocsResolvedConfig } from './types-DFbjpjXX.mjs';
13
- import { FarmObservabilityUserConfig } from './observability.mjs';
14
+ import { L as FarmObservabilityUserConfig } from './observability-BupkiN0m.mjs';
14
15
  import * as vite from 'vite';
15
16
  import { ViteDevServer, UserConfig, Plugin as Plugin$1, Connect } from 'vite';
16
17
  import { k as FarmWorkflowsUserConfig, a as FarmServerConfig, F as FarmWorkflowsResolvedConfig, R as ResolvedFarmServerConfig } from './workflows-CR9ex-gz.mjs';
@@ -20,339 +21,232 @@ import { FarmServerActionsConfig, ResolvedFarmServerActionsConfig } from './serv
20
21
  import * as rolldown_utils from 'rolldown/utils';
21
22
  import { Plugin } from 'rolldown';
22
23
  import { F as FarmImageConfig, R as ResolvedFarmImageConfig } from './image-config-Duob7wER.mjs';
23
- import { g as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types-Z0aotQ8w.mjs';
24
24
  import { FarmCacheUserConfig } from './cache.mjs';
25
- import { ServerFn } from './server-fn.mjs';
26
- import { ServerQuery } from './server-query.mjs';
27
25
  import { R as ResolvedFarmThemeConfig, d as FarmThemeConfig } from './types-DQnyD3VD.mjs';
28
26
  import { FarmLayoutFonts } from './font.mjs';
29
27
  import { _withAfterNodeMiddleware } from './after.mjs';
30
28
  import { F as FarmIslandStrategy } from './island-CfGru1MO.mjs';
31
29
 
32
- interface FarmLlmsTxtLink {
33
- title: string;
34
- url: string;
35
- description?: string;
36
- }
37
- interface FarmLlmsTxtSection {
38
- title: string;
39
- links: FarmLlmsTxtLink[];
40
- }
41
- interface FarmLlmsTxt {
42
- /** Site or project name, rendered as the `# H1`. Required by the format. */
43
- title: string;
44
- /** One-sentence summary, rendered as a `> blockquote`. */
45
- summary?: string;
46
- /** Free-form Markdown placed after the summary. */
47
- details?: string;
48
- /** `## H2` sections of links. A section titled "Optional" marks skippable links. */
49
- sections?: FarmLlmsTxtSection[];
30
+ /** @internal The environment registry is owned and closed by Vite. */
31
+ interface FarmDevModuleServer {
32
+ environments: Record<string, unknown>;
50
33
  }
51
- /** A static page of the app, ready to use as an llms.txt link. */
52
- interface FarmLlmsTxtPage extends FarmLlmsTxtLink {
53
- /** The page's route path, such as `/docs/install`. */
54
- path: string;
34
+ /** @internal Distinguishes an unsupported runtime from a module evaluation error. */
35
+ declare class FarmDevEnvironmentError extends Error {
55
36
  }
56
- interface FarmLlmsTxtUserConfig {
57
- /** Set to `false` to turn llms.txt off while keeping these options. */
58
- enabled?: boolean;
59
- /** Site name for the `# H1`. Defaults to the root layout's metadata title. */
60
- title?: string;
61
- /** Summary for the `> blockquote`. Defaults to the root layout's metadata description. */
62
- summary?: string;
63
- /** Markdown placed after the summary. */
64
- details?: string;
65
- /**
66
- * Route patterns to list, using the same syntax as `md.expose`
67
- * (`/docs/[...slug]`). Defaults to every static page.
68
- */
69
- include?: string[];
70
- /** Route patterns to leave out, such as `/admin/[...path]`. */
71
- exclude?: string[];
37
+ /** @internal Load in the selected environment without sharing SSR/RSC module state. */
38
+ declare function loadFarmDevModule<T = Record<string, any>>(server: FarmDevModuleServer, id: string, environmentName?: "ssr" | "rsc"): Promise<T>;
39
+
40
+ type ResolvedSchemaField = FarmSchemaField & {
41
+ name: string;
42
+ };
43
+ type ResolvedSchemaModel = Omit<FarmSchemaModel, "fields"> & {
44
+ name: string;
45
+ fields: Record<string, ResolvedSchemaField>;
46
+ };
47
+ /**
48
+ * Resolve a schema's extensions, overrides, and name mappings.
49
+ *
50
+ * Table and column names fall back to the schema's own keys, which is what the
51
+ * runtime ORM uses. Any other default would generate artifacts describing
52
+ * tables the app cannot actually read.
53
+ */
54
+ declare function resolveSchemaModels(ownerKey: string, schema: FarmSchema): Record<string, ResolvedSchemaModel>;
55
+
56
+ type FarmSqlDialect = "postgres" | "mysql" | "sqlite";
57
+ type CollectedSchemaModel = {
58
+ /** Namespace that owns the model: an integration key or a plugin name. */
59
+ ownerKey: string;
60
+ modelKey: string;
61
+ modelName: string;
62
+ exportName: string;
63
+ prismaModelName: string;
64
+ model: ResolvedSchemaModel;
72
65
  /**
73
- * Also serve `/llms-full.txt`, the index with each page's Markdown mirror inlined.
74
- *
75
- * @default true
66
+ * Real table and column for references to models this owner describes but
67
+ * does not create (external, or outside its `models`), keyed by field. Only
68
+ * shown in comments: Farm never creates a foreign key to them.
76
69
  */
77
- full?: boolean;
70
+ referenceTargets?: Record<string, {
71
+ table: string;
72
+ column: string;
73
+ }>;
78
74
  /**
79
- * Seconds a CDN may cache the generated files, and the production server may
80
- * reuse an llms-full.txt render, which renders every listed page. Defaults to
81
- * no caching; concurrent llms-full.txt requests still share one render.
75
+ * References to tables other owners create that may carry a real foreign
76
+ * key, keyed by field. Set by migrate after checking the database; only a
77
+ * table created now gets one inline.
82
78
  */
83
- revalidate?: number;
84
- }
85
- interface ResolvedFarmLlmsTxtConfig {
86
- enabled: boolean;
87
- title?: string;
88
- summary?: string;
89
- details?: string;
90
- include: string[];
91
- exclude: string[];
92
- full: boolean;
93
- revalidate?: number;
94
- }
95
- interface FarmLlmsTxtPageSource {
96
- pattern: string;
97
- metadata?: unknown;
98
- }
99
- declare function collectFarmLlmsTxtPages(sources: Iterable<FarmLlmsTxtPageSource>, options: {
100
- origin: string;
101
- basePath?: string;
102
- markdown?: FarmMarkdownResolvedConfig;
103
- include?: string[];
104
- exclude?: string[];
105
- }): FarmLlmsTxtPage[];
106
- declare function createFarmDefaultLlmsTxt(options: {
107
- origin: string;
108
- pages: FarmLlmsTxtPage[];
109
- config: ResolvedFarmLlmsTxtConfig;
110
- rootMetadata?: unknown;
111
- }): FarmLlmsTxt;
79
+ foreignKeys?: Record<string, {
80
+ table: string;
81
+ column: string;
82
+ onDelete: NonNullable<FarmSchemaReference["onDelete"]>;
83
+ }>;
84
+ };
85
+ /** `table.column` a field's reference points at, using real names when known. */
86
+ declare function describeSchemaReference(model: CollectedSchemaModel, fieldKey: string): string;
112
87
  /**
113
- * Reads a page's Markdown the way an agent would: a fresh `.md` request with no
114
- * cookies or credentials, so a page behind auth answers 401 and is left out of
115
- * a file that CDNs may cache, instead of leaking into it.
88
+ * Flatten owners' schemas into one list, rejecting two models that would
89
+ * resolve to the same table.
90
+ *
91
+ * `only` narrows an owner to the models it actually controls; an owner handed a
92
+ * schema it shares with the rest of the app should not claim all of it.
116
93
  */
117
- declare function createFarmLlmsMarkdownReader(fetchMarkdown: (request: Request) => Promise<Response>): (url: string) => Promise<string | null>;
94
+ declare function collectSchemaModels(entries: ReadonlyArray<readonly [string, FarmSchema, (readonly string[])?]>): CollectedSchemaModel[];
95
+ type FarmSqlStatement = {
96
+ kind: "table" | "index" | "column";
97
+ /** The object this statement creates, for drift reporting. */
98
+ target: string;
99
+ sql: string;
100
+ };
118
101
  /**
119
- * Renders llms-full.txt: the llms.txt header, then one block per linked page with
120
- * its Markdown inlined, in the layout the docs engine uses. A string passes
121
- * through unchanged. Only same-origin links are fetched.
102
+ * Emit create statements for a set of models.
103
+ *
104
+ * Everything here is derivable from the schema: nothing is inferred from a live
105
+ * database, so the output is stable and reviewable before it is applied.
122
106
  */
123
- declare function renderFarmLlmsFullTxt(value: unknown, options: {
124
- origin: string;
125
- readMarkdown: (url: string) => Promise<string | null>;
126
- concurrency?: number;
127
- }): Promise<string>;
107
+ declare function generateSqlStatements(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): FarmSqlStatement[];
108
+ /** Render models as a standalone `.sql` file. */
109
+ declare function renderSqlSchemaFile(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): string;
110
+ declare function getSqlColumnType(field: ResolvedSchemaField, dialect: FarmSqlDialect): "BOOLEAN" | "INTEGER" | "DOUBLE PRECISION" | "TIMESTAMPTZ" | "JSONB" | "TEXT" | "INT" | "DOUBLE" | "DATETIME" | "JSON" | "VARCHAR(255)" | "REAL";
111
+ declare function getSqlDefaultExpression(field: ResolvedSchemaField, dialect: FarmSqlDialect): string | null;
112
+ declare function isNullableField(field: ResolvedSchemaField): boolean;
113
+ declare function quoteSqlIdentifier(dialect: FarmSqlDialect, value: string): string;
114
+ declare function toSnakeCase(value: string): string;
115
+ declare function toPascalCase(value: string): string;
116
+ declare function toCamelCase(value: string): string;
117
+ declare function escapeSqlString(value: string, dialect?: FarmSqlDialect): string;
118
+
128
119
  /**
129
- * Shares llms-full.txt renders, which read every listed page. Requests for the
130
- * same origin while a render runs, or within `revalidate` seconds after it, get
131
- * that result; renders run one at a time, so a burst of requests, even with
132
- * varied Host headers, cannot multiply page renders. The content is the same for
133
- * every caller: pages are read with fresh requests that carry no credentials.
120
+ * An ordered change a plugin release makes to its own tables that Farm will
121
+ * not infer: a rename looks exactly like a removal plus an addition. Each step
122
+ * runs once per database, in the order listed.
123
+ *
124
+ * Names are the plugin's own: `model` and `to` are keys in the current
125
+ * schema, so the app's renames apply; `from` is the old name in the database.
134
126
  */
135
- declare function createFarmLlmsFullRenderer(options?: {
136
- revalidate?: number;
137
- now?: () => number;
138
- maxEntries?: number;
139
- }): (origin: string, render: () => Promise<string>) => Promise<string>;
127
+ type FarmSchemaMigrationStep = {
128
+ id: string;
129
+ description?: string;
130
+ } & ({
131
+ renameColumn: {
132
+ model: string;
133
+ from: string;
134
+ to: string;
135
+ };
136
+ } | {
137
+ renameTable: {
138
+ from: string;
139
+ to: string;
140
+ };
141
+ }
142
+ /**
143
+ * Deletes data, so it runs only with `--allow-destructive`, and only on a
144
+ * column or table Farm recorded this plugin creating.
145
+ */
146
+ | {
147
+ dropColumn: {
148
+ model: string;
149
+ column: string;
150
+ };
151
+ } | {
152
+ dropTable: {
153
+ table: string;
154
+ };
155
+ } | {
156
+ /** Per dialect; a dialect without SQL cannot run the step. */
157
+ sql: Partial<Record<FarmSqlDialect, string | readonly string[]>>;
158
+ /**
159
+ * Custom SQL runs after this release's new tables and columns exist, so
160
+ * a backfill can fill them. Set `before` to run it with the renames.
161
+ */
162
+ before?: boolean;
163
+ });
140
164
 
141
- type ApplicationMetadataRouteKind = "sitemap" | "robots" | "manifest" | "llms" | "llms-full";
142
- declare namespace MetadataRoute {
143
- type SitemapChangeFrequency = "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
144
- interface SitemapEntry {
145
- url: string;
146
- lastModified?: string | Date;
147
- changeFrequency?: SitemapChangeFrequency;
148
- priority?: number;
149
- alternates?: {
150
- languages?: Record<string, string>;
151
- };
152
- }
153
- type Sitemap = SitemapEntry[];
154
- interface RobotsRule {
155
- userAgent: string | string[];
156
- allow?: string | string[];
157
- disallow?: string | string[];
158
- crawlDelay?: number;
159
- }
160
- interface Robots {
161
- rules: RobotsRule | RobotsRule[];
162
- sitemap?: string | string[];
163
- host?: string;
164
- }
165
- interface ManifestIcon {
166
- src: string;
167
- sizes?: string;
168
- type?: string;
169
- purpose?: string;
170
- }
171
- interface Manifest {
172
- name?: string;
173
- short_name?: string;
174
- description?: string;
175
- id?: string;
176
- start_url?: string;
177
- scope?: string;
178
- display?: "fullscreen" | "standalone" | "minimal-ui" | "browser" | string;
179
- orientation?: string;
180
- background_color?: string;
181
- theme_color?: string;
182
- lang?: string;
183
- dir?: "ltr" | "rtl" | "auto";
184
- categories?: string[];
185
- icons?: ManifestIcon[];
186
- [key: string]: unknown;
187
- }
188
- /**
189
- * The object an `llms.ts` metadata route returns, rendered as llms.txt. An
190
- * `llms.ts` can also return the complete file as a string, or a `Response`.
191
- */
192
- type LlmsTxt = FarmLlmsTxt;
193
- type LlmsTxtSection = FarmLlmsTxtSection;
194
- type LlmsTxtLink = FarmLlmsTxtLink;
195
- /** A static page of the app, usable directly as an llms.txt link. */
196
- type LlmsTxtPage = FarmLlmsTxtPage;
197
- /** What an `llms.ts` default-export function receives. */
198
- interface LlmsTxtContext extends MetadataRouteContext {
199
- /** The app's static pages, linking to their Markdown mirrors when exposed. */
200
- pages: LlmsTxtPage[];
201
- /** The llms.txt that `agent.llmsTxt` would serve, to extend instead of replace. */
202
- defaults: LlmsTxt;
203
- }
204
- /**
205
- * What an `llms-full.ts` default-export function receives. Returning an
206
- * `LlmsTxt` object inlines each same-origin link's Markdown; returning a string
207
- * serves it as the complete file.
208
- */
209
- interface LlmsFullTxtContext extends LlmsTxtContext {
210
- /** A page's Markdown mirror, read without the request's cookies; `null` if unavailable. */
211
- markdown(url: string): Promise<string | null>;
212
- }
213
- }
214
- interface MetadataRouteContext {
215
- request: Request;
216
- params: Record<string, string>;
217
- searchParams: URLSearchParams;
218
- /** The concrete route-segment path that owns the metadata file. */
219
- path: string;
165
+ /**
166
+ * Typed, validated plugin options.
167
+ *
168
+ * A plugin factory takes one options object. Describing it with a Standard
169
+ * Schema (Zod, Valibot, ArkType, ...) gives the call site its input type for
170
+ * autocomplete, gives the plugin the parsed type with defaults applied, and
171
+ * rejects bad options while the config loads instead of deep inside a hook.
172
+ */
173
+ type MaybePromise$2<T> = T | Promise<T>;
174
+ type FarmPluginOptionsIssuePathSegment = PropertyKey | {
175
+ readonly key: PropertyKey;
176
+ };
177
+ interface FarmPluginOptionsIssue {
178
+ readonly message: string;
179
+ readonly path?: ReadonlyArray<FarmPluginOptionsIssuePathSegment> | undefined;
220
180
  }
221
- interface FarmMetadataRouteModule {
222
- revalidate?: number | false;
181
+ type FarmPluginOptionsResult<TOutput> = {
182
+ readonly value: TOutput;
183
+ readonly issues?: undefined;
184
+ } | {
185
+ readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
186
+ };
187
+ /** The part of the Standard Schema interface plugin options need. */
188
+ interface FarmPluginOptionsSchema<TInput = unknown, TOutput = TInput> {
189
+ readonly "~standard": {
190
+ readonly version: 1;
191
+ readonly vendor: string;
192
+ readonly validate: (value: unknown) => MaybePromise$2<FarmPluginOptionsResult<TOutput>>;
193
+ readonly types?: {
194
+ readonly input: TInput;
195
+ readonly output: TOutput;
196
+ } | undefined;
197
+ };
223
198
  }
224
- interface FarmMetadataRouteResponseOptions {
225
- method?: string;
199
+ /** What the app passes to the plugin factory. */
200
+ type InferPluginOptionsInput<TSchema> = TSchema extends FarmPluginOptionsSchema<infer TInput, any> ? TInput : never;
201
+ /** What the plugin receives, after parsing and defaults. */
202
+ type InferPluginOptionsOutput<TSchema> = TSchema extends FarmPluginOptionsSchema<any, infer TOutput> ? TOutput : never;
203
+ /**
204
+ * The factory a plugin exports. Options can be left out when every option is
205
+ * optional, so `plugin()` and `plugin({})` mean the same thing.
206
+ */
207
+ type FarmPluginFactory<TInput, TPlugin> = {} extends TInput ? (options?: TInput) => TPlugin : (options: TInput) => TPlugin;
208
+ /** Thrown when an app passes options its plugin's schema rejects. */
209
+ declare class FarmPluginOptionsError extends TypeError {
210
+ readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
211
+ constructor(issues: ReadonlyArray<FarmPluginOptionsIssue>);
226
212
  }
227
- /** @internal */
228
- declare function createFarmMetadataRouteResponse(kind: ApplicationMetadataRouteKind, value: unknown, routeModule?: FarmMetadataRouteModule, options?: FarmMetadataRouteResponseOptions): Response;
229
213
 
230
- type FarmCrawlerPolicy = "allow" | "block";
231
- interface FarmAgentCrawlers {
232
- /** Set to `false` to stop serving the generated robots.txt while keeping these options. */
233
- enabled?: boolean;
234
- /**
235
- * AI search and user-triggered agents such as OAI-SearchBot, Claude-SearchBot,
236
- * and PerplexityBot. Left unset, they follow the `User-agent: *` rules.
237
- */
238
- search?: FarmCrawlerPolicy;
239
- /**
240
- * AI training crawlers such as GPTBot, ClaudeBot, Google-Extended, and CCBot.
241
- * Left unset, they follow the `User-agent: *` rules.
242
- */
243
- training?: FarmCrawlerPolicy;
244
- /**
245
- * More robots.txt groups, written after the generated ones. Crawlers combine
246
- * groups that name the same agent. A rule for `*` replaces the default
247
- * `User-agent: *` / `Allow: /` group.
248
- */
249
- rules?: MetadataRoute.RobotsRule[];
250
- /**
251
- * Absolute sitemap URLs. Defaults to the app's `sitemap.ts` route, resolved
252
- * against the root layout's `metadataBase`; with neither, no `Sitemap:` line.
253
- */
254
- sitemap?: string | string[];
255
- }
256
- interface ResolvedFarmAgentCrawlers {
257
- enabled: boolean;
258
- search?: FarmCrawlerPolicy;
259
- training?: FarmCrawlerPolicy;
260
- rules: MetadataRoute.RobotsRule[];
261
- sitemap?: string[];
214
+ interface ResolvedClientCacheAdapterEntry {
215
+ /** Absolute adapter module path with forward slashes, ready for codegen. */
216
+ importPath: string;
217
+ options: {
218
+ version?: string;
219
+ flushDelayMs?: number;
220
+ };
262
221
  }
263
- interface FarmAgentRobotsOptions {
264
- crawlers: ResolvedFarmAgentCrawlers;
265
- /** The app's root sitemap route, such as `/sitemap.xml`, when it has one. */
266
- sitemapPath?: string;
267
- /** The root layout's `metadataBase`, which makes the sitemap URL absolute. */
268
- metadataBase?: unknown;
269
- basePath?: string;
222
+ interface ClientCachePersistenceEntryCode {
223
+ imports: string;
224
+ init: string;
270
225
  }
271
- /** The robots.txt `agent.crawlers` serves. */
272
- declare function createFarmAgentRobots(options: FarmAgentRobotsOptions): MetadataRoute.Robots;
273
-
274
226
  /**
275
- * Agent-readiness configuration: opt-in primitives that make a Farm site easier
276
- * for AI agents and crawlers to discover, resolve, and use. Off by default so
277
- * sites that do not want agent exposure (internal tools, private dashboards) are
278
- * unaffected.
227
+ * Resolve `cache.client.adapter` from configuration to an absolute module
228
+ * path for the generated client entries. Fails the build with an actionable
229
+ * error when the option is set but the module cannot be found.
230
+ */
231
+ declare function resolveFarmClientCacheAdapterEntry(root: string, cache: FarmCacheUserConfig | undefined): ResolvedClientCacheAdapterEntry | undefined;
232
+ /**
233
+ * Code fragments for the generated client entries: an import of the user's
234
+ * adapter module and an init call that runs before hydration starts. Empty
235
+ * strings when persistence is not configured, so entries stay unchanged.
279
236
  */
237
+ declare function generateClientCachePersistenceCode(entry: ResolvedClientCacheAdapterEntry | undefined): ClientCachePersistenceEntryCode;
280
238
 
281
- /** schema.org JSON-LD emitted in the document head to identify the site. */
282
- interface FarmAgentJsonLd {
283
- /**
284
- * schema.org `@type`. Common values: `"Organization"` for a company or
285
- * project, `"SoftwareApplication"` for a product, `"WebSite"`, `"Person"`.
286
- *
287
- * @default "Organization"
288
- */
289
- type?: string;
290
- /** Entity name. Defaults to the site's Open Graph site name or page title. */
291
- name?: string;
292
- /** Canonical URL for the entity. Defaults to the configured `metadataBase`. */
293
- url?: string;
294
- /** Short description. Defaults to the page/site metadata description. */
295
- description?: string;
296
- /** Logo URL. */
297
- logo?: string;
298
- /** URLs that also represent this entity (social profiles, repos) — schema.org `sameAs`. */
299
- sameAs?: string[];
300
- /** Additional schema.org properties merged into the emitted object. */
301
- properties?: Record<string, unknown>;
302
- }
303
- interface FarmAgentUserConfig {
304
- /**
305
- * Emit schema.org JSON-LD in the document head so agents and crawlers can
306
- * resolve the site's identity. `true` emits an `Organization` built from the
307
- * site's metadata; an object customizes the type and fields.
308
- *
309
- * @default false
310
- */
311
- jsonLd?: boolean | FarmAgentJsonLd;
312
- /**
313
- * On a preview deployment, send `X-Robots-Tag: noindex, nofollow` with every
314
- * response from Farm's server. Previews are detected from `FARM_PREVIEW`,
315
- * `VERCEL_ENV=preview`, Netlify's deploy-preview and branch-deploy contexts,
316
- * and Render pull request previews. Production is unaffected.
317
- *
318
- * @default false
319
- */
320
- noindexPreviews?: boolean;
321
- /**
322
- * Serve `/llms.txt` (https://llmstxt.org): a Markdown index of the app's static
323
- * pages, linking to their Markdown mirrors. `true` builds it from page metadata;
324
- * an object sets the title, summary, details, and which routes to list. A
325
- * `src/app/llms.ts` metadata route replaces the generated file.
326
- *
327
- * @default false
328
- */
329
- llmsTxt?: boolean | FarmLlmsTxtUserConfig;
330
- /**
331
- * Serve a generated `/robots.txt` that allows or blocks AI search agents
332
- * (`search`) and AI training crawlers (`training`), plus your own `rules`.
333
- * `true` serves only `User-agent: *` / `Allow: /` and the sitemap. A
334
- * `public/robots.txt` or `src/app/robots.ts` replaces the generated file.
335
- *
336
- * @default false
337
- */
338
- crawlers?: boolean | FarmAgentCrawlers;
339
- /**
340
- * Serve `/.well-known/api-catalog` (RFC 9727): a Linkset listing the app's
341
- * OpenAPI description and reference (when `openapi` is enabled) and its MCP
342
- * endpoint (when the top-level `mcp` is enabled), so agents can find them
343
- * from the origin alone.
344
- *
345
- * @default false
346
- */
347
- apiCatalog?: boolean;
348
- }
349
- interface ResolvedFarmAgentConfig {
350
- jsonLd: FarmAgentJsonLd | false;
351
- noindexPreviews: boolean;
352
- llmsTxt: ResolvedFarmLlmsTxtConfig;
353
- crawlers: ResolvedFarmAgentCrawlers;
354
- apiCatalog: boolean;
239
+ type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
240
+ interface FarmRedirectSignal {
241
+ url: string;
242
+ status: FarmRedirectStatus;
355
243
  }
244
+ declare function redirect(url: string, status?: FarmRedirectStatus): never;
245
+ declare function permanentRedirect(url: string): never;
246
+ declare function notFound(): never;
247
+ declare function isFarmRedirectError(error: unknown): boolean;
248
+ declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
249
+ declare function isFarmNotFoundError(error: unknown): boolean;
356
250
 
357
251
  /**
358
252
  * Integration auth routes accept ordinary form posts, which browsers send
@@ -445,1011 +339,1164 @@ declare function resolveIntegrationOrmRuntimeClient<TClient = unknown>(options:
445
339
  declare function farmIntegrationSchemaToOrmSchema(schema: FarmIntegrationSchema): Promise<FarmIntegrationOrmSchema>;
446
340
  type IntegrationOrmModelNames<TSchema extends FarmIntegrationOrmSchema> = keyof SchemaModels<TSchema> & string;
447
341
 
448
- /** @internal The environment registry is owned and closed by Vite. */
449
- interface FarmDevModuleServer {
450
- environments: Record<string, unknown>;
451
- }
452
- /** @internal Distinguishes an unsupported runtime from a module evaluation error. */
453
- declare class FarmDevEnvironmentError extends Error {
454
- }
455
- /** @internal Load in the selected environment without sharing SSR/RSC module state. */
456
- declare function loadFarmDevModule<T = Record<string, any>>(server: FarmDevModuleServer, id: string, environmentName?: "ssr" | "rsc"): Promise<T>;
457
-
458
- type ResolvedSchemaField = FarmSchemaField & {
459
- name: string;
460
- };
461
- type ResolvedSchemaModel = Omit<FarmSchemaModel, "fields"> & {
462
- name: string;
463
- fields: Record<string, ResolvedSchemaField>;
464
- };
465
- /**
466
- * Resolve a schema's extensions, overrides, and name mappings.
467
- *
468
- * Table and column names fall back to the schema's own keys, which is what the
469
- * runtime ORM uses. Any other default would generate artifacts describing
470
- * tables the app cannot actually read.
471
- */
472
- declare function resolveSchemaModels(ownerKey: string, schema: FarmSchema): Record<string, ResolvedSchemaModel>;
473
-
474
- type FarmSqlDialect = "postgres" | "mysql" | "sqlite";
475
- type CollectedSchemaModel = {
476
- /** Namespace that owns the model: an integration key or a plugin name. */
477
- ownerKey: string;
478
- modelKey: string;
479
- modelName: string;
480
- exportName: string;
481
- prismaModelName: string;
482
- model: ResolvedSchemaModel;
483
- /**
484
- * Real table and column for references to models this owner describes but
485
- * does not create (external, or outside its `models`), keyed by field. Only
486
- * shown in comments: Farm never creates a foreign key to them.
487
- */
488
- referenceTargets?: Record<string, {
489
- table: string;
490
- column: string;
491
- }>;
492
- /**
493
- * References to tables other owners create that may carry a real foreign
494
- * key, keyed by field. Set by migrate after checking the database; only a
495
- * table created now gets one inline.
496
- */
497
- foreignKeys?: Record<string, {
498
- table: string;
499
- column: string;
500
- onDelete: NonNullable<FarmSchemaReference["onDelete"]>;
501
- }>;
502
- };
503
- /** `table.column` a field's reference points at, using real names when known. */
504
- declare function describeSchemaReference(model: CollectedSchemaModel, fieldKey: string): string;
505
- /**
506
- * Flatten owners' schemas into one list, rejecting two models that would
507
- * resolve to the same table.
508
- *
509
- * `only` narrows an owner to the models it actually controls; an owner handed a
510
- * schema it shares with the rest of the app should not claim all of it.
511
- */
512
- declare function collectSchemaModels(entries: ReadonlyArray<readonly [string, FarmSchema, (readonly string[])?]>): CollectedSchemaModel[];
513
- type FarmSqlStatement = {
514
- kind: "table" | "index" | "column";
515
- /** The object this statement creates, for drift reporting. */
516
- target: string;
517
- sql: string;
342
+ type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
343
+ /** @deprecated Use FarmIntegrationCategory instead. */
344
+ type FarmIntegrationSlot = FarmIntegrationCategory;
345
+ type FarmIntegrationRouteParamValue = string | string[];
346
+ type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
347
+ type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
348
+ type FarmIntegrationRouteInputSource = "body" | "query";
349
+ type MaybePromise$1<T> = T | Promise<T>;
350
+ type FarmIntegrationValidationPathSegment = PropertyKey | {
351
+ readonly key: PropertyKey;
518
352
  };
519
- /**
520
- * Emit create statements for a set of models.
521
- *
522
- * Everything here is derivable from the schema: nothing is inferred from a live
523
- * database, so the output is stable and reviewable before it is applied.
524
- */
525
- declare function generateSqlStatements(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): FarmSqlStatement[];
526
- /** Render models as a standalone `.sql` file. */
527
- declare function renderSqlSchemaFile(models: readonly CollectedSchemaModel[], dialect: FarmSqlDialect): string;
528
- declare function getSqlColumnType(field: ResolvedSchemaField, dialect: FarmSqlDialect): "BOOLEAN" | "INTEGER" | "DOUBLE PRECISION" | "TIMESTAMPTZ" | "JSONB" | "TEXT" | "INT" | "DOUBLE" | "DATETIME" | "JSON" | "VARCHAR(255)" | "REAL";
529
- declare function getSqlDefaultExpression(field: ResolvedSchemaField, dialect: FarmSqlDialect): string | null;
530
- declare function isNullableField(field: ResolvedSchemaField): boolean;
531
- declare function quoteSqlIdentifier(dialect: FarmSqlDialect, value: string): string;
532
- declare function toSnakeCase(value: string): string;
533
- declare function toPascalCase(value: string): string;
534
- declare function toCamelCase(value: string): string;
535
- declare function escapeSqlString(value: string, dialect?: FarmSqlDialect): string;
536
-
537
- /**
538
- * An ordered change a plugin release makes to its own tables that Farm will
539
- * not infer: a rename looks exactly like a removal plus an addition. Each step
540
- * runs once per database, in the order listed.
541
- *
542
- * Names are the plugin's own: `model` and `to` are keys in the current
543
- * schema, so the app's renames apply; `from` is the old name in the database.
544
- */
545
- type FarmSchemaMigrationStep = {
546
- id: string;
547
- description?: string;
548
- } & ({
549
- renameColumn: {
550
- model: string;
551
- from: string;
552
- to: string;
553
- };
554
- } | {
555
- renameTable: {
556
- from: string;
557
- to: string;
558
- };
353
+ interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
354
+ body?: TBody;
355
+ query?: TQuery;
559
356
  }
560
- /**
561
- * Deletes data, so it runs only with `--allow-destructive`, and only on a
562
- * column or table Farm recorded this plugin creating.
563
- */
564
- | {
565
- dropColumn: {
566
- model: string;
567
- column: string;
568
- };
569
- } | {
570
- dropTable: {
571
- table: string;
572
- };
357
+ interface FarmIntegrationValidationIssue {
358
+ source: FarmIntegrationRouteInputSource;
359
+ path?: readonly (string | number)[];
360
+ code?: string;
361
+ message: string;
362
+ }
363
+ interface FarmIntegrationValidationErrorLike {
364
+ issues?: readonly {
365
+ path?: readonly FarmIntegrationValidationPathSegment[];
366
+ code?: string;
367
+ message?: string;
368
+ }[];
369
+ message?: string;
370
+ }
371
+ type FarmIntegrationValidationResult<TValue> = {
372
+ success: true;
373
+ data: TValue;
573
374
  } | {
574
- /** Per dialect; a dialect without SQL cannot run the step. */
575
- sql: Partial<Record<FarmSqlDialect, string | readonly string[]>>;
576
- /**
577
- * Custom SQL runs after this release's new tables and columns exist, so
578
- * a backfill can fill them. Set `before` to run it with the renames.
579
- */
580
- before?: boolean;
581
- });
582
-
583
- /**
584
- * Typed, validated plugin options.
585
- *
586
- * A plugin factory takes one options object. Describing it with a Standard
587
- * Schema (Zod, Valibot, ArkType, ...) gives the call site its input type for
588
- * autocomplete, gives the plugin the parsed type with defaults applied, and
589
- * rejects bad options while the config loads instead of deep inside a hook.
590
- */
591
- type MaybePromise$2<T> = T | Promise<T>;
592
- type FarmPluginOptionsIssuePathSegment = PropertyKey | {
593
- readonly key: PropertyKey;
375
+ success: false;
376
+ error: FarmIntegrationValidationErrorLike;
594
377
  };
595
- interface FarmPluginOptionsIssue {
596
- readonly message: string;
597
- readonly path?: ReadonlyArray<FarmPluginOptionsIssuePathSegment> | undefined;
598
- }
599
- type FarmPluginOptionsResult<TOutput> = {
600
- readonly value: TOutput;
601
- readonly issues?: undefined;
378
+ type FarmIntegrationStandardValidationResult<TValue> = {
379
+ value: TValue;
602
380
  } | {
603
- readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
381
+ issues: readonly {
382
+ path?: readonly FarmIntegrationValidationPathSegment[];
383
+ code?: string;
384
+ message: string;
385
+ }[];
604
386
  };
605
- /** The part of the Standard Schema interface plugin options need. */
606
- interface FarmPluginOptionsSchema<TInput = unknown, TOutput = TInput> {
607
- readonly "~standard": {
608
- readonly version: 1;
609
- readonly vendor: string;
610
- readonly validate: (value: unknown) => MaybePromise$2<FarmPluginOptionsResult<TOutput>>;
611
- readonly types?: {
612
- readonly input: TInput;
613
- readonly output: TOutput;
614
- } | undefined;
615
- };
616
- }
617
- /** What the app passes to the plugin factory. */
618
- type InferPluginOptionsInput<TSchema> = TSchema extends FarmPluginOptionsSchema<infer TInput, any> ? TInput : never;
619
- /** What the plugin receives, after parsing and defaults. */
620
- type InferPluginOptionsOutput<TSchema> = TSchema extends FarmPluginOptionsSchema<any, infer TOutput> ? TOutput : never;
621
- /**
622
- * The factory a plugin exports. Options can be left out when every option is
623
- * optional, so `plugin()` and `plugin({})` mean the same thing.
624
- */
625
- type FarmPluginFactory<TInput, TPlugin> = {} extends TInput ? (options?: TInput) => TPlugin : (options: TInput) => TPlugin;
626
- /** Thrown when an app passes options its plugin's schema rejects. */
627
- declare class FarmPluginOptionsError extends TypeError {
628
- readonly issues: ReadonlyArray<FarmPluginOptionsIssue>;
629
- constructor(issues: ReadonlyArray<FarmPluginOptionsIssue>);
630
- }
631
-
632
- interface ResolvedClientCacheAdapterEntry {
633
- /** Absolute adapter module path with forward slashes, ready for codegen. */
634
- importPath: string;
635
- options: {
636
- version?: string;
637
- flushDelayMs?: number;
387
+ interface FarmIntegrationInputSchema<TValue = unknown> {
388
+ _output?: TValue;
389
+ parse?(value: unknown): MaybePromise$1<TValue>;
390
+ safeParse?(value: unknown): MaybePromise$1<FarmIntegrationValidationResult<TValue>>;
391
+ safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
392
+ "~standard"?: {
393
+ validate(value: unknown): MaybePromise$1<FarmIntegrationStandardValidationResult<TValue>>;
394
+ types?: {
395
+ output: TValue;
396
+ };
638
397
  };
639
398
  }
640
- interface ClientCachePersistenceEntryCode {
641
- imports: string;
642
- init: string;
399
+ interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
400
+ body?: FarmIntegrationInputSchema<TBody>;
401
+ query?: FarmIntegrationInputSchema<TQuery>;
643
402
  }
403
+ /** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
404
+ type FarmIntegrationRequestContextStore = FarmRequestStore;
405
+ declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
644
406
  /**
645
- * Resolve `cache.client.adapter` from configuration to an absolute module
646
- * path for the generated client entries. Fails the build with an actionable
647
- * error when the option is set but the module cannot be found.
407
+ * Request-context key under which an integration middleware can hand
408
+ * `Set-Cookie` values to the runtime when it returns `void` (i.e. lets the
409
+ * request continue to the downstream route/page handler). The runtime reads
410
+ * this key back after a `void` middleware return and forwards the cookies onto
411
+ * the response it ultimately sends, so a server-side session refresh (or any
412
+ * other cookie rotation) reaches the browser instead of being dropped.
648
413
  */
649
- declare function resolveFarmClientCacheAdapterEntry(root: string, cache: FarmCacheUserConfig | undefined): ResolvedClientCacheAdapterEntry | undefined;
414
+ declare const FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
650
415
  /**
651
- * Code fragments for the generated client entries: an import of the user's
652
- * adapter module and an init call that runs before hydration starts. Empty
653
- * strings when persistence is not configured, so entries stay unchanged.
416
+ * Forward `Set-Cookie` values from an integration middleware that returns
417
+ * `void` (the authenticated/passthrough branch) to the runtime, so they are
418
+ * merged onto the response the runtime sends for the matched route. This is
419
+ * the passthrough counterpart to appending `Set-Cookie` to a `Response` the
420
+ * middleware returns directly (e.g. a failure redirect): both paths can rotate
421
+ * auth cookies, and both must be able to reach the browser.
654
422
  */
655
- declare function generateClientCachePersistenceCode(entry: ResolvedClientCacheAdapterEntry | undefined): ClientCachePersistenceEntryCode;
656
-
657
- type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
658
- interface FarmRedirectSignal {
659
- url: string;
660
- status: FarmRedirectStatus;
423
+ declare function forwardIntegrationSetCookies(context: Pick<FarmIntegrationHandlerContext, "req">, cookies: string[]): void;
424
+ type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
425
+ interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
426
+ getClient(): Promise<unknown | undefined>;
427
+ getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
661
428
  }
662
- declare function redirect(url: string, status?: FarmRedirectStatus): never;
663
- declare function permanentRedirect(url: string): never;
664
- declare function notFound(): never;
665
- declare function isFarmRedirectError(error: unknown): boolean;
666
- declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
667
- declare function isFarmNotFoundError(error: unknown): boolean;
668
-
669
- /**
670
- * Farm.js Middleware System
671
- *
672
- * Type definitions for the middleware system
673
- */
674
-
675
- /**
676
- * Next function type for middleware chain
677
- */
678
- type MiddlewareResult = void | Response;
679
- type NextFunction = () => Promise<MiddlewareResult>;
680
- type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
681
- /**
682
- * A typed view over the request-scoped maps used by middleware.
683
- */
684
- interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
685
- readonly size: number;
686
- get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
687
- has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
688
- entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
689
- keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
690
- values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
691
- forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
692
- [Symbol.iterator](): IterableIterator<[
693
- MiddlewareStoreKey<TValues>,
694
- TValues[MiddlewareStoreKey<TValues>]
695
- ]>;
429
+ interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
430
+ db: FarmIntegrationRouteDb<TSchema>;
431
+ getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
432
+ storage: FarmIntegrationRouteStorageArgs<TSchema>;
696
433
  }
697
- interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
698
- clear(): void;
699
- delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
700
- set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
434
+ interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
435
+ key: string;
436
+ integration: FarmIntegration<TSchema, any>;
437
+ appConfig: FarmPluginContext["config"];
438
+ /** Alias for appConfig. */
439
+ config: FarmPluginContext["config"];
440
+ args: FarmIntegrationRouteArgs<TSchema>;
441
+ env: Record<string, string | undefined>;
442
+ isDev: boolean;
443
+ isProd: boolean;
701
444
  }
702
- /**
703
- * Middleware function signature
704
- */
705
- type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
706
- /**
707
- * Context passed to a named, request-first middleware export.
708
- * `locals` and the get/set helpers stay on the server. `data` can be exposed
709
- * through page props and should contain only serializable, client-safe values.
710
- */
711
- interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
712
- readonly url: URL;
713
- readonly pathname: string;
714
- readonly searchParams: URLSearchParams;
715
- readonly method: string;
716
- readonly params: Record<string, string>;
717
- readonly route: string;
718
- readonly locals: MiddlewareStore<TLocals>;
719
- readonly data: MiddlewareStore<TData>;
720
- readonly headers: Map<string, string>;
721
- readonly cookies: CookieJar;
722
- get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
723
- has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
724
- set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
725
- delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
726
- redirect(url: string, status?: number): void;
727
- rewrite(url: string): void;
728
- json(data: any, status?: number): void;
729
- text(content: string, status?: number): void;
730
- html(content: string, status?: number): void;
445
+ interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
446
+ schema?: FarmIntegrationInputSchema<TConfig>;
447
+ env?: Record<string, string | readonly string[]>;
448
+ defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise$1<Partial<TConfig>>);
449
+ input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise$1<Partial<TConfig>>);
450
+ resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise$1<TConfig | Partial<TConfig> | undefined>;
731
451
  }
732
- type RequestMiddleware<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> = (request: Request, context: RequestMiddlewareContext<TLocals, TData>) => MiddlewareResult | Promise<MiddlewareResult>;
733
- /**
734
- * Cookie options
735
- */
736
- interface CookieOptions {
737
- maxAge?: number;
738
- expires?: Date;
739
- path?: string;
740
- domain?: string;
741
- secure?: boolean;
742
- httpOnly?: boolean;
743
- sameSite?: "strict" | "lax" | "none";
452
+ type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
453
+ type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
454
+ interface FarmIntegrationLifecycleLogger {
455
+ info(message: string, meta?: Record<string, unknown>): void;
456
+ warn(message: string, meta?: Record<string, unknown>): void;
457
+ error(message: string, meta?: Record<string, unknown>): void;
458
+ }
459
+ interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
460
+ integration: FarmIntegration<TSchema, TConfig>;
461
+ integrationConfig: TConfig;
462
+ log: FarmIntegrationLifecycleLogger;
463
+ reason?: string;
464
+ cleanup(callback?: () => MaybePromise$1<void>): Promise<void>;
744
465
  }
466
+ type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise$1<void>;
745
467
  /**
746
- * Cookie management interface
468
+ * Small per-call integration metadata. Values received over HTTP are
469
+ * client-controlled and should be validated before authorization decisions.
747
470
  */
748
- interface CookieJar {
749
- get(name: string): string | undefined;
750
- set(name: string, value: string, options?: CookieOptions): void;
751
- /**
752
- * Remove a cookie. Pass the `path`/`domain` it was set with; a tombstone only
753
- * matches a cookie with the same scope.
754
- */
755
- delete(name: string, options?: CookieOptions): void;
756
- getAll(): Record<string, string>;
471
+ type FarmIntegrationData = Record<string, unknown>;
472
+ interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
473
+ request: Request;
474
+ requestId: string;
475
+ url: URL;
476
+ pathname: string;
477
+ method: string;
478
+ params: FarmIntegrationRouteParams;
479
+ input: FarmIntegrationRouteInput<TBody, TQuery>;
480
+ args: FarmIntegrationRouteArgs<TSchema>;
481
+ data: FarmIntegrationData;
482
+ integration: {
483
+ category: FarmIntegrationCategory;
484
+ /** @deprecated Use category instead. */
485
+ slot: FarmIntegrationCategory;
486
+ type: string;
487
+ instance: unknown;
488
+ };
489
+ route: {
490
+ kind: "route" | "middleware";
491
+ path: string;
492
+ methods: readonly string[];
493
+ };
494
+ req: FarmRequestStore;
495
+ /** @deprecated Use `req` instead. */
496
+ requestContext: FarmRequestStore;
497
+ config: FarmPluginContext["config"];
498
+ isDev: boolean;
499
+ isProd: boolean;
757
500
  }
758
- interface RateLimitIncrementResult {
759
- count: number;
760
- /** Unix epoch timestamp in milliseconds when the fixed window resets. */
761
- resetAt: number;
501
+ interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
502
+ response?: Response;
762
503
  }
763
- interface RateLimitStorage {
764
- /** Atomically increment a key and create or retain its fixed expiry window. */
765
- increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
766
- /** Optional inspection support used by getRateLimitStatus(). */
767
- get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
504
+ type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
505
+ bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
506
+ }["bivarianceHack"];
507
+ interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
508
+ path: string;
509
+ method?: FarmIntegrationRouteMethod;
510
+ methods?: readonly FarmIntegrationRouteMethod[];
511
+ middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
512
+ before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
513
+ after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
514
+ rawBody?: boolean;
515
+ bodyFormat?: FarmIntegrationAPIBodyFormat;
516
+ body?: FarmIntegrationInputSchema<TBody>;
517
+ query?: FarmIntegrationInputSchema<TQuery>;
518
+ input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
519
+ handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
768
520
  }
769
- interface MemoryRateLimitStorageOptions {
770
- /** Maximum number of active keys retained by this process. */
771
- maxEntries?: number;
521
+ interface FarmTypedIntegrationRoute<TPath extends string = string, TBody = never, TQuery = never, TResponse = unknown, TServer extends boolean = false, TMethod extends FarmIntegrationAPIMethod = FarmIntegrationAPIMethod, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoute<TBody, TQuery, TSchema> {
522
+ path: TPath;
523
+ method: TMethod;
524
+ __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
772
525
  }
773
- interface RateLimitConfig {
774
- requests: number;
775
- window: string;
776
- keyGenerator?: (ctx: MiddlewareContext) => string;
777
- onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
778
- storage?: RateLimitStorage;
526
+ interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
527
+ handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
779
528
  }
780
- interface RateLimitStatus {
781
- requests: number;
782
- limit: number;
783
- remaining: number;
784
- resetIn: number | null;
785
- resetAt: Date | null;
786
- isLimited: boolean;
529
+ interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
530
+ matcher?: string | string[];
531
+ handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
787
532
  }
788
- /**
789
- * Middleware configuration
790
- */
791
- type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
792
- interface MiddlewareConfig$1 {
793
- matcher?: MiddlewareMatcher | MiddlewareMatcher[];
794
- exclude?: (string | RegExp)[];
795
- runtime?: "nodejs" | "edge";
533
+ interface FarmIntegrationProviderProps {
534
+ children: ReactNode;
796
535
  }
797
- interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
798
- handler?: MiddlewareFunction;
799
- handlers?: MiddlewareFunction[];
536
+ interface FarmIntegrationProviderComponentReference {
537
+ /** Client-safe module specifier using `@/`, a path relative to the app root, or a package. */
538
+ module: string;
539
+ /** Named export to use. Defaults to the module's default export. */
540
+ export?: string;
800
541
  }
801
- type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
802
- /**
803
- * Middleware context - the main object passed to middleware functions
804
- */
805
- interface MiddlewareContext {
806
- request: IncomingMessage;
807
- response: ServerResponse;
808
- url: URL;
809
- pathname: string;
810
- searchParams: URLSearchParams;
811
- method: string;
812
- params: Record<string, string>;
813
- route: string;
814
- parent?: {
815
- data: Map<string, any>;
816
- locals?: Map<string, any>;
817
- headers: Record<string, string>;
818
- };
819
- vite: {
820
- isDev: boolean;
821
- hmr: boolean;
822
- server?: ViteDevServer;
823
- };
824
- data: Map<string, any>;
825
- locals: Map<string, any>;
826
- headers: Map<string, string>;
827
- cookies: CookieJar;
828
- _handled: boolean;
829
- _redirectUrl?: string;
830
- _rewriteUrl?: string;
831
- redirect(url: string, status?: number): void;
832
- rewrite(url: string): void;
833
- json(data: any, status?: number): void;
834
- text(content: string, status?: number): void;
835
- html(content: string, status?: number): void;
836
- }
837
- /**
838
- * Middleware chain interface
839
- */
840
- interface MiddlewareChain {
841
- use(fn: MiddlewareFunction): MiddlewareChain;
842
- /**
843
- * Conditionally run middleware based on a condition.
844
- * Supports boolean values or functions that evaluate to boolean.
845
- *
846
- * @example
847
- * .when(true, (ctx, next) => { ... }) // Always run
848
- * .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
849
- */
850
- when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
851
- rateLimit(config: RateLimitConfig): MiddlewareChain;
852
- redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
542
+ interface FarmIntegrationProvider {
543
+ name: string;
544
+ type: string;
545
+ props?: Record<string, unknown>;
853
546
  /**
854
- * Rewrite the current route to a new destination.
855
- * In route-specific middleware, this rewrites the middleware's route.
856
- *
857
- * @param destination - The destination path to rewrite to
858
- * @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
859
- *
860
- * @example
861
- * // In /contact/middleware.ts
862
- * .rewrite('/about') // Always rewrites /contact to /about
863
- * .rewrite('/about', true) // Always rewrites
864
- * .rewrite('/about', false) // Never rewrites
865
- * .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
547
+ * The provider can be instantiated independently around each isolated
548
+ * client root without relying on context or state owned by the route root.
549
+ * Providers are treated as route-wide unless they explicitly opt in.
866
550
  */
867
- rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
868
- build(): {
869
- handlers: MiddlewareFunction[];
870
- config?: MiddlewareConfig$1;
871
- };
872
- }
873
- /**
874
- * Middleware module export
875
- */
876
- interface MiddlewareModule {
877
- default?: MiddlewareChain | MiddlewareFunction;
878
- middleware?: RequestMiddleware;
879
- config?: MiddlewareConfig$1;
551
+ supportsIsolatedHydration?: boolean;
552
+ component?: ComponentType<FarmIntegrationProviderProps> | FarmIntegrationProviderComponentReference;
880
553
  }
881
-
882
- type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
883
- type FarmMdxComponents = Record<string, FarmMdxComponent>;
884
- interface FarmMdxUserConfig {
885
- /**
886
- * Component map or module path that exports `components` or a default component map.
887
- * Relative paths resolve from the project root.
888
- */
889
- components?: string | FarmMdxComponents;
890
- /**
891
- * Serve source-authored markdown pages at `/route.md`.
892
- * Enabled by default for `page.md` and `page.mdx`.
893
- */
894
- markdownRoutes?: boolean;
895
- /** Class name used for the wrapper around rendered markdown content. */
896
- className?: string;
554
+ interface FarmIntegrationDocumentNavigation {
555
+ matcher: string | readonly string[];
897
556
  }
898
- interface FarmMdxResolvedConfig {
899
- components?: string | FarmMdxComponents;
900
- markdownRoutes: boolean;
901
- className: string;
557
+ /** @deprecated Use `FarmSchemaFieldType`. */
558
+ type FarmIntegrationSchemaFieldType = FarmSchemaFieldType;
559
+ /** @deprecated Use `FarmSchemaReference`. */
560
+ type FarmIntegrationSchemaReference = FarmSchemaReference;
561
+ /** @deprecated Use `FarmSchemaField`. */
562
+ type FarmIntegrationSchemaField = FarmSchemaField;
563
+ /** @deprecated Use `FarmSchemaConstraint`. */
564
+ type FarmIntegrationSchemaConstraint = FarmSchemaConstraint;
565
+ /** @deprecated Use `FarmSchemaModel`. */
566
+ type FarmIntegrationSchemaModel = FarmSchemaModel;
567
+ /** @deprecated Use `FarmSchemaModelExtension`. */
568
+ type FarmIntegrationSchemaModelExtension = FarmSchemaModelExtension;
569
+ /** @deprecated Use `FarmSchemaModelOverride`. */
570
+ type FarmIntegrationSchemaModelOverride = FarmSchemaModelOverride;
571
+ /** @deprecated Use `FarmSchema`. */
572
+ type FarmIntegrationSchema = FarmSchema;
573
+ /** @deprecated Use `defineSchema`. This is an exact alias, not a wrapper. */
574
+ declare const defineIntegrationSchema: typeof defineSchema;
575
+ type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
576
+ interface FarmIntegrationLogEvent {
577
+ category: FarmIntegrationCategory;
578
+ /** @deprecated Use category instead. */
579
+ slot: FarmIntegrationCategory;
580
+ type: string;
581
+ phase: FarmIntegrationLogPhase;
582
+ route?: {
583
+ kind: "route" | "middleware";
584
+ path: string;
585
+ methods: readonly string[];
586
+ };
587
+ requestId?: string;
588
+ request?: Request;
589
+ response?: Response;
590
+ error?: unknown;
591
+ durationMs?: number;
592
+ level?: FarmIntegrationLifecycleLogLevel;
593
+ message?: string;
594
+ meta?: Record<string, unknown>;
595
+ context: Map<string, unknown>;
902
596
  }
903
- declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
904
- /**
905
- * The MDX components module a Markdown page renders from, as an absolute path. Undefined when
906
- * the components are an inline object, which cannot be analyzed for client components.
907
- */
908
- declare function resolveFarmMdxComponentsModulePath(config: FarmMdxResolvedConfig | undefined, root: string): string | undefined;
909
-
910
- type FarmRouteRuntime = "auto" | "node" | "edge";
911
- type FarmRouteRegions = "auto" | readonly string[];
912
- type FarmRouteMaxDuration = "auto" | number;
913
- /** Portable execution controls shared by file, programmatic, and config routes. */
914
- interface FarmRouteRuntimeConfig {
915
- runtime?: FarmRouteRuntime;
916
- regions?: FarmRouteRegions;
917
- maxDuration?: FarmRouteMaxDuration;
597
+ type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
598
+ interface FarmIntegrationPluginOwner {
599
+ key: string;
600
+ category: FarmIntegrationCategory;
601
+ type: string;
602
+ source: "lifecycle" | "contribution";
603
+ serverRuntime: boolean;
918
604
  }
919
- interface ResolvedFarmRouteRuntimeConfig {
920
- runtime: FarmRouteRuntime;
921
- regions?: string[];
922
- maxDuration?: number;
605
+ /** A normal plugin or an integration-bound plugin compatible with the shared instance. */
606
+ type FarmIntegrationContributedPlugin<TInstance = unknown> = FarmPlugin<any, any, any, any, unknown, false> | FarmPlugin<any, any, any, any, TInstance, true>;
607
+ interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> {
608
+ readonly kind: "farm-integration";
609
+ category: FarmIntegrationCategory;
610
+ /** @deprecated Use category instead. */
611
+ slot?: FarmIntegrationCategory;
612
+ type: string;
613
+ instance: TInstance;
614
+ /** Set to false when a platform adapter owns this integration's production routes. */
615
+ serverRuntime?: boolean;
616
+ api?: FarmIntegrationAPI;
617
+ schema?: TSchema;
618
+ config?: FarmIntegrationConfigInput<TConfig, TSchema>;
619
+ validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
620
+ setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
621
+ ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
622
+ dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
623
+ log?: FarmIntegrationLogger;
624
+ routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
625
+ endpoints?: FarmIntegrationEndpoints<TSchema>;
626
+ middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
627
+ providers?: readonly FarmIntegrationProvider[];
628
+ documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
629
+ /** Additional Farm plugins owned and configured by this integration. */
630
+ plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
923
631
  }
924
- type FarmRouteRuntimeEntryKind = "page" | "api" | "metadata" | "rule";
925
- type FarmRouteRenderingMode = "static" | "dynamic";
926
- interface FarmRouteRuntimeManifestEntry extends ResolvedFarmRouteRuntimeConfig {
927
- kind: FarmRouteRuntimeEntryKind;
928
- pattern: string;
929
- rendering: FarmRouteRenderingMode;
930
- source?: string;
632
+ type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any, any> | undefined>;
633
+ /** @internal Identifies plugins owned by platform-managed integrations. */
634
+ declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
635
+ /** Returns the integration that contributed a normalized plugin, when applicable. */
636
+ declare function getFarmIntegrationPluginOwner(plugin: FarmPlugin): Readonly<FarmIntegrationPluginOwner> | undefined;
637
+ type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
638
+ middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
639
+ before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
640
+ after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
641
+ rawBody?: boolean;
642
+ headers?: Record<string, string>;
643
+ credentials?: RequestCredentials;
644
+ bodyFormat?: FarmIntegrationAPIBodyFormat;
645
+ responseFormat?: FarmIntegrationAPIResponseFormat;
646
+ isServer?: TServer;
647
+ body?: FarmIntegrationInputSchema<TBody>;
648
+ query?: FarmIntegrationInputSchema<TQuery>;
649
+ input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
650
+ handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
651
+ };
652
+ interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
653
+ get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "GET", TSchema>;
654
+ post<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "POST", TSchema>;
655
+ query<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "QUERY", TSchema>;
656
+ put<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PUT", TSchema>;
657
+ patch<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PATCH", TSchema>;
658
+ delete<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "DELETE", TSchema>;
659
+ options<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "OPTIONS", TSchema>;
660
+ head<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "HEAD", TSchema>;
931
661
  }
932
- interface FarmRouteRuntimeManifest {
933
- version: 1;
934
- routes: FarmRouteRuntimeManifestEntry[];
662
+ interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
663
+ route: FarmIntegrationRouteFactory<TSchema>;
664
+ integrationRoute: FarmIntegrationRouteFactory<TSchema>;
935
665
  }
936
- declare function normalizeFarmRouteRuntimeConfig(value: FarmRouteRuntimeConfig | null | undefined, source?: string): FarmRouteRuntimeConfig;
937
- /** Merge from lowest to highest precedence. Explicit "auto" values reset inherited hints. */
938
- declare function mergeFarmRouteRuntimeConfigs(...configs: Array<FarmRouteRuntimeConfig | null | undefined>): FarmRouteRuntimeConfig;
939
- declare function resolveFarmRouteRuntimeConfig(config: FarmRouteRuntimeConfig | null | undefined, source?: string): ResolvedFarmRouteRuntimeConfig;
940
- declare function hasFarmRouteRuntimeControls(config: FarmRouteRuntimeConfig | null | undefined): boolean;
941
- declare function getFarmRouteRuntimeConfig(value: unknown): FarmRouteRuntimeConfig;
942
- declare function createFarmRouteRuntimeKey(config: ResolvedFarmRouteRuntimeConfig): string;
943
- /** Resolve matching route rules from broadest to most specific. */
944
- declare function resolveFarmRouteRuleRuntimeConfig(pathname: string, routeRules: Record<string, FarmRouteRuntimeConfig> | null | undefined): FarmRouteRuntimeConfig;
945
- declare function farmRouteRuleMatches(pattern: string, pathname: string): boolean;
946
-
947
- type FarmRouteRuleRenderMode = "static" | "dynamic";
948
- type FarmRouteRuleRedirect = string | {
949
- to: string;
950
- statusCode?: FarmRedirectStatus;
951
- permanent?: boolean;
666
+ type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
667
+ type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
668
+ readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
952
669
  };
953
- type FarmRouteRuleCors = boolean | {
954
- origin?: string;
955
- methods?: string | readonly string[];
956
- headers?: string | readonly string[];
670
+ type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
671
+ readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
957
672
  };
958
- interface FarmRouteRule extends FarmRouteRuntimeConfig {
959
- prerender?: boolean;
960
- render?: FarmRouteRuleRenderMode;
961
- ssr?: boolean;
962
- swr?: boolean | number;
963
- isr?: boolean | number;
964
- cors?: FarmRouteRuleCors;
965
- headers?: Record<string, string>;
966
- redirect?: FarmRouteRuleRedirect;
673
+ interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
674
+ endpoint: FarmIntegrationRouteFactory<TSchema>;
967
675
  }
968
- type FarmRouteRules = Record<string, FarmRouteRule>;
969
- declare function normalizeRouteRules(routeRules: FarmRouteRules | undefined): FarmRouteRules;
970
- declare function routeRulesToRedirects(routeRules: FarmRouteRules): RedirectConfig[];
971
- declare function routeRulesToHeaders(routeRules: FarmRouteRules): HeaderConfig[];
972
- declare function routeRulesToNitroRouteRules(routeRules: FarmRouteRules): Record<string, any>;
973
-
974
- type OxcTransform = (typeof rolldown_utils)["transform"];
975
- type FarmLayerEntry = string;
976
- interface ResolvedFarmLayer {
977
- /** The value used in `extends`. */
978
- source: string;
979
- /** Stable name used by the `#layers/<name>` alias. */
980
- name: string;
981
- /** Absolute layer package or directory root. */
982
- root: string;
983
- /** Source directory relative to the layer root. */
984
- srcDir: string;
985
- /** Resolved layer config file when one exists. */
986
- configFile?: string;
987
- }
988
- interface FarmSourceRoot {
989
- name: string;
990
- root: string;
991
- srcDir: string;
992
- layer: boolean;
993
- }
994
- interface ResolveFarmLayersOptions {
995
- root: string;
996
- mode: "development" | "production";
997
- }
998
- interface FarmLayerResolution<TConfig extends Record<string, any>> {
999
- config: TConfig & {
1000
- extends?: readonly FarmLayerEntry[];
1001
- layers: ResolvedFarmLayer[];
676
+ type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
677
+ declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
678
+ declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
679
+ type RegisteredIntegrationRuntime = {
680
+ integration: FarmIntegration;
681
+ config: FarmPluginContext["config"];
682
+ isDev: boolean;
683
+ isProd: boolean;
684
+ };
685
+ type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
686
+ type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
687
+ type FarmIntegrationInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> = Omit<FarmIntegration<TSchema, TConfig, TInstance>, "kind" | "category" | "slot" | "instance" | "config" | "routes" | "endpoints" | "plugins"> & {
688
+ instance: TInstance;
689
+ config?: FarmIntegrationConfigInput<TConfig, TSchema>;
690
+ routes?: FarmIntegrationRoutesInput<TSchema>;
691
+ endpoints?: FarmIntegrationEndpointsInput<TSchema>;
692
+ plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
693
+ } & ({
694
+ category: FarmIntegrationCategory;
695
+ slot?: FarmIntegrationCategory;
696
+ } | {
697
+ category?: FarmIntegrationCategory;
698
+ slot: FarmIntegrationCategory;
699
+ });
700
+ type FarmIntegrationCategoryInput = {
701
+ category: FarmIntegrationCategory;
702
+ slot?: FarmIntegrationCategory;
703
+ } | {
704
+ category?: FarmIntegrationCategory;
705
+ slot: FarmIntegrationCategory;
706
+ };
707
+ type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
708
+ api?: FarmIntegrationAPI;
709
+ schema?: FarmIntegrationSchema;
710
+ config?: unknown;
711
+ routes?: unknown;
712
+ endpoints?: unknown;
713
+ };
714
+ type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
715
+ schema: infer TSchema extends FarmIntegrationSchema;
716
+ } ? TSchema : undefined;
717
+ type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
718
+ type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
719
+ type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
720
+ type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
721
+ type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
722
+ type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
723
+ routes: infer TRoutes;
724
+ } ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
725
+ endpoints: infer TEndpoints;
726
+ } ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
727
+ type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
728
+ type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
729
+ endpoints: infer TEndpoints;
730
+ } ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
731
+ type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
732
+ type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
733
+ category: infer TCategory extends FarmIntegrationCategory;
734
+ } ? TCategory : TIntegration extends {
735
+ slot: infer TSlot extends FarmIntegrationCategory;
736
+ } ? TSlot : FarmIntegrationCategory;
737
+ type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
738
+ api: infer TAPI extends FarmIntegrationAPI;
739
+ } ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
740
+ type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
741
+ readonly kind: "farm-integration";
742
+ category: ExtractIntegrationCategory<TIntegration>;
743
+ slot: ExtractIntegrationCategory<TIntegration>;
744
+ routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
745
+ endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
746
+ api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
747
+ };
748
+ declare function defineIntegration<const TSchema extends FarmIntegrationSchema | undefined, const TConfig, TIntegration extends FarmIntegrationInput<TSchema, TConfig, any>>(integration: TIntegration & FarmIntegrationInput<TSchema, TConfig, NoInfer<TIntegration["instance"]>>): DefinedIntegration<TIntegration, TSchema>;
749
+ declare function isFarmIntegration(value: unknown): value is FarmIntegration;
750
+ declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
751
+ declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): FarmIntegrationProvider[];
752
+ declare function isFarmIntegrationProviderComponentReference(value: FarmIntegrationProvider["component"]): value is FarmIntegrationProviderComponentReference;
753
+ declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
754
+ declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
755
+ declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
756
+ declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
757
+ declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
758
+ declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
759
+ pathname: string;
760
+ method?: string;
761
+ }): {
762
+ key: string;
763
+ integration: FarmIntegration;
764
+ route: {
765
+ path: string;
766
+ methods: readonly string[];
1002
767
  };
1003
- layers: ResolvedFarmLayer[];
1004
- }
1005
- declare function resolveFarmLayers<TConfig extends Record<string, any>>(projectConfig: TConfig, options: ResolveFarmLayersOptions): Promise<FarmLayerResolution<TConfig>>;
1006
- declare function getFarmSourceRoots(config: {
1007
- root?: string;
1008
- srcDir?: string;
1009
- layers?: readonly ResolvedFarmLayer[];
1010
- }): FarmSourceRoot[];
1011
- declare function getFarmAppDirectories(config: {
1012
- root?: string;
1013
- srcDir?: string;
1014
- layers?: readonly ResolvedFarmLayer[];
1015
- }): string[];
1016
- declare function getFarmLayerAliases(layers: readonly ResolvedFarmLayer[] | undefined): Record<string, string>;
1017
- declare function createFarmConfigResolutionPlugin(options: {
1018
- transform: OxcTransform;
1019
- }): Plugin;
1020
- declare function loadFarmConfigFile<TConfig = Record<string, any>>(configPath: string, options: {
1021
- root: string;
1022
- cacheRoot?: string;
1023
- }): Promise<TConfig>;
768
+ params: FarmIntegrationRouteParams;
769
+ } | null;
770
+ declare function matchRegisteredIntegrationRoute(input: {
771
+ pathname: string;
772
+ method?: string;
773
+ }): {
774
+ key: string;
775
+ integration: FarmIntegration;
776
+ route: {
777
+ path: string;
778
+ methods: readonly string[];
779
+ };
780
+ params: FarmIntegrationRouteParams;
781
+ } | null;
782
+ declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
783
+ declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
784
+ currentRequest?: Request;
785
+ data?: FarmIntegrationData;
786
+ internal?: boolean;
787
+ /**
788
+ * Receives `Set-Cookie` values that a middleware forwarded via
789
+ * forwardIntegrationSetCookies while returning `void`, when this dispatch
790
+ * ends without a Response of its own. The request continues downstream, so
791
+ * the caller owns merging them onto whatever response it finally produces.
792
+ * Only called on the `null` return path: a Response returned from here has
793
+ * already had the forwarded cookies appended.
794
+ */
795
+ onForwardedCookies?: (cookies: string[]) => void;
796
+ }): Promise<Response | null>;
797
+ /**
798
+ * Run every configured integration's middleware and routes for one request.
799
+ *
800
+ * Integration middleware is not route scoped: it is the mechanism behind
801
+ * `protectedRoutes` guards and provider session refresh, so it has to run for
802
+ * ordinary page and API requests that match no integration route at all. That
803
+ * makes this, not `matchIntegrationRoute`, the correct entry point for a
804
+ * runtime dispatching integrations for every request.
805
+ *
806
+ * The first integration that produces a Response short-circuits the rest.
807
+ * `Set-Cookie` values forwarded by middleware that returned `void` are
808
+ * collected: they ride the short-circuiting Response when there is one, and are
809
+ * otherwise handed back so the caller can merge them onto the downstream
810
+ * response.
811
+ */
812
+ declare function dispatchIntegrationRequests(integrations: FarmIntegrationsUserConfig | undefined, runtime: Omit<RegisteredIntegrationRuntime, "integration">, request: Request, options?: {
813
+ currentRequest?: Request;
814
+ }): Promise<{
815
+ response: Response | null;
816
+ setCookies: string[];
817
+ }>;
1024
818
 
1025
- declare const DEFAULT_FARM_DEVTOOLS_SHORTCUT = "mod+shift+.";
1026
- declare const FARM_DEVTOOLS_PATH = "/__farm/devtools";
1027
- declare const FARM_DEVTOOLS_LAUNCH_PARAM = "__farm_devtools";
1028
819
  /**
1029
- * Configuration for the built-in DevTools dashboard. The dashboard is deprecated in favor
1030
- * of the `@farm.js/devtools` plugin, which reuses this configuration for enablement and
1031
- * the keyboard shortcut. Both options keep working while the built-in UI remains available.
820
+ * Farm.js Middleware System
821
+ *
822
+ * Type definitions for the middleware system
1032
823
  */
1033
- interface FarmDevtoolsConfig {
1034
- /** Enable the development-only DevTools UI and runtime endpoints. */
1035
- enabled?: boolean;
1036
- /** Keyboard shortcut used to toggle DevTools, or false to disable the shortcut. */
1037
- shortcut?: string | false;
1038
- }
1039
- type FarmDevtoolsUserConfig = boolean | FarmDevtoolsConfig;
1040
- interface ResolvedFarmDevtoolsConfig {
1041
- enabled: boolean;
1042
- shortcut: string | false;
1043
- }
1044
- declare function resolveFarmDevtoolsConfig(config: FarmDevtoolsUserConfig | ResolvedFarmDevtoolsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevtoolsConfig;
1045
824
 
1046
- type FarmBuildActivityPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
1047
- interface FarmDevIndicatorsConfig {
1048
- /** Show build and HMR activity in the browser during development. */
1049
- buildActivity?: boolean;
1050
- /** Corner used by the build activity indicator. */
1051
- buildActivityPosition?: FarmBuildActivityPosition;
1052
- }
1053
- interface ResolvedFarmDevIndicatorsConfig {
1054
- buildActivity: boolean;
1055
- buildActivityPosition: FarmBuildActivityPosition;
825
+ /**
826
+ * Next function type for middleware chain
827
+ */
828
+ type MiddlewareResult = void | Response;
829
+ type NextFunction = () => Promise<MiddlewareResult>;
830
+ type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
831
+ /**
832
+ * A typed view over the request-scoped maps used by middleware.
833
+ */
834
+ interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
835
+ readonly size: number;
836
+ get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
837
+ has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
838
+ entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
839
+ keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
840
+ values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
841
+ forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
842
+ [Symbol.iterator](): IterableIterator<[
843
+ MiddlewareStoreKey<TValues>,
844
+ TValues[MiddlewareStoreKey<TValues>]
845
+ ]>;
1056
846
  }
1057
- declare function resolveFarmDevIndicatorsConfig(config: FarmDevIndicatorsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevIndicatorsConfig;
1058
- declare function generateFarmDevIndicatorsClientRuntime(config: ResolvedFarmDevIndicatorsConfig): string;
1059
-
1060
- interface FarmAuthEmailAndPasswordConfig {
1061
- /** Require a verified email before creating a session. @default false */
1062
- requireEmailVerification?: boolean;
1063
- /** Smallest accepted password length. @default 8 */
1064
- minPasswordLength?: number;
1065
- /** Largest accepted password length. @default 128 */
1066
- maxPasswordLength?: number;
847
+ interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
848
+ clear(): void;
849
+ delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
850
+ set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
1067
851
  }
1068
- interface FarmAuthSessionConfig {
1069
- /** Session lifetime in seconds. @default 604800 */
1070
- expiresIn?: number;
1071
- /** Session refresh interval in seconds. @default 86400 */
1072
- updateAge?: number;
852
+ /**
853
+ * Middleware function signature
854
+ */
855
+ type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
856
+ /**
857
+ * Context passed to a named, request-first middleware export.
858
+ * `locals` and the get/set helpers stay on the server. `data` can be exposed
859
+ * through page props and should contain only serializable, client-safe values.
860
+ */
861
+ interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
862
+ readonly url: URL;
863
+ readonly pathname: string;
864
+ readonly searchParams: URLSearchParams;
865
+ readonly method: string;
866
+ readonly params: Record<string, string>;
867
+ readonly route: string;
868
+ readonly locals: MiddlewareStore<TLocals>;
869
+ readonly data: MiddlewareStore<TData>;
870
+ readonly headers: Map<string, string>;
871
+ readonly cookies: CookieJar;
872
+ get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
873
+ has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
874
+ set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
875
+ delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
876
+ redirect(url: string, status?: number): void;
877
+ rewrite(url: string): void;
878
+ json(data: any, status?: number): void;
879
+ text(content: string, status?: number): void;
880
+ html(content: string, status?: number): void;
1073
881
  }
1074
- interface FarmAuthDatabaseConfig {
1075
- /**
1076
- * Postgres connection string. Defaults to DATABASE_URL.
1077
- * Local development falls back to SQLite when no URL is present.
1078
- */
1079
- url?: string;
1080
- /** Local SQLite path. @default ".farm/auth.sqlite" */
882
+ type RequestMiddleware<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> = (request: Request, context: RequestMiddlewareContext<TLocals, TData>) => MiddlewareResult | Promise<MiddlewareResult>;
883
+ /**
884
+ * Cookie options
885
+ */
886
+ interface CookieOptions {
887
+ maxAge?: number;
888
+ expires?: Date;
1081
889
  path?: string;
1082
- /** Automatically update the auth schema in development. @default true */
1083
- migrateInDevelopment?: boolean;
890
+ domain?: string;
891
+ secure?: boolean;
892
+ httpOnly?: boolean;
893
+ sameSite?: "strict" | "lax" | "none";
1084
894
  }
1085
- interface FarmAuthConfig {
1086
- /** Set false to disable auth without removing its configuration. @default true */
1087
- enabled?: boolean;
1088
- /** Display name used by authentication emails and metadata. */
1089
- appName?: string;
1090
- /** Route prefix for the auth endpoints. @default "/api/auth" */
1091
- basePath?: string;
895
+ /**
896
+ * Cookie management interface
897
+ */
898
+ interface CookieJar {
899
+ get(name: string): string | undefined;
900
+ set(name: string, value: string, options?: CookieOptions): void;
1092
901
  /**
1093
- * Email/password authentication. It is enabled by default; set false to
1094
- * disable it when adding another sign-in method.
902
+ * Remove a cookie. Pass the `path`/`domain` it was set with; a tombstone only
903
+ * matches a cookie with the same scope.
1095
904
  */
1096
- emailAndPassword?: boolean | FarmAuthEmailAndPasswordConfig;
1097
- session?: FarmAuthSessionConfig;
1098
- database?: FarmAuthDatabaseConfig;
905
+ delete(name: string, options?: CookieOptions): void;
906
+ getAll(): Record<string, string>;
1099
907
  }
1100
- type FarmAuthUserConfig = boolean | FarmAuthConfig;
1101
- interface ResolvedFarmAuthConfig {
1102
- enabled: boolean;
1103
- appName?: string;
1104
- basePath: string;
1105
- emailAndPassword: {
1106
- enabled: boolean;
1107
- requireEmailVerification: boolean;
1108
- minPasswordLength: number;
1109
- maxPasswordLength: number;
1110
- };
1111
- session: {
1112
- expiresIn: number;
1113
- updateAge: number;
1114
- };
1115
- database: {
1116
- url?: string;
1117
- path: string;
1118
- migrateInDevelopment: boolean;
1119
- };
908
+ interface RateLimitIncrementResult {
909
+ count: number;
910
+ /** Unix epoch timestamp in milliseconds when the fixed window resets. */
911
+ resetAt: number;
1120
912
  }
1121
-
1122
- /** A server-only endpoint reference. Config references must declare an explicit /api path. */
1123
- type FarmMCPEndpoint = TypedEndpoint<any, any, any, any, any, any, any, any>;
1124
- interface FarmMCPExecuteContext {
1125
- /** The principal returned by authorize, or { subject: "anonymous" } for public servers. */
1126
- readonly authorization: Readonly<FarmMCPAuthorization>;
1127
- readonly request: Request;
1128
- /** Observe this signal in cancellable work. Cancellation cannot undo side effects. */
1129
- readonly signal: AbortSignal;
913
+ interface RateLimitStorage {
914
+ /** Atomically increment a key and create or retain its fixed expiry window. */
915
+ increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
916
+ /** Optional inspection support used by getRateLimitStatus(). */
917
+ get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
1130
918
  }
1131
- /** A server-only tool with no corresponding HTTP endpoint. */
1132
- interface FarmMCPStandaloneTool<Schema extends RouteSchema = RouteSchema, Result = unknown, OutputSchema extends RouteSchema | undefined = undefined> extends EndpointMCPMetadata {
1133
- name: string;
1134
- /** Must describe an object and support input JSON Schema conversion. */
1135
- inputSchema: Schema;
1136
- /** Validate/transform returned data and advertise its output shape inside MCP's result envelope. */
1137
- outputSchema?: OutputSchema;
1138
- /** Return JSON-serializable data, not a Response or an MCP protocol envelope. */
1139
- execute(input: RouteSchemaOutput<Schema>, context: FarmMCPExecuteContext): OutputSchema extends RouteSchema ? NoInfer<RouteSchemaInput<OutputSchema>> | Promise<NoInfer<RouteSchemaInput<OutputSchema>>> : Result | Promise<Result>;
1140
- endpoint?: never;
919
+ interface MemoryRateLimitStorageOptions {
920
+ /** Maximum number of active keys retained by this process. */
921
+ maxEntries?: number;
922
+ }
923
+ interface RateLimitConfig {
924
+ requests: number;
925
+ window: string;
926
+ keyGenerator?: (ctx: MiddlewareContext) => string;
927
+ onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
928
+ storage?: RateLimitStorage;
929
+ }
930
+ interface RateLimitStatus {
931
+ requests: number;
932
+ limit: number;
933
+ remaining: number;
934
+ resetIn: number | null;
935
+ resetAt: Date | null;
936
+ isLimited: boolean;
1141
937
  }
1142
938
  /**
1143
- * A createServerFn or createServerQuery function with `mcp` metadata. It runs through its own
1144
- * input schema, middleware and output schema, with the MCP request as its request.
939
+ * Middleware configuration
1145
940
  */
1146
- type FarmMCPServerFunction = ServerFn<any, any, any> | ServerQuery<any, any>;
1147
- /** Compose endpoint references, server functions and standalone tools. */
1148
- type FarmMCPToolDefinition = FarmMCPEndpoint | FarmMCPServerFunction | (EndpointMCPMetadata & {
1149
- endpoint: FarmMCPEndpoint;
1150
- execute?: never;
1151
- }) | FarmMCPStandaloneTool<any, unknown, any>;
1152
- /** Resolved tool identity, without handlers, validators, or a way to bypass authorization. */
1153
- type FarmMCPTool = Readonly<EndpointMCPMetadata> & {
1154
- readonly name: string;
1155
- } & ({
1156
- readonly kind: "endpoint";
1157
- readonly method: RouteMethod;
1158
- readonly path: string;
1159
- } | {
1160
- readonly kind: "standalone";
1161
- readonly method?: never;
1162
- readonly path?: never;
1163
- } | {
1164
- readonly kind: "serverFunction";
1165
- readonly method?: never;
1166
- readonly path?: never;
1167
- });
1168
- interface FarmMCPServer {
1169
- readonly name: string;
1170
- readonly version: string;
1171
- readonly path: `/api/${string}`;
941
+ type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
942
+ interface MiddlewareConfig$1 {
943
+ matcher?: MiddlewareMatcher | MiddlewareMatcher[];
944
+ exclude?: (string | RegExp)[];
945
+ runtime?: "nodejs" | "edge";
1172
946
  }
1173
- interface FarmMCPAuthorization extends Record<string, unknown> {
1174
- /** Stable application principal identifier. Never written to a response or log by Farm. */
1175
- subject: string;
1176
- scopes?: string[];
1177
- /** Allowed tool names for this request. Omit for all configured tools; [] denies all tools. */
1178
- tools?: readonly string[];
947
+ interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
948
+ handler?: MiddlewareFunction;
949
+ handlers?: MiddlewareFunction[];
1179
950
  }
1180
- interface FarmMCPAuthorizeContext {
1181
- request: Request;
1182
- /** Untrusted requested name for a tools/call; authorization runs separately for every JSON-RPC batch item. */
1183
- tool?: string;
1184
- /** Complete configured catalog, before applying this caller's permissions. */
1185
- tools: readonly FarmMCPTool[];
1186
- /** Resolved transport identity, for policies shared by multiple MCP endpoints. */
1187
- server: FarmMCPServer;
951
+ type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
952
+ /**
953
+ * Middleware context - the main object passed to middleware functions
954
+ */
955
+ interface MiddlewareContext {
956
+ request: IncomingMessage;
957
+ response: ServerResponse;
958
+ url: URL;
959
+ pathname: string;
960
+ searchParams: URLSearchParams;
961
+ method: string;
962
+ params: Record<string, string>;
963
+ route: string;
964
+ parent?: {
965
+ data: Map<string, any>;
966
+ locals?: Map<string, any>;
967
+ headers: Record<string, string>;
968
+ };
969
+ vite: {
970
+ isDev: boolean;
971
+ hmr: boolean;
972
+ server?: ViteDevServer;
973
+ };
974
+ data: Map<string, any>;
975
+ locals: Map<string, any>;
976
+ headers: Map<string, string>;
977
+ cookies: CookieJar;
978
+ _handled: boolean;
979
+ _redirectUrl?: string;
980
+ _rewriteUrl?: string;
981
+ redirect(url: string, status?: number): void;
982
+ rewrite(url: string): void;
983
+ json(data: any, status?: number): void;
984
+ text(content: string, status?: number): void;
985
+ html(content: string, status?: number): void;
1188
986
  }
1189
- interface FarmMCPConfig {
1190
- /** Set false to disable MCP without removing its configuration. @default true */
1191
- enabled?: boolean;
1192
- /** Canonical Farm API path for the Streamable HTTP endpoint. @default "/api/mcp" */
1193
- path?: `/api/${string}`;
1194
- /** MCP server identity. @default "farm-api" */
1195
- name?: string;
1196
- /** MCP server version. @default "1.0.0" */
1197
- version?: string;
1198
- /** Explicit endpoint/standalone tool allowlist. Omit to discover route-owned MCP metadata. */
1199
- tools?: readonly FarmMCPToolDefinition[];
1200
- /** Authorize every MCP request. Returning false responds with 401 before protocol handling. */
1201
- authorize?: (context: FarmMCPAuthorizeContext) => FarmMCPAuthorization | false | Promise<FarmMCPAuthorization | false>;
1202
- /** Deliberate escape hatch for public servers. Authentication is required by default. */
1203
- allowUnauthenticated?: boolean;
987
+ /**
988
+ * Middleware chain interface
989
+ */
990
+ interface MiddlewareChain {
991
+ use(fn: MiddlewareFunction): MiddlewareChain;
1204
992
  /**
1205
- * OAuth discovery for MCP clients. When set, a rejected request's 401 points at
1206
- * RFC 9728 Protected Resource Metadata naming these authorization servers, which
1207
- * Farm serves at `/.well-known/oauth-protected-resource/<endpoint path>`.
1208
- * Validating tokens stays in `authorize`.
993
+ * Conditionally run middleware based on a condition.
994
+ * Supports boolean values or functions that evaluate to boolean.
995
+ *
996
+ * @example
997
+ * .when(true, (ctx, next) => { ... }) // Always run
998
+ * .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
1209
999
  */
1210
- oauth?: FarmMCPOAuthConfig;
1211
- }
1212
- interface FarmMCPOAuthConfig {
1213
- /** Issuer URLs of the OAuth authorization servers that issue tokens for this endpoint. */
1214
- authorizationServers: readonly string[];
1215
- /** Scopes clients may request, advertised as `scopes_supported` and in the 401 challenge. */
1216
- scopes?: readonly string[];
1217
- /** Human-readable name for consent screens. @default the MCP server name */
1218
- resourceName?: string;
1000
+ when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
1001
+ rateLimit(config: RateLimitConfig): MiddlewareChain;
1002
+ redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
1003
+ /**
1004
+ * Rewrite the current route to a new destination.
1005
+ * In route-specific middleware, this rewrites the middleware's route.
1006
+ *
1007
+ * @param destination - The destination path to rewrite to
1008
+ * @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
1009
+ *
1010
+ * @example
1011
+ * // In /contact/middleware.ts
1012
+ * .rewrite('/about') // Always rewrites /contact to /about
1013
+ * .rewrite('/about', true) // Always rewrites
1014
+ * .rewrite('/about', false) // Never rewrites
1015
+ * .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
1016
+ */
1017
+ rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
1018
+ build(): {
1019
+ handlers: MiddlewareFunction[];
1020
+ config?: MiddlewareConfig$1;
1021
+ };
1219
1022
  }
1220
- type FarmMCPUserConfig = FarmMCPConfig | false;
1221
- interface ResolvedFarmMCPConfig extends FarmMCPConfig {
1222
- enabled: boolean;
1023
+ /**
1024
+ * Middleware module export
1025
+ */
1026
+ interface MiddlewareModule {
1027
+ default?: MiddlewareChain | MiddlewareFunction;
1028
+ middleware?: RequestMiddleware;
1029
+ config?: MiddlewareConfig$1;
1223
1030
  }
1224
1031
 
1225
- type FarmPreloadMode = "warn" | "enforce";
1226
- interface FarmPreloadUserConfig {
1227
- /** Report excess hints or remove the lower-priority hints. @default "enforce" */
1228
- mode?: FarmPreloadMode;
1229
- /** Maximum image preload hints per document. @default 1 */
1230
- maxImages?: number;
1231
- /** Maximum font preload hints per document. @default 2 */
1232
- maxFonts?: number;
1233
- }
1234
- interface ResolvedFarmPreloadConfig {
1235
- mode: FarmPreloadMode;
1236
- maxImages: number;
1237
- maxFonts: number;
1238
- }
1239
- interface FarmPerformanceConfig {
1240
- preload?: FarmPreloadUserConfig;
1241
- }
1242
- interface ResolvedFarmPerformanceConfig {
1243
- preload: ResolvedFarmPreloadConfig;
1244
- }
1245
- type FarmPreloadKind = "image" | "font";
1246
- interface FarmPreloadBudgetWarning {
1247
- kind: FarmPreloadKind;
1248
- count: number;
1249
- budget: number;
1250
- removed: number;
1251
- }
1252
- interface FarmManagedPreloads {
1253
- value: string;
1254
- warnings: FarmPreloadBudgetWarning[];
1032
+ type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
1033
+ type FarmMdxComponents = Record<string, FarmMdxComponent>;
1034
+ interface FarmMdxUserConfig {
1035
+ /**
1036
+ * Component map or module path that exports `components` or a default component map.
1037
+ * Relative paths resolve from the project root.
1038
+ */
1039
+ components?: string | FarmMdxComponents;
1040
+ /**
1041
+ * Serve source-authored markdown pages at `/route.md`.
1042
+ * Enabled by default for `page.md` and `page.mdx`.
1043
+ */
1044
+ markdownRoutes?: boolean;
1045
+ /** Class name used for the wrapper around rendered markdown content. */
1046
+ className?: string;
1255
1047
  }
1256
- interface FarmManagedDocumentPreloads {
1257
- html: string;
1258
- linkHeader: string;
1259
- warnings: FarmPreloadBudgetWarning[];
1048
+ interface FarmMdxResolvedConfig {
1049
+ components?: string | FarmMdxComponents;
1050
+ markdownRoutes: boolean;
1051
+ className: string;
1260
1052
  }
1053
+ declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
1261
1054
  /**
1262
- * Apply image and font budgets to HTML preload elements. High-priority image
1263
- * hints are retained before ordinary hints, making an explicitly preloaded LCP
1264
- * image the winner when a document contains too many React-generated hints.
1055
+ * The MDX components module a Markdown page renders from, as an absolute path. Undefined when
1056
+ * the components are an inline object, which cannot be analyzed for client components.
1265
1057
  */
1266
- declare function manageFarmHtmlPreloads(html: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
1267
- /** Apply the same budgets to HTTP Link preload hints, including Farm fonts. */
1268
- declare function manageFarmLinkHeaderPreloads(value: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
1269
- /** Apply a single document budget across HTML and HTTP Link header hints. */
1270
- declare function manageFarmDocumentPreloads(html: string, linkHeader: string, config: ResolvedFarmPreloadConfig): FarmManagedDocumentPreloads;
1271
- /** Rate-limit identical route-and-budget warnings within a server process. */
1272
- declare function reportFarmPreloadWarnings(warnings: FarmPreloadBudgetWarning[], context?: string): void;
1058
+ declare function resolveFarmMdxComponentsModulePath(config: FarmMdxResolvedConfig | undefined, root: string): string | undefined;
1273
1059
 
1274
- type FarmCspDirectiveValue = string | readonly string[] | boolean | null | undefined;
1275
- type FarmCspDirectives = Readonly<Record<string, FarmCspDirectiveValue>>;
1276
- interface FarmCspOptions {
1277
- /** A pre-serialized CSP value. Cannot be combined with directives. */
1278
- policy?: string;
1279
- /** CSP directives using camelCase or kebab-case names. */
1280
- directives?: FarmCspDirectives;
1281
- /** Emit Content-Security-Policy-Report-Only instead of enforcing the policy. */
1282
- reportOnly?: boolean;
1283
- /**
1284
- * Generate a fresh nonce for every dynamic HTML response and per-page
1285
- * script hashes for prerendered HTML. Farm adds the matching sources to the
1286
- * governing script directive and stamps dynamic script elements with the
1287
- * response nonce.
1288
- */
1289
- nonce?: boolean;
1060
+ type FarmRouteRuntime = "auto" | "node" | "edge";
1061
+ type FarmRouteRegions = "auto" | readonly string[];
1062
+ type FarmRouteMaxDuration = "auto" | number;
1063
+ /** Portable execution controls shared by file, programmatic, and config routes. */
1064
+ interface FarmRouteRuntimeConfig {
1065
+ runtime?: FarmRouteRuntime;
1066
+ regions?: FarmRouteRegions;
1067
+ maxDuration?: FarmRouteMaxDuration;
1290
1068
  }
1291
- type FarmCspConfig = string | FarmCspOptions;
1292
- interface FarmSecurityConfig {
1293
- /** App-wide CSP for dynamic responses and prerendered output. */
1294
- csp?: FarmCspConfig | false;
1295
- /** @deprecated Use csp. */
1296
- contentSecurityPolicy?: never;
1069
+ interface ResolvedFarmRouteRuntimeConfig {
1070
+ runtime: FarmRouteRuntime;
1071
+ regions?: string[];
1072
+ maxDuration?: number;
1297
1073
  }
1298
- interface ResolvedFarmCspConfig {
1299
- value: string;
1300
- reportOnly: boolean;
1301
- nonce: boolean;
1074
+ type FarmRouteRuntimeEntryKind = "page" | "api" | "metadata" | "rule";
1075
+ type FarmRouteRenderingMode = "static" | "dynamic";
1076
+ interface FarmRouteRuntimeManifestEntry extends ResolvedFarmRouteRuntimeConfig {
1077
+ kind: FarmRouteRuntimeEntryKind;
1078
+ pattern: string;
1079
+ rendering: FarmRouteRenderingMode;
1080
+ source?: string;
1302
1081
  }
1303
- interface ResolvedFarmSecurityConfig {
1304
- csp: ResolvedFarmCspConfig | false;
1082
+ interface FarmRouteRuntimeManifest {
1083
+ version: 1;
1084
+ routes: FarmRouteRuntimeManifestEntry[];
1305
1085
  }
1306
- declare function resolveFarmSecurityConfig(input: FarmSecurityConfig | ResolvedFarmSecurityConfig | undefined): ResolvedFarmSecurityConfig;
1307
- declare function applyFarmCspNonceToResponse(response: Response, security: ResolvedFarmSecurityConfig): Response;
1086
+ declare function normalizeFarmRouteRuntimeConfig(value: FarmRouteRuntimeConfig | null | undefined, source?: string): FarmRouteRuntimeConfig;
1087
+ /** Merge from lowest to highest precedence. Explicit "auto" values reset inherited hints. */
1088
+ declare function mergeFarmRouteRuntimeConfigs(...configs: Array<FarmRouteRuntimeConfig | null | undefined>): FarmRouteRuntimeConfig;
1089
+ declare function resolveFarmRouteRuntimeConfig(config: FarmRouteRuntimeConfig | null | undefined, source?: string): ResolvedFarmRouteRuntimeConfig;
1090
+ declare function hasFarmRouteRuntimeControls(config: FarmRouteRuntimeConfig | null | undefined): boolean;
1091
+ declare function getFarmRouteRuntimeConfig(value: unknown): FarmRouteRuntimeConfig;
1092
+ declare function createFarmRouteRuntimeKey(config: ResolvedFarmRouteRuntimeConfig): string;
1093
+ /** Resolve matching route rules from broadest to most specific. */
1094
+ declare function resolveFarmRouteRuleRuntimeConfig(pathname: string, routeRules: Record<string, FarmRouteRuntimeConfig> | null | undefined): FarmRouteRuntimeConfig;
1095
+ declare function farmRouteRuleMatches(pattern: string, pathname: string): boolean;
1308
1096
 
1309
- declare const DEFAULT_FARM_API_BASE_PATH = "/api";
1310
- interface FarmAPIConfigResolverContext {
1311
- root: string;
1312
- mode: "development" | "production";
1313
- env: ResolvedFarmEnv;
1314
- }
1315
- type FarmAPIConfigValue = string | undefined | ((context: FarmAPIConfigResolverContext) => string | undefined | Promise<string | undefined>);
1316
- interface FarmAPIConfig {
1317
- /**
1318
- * Public API root. An origin-only URL is joined with `basePath`; a URL that
1319
- * already has a path is used as-is. May be resolved from deployment context.
1320
- */
1321
- baseURL?: FarmAPIConfigValue;
1322
- /** Public API path and same-origin server mount used when `baseURL` has no path. @default "/api" */
1323
- basePath?: FarmAPIConfigValue;
1324
- }
1325
- interface ResolvedFarmAPIConfig {
1326
- /** Fully resolved public API root, either absolute or root-relative. */
1327
- baseURL: string;
1328
- /** Effective pathname of `baseURL`. */
1329
- basePath: string;
1097
+ type FarmRouteRuleRenderMode = "static" | "dynamic";
1098
+ type FarmRouteRuleRedirect = string | {
1099
+ to: string;
1100
+ statusCode?: FarmRedirectStatus;
1101
+ permanent?: boolean;
1102
+ };
1103
+ type FarmRouteRuleCors = boolean | {
1104
+ origin?: string;
1105
+ methods?: string | readonly string[];
1106
+ headers?: string | readonly string[];
1107
+ };
1108
+ interface FarmRouteRule extends FarmRouteRuntimeConfig {
1109
+ prerender?: boolean;
1110
+ render?: FarmRouteRuleRenderMode;
1111
+ ssr?: boolean;
1112
+ swr?: boolean | number;
1113
+ isr?: boolean | number;
1114
+ cors?: FarmRouteRuleCors;
1115
+ headers?: Record<string, string>;
1116
+ redirect?: FarmRouteRuleRedirect;
1330
1117
  }
1331
- declare function resolveFarmAPIConfig(config: FarmAPIConfig | undefined, context: FarmAPIConfigResolverContext): Promise<ResolvedFarmAPIConfig>;
1332
- /** Normalize already-resolved API strings. */
1333
- declare function normalizeFarmAPIConfig(config: {
1334
- baseURL?: string;
1335
- basePath?: string;
1336
- } | undefined): ResolvedFarmAPIConfig;
1337
- declare function normalizeFarmAPIBasePath(value: string): string;
1338
- /** Read the API root embedded by Farm's Vite build. */
1339
- declare function getFarmAPIBaseURL(): string;
1340
- /** Resolve a canonical Farm route such as `/api/users` against an API root. */
1341
- declare function resolveFarmAPIRequestURL(routePath: string, baseURL?: string, fallbackOrigin?: string): URL;
1342
-
1343
- declare const FARM_RESOLVED_CUSTOM_CONTEXT: unique symbol;
1118
+ type FarmRouteRules = Record<string, FarmRouteRule>;
1119
+ declare function normalizeRouteRules(routeRules: FarmRouteRules | undefined): FarmRouteRules;
1120
+ declare function routeRulesToRedirects(routeRules: FarmRouteRules): RedirectConfig[];
1121
+ declare function routeRulesToHeaders(routeRules: FarmRouteRules): HeaderConfig[];
1122
+ declare function routeRulesToNitroRouteRules(routeRules: FarmRouteRules): Record<string, any>;
1344
1123
 
1345
- interface RedirectConfig {
1124
+ type OxcTransform = (typeof rolldown_utils)["transform"];
1125
+ type FarmLayerEntry = string;
1126
+ interface ResolvedFarmLayer {
1127
+ /** The value used in `extends`. */
1346
1128
  source: string;
1347
- destination: string;
1348
- permanent?: boolean;
1349
- statusCode?: FarmRedirectStatus;
1129
+ /** Stable name used by the `#layers/<name>` alias. */
1130
+ name: string;
1131
+ /** Absolute layer package or directory root. */
1132
+ root: string;
1133
+ /** Source directory relative to the layer root. */
1134
+ srcDir: string;
1135
+ /** Resolved layer config file when one exists. */
1136
+ configFile?: string;
1350
1137
  }
1351
- interface HeaderConfig {
1352
- source: string;
1353
- headers: Array<{
1354
- key: string;
1355
- value: string;
1356
- }>;
1138
+ interface FarmSourceRoot {
1139
+ name: string;
1140
+ root: string;
1141
+ srcDir: string;
1142
+ layer: boolean;
1357
1143
  }
1358
- interface RewriteConfig {
1359
- source: string;
1360
- destination: string;
1144
+ interface ResolveFarmLayersOptions {
1145
+ root: string;
1146
+ mode: "development" | "production";
1361
1147
  }
1362
- /** @deprecated Use FarmImageConfig. */
1363
- type ImageConfig = FarmImageConfig;
1364
- /** @deprecated Use FarmI18nUserConfig. */
1365
- type I18nConfig = FarmI18nUserConfig;
1366
- interface OpenAPIConfig {
1148
+ interface FarmLayerResolution<TConfig extends Record<string, any>> {
1149
+ config: TConfig & {
1150
+ extends?: readonly FarmLayerEntry[];
1151
+ layers: ResolvedFarmLayer[];
1152
+ };
1153
+ layers: ResolvedFarmLayer[];
1154
+ }
1155
+ declare function resolveFarmLayers<TConfig extends Record<string, any>>(projectConfig: TConfig, options: ResolveFarmLayersOptions): Promise<FarmLayerResolution<TConfig>>;
1156
+ declare function getFarmSourceRoots(config: {
1157
+ root?: string;
1158
+ srcDir?: string;
1159
+ layers?: readonly ResolvedFarmLayer[];
1160
+ }): FarmSourceRoot[];
1161
+ declare function getFarmAppDirectories(config: {
1162
+ root?: string;
1163
+ srcDir?: string;
1164
+ layers?: readonly ResolvedFarmLayer[];
1165
+ }): string[];
1166
+ declare function getFarmLayerAliases(layers: readonly ResolvedFarmLayer[] | undefined): Record<string, string>;
1167
+ declare function createFarmConfigResolutionPlugin(options: {
1168
+ transform: OxcTransform;
1169
+ }): Plugin;
1170
+ declare function loadFarmConfigFile<TConfig = Record<string, any>>(configPath: string, options: {
1171
+ root: string;
1172
+ cacheRoot?: string;
1173
+ }): Promise<TConfig>;
1174
+
1175
+ declare const DEFAULT_FARM_DEVTOOLS_SHORTCUT = "mod+shift+.";
1176
+ declare const FARM_DEVTOOLS_PATH = "/__farm/devtools";
1177
+ declare const FARM_DEVTOOLS_LAUNCH_PARAM = "__farm_devtools";
1178
+ /**
1179
+ * Configuration for the built-in DevTools dashboard. The dashboard is deprecated in favor
1180
+ * of the `@farm.js/devtools` plugin, which reuses this configuration for enablement and
1181
+ * the keyboard shortcut. Both options keep working while the built-in UI remains available.
1182
+ */
1183
+ interface FarmDevtoolsConfig {
1184
+ /** Enable the development-only DevTools UI and runtime endpoints. */
1367
1185
  enabled?: boolean;
1368
- route?: string;
1186
+ /** Keyboard shortcut used to toggle DevTools, or false to disable the shortcut. */
1187
+ shortcut?: string | false;
1188
+ }
1189
+ type FarmDevtoolsUserConfig = boolean | FarmDevtoolsConfig;
1190
+ interface ResolvedFarmDevtoolsConfig {
1191
+ enabled: boolean;
1192
+ shortcut: string | false;
1193
+ }
1194
+ declare function resolveFarmDevtoolsConfig(config: FarmDevtoolsUserConfig | ResolvedFarmDevtoolsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevtoolsConfig;
1195
+
1196
+ type FarmBuildActivityPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
1197
+ interface FarmDevIndicatorsConfig {
1198
+ /** Show build and HMR activity in the browser during development. */
1199
+ buildActivity?: boolean;
1200
+ /** Corner used by the build activity indicator. */
1201
+ buildActivityPosition?: FarmBuildActivityPosition;
1202
+ }
1203
+ interface ResolvedFarmDevIndicatorsConfig {
1204
+ buildActivity: boolean;
1205
+ buildActivityPosition: FarmBuildActivityPosition;
1206
+ }
1207
+ declare function resolveFarmDevIndicatorsConfig(config: FarmDevIndicatorsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevIndicatorsConfig;
1208
+ declare function generateFarmDevIndicatorsClientRuntime(config: ResolvedFarmDevIndicatorsConfig): string;
1209
+
1210
+ interface FarmAuthEmailAndPasswordConfig {
1211
+ /** Require a verified email before creating a session. @default false */
1212
+ requireEmailVerification?: boolean;
1213
+ /** Smallest accepted password length. @default 8 */
1214
+ minPasswordLength?: number;
1215
+ /** Largest accepted password length. @default 128 */
1216
+ maxPasswordLength?: number;
1217
+ }
1218
+ interface FarmAuthSessionConfig {
1219
+ /** Session lifetime in seconds. @default 604800 */
1220
+ expiresIn?: number;
1221
+ /** Session refresh interval in seconds. @default 86400 */
1222
+ updateAge?: number;
1223
+ }
1224
+ interface FarmAuthDatabaseConfig {
1369
1225
  /**
1370
- * Path where the raw OpenAPI spec is served as JSON, so agents and API tools
1371
- * can fetch it at a predictable URL. Set to `false` to disable.
1372
- *
1373
- * @default "/openapi.json"
1226
+ * Postgres connection string. Defaults to DATABASE_URL.
1227
+ * Local development falls back to SQLite when no URL is present.
1374
1228
  */
1375
- specRoute?: string | false;
1376
- title?: string;
1377
- description?: string;
1378
- version?: string;
1379
- /** Default authentication requirement for operations without an endpoint override. */
1380
- security?: OpenAPISecurityMode;
1381
- servers?: Array<{
1382
- url: string;
1383
- description?: string;
1384
- }>;
1385
- contact?: {
1386
- name?: string;
1387
- email?: string;
1388
- url?: string;
1389
- };
1390
- license?: {
1391
- name: string;
1392
- url?: string;
1393
- };
1394
- }
1395
- type MiddlewareConfig = FarmMiddlewareConfig;
1396
- interface NotFoundConfig {
1397
- /** Path to a custom 404 page component (e.g., "./src/app/not-found.tsx") */
1398
- component?: string;
1229
+ url?: string;
1230
+ /** Local SQLite path. @default ".farm/auth.sqlite" */
1231
+ path?: string;
1232
+ /** Automatically update the auth schema in development. @default true */
1233
+ migrateInDevelopment?: boolean;
1399
1234
  }
1400
- type FarmDeployTarget = "vercel" | "cloudflare" | "netlify" | "node" | string;
1401
- interface FarmDeployConfig {
1235
+ interface FarmAuthConfig {
1236
+ /** Set false to disable auth without removing its configuration. @default true */
1237
+ enabled?: boolean;
1238
+ /** Display name used by authentication emails and metadata. */
1239
+ appName?: string;
1240
+ /** Route prefix for the auth endpoints. @default "/api/auth" */
1241
+ basePath?: string;
1402
1242
  /**
1403
- * Deployment platform. When present, Farm picks the matching Nitro preset and
1404
- * output directory unless explicitly overridden.
1243
+ * Email/password authentication. It is enabled by default; set false to
1244
+ * disable it when adding another sign-in method.
1405
1245
  */
1406
- target?: FarmDeployTarget;
1407
- /** Nitro preset override. Usually inferred from target. */
1408
- preset?: FarmConfig["preset"];
1409
- /** Deployable output directory, relative to project root unless absolute. */
1410
- outputDir?: string;
1411
- /** Alias for outputDir for terser config. */
1412
- output?: string;
1413
- /** Cloudflare Pages project name used by `farm deploy --cloudflare`. */
1414
- projectName?: string;
1415
- vercel?: {
1416
- outputDirectory?: string;
1417
- buildCommand?: string;
1418
- installCommand?: string;
1419
- framework?: string | null;
1246
+ emailAndPassword?: boolean | FarmAuthEmailAndPasswordConfig;
1247
+ session?: FarmAuthSessionConfig;
1248
+ database?: FarmAuthDatabaseConfig;
1249
+ }
1250
+ type FarmAuthUserConfig = boolean | FarmAuthConfig;
1251
+ interface ResolvedFarmAuthConfig {
1252
+ enabled: boolean;
1253
+ appName?: string;
1254
+ basePath: string;
1255
+ emailAndPassword: {
1256
+ enabled: boolean;
1257
+ requireEmailVerification: boolean;
1258
+ minPasswordLength: number;
1259
+ maxPasswordLength: number;
1420
1260
  };
1421
- cloudflare?: {
1422
- outputDir?: string;
1423
- projectName?: string;
1261
+ session: {
1262
+ expiresIn: number;
1263
+ updateAge: number;
1424
1264
  };
1425
- netlify?: {
1426
- outputDir?: string;
1427
- site?: string;
1265
+ database: {
1266
+ url?: string;
1267
+ path: string;
1268
+ migrateInDevelopment: boolean;
1428
1269
  };
1429
1270
  }
1430
- interface ResolvedFarmDeployConfig extends Omit<FarmDeployConfig, "output"> {
1431
- target?: FarmDeployTarget;
1432
- preset: FarmConfig["preset"];
1433
- outputDir: string;
1271
+
1272
+ type FarmPreloadMode = "warn" | "enforce";
1273
+ interface FarmPreloadUserConfig {
1274
+ /** Report excess hints or remove the lower-priority hints. @default "enforce" */
1275
+ mode?: FarmPreloadMode;
1276
+ /** Maximum image preload hints per document. @default 1 */
1277
+ maxImages?: number;
1278
+ /** Maximum font preload hints per document. @default 2 */
1279
+ maxFonts?: number;
1434
1280
  }
1435
- interface FarmUserConfig extends Omit<FarmConfig, "vite" | "docs" | "env" | "layers"> {
1436
- /** Reusable Farm directories or installed packages, applied from left to right. */
1437
- extends?: readonly FarmLayerEntry[];
1438
- /** Global plugins. Integration-bound plugins must be contributed through an integration. */
1439
- plugins?: FarmPlugin<any, any, any, any, unknown, false>[];
1440
- integrations?: FarmIntegrationsUserConfig;
1281
+ interface ResolvedFarmPreloadConfig {
1282
+ mode: FarmPreloadMode;
1283
+ maxImages: number;
1284
+ maxFonts: number;
1285
+ }
1286
+ interface FarmPerformanceConfig {
1287
+ preload?: FarmPreloadUserConfig;
1288
+ }
1289
+ interface ResolvedFarmPerformanceConfig {
1290
+ preload: ResolvedFarmPreloadConfig;
1291
+ }
1292
+ type FarmPreloadKind = "image" | "font";
1293
+ interface FarmPreloadBudgetWarning {
1294
+ kind: FarmPreloadKind;
1295
+ count: number;
1296
+ budget: number;
1297
+ removed: number;
1298
+ }
1299
+ interface FarmManagedPreloads {
1300
+ value: string;
1301
+ warnings: FarmPreloadBudgetWarning[];
1302
+ }
1303
+ interface FarmManagedDocumentPreloads {
1304
+ html: string;
1305
+ linkHeader: string;
1306
+ warnings: FarmPreloadBudgetWarning[];
1307
+ }
1308
+ /**
1309
+ * Apply image and font budgets to HTML preload elements. High-priority image
1310
+ * hints are retained before ordinary hints, making an explicitly preloaded LCP
1311
+ * image the winner when a document contains too many React-generated hints.
1312
+ */
1313
+ declare function manageFarmHtmlPreloads(html: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
1314
+ /** Apply the same budgets to HTTP Link preload hints, including Farm fonts. */
1315
+ declare function manageFarmLinkHeaderPreloads(value: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
1316
+ /** Apply a single document budget across HTML and HTTP Link header hints. */
1317
+ declare function manageFarmDocumentPreloads(html: string, linkHeader: string, config: ResolvedFarmPreloadConfig): FarmManagedDocumentPreloads;
1318
+ /** Rate-limit identical route-and-budget warnings within a server process. */
1319
+ declare function reportFarmPreloadWarnings(warnings: FarmPreloadBudgetWarning[], context?: string): void;
1320
+
1321
+ type FarmCspDirectiveValue = string | readonly string[] | boolean | null | undefined;
1322
+ type FarmCspDirectives = Readonly<Record<string, FarmCspDirectiveValue>>;
1323
+ interface FarmCspOptions {
1324
+ /** A pre-serialized CSP value. Cannot be combined with directives. */
1325
+ policy?: string;
1326
+ /** CSP directives using camelCase or kebab-case names. */
1327
+ directives?: FarmCspDirectives;
1328
+ /** Emit Content-Security-Policy-Report-Only instead of enforcing the policy. */
1329
+ reportOnly?: boolean;
1441
1330
  /**
1442
- * Farm-native authentication. `true` enables email/password auth with
1443
- * server helpers from `@farm.js/auth/server` and React APIs from
1444
- * `@farm.js/auth/client`.
1331
+ * Generate a fresh nonce for every dynamic HTML response and per-page
1332
+ * script hashes for prerendered HTML. Farm adds the matching sources to the
1333
+ * governing script directive and stamps dynamic script elements with the
1334
+ * response nonce.
1445
1335
  */
1446
- auth?: FarmAuthUserConfig;
1447
- /** Compose opted-in API routes and standalone tools through an authenticated MCP transport. */
1448
- mcp?: FarmMCPUserConfig;
1449
- /** Shared application data, route, ISR, and PPR cache. */
1450
- cache?: FarmCacheUserConfig;
1451
- migrations?: FarmMigrationsUserConfig;
1452
- /** Map portable cron schedules to ordinary GET API routes. */
1336
+ nonce?: boolean;
1337
+ }
1338
+ type FarmCspConfig = string | FarmCspOptions;
1339
+ interface FarmSecurityConfig {
1340
+ /** App-wide CSP for dynamic responses and prerendered output. */
1341
+ csp?: FarmCspConfig | false;
1342
+ /** @deprecated Use csp. */
1343
+ contentSecurityPolicy?: never;
1344
+ }
1345
+ interface ResolvedFarmCspConfig {
1346
+ value: string;
1347
+ reportOnly: boolean;
1348
+ nonce: boolean;
1349
+ }
1350
+ interface ResolvedFarmSecurityConfig {
1351
+ csp: ResolvedFarmCspConfig | false;
1352
+ }
1353
+ declare function resolveFarmSecurityConfig(input: FarmSecurityConfig | ResolvedFarmSecurityConfig | undefined): ResolvedFarmSecurityConfig;
1354
+ declare function applyFarmCspNonceToResponse(response: Response, security: ResolvedFarmSecurityConfig): Response;
1355
+
1356
+ declare const DEFAULT_FARM_API_BASE_PATH = "/api";
1357
+ interface FarmAPIConfigResolverContext {
1358
+ root: string;
1359
+ mode: "development" | "production";
1360
+ env: ResolvedFarmEnv;
1361
+ }
1362
+ type FarmAPIConfigValue = string | undefined | ((context: FarmAPIConfigResolverContext) => string | undefined | Promise<string | undefined>);
1363
+ interface FarmAPIConfig {
1364
+ /**
1365
+ * Public API root. An origin-only URL is joined with `basePath`; a URL that
1366
+ * already has a path is used as-is. May be resolved from deployment context.
1367
+ */
1368
+ baseURL?: FarmAPIConfigValue;
1369
+ /** Public API path and same-origin server mount used when `baseURL` has no path. @default "/api" */
1370
+ basePath?: FarmAPIConfigValue;
1371
+ }
1372
+ interface ResolvedFarmAPIConfig {
1373
+ /** Fully resolved public API root, either absolute or root-relative. */
1374
+ baseURL: string;
1375
+ /** Effective pathname of `baseURL`. */
1376
+ basePath: string;
1377
+ }
1378
+ declare function resolveFarmAPIConfig(config: FarmAPIConfig | undefined, context: FarmAPIConfigResolverContext): Promise<ResolvedFarmAPIConfig>;
1379
+ /** Normalize already-resolved API strings. */
1380
+ declare function normalizeFarmAPIConfig(config: {
1381
+ baseURL?: string;
1382
+ basePath?: string;
1383
+ } | undefined): ResolvedFarmAPIConfig;
1384
+ declare function normalizeFarmAPIBasePath(value: string): string;
1385
+ /** Read the API root embedded by Farm's Vite build. */
1386
+ declare function getFarmAPIBaseURL(): string;
1387
+ /** Resolve a canonical Farm route such as `/api/users` against an API root. */
1388
+ declare function resolveFarmAPIRequestURL(routePath: string, baseURL?: string, fallbackOrigin?: string): URL;
1389
+
1390
+ declare const FARM_RESOLVED_CUSTOM_CONTEXT: unique symbol;
1391
+
1392
+ interface RedirectConfig {
1393
+ source: string;
1394
+ destination: string;
1395
+ permanent?: boolean;
1396
+ statusCode?: FarmRedirectStatus;
1397
+ }
1398
+ interface HeaderConfig {
1399
+ source: string;
1400
+ headers: Array<{
1401
+ key: string;
1402
+ value: string;
1403
+ }>;
1404
+ }
1405
+ interface RewriteConfig {
1406
+ source: string;
1407
+ destination: string;
1408
+ }
1409
+ /** @deprecated Use FarmImageConfig. */
1410
+ type ImageConfig = FarmImageConfig;
1411
+ /** @deprecated Use FarmI18nUserConfig. */
1412
+ type I18nConfig = FarmI18nUserConfig;
1413
+ interface OpenAPIConfig {
1414
+ enabled?: boolean;
1415
+ route?: string;
1416
+ /**
1417
+ * Path where the raw OpenAPI spec is served as JSON, so agents and API tools
1418
+ * can fetch it at a predictable URL. Set to `false` to disable.
1419
+ *
1420
+ * @default "/openapi.json"
1421
+ */
1422
+ specRoute?: string | false;
1423
+ title?: string;
1424
+ description?: string;
1425
+ version?: string;
1426
+ /** Default authentication requirement for operations without an endpoint override. */
1427
+ security?: OpenAPISecurityMode;
1428
+ servers?: Array<{
1429
+ url: string;
1430
+ description?: string;
1431
+ }>;
1432
+ contact?: {
1433
+ name?: string;
1434
+ email?: string;
1435
+ url?: string;
1436
+ };
1437
+ license?: {
1438
+ name: string;
1439
+ url?: string;
1440
+ };
1441
+ }
1442
+ type MiddlewareConfig = FarmMiddlewareConfig;
1443
+ interface NotFoundConfig {
1444
+ /** Path to a custom 404 page component (e.g., "./src/app/not-found.tsx") */
1445
+ component?: string;
1446
+ }
1447
+ type FarmDeployTarget = "vercel" | "cloudflare" | "netlify" | "node" | string;
1448
+ interface FarmDeployConfig {
1449
+ /**
1450
+ * Deployment platform. When present, Farm picks the matching Nitro preset and
1451
+ * output directory unless explicitly overridden.
1452
+ */
1453
+ target?: FarmDeployTarget;
1454
+ /** Nitro preset override. Usually inferred from target. */
1455
+ preset?: FarmConfig["preset"];
1456
+ /** Deployable output directory, relative to project root unless absolute. */
1457
+ outputDir?: string;
1458
+ /** Alias for outputDir for terser config. */
1459
+ output?: string;
1460
+ /** Cloudflare Pages project name used by `farm deploy --cloudflare`. */
1461
+ projectName?: string;
1462
+ vercel?: {
1463
+ outputDirectory?: string;
1464
+ buildCommand?: string;
1465
+ installCommand?: string;
1466
+ framework?: string | null;
1467
+ };
1468
+ cloudflare?: {
1469
+ outputDir?: string;
1470
+ projectName?: string;
1471
+ };
1472
+ netlify?: {
1473
+ outputDir?: string;
1474
+ site?: string;
1475
+ };
1476
+ }
1477
+ interface ResolvedFarmDeployConfig extends Omit<FarmDeployConfig, "output"> {
1478
+ target?: FarmDeployTarget;
1479
+ preset: FarmConfig["preset"];
1480
+ outputDir: string;
1481
+ }
1482
+ interface FarmUserConfig extends Omit<FarmConfig, "vite" | "docs" | "env" | "layers"> {
1483
+ /** Reusable Farm directories or installed packages, applied from left to right. */
1484
+ extends?: readonly FarmLayerEntry[];
1485
+ /** Global plugins. Integration-bound plugins must be contributed through an integration. */
1486
+ plugins?: FarmPlugin<any, any, any, any, unknown, false>[];
1487
+ integrations?: FarmIntegrationsUserConfig;
1488
+ /**
1489
+ * Farm-native authentication. `true` enables email/password auth with
1490
+ * server helpers from `@farm.js/auth/server` and React APIs from
1491
+ * `@farm.js/auth/client`.
1492
+ */
1493
+ auth?: FarmAuthUserConfig;
1494
+ /** Compose opted-in API routes and standalone tools through an authenticated MCP transport. */
1495
+ mcp?: FarmMCPUserConfig;
1496
+ /** Shared application data, route, ISR, and PPR cache. */
1497
+ cache?: FarmCacheUserConfig;
1498
+ migrations?: FarmMigrationsUserConfig;
1499
+ /** Map portable cron schedules to ordinary GET API routes. */
1453
1500
  cron?: FarmCronUserConfig | FarmCronResolvedConfig | false;
1454
1501
  workflows?: FarmWorkflowsUserConfig | boolean;
1455
1502
  preset?: FarmConfig["preset"];
@@ -1591,7 +1638,7 @@ declare function shouldEmitFarmClientRootHmr(renderer?: FarmRenderer): boolean;
1591
1638
  declare function farmPlugin(options?: FarmVitePluginOptions, initialPluginManager?: PluginManager): Plugin$1;
1592
1639
  declare function defineConfig(config?: FarmVitePluginOptions): Promise<UserConfig>;
1593
1640
 
1594
- type MaybePromise$1<T> = T | Promise<T>;
1641
+ type MaybePromise<T> = T | Promise<T>;
1595
1642
  /** @internal Marks a Node response whose intercepted end is awaiting response hooks. */
1596
1643
  declare const FARM_NODE_RESPONSE_END_PENDING: unique symbol;
1597
1644
  declare const FARM_PLUGIN_INTEGRATION_INSTANCE: unique symbol;
@@ -1758,7 +1805,7 @@ interface FarmPluginRuntimeEndpointEvent<TState = unknown, TIntegrationInstance
1758
1805
  interface FarmPluginRuntimeEndpoint<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1759
1806
  /** Exact application-relative pathname, before Farm's configured basePath. */
1760
1807
  path: string;
1761
- handler(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeEndpointEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<Response>;
1808
+ handler(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeEndpointEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<Response>;
1762
1809
  }
1763
1810
  interface FarmPluginRuntimeBeforeEvent<TState = unknown, TRequestContext extends object = Record<string, unknown>, TIntegrationInstance = unknown> extends FarmPluginRuntimeBaseEvent<TState, TIntegrationInstance> {
1764
1811
  ctx: Readonly<TRequestContext>;
@@ -1782,19 +1829,19 @@ type FarmPluginRuntimeEventFor<TEvent, TIntegrationInstance, TIntegrationBound e
1782
1829
  interface FarmPluginRuntimeHooks<TState = unknown, TRequestContext extends object = Record<string, unknown>, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1783
1830
  /** Exact request endpoints owned by this plugin. */
1784
1831
  endpoints?: readonly FarmPluginRuntimeEndpoint<TState, TIntegrationInstance, TIntegrationBound>[];
1785
- start?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeStartEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1786
- context?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeContextEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<TRequestContext>;
1787
- before?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<Request | Response | void>;
1788
- after?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeAfterEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<Response | void>;
1789
- error?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeErrorEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1790
- close?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeCloseEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1832
+ start?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeStartEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1833
+ context?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeContextEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<TRequestContext>;
1834
+ before?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeBeforeEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<Request | Response | void>;
1835
+ after?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeAfterEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<Response | void>;
1836
+ error?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeErrorEvent<TState, TRequestContext, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1837
+ close?(event: FarmPluginRuntimeEventFor<FarmPluginRuntimeCloseEvent<TState, TIntegrationInstance>, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1791
1838
  }
1792
1839
  interface FarmPluginRuntimeRequestOptions {
1793
1840
  kind?: FarmPluginRuntimeKind;
1794
1841
  route?: FarmPluginRouteRuntimePayload;
1795
1842
  waitUntil?: (promise: Promise<unknown>) => void;
1796
1843
  }
1797
- type FarmPluginRuntimeRequestHandler = (request: Request) => MaybePromise$1<Response>;
1844
+ type FarmPluginRuntimeRequestHandler = (request: Request) => MaybePromise<Response>;
1798
1845
  interface FarmPluginRuntimeSession {
1799
1846
  request: Request;
1800
1847
  response?: Response;
@@ -1809,23 +1856,23 @@ type FarmPluginDiscoveredRoute = RouteDiscoveredPayload | ({
1809
1856
  kind: "api";
1810
1857
  } & APIRouteDiscoveredPayload);
1811
1858
  interface FarmPluginRouterHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1812
- discovered?(route: FarmPluginDiscoveredRoute, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1813
- generated?(routes: RoutesGeneratedPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1814
- before?(route: RouteMatchPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1815
- after?(result: RouteMatchResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1859
+ discovered?(route: FarmPluginDiscoveredRoute, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1860
+ generated?(routes: RoutesGeneratedPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1861
+ before?(route: RouteMatchPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1862
+ after?(result: RouteMatchResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1816
1863
  }
1817
1864
  interface FarmPluginRenderHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1818
- before?(render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1819
- html?(html: string, render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<string | void>;
1865
+ before?(render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1866
+ html?(html: string, render: RenderLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<string | void>;
1820
1867
  }
1821
1868
  interface FarmPluginBuildHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1822
- before?(bundle: BundleLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1823
- configure?(buildConfig: any, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<any>;
1824
- after?(result: BundleResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1869
+ before?(bundle: BundleLifecyclePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1870
+ configure?(buildConfig: any, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<any>;
1871
+ after?(result: BundleResultPayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1825
1872
  }
1826
1873
  interface FarmPluginDevHooks<TState = unknown, TIntegrationInstance = unknown, TIntegrationBound extends boolean = false> {
1827
- server?(viteServer: ViteDevServer, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1828
- update?(update: HMRUpdatePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise$1<void>;
1874
+ server?(viteServer: ViteDevServer, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1875
+ update?(update: HMRUpdatePayload, context: FarmPluginStateContextFor<TState, TIntegrationInstance, TIntegrationBound>): MaybePromise<void>;
1829
1876
  }
1830
1877
  interface FarmPluginClientConfig<TState = unknown, TPublic = undefined> extends FarmClientPlugin<TState, TPublic> {
1831
1878
  /** Explicitly public, JSON-safe data embedded in the browser bundle. */
@@ -1838,9 +1885,9 @@ interface FarmPlugin<TState = any, TRequestContext extends object = Record<strin
1838
1885
  /** Declarative API routes, mounted through the normal dev and production API pipeline. */
1839
1886
  routes?: PluginRoutesFactory<TRoutes>;
1840
1887
  /** Transform Farm config before the development or production pipeline is created. */
1841
- configure?: (config: FarmConfig, context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise$1<FarmConfig | void>;
1888
+ configure?: (config: FarmConfig, context: FarmPluginContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise<FarmConfig | void>;
1842
1889
  /** Initialize private plugin state once for this plugin manager. */
1843
- setup?: (context: FarmPluginSetupContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise$1<TState>;
1890
+ setup?: (context: FarmPluginSetupContextFor<TIntegrationInstance, TIntegrationBound>) => MaybePromise<TState>;
1844
1891
  runtime?: FarmPluginRuntimeHooks<TState, TRequestContext, TIntegrationInstance, TIntegrationBound>;
1845
1892
  router?: FarmPluginRouterHooks<TState, TIntegrationInstance, TIntegrationBound>;
1846
1893
  render?: FarmPluginRenderHooks<TState, TIntegrationInstance, TIntegrationBound>;
@@ -2000,9 +2047,9 @@ type FarmPluginDefinition<TState = undefined, TRequestContext extends object = R
2000
2047
  */
2001
2048
  options?: TSchema;
2002
2049
  /** Transform Farm config before the development or production pipeline is created. */
2003
- configure?: (config: FarmConfig, context: WithPluginOptions<FarmPluginContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise$1<FarmConfig | void>;
2050
+ configure?: (config: FarmConfig, context: WithPluginOptions<FarmPluginContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise<FarmConfig | void>;
2004
2051
  /** Initialize private plugin state once for this plugin manager. */
2005
- setup?: (context: WithPluginOptions<FarmPluginSetupContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise$1<TState>;
2052
+ setup?: (context: WithPluginOptions<FarmPluginSetupContextFor<TIntegrationInstance, false>, TSchema>) => MaybePromise<TState>;
2006
2053
  };
2007
2054
  type DefinedPlugin<TState, TRequestContext extends object, TClientState, TClientPublic, TIntegrationInstance, TRoutes extends PluginRoutes, TSchema> = FarmPlugin<ResolvedPluginState<TState, TSchema>, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, false, TRoutes>;
2008
2055
  /** The database a plugin's `schema` tables live in, when not `storage.client`. */
@@ -2041,482 +2088,698 @@ declare namespace definePlugin {
2041
2088
  function forIntegration<TIntegrationInstance>(): <TState = undefined, TRequestContext extends object = Record<string, never>, TClientState = unknown, TClientPublic = undefined>(plugin: FarmPlugin<TState, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, true>) => FarmPlugin<TState, TRequestContext, TClientState, TClientPublic, TIntegrationInstance, true>;
2042
2089
  }
2043
2090
 
2044
- type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
2045
- /** @deprecated Use FarmIntegrationCategory instead. */
2046
- type FarmIntegrationSlot = FarmIntegrationCategory;
2047
- type FarmIntegrationRouteParamValue = string | string[];
2048
- type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
2049
- type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
2050
- type FarmIntegrationRouteInputSource = "body" | "query";
2051
- type MaybePromise<T> = T | Promise<T>;
2052
- type FarmIntegrationValidationPathSegment = PropertyKey | {
2053
- readonly key: PropertyKey;
2054
- };
2055
- interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
2056
- body?: TBody;
2057
- query?: TQuery;
2091
+ /** A server-only endpoint reference. Config references must declare an explicit /api path. */
2092
+ type FarmMCPEndpoint = TypedEndpoint<any, any, any, any, any, any, any, any>;
2093
+ interface FarmMCPExecuteContext {
2094
+ /** The principal returned by authorize, or { subject: "anonymous" } for public servers. */
2095
+ readonly authorization: Readonly<FarmMCPAuthorization>;
2096
+ readonly request: Request;
2097
+ /** Observe this signal in cancellable work. Cancellation cannot undo side effects. */
2098
+ readonly signal: AbortSignal;
2058
2099
  }
2059
- interface FarmIntegrationValidationIssue {
2060
- source: FarmIntegrationRouteInputSource;
2061
- path?: readonly (string | number)[];
2062
- code?: string;
2063
- message: string;
2100
+ /** A server-only tool with no corresponding HTTP endpoint. */
2101
+ interface FarmMCPStandaloneTool<Schema extends RouteSchema = RouteSchema, Result = unknown, OutputSchema extends RouteSchema | undefined = undefined> extends EndpointMCPMetadata {
2102
+ name: string;
2103
+ /** Must describe an object and support input JSON Schema conversion. */
2104
+ inputSchema: Schema;
2105
+ /** Validate/transform returned data and advertise its output shape inside MCP's result envelope. */
2106
+ outputSchema?: OutputSchema;
2107
+ /** Return JSON-serializable data, not a Response or an MCP protocol envelope. */
2108
+ execute(input: RouteSchemaOutput<Schema>, context: FarmMCPExecuteContext): OutputSchema extends RouteSchema ? NoInfer<RouteSchemaInput<OutputSchema>> | Promise<NoInfer<RouteSchemaInput<OutputSchema>>> : Result | Promise<Result>;
2109
+ endpoint?: never;
2064
2110
  }
2065
- interface FarmIntegrationValidationErrorLike {
2066
- issues?: readonly {
2067
- path?: readonly FarmIntegrationValidationPathSegment[];
2068
- code?: string;
2069
- message?: string;
2070
- }[];
2071
- message?: string;
2111
+ /**
2112
+ * A createServerFn or createServerQuery function with `mcp` metadata. It runs through its own
2113
+ * input schema, middleware and output schema, with the MCP request as its request.
2114
+ */
2115
+ type FarmMCPServerFunction = ServerFn<any, any, any> | ServerQuery<any, any>;
2116
+ /** Compose endpoint references, server functions and standalone tools. */
2117
+ type FarmMCPToolDefinition = FarmMCPEndpoint | FarmMCPServerFunction | (EndpointMCPMetadata & {
2118
+ endpoint: FarmMCPEndpoint;
2119
+ execute?: never;
2120
+ }) | FarmMCPStandaloneTool<any, unknown, any>;
2121
+ /** Resolved tool identity, without handlers, validators, or a way to bypass authorization. */
2122
+ type FarmMCPTool = Readonly<EndpointMCPMetadata> & {
2123
+ readonly name: string;
2124
+ } & ({
2125
+ readonly kind: "endpoint";
2126
+ readonly method: RouteMethod;
2127
+ readonly path: string;
2128
+ } | {
2129
+ readonly kind: "standalone";
2130
+ readonly method?: never;
2131
+ readonly path?: never;
2132
+ } | {
2133
+ readonly kind: "serverFunction";
2134
+ readonly method?: never;
2135
+ readonly path?: never;
2136
+ });
2137
+ /** What a resource's `read` receives: the URI asked for, its template variables, and the caller. */
2138
+ interface FarmMCPResourceContext extends FarmMCPExecuteContext {
2139
+ readonly uri: URL;
2140
+ /** Values matched by `uriTemplate`; empty for a fixed `uri`. */
2141
+ readonly variables: Readonly<Record<string, string | string[]>>;
2072
2142
  }
2073
- type FarmIntegrationValidationResult<TValue> = {
2074
- success: true;
2075
- data: TValue;
2143
+ /**
2144
+ * One piece of resource content: a string (sent as `mimeType`, or text/plain),
2145
+ * text with its own type, JSON data, or binary data.
2146
+ */
2147
+ type FarmMCPResourceContent = string | {
2148
+ text: string;
2149
+ mimeType?: string;
2076
2150
  } | {
2077
- success: false;
2078
- error: FarmIntegrationValidationErrorLike;
2079
- };
2080
- type FarmIntegrationStandardValidationResult<TValue> = {
2081
- value: TValue;
2151
+ json: unknown;
2082
2152
  } | {
2083
- issues: readonly {
2084
- path?: readonly FarmIntegrationValidationPathSegment[];
2085
- code?: string;
2086
- message: string;
2087
- }[];
2153
+ blob: Uint8Array | ArrayBuffer;
2154
+ mimeType?: string;
2088
2155
  };
2089
- interface FarmIntegrationInputSchema<TValue = unknown> {
2090
- _output?: TValue;
2091
- parse?(value: unknown): MaybePromise<TValue>;
2092
- safeParse?(value: unknown): MaybePromise<FarmIntegrationValidationResult<TValue>>;
2093
- safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
2094
- "~standard"?: {
2095
- validate(value: unknown): MaybePromise<FarmIntegrationStandardValidationResult<TValue>>;
2096
- types?: {
2097
- output: TValue;
2098
- };
2099
- };
2100
- }
2101
- interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
2102
- body?: FarmIntegrationInputSchema<TBody>;
2103
- query?: FarmIntegrationInputSchema<TQuery>;
2156
+ /** One concrete URI a templated resource lists. */
2157
+ interface FarmMCPResourceListing {
2158
+ uri: string;
2159
+ name?: string;
2160
+ title?: string;
2161
+ description?: string;
2162
+ mimeType?: string;
2104
2163
  }
2105
- /** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
2106
- type FarmIntegrationRequestContextStore = FarmRequestStore;
2107
- declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
2108
2164
  /**
2109
- * Request-context key under which an integration middleware can hand
2110
- * `Set-Cookie` values to the runtime when it returns `void` (i.e. lets the
2111
- * request continue to the downstream route/page handler). The runtime reads
2112
- * this key back after a `void` middleware return and forwards the cookies onto
2113
- * the response it ultimately sends, so a server-side session refresh (or any
2114
- * other cookie rotation) reaches the browser instead of being dropped.
2165
+ * A server-only MCP resource: read-only context an agent can load, at a fixed
2166
+ * `uri` or at every URI matching an RFC 6570 `uriTemplate`.
2115
2167
  */
2116
- declare const FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
2168
+ interface FarmMCPResource {
2169
+ /** Stable name, used in authorization and in `authorize`'s `resources` allowlist. */
2170
+ name: string;
2171
+ title?: string;
2172
+ description?: string;
2173
+ mimeType?: string;
2174
+ /** A fixed absolute URI, such as `docs://handbook`. Set this or `uriTemplate`. */
2175
+ uri?: string;
2176
+ /** An RFC 6570 template, such as `notes://{id}`. Set this or `uri`. */
2177
+ uriTemplate?: string;
2178
+ /** For a template: the concrete resources to list. Omit to list none. */
2179
+ list?(context: FarmMCPExecuteContext): readonly FarmMCPResourceListing[] | Promise<readonly FarmMCPResourceListing[]>;
2180
+ /** Return the content, or null when the URI names nothing. */
2181
+ read(context: FarmMCPResourceContext): FarmMCPResourceContent | readonly FarmMCPResourceContent[] | null | Promise<FarmMCPResourceContent | readonly FarmMCPResourceContent[] | null>;
2182
+ }
2183
+ interface FarmMCPPromptMessage {
2184
+ role: "user" | "assistant";
2185
+ text: string;
2186
+ }
2117
2187
  /**
2118
- * Forward `Set-Cookie` values from an integration middleware that returns
2119
- * `void` (the authenticated/passthrough branch) to the runtime, so they are
2120
- * merged onto the response the runtime sends for the matched route. This is
2121
- * the passthrough counterpart to appending `Set-Cookie` to a `Response` the
2122
- * middleware returns directly (e.g. a failure redirect): both paths can rotate
2123
- * auth cookies, and both must be able to reach the browser.
2188
+ * A server-only MCP prompt: a reusable message template a client offers its
2189
+ * user. Arguments arrive as strings, as MCP sends them, and are validated by
2190
+ * `arguments` before `render` runs.
2124
2191
  */
2125
- declare function forwardIntegrationSetCookies(context: Pick<FarmIntegrationHandlerContext, "req">, cookies: string[]): void;
2126
- type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
2127
- interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2128
- getClient(): Promise<unknown | undefined>;
2129
- getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
2192
+ interface FarmMCPPrompt<Schema extends RouteSchema | undefined = RouteSchema | undefined> {
2193
+ /** Stable name: 1-128 letters, numbers, dots, underscores, or hyphens. */
2194
+ name: string;
2195
+ title?: string;
2196
+ description?: string;
2197
+ /** An object schema of string arguments. */
2198
+ arguments?: Schema;
2199
+ /** Return the prompt text, sent as one user message, or a list of messages. */
2200
+ render(args: Schema extends RouteSchema ? RouteSchemaOutput<Schema> : Record<string, never>, context: FarmMCPExecuteContext): string | readonly FarmMCPPromptMessage[] | Promise<string | readonly FarmMCPPromptMessage[]>;
2130
2201
  }
2131
- interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2132
- db: FarmIntegrationRouteDb<TSchema>;
2133
- getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
2134
- storage: FarmIntegrationRouteStorageArgs<TSchema>;
2202
+ interface FarmMCPServer {
2203
+ readonly name: string;
2204
+ readonly version: string;
2205
+ readonly path: `/api/${string}`;
2135
2206
  }
2136
- interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2137
- key: string;
2138
- integration: FarmIntegration<TSchema, any>;
2139
- appConfig: FarmPluginContext["config"];
2140
- /** Alias for appConfig. */
2141
- config: FarmPluginContext["config"];
2142
- args: FarmIntegrationRouteArgs<TSchema>;
2143
- env: Record<string, string | undefined>;
2144
- isDev: boolean;
2145
- isProd: boolean;
2207
+ interface FarmMCPAuthorization extends Record<string, unknown> {
2208
+ /** Stable application principal identifier. Never written to a response or log by Farm. */
2209
+ subject: string;
2210
+ scopes?: string[];
2211
+ /** Allowed tool names for this request. Omit for all configured tools; [] denies all tools. */
2212
+ tools?: readonly string[];
2213
+ /** Allowed resource names. Omit for all configured resources; [] denies all resources. */
2214
+ resources?: readonly string[];
2215
+ /** Allowed prompt names. Omit for all configured prompts; [] denies all prompts. */
2216
+ prompts?: readonly string[];
2146
2217
  }
2147
- interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2148
- schema?: FarmIntegrationInputSchema<TConfig>;
2149
- env?: Record<string, string | readonly string[]>;
2150
- defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
2151
- input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
2152
- resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise<TConfig | Partial<TConfig> | undefined>;
2218
+ interface FarmMCPAuthorizeContext {
2219
+ request: Request;
2220
+ /** Untrusted requested name for a tools/call; authorization runs separately for every JSON-RPC batch item. */
2221
+ tool?: string;
2222
+ /** Untrusted requested URI for a resources/read. */
2223
+ resource?: string;
2224
+ /** Untrusted requested name for a prompts/get. */
2225
+ prompt?: string;
2226
+ /** Complete configured catalog, before applying this caller's permissions. */
2227
+ tools: readonly FarmMCPTool[];
2228
+ /** Resolved transport identity, for policies shared by multiple MCP endpoints. */
2229
+ server: FarmMCPServer;
2153
2230
  }
2154
- type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
2155
- type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
2156
- interface FarmIntegrationLifecycleLogger {
2157
- info(message: string, meta?: Record<string, unknown>): void;
2158
- warn(message: string, meta?: Record<string, unknown>): void;
2159
- error(message: string, meta?: Record<string, unknown>): void;
2231
+ interface FarmMCPConfig {
2232
+ /** Set false to disable MCP without removing its configuration. @default true */
2233
+ enabled?: boolean;
2234
+ /** Canonical Farm API path for the Streamable HTTP endpoint. @default "/api/mcp" */
2235
+ path?: `/api/${string}`;
2236
+ /** MCP server identity. @default "farm-api" */
2237
+ name?: string;
2238
+ /** MCP server version. @default "1.0.0" */
2239
+ version?: string;
2240
+ /** Explicit endpoint/standalone tool allowlist. Omit to discover route-owned MCP metadata. */
2241
+ tools?: readonly FarmMCPToolDefinition[];
2242
+ /** Read-only context for agents, from `defineResource()`. */
2243
+ resources?: readonly FarmMCPResource[];
2244
+ /** Reusable prompt templates, from `definePrompt()`. */
2245
+ prompts?: readonly FarmMCPPrompt<any>[];
2246
+ /** Authorize every MCP request. Returning false responds with 401 before protocol handling. */
2247
+ authorize?: (context: FarmMCPAuthorizeContext) => FarmMCPAuthorization | false | Promise<FarmMCPAuthorization | false>;
2248
+ /** Deliberate escape hatch for public servers. Authentication is required by default. */
2249
+ allowUnauthenticated?: boolean;
2250
+ /**
2251
+ * OAuth discovery for MCP clients. When set, a rejected request's 401 points at
2252
+ * RFC 9728 Protected Resource Metadata naming these authorization servers, which
2253
+ * Farm serves at `/.well-known/oauth-protected-resource/<endpoint path>`.
2254
+ * Validating tokens stays in `authorize`.
2255
+ */
2256
+ oauth?: FarmMCPOAuthConfig;
2160
2257
  }
2161
- interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
2162
- integration: FarmIntegration<TSchema, TConfig>;
2163
- integrationConfig: TConfig;
2164
- log: FarmIntegrationLifecycleLogger;
2165
- reason?: string;
2166
- cleanup(callback?: () => MaybePromise<void>): Promise<void>;
2258
+ interface FarmMCPOAuthConfig {
2259
+ /** Issuer URLs of the OAuth authorization servers that issue tokens for this endpoint. */
2260
+ authorizationServers: readonly string[];
2261
+ /** Scopes clients may request, advertised as `scopes_supported` and in the 401 challenge. */
2262
+ scopes?: readonly string[];
2263
+ /** Human-readable name for consent screens. @default the MCP server name */
2264
+ resourceName?: string;
2265
+ }
2266
+ type FarmMCPUserConfig = FarmMCPConfig | false;
2267
+ interface ResolvedFarmMCPConfig extends FarmMCPConfig {
2268
+ enabled: boolean;
2167
2269
  }
2168
- type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise<void>;
2270
+
2169
2271
  /**
2170
- * Small per-call integration metadata. Values received over HTTP are
2171
- * client-controlled and should be validated before authorization decisions.
2272
+ * @internal Publishes one MCP server's tools, replacing an earlier catalog for
2273
+ * the same endpoint. Returns a function that removes it.
2172
2274
  */
2173
- type FarmIntegrationData = Record<string, unknown>;
2174
- interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2175
- request: Request;
2176
- requestId: string;
2177
- url: URL;
2178
- pathname: string;
2179
- method: string;
2180
- params: FarmIntegrationRouteParams;
2181
- input: FarmIntegrationRouteInput<TBody, TQuery>;
2182
- args: FarmIntegrationRouteArgs<TSchema>;
2183
- data: FarmIntegrationData;
2184
- integration: {
2185
- category: FarmIntegrationCategory;
2186
- /** @deprecated Use category instead. */
2187
- slot: FarmIntegrationCategory;
2188
- type: string;
2189
- instance: unknown;
2190
- };
2191
- route: {
2192
- kind: "route" | "middleware";
2193
- path: string;
2194
- methods: readonly string[];
2195
- };
2196
- req: FarmRequestStore;
2197
- /** @deprecated Use `req` instead. */
2198
- requestContext: FarmRequestStore;
2199
- config: FarmPluginContext["config"];
2200
- isDev: boolean;
2201
- isProd: boolean;
2275
+ declare function _publishFarmMCPCatalog(server: FarmMCPServer, tools: readonly FarmMCPTool[]): () => void;
2276
+ interface FarmMCPEndpointTool {
2277
+ /** The MCP tool name. */
2278
+ name: string;
2279
+ /** The public path of the MCP endpoint that serves the tool. */
2280
+ endpoint: string;
2202
2281
  }
2203
- interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
2204
- response?: Response;
2282
+ /**
2283
+ * @internal Finds the MCP tool that runs the API endpoint a request to
2284
+ * `method pathname` reaches, if a published catalog exposes one.
2285
+ * `serverBasePath` is the app's public API path, which maps to `/api`.
2286
+ */
2287
+ declare function _findFarmMCPEndpointTool(method: string, pathname: string, serverBasePath?: string): FarmMCPEndpointTool | undefined;
2288
+
2289
+ /** Content type for Markdown responses, including agent-facing error bodies. */
2290
+ declare const FARM_MARKDOWN_CONTENT_TYPE = "text/markdown; charset=utf-8";
2291
+ declare function farmRequestWantsMarkdown(pathname: string, accept: string | null | undefined): boolean;
2292
+ declare function createFarmMarkdownErrorBody(status: number, pathname: string, homeHref?: string): string;
2293
+ type FarmMarkdownRouteInput = string | {
2294
+ route: string;
2295
+ title?: string;
2296
+ cache?: number | false;
2297
+ };
2298
+ interface FarmMarkdownUserConfig {
2299
+ /**
2300
+ * Enable generated markdown representations for React pages.
2301
+ * @default true
2302
+ */
2303
+ enabled?: boolean;
2304
+ /**
2305
+ * Routes that may expose generated markdown. Every page is exposed by default.
2306
+ */
2307
+ expose?: boolean | FarmMarkdownRouteInput[];
2308
+ /** @deprecated Use `expose`. */
2309
+ routes?: FarmMarkdownRouteInput[];
2310
+ cache?: number | false;
2311
+ includeMetadata?: boolean;
2205
2312
  }
2206
- type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
2207
- bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
2208
- }["bivarianceHack"];
2209
- interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2210
- path: string;
2211
- method?: FarmIntegrationRouteMethod;
2212
- methods?: readonly FarmIntegrationRouteMethod[];
2213
- middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
2214
- before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2215
- after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2216
- rawBody?: boolean;
2217
- bodyFormat?: FarmIntegrationAPIBodyFormat;
2218
- body?: FarmIntegrationInputSchema<TBody>;
2219
- query?: FarmIntegrationInputSchema<TQuery>;
2220
- input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
2221
- handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
2313
+ interface FarmMarkdownResolvedRoute {
2314
+ route: string;
2315
+ title?: string;
2316
+ cache?: number | false;
2222
2317
  }
2223
- interface FarmTypedIntegrationRoute<TPath extends string = string, TBody = never, TQuery = never, TResponse = unknown, TServer extends boolean = false, TMethod extends FarmIntegrationAPIMethod = FarmIntegrationAPIMethod, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoute<TBody, TQuery, TSchema> {
2224
- path: TPath;
2225
- method: TMethod;
2226
- __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
2318
+ interface FarmMarkdownResolvedConfig {
2319
+ enabled: boolean;
2320
+ expose: true | FarmMarkdownResolvedRoute[];
2321
+ cache: number | false;
2322
+ includeMetadata: boolean;
2227
2323
  }
2228
- interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2229
- handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
2324
+ interface FarmMarkdownMirrorTarget {
2325
+ pathname: string;
2326
+ route: FarmMarkdownResolvedRoute | null;
2230
2327
  }
2231
- interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2232
- matcher?: string | string[];
2233
- handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
2328
+ interface ResolveMarkdownMirrorTargetOptions {
2329
+ accept?: string | null;
2234
2330
  }
2235
- interface FarmIntegrationProviderProps {
2236
- children: ReactNode;
2331
+ interface CreateMarkdownMirrorResponseOptions {
2332
+ request: Request;
2333
+ /** @internal Reuse a parse only while its href still matches this request. */
2334
+ requestUrl?: URL;
2335
+ config?: FarmMarkdownResolvedConfig;
2336
+ routeExists?: (pathname: string) => boolean;
2337
+ renderPage: (request: Request) => Response | Promise<Response>;
2338
+ /** The app's public API path, so a form posting to an API route can be matched to its MCP tool. */
2339
+ apiServerBasePath?: string;
2340
+ }
2341
+ interface ApplyMarkdownNegotiationHeadersOptions {
2342
+ config?: FarmMarkdownResolvedConfig;
2343
+ pathname: string;
2237
2344
  }
2238
- interface FarmIntegrationProviderComponentReference {
2239
- /** Client-safe module specifier using `@/`, a path relative to the app root, or a package. */
2240
- module: string;
2241
- /** Named export to use. Defaults to the module's default export. */
2242
- export?: string;
2345
+ declare function resolveMarkdownConfig(config: FarmMarkdownUserConfig | boolean | undefined): FarmMarkdownResolvedConfig;
2346
+ declare function resolveMarkdownMirrorTarget(config: FarmMarkdownResolvedConfig | undefined, pathname: string, options?: ResolveMarkdownMirrorTargetOptions): FarmMarkdownMirrorTarget | null;
2347
+ declare function createMarkdownMirrorResponse(options: CreateMarkdownMirrorResponseOptions): Promise<Response | null>;
2348
+ declare function applyMarkdownNegotiationHeaders(response: Response, options: ApplyMarkdownNegotiationHeadersOptions): Response;
2349
+ declare function htmlToMarkdown(html: string, options?: {
2350
+ title?: string;
2351
+ sourcePath?: string;
2352
+ includeMetadata?: boolean;
2353
+ /** Where the page's forms are described, listed when the page has any. */
2354
+ actionsPath?: string;
2355
+ }): string;
2356
+ /**
2357
+ * Quality value an `Accept` header assigns a media type, or 0 when the client
2358
+ * will not take it.
2359
+ *
2360
+ * `q=0` means "not acceptable" per RFC 9110, so it has to be distinguished from
2361
+ * an absent entry rather than treated as a match. Wildcards are opt-in: a client
2362
+ * sending `*&#47;*` will take anything, which says nothing about whether it would
2363
+ * rather have Markdown than HTML, so callers negotiating between two concrete
2364
+ * types should ask for exact entries only.
2365
+ */
2366
+ declare function farmAcceptQuality(accept: string | null | undefined, mediaType: string, options?: {
2367
+ wildcards?: boolean;
2368
+ }): number;
2369
+ declare function requestAcceptsMarkdown(accept: string | null | undefined): boolean;
2370
+ /** @internal The `.md` URL that serves a page's Markdown mirror. */
2371
+ declare function getFarmMarkdownMirrorPath(pathname: string): string;
2372
+ /**
2373
+ * @internal The `.md` URL to advertise for the HTML page at `pathname`, or
2374
+ * null when it has no Markdown mirror. Both the `Link` response header and the
2375
+ * `<link rel="alternate">` in the document head come from this.
2376
+ */
2377
+ declare function getFarmMarkdownAlternatePath(config: FarmMarkdownResolvedConfig | undefined, pathname: string): string | null;
2378
+ /** @internal Whether `pathname` has a Markdown mirror under `config`. */
2379
+ declare function isFarmMarkdownMirrorExposed(config: FarmMarkdownResolvedConfig | undefined, pathname: string): boolean;
2380
+ /** @internal Matches a page pathname against a route pattern such as `/docs/[...slug]`. */
2381
+ declare function matchesFarmMarkdownRoutePattern(pattern: string, pathname: string): boolean;
2382
+ interface FarmPageFormOption {
2383
+ value: string;
2384
+ label?: string;
2385
+ selected?: true;
2243
2386
  }
2244
- interface FarmIntegrationProvider {
2387
+ interface FarmPageFormField {
2245
2388
  name: string;
2389
+ /** The input type, or `select`, `textarea`, `radio`, or `checkbox` for a group. */
2246
2390
  type: string;
2247
- props?: Record<string, unknown>;
2391
+ label?: string;
2392
+ required?: true;
2393
+ multiple?: true;
2394
+ /** A preset value: always present for hidden fields. */
2395
+ value?: string;
2396
+ checked?: true;
2397
+ /** Choices of a select, or of radio buttons and checkboxes sharing a name. */
2398
+ options?: FarmPageFormOption[];
2399
+ placeholder?: string;
2400
+ pattern?: string;
2401
+ min?: string;
2402
+ max?: string;
2403
+ step?: string;
2404
+ minLength?: number;
2405
+ maxLength?: number;
2406
+ accept?: string;
2407
+ }
2408
+ interface FarmPageFormSubmit {
2409
+ label: string;
2410
+ name?: string;
2411
+ value?: string;
2412
+ /** Set when the button submits somewhere other than its form (`formaction`). */
2413
+ action?: string;
2414
+ method?: string;
2415
+ }
2416
+ interface FarmPageFormAction {
2417
+ type: "form";
2418
+ name?: string;
2419
+ method: "GET" | "POST";
2248
2420
  /**
2249
- * The provider can be instantiated independently around each isolated
2250
- * client root without relying on context or state owned by the route root.
2251
- * Providers are treated as route-wide unless they explicitly opt in.
2421
+ * Where the form submits: a root-relative URL on the page's origin, or an
2422
+ * absolute URL elsewhere. Absent when the form only submits with JavaScript.
2252
2423
  */
2253
- supportsIsolatedHydration?: boolean;
2254
- component?: ComponentType<FarmIntegrationProviderProps> | FarmIntegrationProviderComponentReference;
2424
+ action?: string;
2425
+ /** Present for POST forms. */
2426
+ enctype?: string;
2427
+ requiresJavaScript?: true;
2428
+ fields: FarmPageFormField[];
2429
+ submit: FarmPageFormSubmit[];
2430
+ /** A React server action form: the id React put in its hidden `$ACTION_` fields. */
2431
+ serverAction?: {
2432
+ id: string;
2433
+ };
2434
+ /**
2435
+ * The MCP tool that runs the same API endpoint, when `@farm.js/mcp` exposes
2436
+ * it: the tool `name` and the MCP `endpoint` to call it at. The caller's
2437
+ * `authorize` policy still decides whether that tool is available to it.
2438
+ */
2439
+ tool?: FarmMCPEndpointTool;
2255
2440
  }
2256
- interface FarmIntegrationDocumentNavigation {
2257
- matcher: string | readonly string[];
2441
+ /**
2442
+ * Describes the forms in the part of the page the mirror reads, so an agent can
2443
+ * see what it can submit: where, how, and with which fields. Controls that are
2444
+ * disabled are left out, since a browser would not submit them; hidden fields
2445
+ * keep their values, so a submission without JavaScript can be replayed.
2446
+ */
2447
+ declare function extractFarmPageActions(html: string, pageUrl: URL): FarmPageFormAction[];
2448
+
2449
+ interface FarmLlmsTxtLink {
2450
+ title: string;
2451
+ url: string;
2452
+ description?: string;
2258
2453
  }
2259
- /** @deprecated Use `FarmSchemaFieldType`. */
2260
- type FarmIntegrationSchemaFieldType = FarmSchemaFieldType;
2261
- /** @deprecated Use `FarmSchemaReference`. */
2262
- type FarmIntegrationSchemaReference = FarmSchemaReference;
2263
- /** @deprecated Use `FarmSchemaField`. */
2264
- type FarmIntegrationSchemaField = FarmSchemaField;
2265
- /** @deprecated Use `FarmSchemaConstraint`. */
2266
- type FarmIntegrationSchemaConstraint = FarmSchemaConstraint;
2267
- /** @deprecated Use `FarmSchemaModel`. */
2268
- type FarmIntegrationSchemaModel = FarmSchemaModel;
2269
- /** @deprecated Use `FarmSchemaModelExtension`. */
2270
- type FarmIntegrationSchemaModelExtension = FarmSchemaModelExtension;
2271
- /** @deprecated Use `FarmSchemaModelOverride`. */
2272
- type FarmIntegrationSchemaModelOverride = FarmSchemaModelOverride;
2273
- /** @deprecated Use `FarmSchema`. */
2274
- type FarmIntegrationSchema = FarmSchema;
2275
- /** @deprecated Use `defineSchema`. This is an exact alias, not a wrapper. */
2276
- declare const defineIntegrationSchema: typeof defineSchema;
2277
- type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
2278
- interface FarmIntegrationLogEvent {
2279
- category: FarmIntegrationCategory;
2280
- /** @deprecated Use category instead. */
2281
- slot: FarmIntegrationCategory;
2282
- type: string;
2283
- phase: FarmIntegrationLogPhase;
2284
- route?: {
2285
- kind: "route" | "middleware";
2286
- path: string;
2287
- methods: readonly string[];
2288
- };
2289
- requestId?: string;
2290
- request?: Request;
2291
- response?: Response;
2292
- error?: unknown;
2293
- durationMs?: number;
2294
- level?: FarmIntegrationLifecycleLogLevel;
2295
- message?: string;
2296
- meta?: Record<string, unknown>;
2297
- context: Map<string, unknown>;
2454
+ interface FarmLlmsTxtSection {
2455
+ title: string;
2456
+ links: FarmLlmsTxtLink[];
2298
2457
  }
2299
- type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
2300
- interface FarmIntegrationPluginOwner {
2301
- key: string;
2302
- category: FarmIntegrationCategory;
2303
- type: string;
2304
- source: "lifecycle" | "contribution";
2305
- serverRuntime: boolean;
2458
+ interface FarmLlmsTxt {
2459
+ /** Site or project name, rendered as the `# H1`. Required by the format. */
2460
+ title: string;
2461
+ /** One-sentence summary, rendered as a `> blockquote`. */
2462
+ summary?: string;
2463
+ /** Free-form Markdown placed after the summary. */
2464
+ details?: string;
2465
+ /** `## H2` sections of links. A section titled "Optional" marks skippable links. */
2466
+ sections?: FarmLlmsTxtSection[];
2306
2467
  }
2307
- /** A normal plugin or an integration-bound plugin compatible with the shared instance. */
2308
- type FarmIntegrationContributedPlugin<TInstance = unknown> = FarmPlugin<any, any, any, any, unknown, false> | FarmPlugin<any, any, any, any, TInstance, true>;
2309
- interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> {
2310
- readonly kind: "farm-integration";
2311
- category: FarmIntegrationCategory;
2312
- /** @deprecated Use category instead. */
2313
- slot?: FarmIntegrationCategory;
2314
- type: string;
2315
- instance: TInstance;
2316
- /** Set to false when a platform adapter owns this integration's production routes. */
2317
- serverRuntime?: boolean;
2318
- api?: FarmIntegrationAPI;
2319
- schema?: TSchema;
2320
- config?: FarmIntegrationConfigInput<TConfig, TSchema>;
2321
- validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2322
- setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2323
- ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2324
- dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2325
- log?: FarmIntegrationLogger;
2326
- routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
2327
- endpoints?: FarmIntegrationEndpoints<TSchema>;
2328
- middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
2329
- providers?: readonly FarmIntegrationProvider[];
2330
- documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
2331
- /** Additional Farm plugins owned and configured by this integration. */
2332
- plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
2468
+ /** A static page of the app, ready to use as an llms.txt link. */
2469
+ interface FarmLlmsTxtPage extends FarmLlmsTxtLink {
2470
+ /** The page's route path, such as `/docs/install`. */
2471
+ path: string;
2333
2472
  }
2334
- type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any, any> | undefined>;
2335
- /** @internal Identifies plugins owned by platform-managed integrations. */
2336
- declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
2337
- /** Returns the integration that contributed a normalized plugin, when applicable. */
2338
- declare function getFarmIntegrationPluginOwner(plugin: FarmPlugin): Readonly<FarmIntegrationPluginOwner> | undefined;
2339
- type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
2340
- middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
2341
- before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2342
- after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2343
- rawBody?: boolean;
2344
- headers?: Record<string, string>;
2345
- credentials?: RequestCredentials;
2346
- bodyFormat?: FarmIntegrationAPIBodyFormat;
2347
- responseFormat?: FarmIntegrationAPIResponseFormat;
2348
- isServer?: TServer;
2349
- body?: FarmIntegrationInputSchema<TBody>;
2350
- query?: FarmIntegrationInputSchema<TQuery>;
2351
- input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
2352
- handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
2353
- };
2354
- interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2355
- get<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "GET", TSchema>;
2356
- post<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "POST", TSchema>;
2357
- query<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "QUERY", TSchema>;
2358
- put<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PUT", TSchema>;
2359
- patch<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "PATCH", TSchema>;
2360
- delete<TPath extends string, TBody = never, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: IntegrationRouteBuilderOptions<TBody, TQuery, TServer, TSchema>): FarmTypedIntegrationRoute<TPath, TBody, TQuery, TResponse, TServer, "DELETE", TSchema>;
2361
- options<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "OPTIONS", TSchema>;
2362
- head<TPath extends string, TResponse = unknown, TQuery = never, TServer extends boolean = false>(path: TPath, input: Omit<IntegrationRouteBuilderOptions<never, TQuery, TServer, TSchema>, "bodyFormat">): FarmTypedIntegrationRoute<TPath, never, TQuery, TResponse, TServer, "HEAD", TSchema>;
2473
+ interface FarmLlmsTxtUserConfig {
2474
+ /** Set to `false` to turn llms.txt off while keeping these options. */
2475
+ enabled?: boolean;
2476
+ /** Site name for the `# H1`. Defaults to the root layout's metadata title. */
2477
+ title?: string;
2478
+ /** Summary for the `> blockquote`. Defaults to the root layout's metadata description. */
2479
+ summary?: string;
2480
+ /** Markdown placed after the summary. */
2481
+ details?: string;
2482
+ /**
2483
+ * Route patterns to list, using the same syntax as `md.expose`
2484
+ * (`/docs/[...slug]`). Defaults to every static page.
2485
+ */
2486
+ include?: string[];
2487
+ /** Route patterns to leave out, such as `/admin/[...path]`. */
2488
+ exclude?: string[];
2489
+ /**
2490
+ * Also serve `/llms-full.txt`, the index with each page's Markdown mirror inlined.
2491
+ *
2492
+ * @default true
2493
+ */
2494
+ full?: boolean;
2495
+ /**
2496
+ * Seconds a CDN may cache the generated files, and the production server may
2497
+ * reuse an llms-full.txt render, which renders every listed page. Defaults to
2498
+ * no caching; concurrent llms-full.txt requests still share one render.
2499
+ */
2500
+ revalidate?: number;
2363
2501
  }
2364
- interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2365
- route: FarmIntegrationRouteFactory<TSchema>;
2366
- integrationRoute: FarmIntegrationRouteFactory<TSchema>;
2502
+ interface ResolvedFarmLlmsTxtConfig {
2503
+ enabled: boolean;
2504
+ title?: string;
2505
+ summary?: string;
2506
+ details?: string;
2507
+ include: string[];
2508
+ exclude: string[];
2509
+ full: boolean;
2510
+ revalidate?: number;
2367
2511
  }
2368
- type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
2369
- type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
2370
- readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
2371
- };
2372
- type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
2373
- readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
2374
- };
2375
- interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
2376
- endpoint: FarmIntegrationRouteFactory<TSchema>;
2512
+ interface FarmLlmsTxtPageSource {
2513
+ pattern: string;
2514
+ metadata?: unknown;
2377
2515
  }
2378
- type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
2379
- declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
2380
- declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
2381
- type RegisteredIntegrationRuntime = {
2382
- integration: FarmIntegration;
2383
- config: FarmPluginContext["config"];
2384
- isDev: boolean;
2385
- isProd: boolean;
2386
- };
2387
- type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
2388
- type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
2389
- type FarmIntegrationInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> = Omit<FarmIntegration<TSchema, TConfig, TInstance>, "kind" | "category" | "slot" | "instance" | "config" | "routes" | "endpoints" | "plugins"> & {
2390
- instance: TInstance;
2391
- config?: FarmIntegrationConfigInput<TConfig, TSchema>;
2392
- routes?: FarmIntegrationRoutesInput<TSchema>;
2393
- endpoints?: FarmIntegrationEndpointsInput<TSchema>;
2394
- plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
2395
- } & ({
2396
- category: FarmIntegrationCategory;
2397
- slot?: FarmIntegrationCategory;
2398
- } | {
2399
- category?: FarmIntegrationCategory;
2400
- slot: FarmIntegrationCategory;
2401
- });
2402
- type FarmIntegrationCategoryInput = {
2403
- category: FarmIntegrationCategory;
2404
- slot?: FarmIntegrationCategory;
2405
- } | {
2406
- category?: FarmIntegrationCategory;
2407
- slot: FarmIntegrationCategory;
2408
- };
2409
- type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
2410
- api?: FarmIntegrationAPI;
2411
- schema?: FarmIntegrationSchema;
2412
- config?: unknown;
2413
- routes?: unknown;
2414
- endpoints?: unknown;
2415
- };
2416
- type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
2417
- schema: infer TSchema extends FarmIntegrationSchema;
2418
- } ? TSchema : undefined;
2419
- type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
2420
- type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
2421
- type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
2422
- type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
2423
- type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
2424
- type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
2425
- routes: infer TRoutes;
2426
- } ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
2427
- endpoints: infer TEndpoints;
2428
- } ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
2429
- type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
2430
- type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
2431
- endpoints: infer TEndpoints;
2432
- } ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
2433
- type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
2434
- type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
2435
- category: infer TCategory extends FarmIntegrationCategory;
2436
- } ? TCategory : TIntegration extends {
2437
- slot: infer TSlot extends FarmIntegrationCategory;
2438
- } ? TSlot : FarmIntegrationCategory;
2439
- type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
2440
- api: infer TAPI extends FarmIntegrationAPI;
2441
- } ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
2442
- type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
2443
- readonly kind: "farm-integration";
2444
- category: ExtractIntegrationCategory<TIntegration>;
2445
- slot: ExtractIntegrationCategory<TIntegration>;
2446
- routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
2447
- endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
2448
- api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
2449
- };
2450
- declare function defineIntegration<const TSchema extends FarmIntegrationSchema | undefined, const TConfig, TIntegration extends FarmIntegrationInput<TSchema, TConfig, any>>(integration: TIntegration & FarmIntegrationInput<TSchema, TConfig, NoInfer<TIntegration["instance"]>>): DefinedIntegration<TIntegration, TSchema>;
2451
- declare function isFarmIntegration(value: unknown): value is FarmIntegration;
2452
- declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
2453
- declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): FarmIntegrationProvider[];
2454
- declare function isFarmIntegrationProviderComponentReference(value: FarmIntegrationProvider["component"]): value is FarmIntegrationProviderComponentReference;
2455
- declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
2456
- declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
2457
- declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
2458
- declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
2459
- declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
2460
- declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
2461
- pathname: string;
2462
- method?: string;
2463
- }): {
2464
- key: string;
2465
- integration: FarmIntegration;
2466
- route: {
2467
- path: string;
2468
- methods: readonly string[];
2469
- };
2470
- params: FarmIntegrationRouteParams;
2471
- } | null;
2472
- declare function matchRegisteredIntegrationRoute(input: {
2473
- pathname: string;
2474
- method?: string;
2475
- }): {
2476
- key: string;
2477
- integration: FarmIntegration;
2478
- route: {
2479
- path: string;
2480
- methods: readonly string[];
2481
- };
2482
- params: FarmIntegrationRouteParams;
2483
- } | null;
2484
- declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
2485
- declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
2486
- currentRequest?: Request;
2487
- data?: FarmIntegrationData;
2488
- internal?: boolean;
2516
+ declare function collectFarmLlmsTxtPages(sources: Iterable<FarmLlmsTxtPageSource>, options: {
2517
+ origin: string;
2518
+ basePath?: string;
2519
+ markdown?: FarmMarkdownResolvedConfig;
2520
+ include?: string[];
2521
+ exclude?: string[];
2522
+ }): FarmLlmsTxtPage[];
2523
+ declare function createFarmDefaultLlmsTxt(options: {
2524
+ origin: string;
2525
+ pages: FarmLlmsTxtPage[];
2526
+ config: ResolvedFarmLlmsTxtConfig;
2527
+ rootMetadata?: unknown;
2528
+ }): FarmLlmsTxt;
2529
+ /**
2530
+ * Reads a page's Markdown the way an agent would: a fresh `.md` request with no
2531
+ * cookies or credentials, so a page behind auth answers 401 and is left out of
2532
+ * a file that CDNs may cache, instead of leaking into it.
2533
+ */
2534
+ declare function createFarmLlmsMarkdownReader(fetchMarkdown: (request: Request) => Promise<Response>): (url: string) => Promise<string | null>;
2535
+ /**
2536
+ * Renders llms-full.txt: the llms.txt header, then one block per linked page with
2537
+ * its Markdown inlined, in the layout the docs engine uses. A string passes
2538
+ * through unchanged. Only same-origin links are fetched.
2539
+ */
2540
+ declare function renderFarmLlmsFullTxt(value: unknown, options: {
2541
+ origin: string;
2542
+ readMarkdown: (url: string) => Promise<string | null>;
2543
+ concurrency?: number;
2544
+ /** Milliseconds to wait for one page's Markdown before leaving it out. */
2545
+ pageTimeout?: number;
2546
+ /** Called when a page is left out because it did not answer in time. */
2547
+ onIncomplete?: () => void;
2548
+ }): Promise<string>;
2549
+ /**
2550
+ * Shares llms-full.txt renders, which read every listed page. Requests for the
2551
+ * same origin while a render runs, or within `revalidate` seconds after it, get
2552
+ * that result; renders run one at a time, so a burst of requests, even with
2553
+ * varied Host headers, cannot multiply page renders. The content is the same for
2554
+ * every caller: pages are read with fresh requests that carry no credentials.
2555
+ * A render that calls `incomplete()`, because a page timed out, is answered but
2556
+ * not reused, so the next request tries that page again.
2557
+ */
2558
+ declare function createFarmLlmsFullRenderer(options?: {
2559
+ revalidate?: number;
2560
+ now?: () => number;
2561
+ maxEntries?: number;
2562
+ }): (origin: string, render: (shared: {
2563
+ incomplete: () => void;
2564
+ }) => Promise<string>, onSettled?: (complete: boolean) => void) => Promise<string>;
2565
+
2566
+ type ApplicationMetadataRouteKind = "sitemap" | "robots" | "manifest" | "llms" | "llms-full";
2567
+ declare namespace MetadataRoute {
2568
+ type SitemapChangeFrequency = "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
2569
+ interface SitemapEntry {
2570
+ url: string;
2571
+ lastModified?: string | Date;
2572
+ changeFrequency?: SitemapChangeFrequency;
2573
+ priority?: number;
2574
+ alternates?: {
2575
+ languages?: Record<string, string>;
2576
+ };
2577
+ }
2578
+ type Sitemap = SitemapEntry[];
2579
+ interface RobotsRule {
2580
+ userAgent: string | string[];
2581
+ allow?: string | string[];
2582
+ disallow?: string | string[];
2583
+ crawlDelay?: number;
2584
+ }
2585
+ interface Robots {
2586
+ rules: RobotsRule | RobotsRule[];
2587
+ sitemap?: string | string[];
2588
+ host?: string;
2589
+ }
2590
+ interface ManifestIcon {
2591
+ src: string;
2592
+ sizes?: string;
2593
+ type?: string;
2594
+ purpose?: string;
2595
+ }
2596
+ interface Manifest {
2597
+ name?: string;
2598
+ short_name?: string;
2599
+ description?: string;
2600
+ id?: string;
2601
+ start_url?: string;
2602
+ scope?: string;
2603
+ display?: "fullscreen" | "standalone" | "minimal-ui" | "browser" | string;
2604
+ orientation?: string;
2605
+ background_color?: string;
2606
+ theme_color?: string;
2607
+ lang?: string;
2608
+ dir?: "ltr" | "rtl" | "auto";
2609
+ categories?: string[];
2610
+ icons?: ManifestIcon[];
2611
+ [key: string]: unknown;
2612
+ }
2489
2613
  /**
2490
- * Receives `Set-Cookie` values that a middleware forwarded via
2491
- * forwardIntegrationSetCookies while returning `void`, when this dispatch
2492
- * ends without a Response of its own. The request continues downstream, so
2493
- * the caller owns merging them onto whatever response it finally produces.
2494
- * Only called on the `null` return path: a Response returned from here has
2495
- * already had the forwarded cookies appended.
2614
+ * The object an `llms.ts` metadata route returns, rendered as llms.txt. An
2615
+ * `llms.ts` can also return the complete file as a string, or a `Response`.
2496
2616
  */
2497
- onForwardedCookies?: (cookies: string[]) => void;
2498
- }): Promise<Response | null>;
2617
+ type LlmsTxt = FarmLlmsTxt;
2618
+ type LlmsTxtSection = FarmLlmsTxtSection;
2619
+ type LlmsTxtLink = FarmLlmsTxtLink;
2620
+ /** A static page of the app, usable directly as an llms.txt link. */
2621
+ type LlmsTxtPage = FarmLlmsTxtPage;
2622
+ /** What an `llms.ts` default-export function receives. */
2623
+ interface LlmsTxtContext extends MetadataRouteContext {
2624
+ /** The app's static pages, linking to their Markdown mirrors when exposed. */
2625
+ pages: LlmsTxtPage[];
2626
+ /** The llms.txt that `agent.llmsTxt` would serve, to extend instead of replace. */
2627
+ defaults: LlmsTxt;
2628
+ }
2629
+ /**
2630
+ * What an `llms-full.ts` default-export function receives. Returning an
2631
+ * `LlmsTxt` object inlines each same-origin link's Markdown; returning a string
2632
+ * serves it as the complete file.
2633
+ */
2634
+ interface LlmsFullTxtContext extends LlmsTxtContext {
2635
+ /** A page's Markdown mirror, read without the request's cookies; `null` if unavailable. */
2636
+ markdown(url: string): Promise<string | null>;
2637
+ }
2638
+ }
2639
+ interface MetadataRouteContext {
2640
+ request: Request;
2641
+ params: Record<string, string>;
2642
+ searchParams: URLSearchParams;
2643
+ /** The concrete route-segment path that owns the metadata file. */
2644
+ path: string;
2645
+ }
2646
+ interface FarmMetadataRouteModule {
2647
+ revalidate?: number | false;
2648
+ }
2649
+ interface FarmMetadataRouteResponseOptions {
2650
+ method?: string;
2651
+ /** The request being answered, so llms.txt reads can be reported as agent traffic. */
2652
+ request?: Request;
2653
+ }
2654
+ /** @internal */
2655
+ declare function createFarmMetadataRouteResponse(kind: ApplicationMetadataRouteKind, value: unknown, routeModule?: FarmMetadataRouteModule, options?: FarmMetadataRouteResponseOptions): Response;
2656
+
2657
+ type FarmCrawlerPolicy = "allow" | "block";
2658
+ interface FarmAgentCrawlers {
2659
+ /** Set to `false` to stop serving the generated robots.txt while keeping these options. */
2660
+ enabled?: boolean;
2661
+ /**
2662
+ * AI search and user-triggered agents such as OAI-SearchBot, Claude-SearchBot,
2663
+ * and PerplexityBot. Left unset, they follow the `User-agent: *` rules.
2664
+ */
2665
+ search?: FarmCrawlerPolicy;
2666
+ /**
2667
+ * AI training crawlers such as GPTBot, ClaudeBot, Google-Extended, and CCBot.
2668
+ * Left unset, they follow the `User-agent: *` rules.
2669
+ */
2670
+ training?: FarmCrawlerPolicy;
2671
+ /**
2672
+ * More robots.txt groups, written after the generated ones. Crawlers combine
2673
+ * groups that name the same agent. A rule for `*` replaces the default
2674
+ * `User-agent: *` / `Allow: /` group.
2675
+ */
2676
+ rules?: MetadataRoute.RobotsRule[];
2677
+ /**
2678
+ * Absolute sitemap URLs. Defaults to the app's `sitemap.ts` route, resolved
2679
+ * against the root layout's `metadataBase`; with neither, no `Sitemap:` line.
2680
+ */
2681
+ sitemap?: string | string[];
2682
+ }
2683
+ interface ResolvedFarmAgentCrawlers {
2684
+ enabled: boolean;
2685
+ search?: FarmCrawlerPolicy;
2686
+ training?: FarmCrawlerPolicy;
2687
+ rules: MetadataRoute.RobotsRule[];
2688
+ sitemap?: string[];
2689
+ }
2690
+ interface FarmAgentRobotsOptions {
2691
+ crawlers: ResolvedFarmAgentCrawlers;
2692
+ /** The app's root sitemap route, such as `/sitemap.xml`, when it has one. */
2693
+ sitemapPath?: string;
2694
+ /** The root layout's `metadataBase`, which makes the sitemap URL absolute. */
2695
+ metadataBase?: unknown;
2696
+ basePath?: string;
2697
+ }
2698
+ /** The robots.txt `agent.crawlers` serves. */
2699
+ declare function createFarmAgentRobots(options: FarmAgentRobotsOptions): MetadataRoute.Robots;
2700
+
2499
2701
  /**
2500
- * Run every configured integration's middleware and routes for one request.
2501
- *
2502
- * Integration middleware is not route scoped: it is the mechanism behind
2503
- * `protectedRoutes` guards and provider session refresh, so it has to run for
2504
- * ordinary page and API requests that match no integration route at all. That
2505
- * makes this, not `matchIntegrationRoute`, the correct entry point for a
2506
- * runtime dispatching integrations for every request.
2507
- *
2508
- * The first integration that produces a Response short-circuits the rest.
2509
- * `Set-Cookie` values forwarded by middleware that returned `void` are
2510
- * collected: they ride the short-circuiting Response when there is one, and are
2511
- * otherwise handed back so the caller can merge them onto the downstream
2512
- * response.
2702
+ * Agent-readiness configuration: opt-in primitives that make a Farm site easier
2703
+ * for AI agents and crawlers to discover, resolve, and use. Off by default so
2704
+ * sites that do not want agent exposure (internal tools, private dashboards) are
2705
+ * unaffected.
2513
2706
  */
2514
- declare function dispatchIntegrationRequests(integrations: FarmIntegrationsUserConfig | undefined, runtime: Omit<RegisteredIntegrationRuntime, "integration">, request: Request, options?: {
2515
- currentRequest?: Request;
2516
- }): Promise<{
2517
- response: Response | null;
2518
- setCookies: string[];
2519
- }>;
2707
+
2708
+ /** schema.org JSON-LD emitted in the document head to identify the site. */
2709
+ interface FarmAgentJsonLd {
2710
+ /**
2711
+ * schema.org `@type`. Common values: `"Organization"` for a company or
2712
+ * project, `"SoftwareApplication"` for a product, `"WebSite"`, `"Person"`.
2713
+ *
2714
+ * @default "Organization"
2715
+ */
2716
+ type?: string;
2717
+ /** Entity name. Defaults to the site's Open Graph site name or page title. */
2718
+ name?: string;
2719
+ /** Canonical URL for the entity. Defaults to the configured `metadataBase`. */
2720
+ url?: string;
2721
+ /** Short description. Defaults to the page/site metadata description. */
2722
+ description?: string;
2723
+ /** Logo URL. */
2724
+ logo?: string;
2725
+ /** URLs that also represent this entity (social profiles, repos) — schema.org `sameAs`. */
2726
+ sameAs?: string[];
2727
+ /** Additional schema.org properties merged into the emitted object. */
2728
+ properties?: Record<string, unknown>;
2729
+ }
2730
+ interface FarmAgentUserConfig {
2731
+ /**
2732
+ * Emit schema.org JSON-LD in the document head so agents and crawlers can
2733
+ * resolve the site's identity. `true` emits an `Organization` built from the
2734
+ * site's metadata; an object customizes the type and fields.
2735
+ *
2736
+ * @default false
2737
+ */
2738
+ jsonLd?: boolean | FarmAgentJsonLd;
2739
+ /**
2740
+ * On a preview deployment, send `X-Robots-Tag: noindex, nofollow` with every
2741
+ * response from Farm's server. Previews are detected from `FARM_PREVIEW`,
2742
+ * `VERCEL_ENV=preview`, Netlify's deploy-preview and branch-deploy contexts,
2743
+ * and Render pull request previews. Production is unaffected.
2744
+ *
2745
+ * @default false
2746
+ */
2747
+ noindexPreviews?: boolean;
2748
+ /**
2749
+ * Serve `/llms.txt` (https://llmstxt.org): a Markdown index of the app's static
2750
+ * pages, linking to their Markdown mirrors. `true` builds it from page metadata;
2751
+ * an object sets the title, summary, details, and which routes to list. A
2752
+ * `src/app/llms.ts` metadata route replaces the generated file.
2753
+ *
2754
+ * @default false
2755
+ */
2756
+ llmsTxt?: boolean | FarmLlmsTxtUserConfig;
2757
+ /**
2758
+ * Serve a generated `/robots.txt` that allows or blocks AI search agents
2759
+ * (`search`) and AI training crawlers (`training`), plus your own `rules`.
2760
+ * `true` serves only `User-agent: *` / `Allow: /` and the sitemap. A
2761
+ * `public/robots.txt` or `src/app/robots.ts` replaces the generated file.
2762
+ *
2763
+ * @default false
2764
+ */
2765
+ crawlers?: boolean | FarmAgentCrawlers;
2766
+ /**
2767
+ * Serve `/.well-known/api-catalog` (RFC 9727): a Linkset listing the app's
2768
+ * OpenAPI description and reference (when `openapi` is enabled) and its MCP
2769
+ * endpoint (when the top-level `mcp` is enabled), so agents can find them
2770
+ * from the origin alone.
2771
+ *
2772
+ * @default false
2773
+ */
2774
+ apiCatalog?: boolean;
2775
+ }
2776
+ interface ResolvedFarmAgentConfig {
2777
+ jsonLd: FarmAgentJsonLd | false;
2778
+ noindexPreviews: boolean;
2779
+ llmsTxt: ResolvedFarmLlmsTxtConfig;
2780
+ crawlers: ResolvedFarmAgentCrawlers;
2781
+ apiCatalog: boolean;
2782
+ }
2520
2783
 
2521
2784
  declare global {
2522
2785
  namespace FarmJS {
@@ -3173,4 +3436,4 @@ interface MetadataRobots extends MetadataRobotsDirectives {
3173
3436
  googleBot?: string | MetadataRobotsDirectives;
3174
3437
  }
3175
3438
 
3176
- export { type LayoutMetadataProps as $, type FarmAgentJsonLd as A, type FarmContextFactory as B, type MiddlewareProps as C, type BundleResultPayload as D, type FarmIntegration as E, type FarmRouteRuntimeConfig as F, type FarmConfig as G, farmPlugin as H, defineConfig as I, type FarmComponentType as J, type AppRoutePattern as K, type LayoutProps as L, type Metadata as M, type PageRouteParams as N, type NitroPreset as O, type ParsedRoute as P, type FarmMigrationCommand as Q, type RouteSegment as R, type FarmMigrationsConfig as S, type FarmMigrationsUserConfig as T, type ResolvedFarmMigrationsConfig as U, type FarmContextFactoryInput as V, type FarmIsolatedClientHydrationMode as W, type LoadingProps as X, type ErrorProps as Y, type PagePropsWithMiddleware as Z, type MetadataProps as _, type FarmPlugin as a, definePlugin as a$, type Page as a0, type Layout as a1, type Loading as a2, type ErrorBoundary as a3, type StaticPathPrimitive as a4, type StaticPathParams as a5, type StaticRouteParams as a6, type GenerateStaticParams as a7, type LayoutModule as a8, type MetadataJsonLd as a9, type ResolvedFarmDevIndicatorsConfig as aA, type ResolvedFarmAuthConfig as aB, type ResolvedFarmPerformanceConfig as aC, type ResolvedFarmSecurityConfig as aD, type APIRequestRuntime as aE, createFarmMetadataRouteResponse as aF, createFarmAgentRobots as aG, collectFarmLlmsTxtPages as aH, createFarmDefaultLlmsTxt as aI, createFarmLlmsMarkdownReader as aJ, renderFarmLlmsFullTxt as aK, createFarmLlmsFullRenderer as aL, manageFarmDocumentPreloads as aM, manageFarmHtmlPreloads as aN, manageFarmLinkHeaderPreloads as aO, reportFarmPreloadWarnings as aP, applyFarmCspNonceToResponse as aQ, resolveFarmSecurityConfig as aR, type ResolvedSchemaField as aS, type FarmSqlDialect as aT, type FarmSqlStatement as aU, type CollectedSchemaModel as aV, type FarmSchemaMigrationStep as aW, type OpenAPIConfig as aX, type FarmAgentUserConfig as aY, type FarmAgentCrawlers as aZ, type FarmCrawlerPolicy as a_, type ServerAction as aa, type BuildOptions as ab, type SSGPage as ac, type SSGCollectionResult as ad, type MetadataRobotsDirectives as ae, type MetadataRobots as af, type FarmLayerEntry as ag, type ResolvedFarmLayer as ah, type FarmSourceRoot as ai, type ResolveFarmLayersOptions as aj, type FarmLayerResolution as ak, resolveFarmLayers as al, getFarmSourceRoots as am, getFarmAppDirectories as an, getFarmLayerAliases as ao, createFarmConfigResolutionPlugin as ap, loadFarmConfigFile as aq, type ReadonlyMiddlewareStore as ar, type FarmMiddlewareConfig as as, type MiddlewareModule as at, type MiddlewareConfig$1 as au, type MiddlewareContext as av, type ResolvedFarmRouteRuntimeConfig as aw, type ApplicationMetadataRouteKind as ax, type ResolvedFarmAPIConfig as ay, type ResolvedFarmDevtoolsConfig as az, isFarmRedirectError as b, type FarmPluginRuntimeAfterEvent as b$, FarmRuntimeShutdownError as b0, PluginManager as b1, type FarmPluginDatabase as b2, type FarmPluginDefinition as b3, FarmPluginOptionsError as b4, type FarmPluginFactory as b5, type FarmPluginOptionsIssue as b6, type FarmPluginOptionsSchema as b7, type InferPluginOptionsInput as b8, type InferPluginOptionsOutput as b9, type FarmMCPAuthorization as bA, type FarmMCPEndpoint as bB, type FarmMCPServerFunction as bC, type FarmMCPToolDefinition as bD, type FarmMCPStandaloneTool as bE, type FarmMCPExecuteContext as bF, type FarmMCPTool as bG, type FarmMCPServer as bH, type FarmMCPAuthorizeContext as bI, type FarmMCPConfig as bJ, type FarmMCPOAuthConfig as bK, type FarmMCPUserConfig as bL, type ResolvedFarmMCPConfig as bM, type PluginRequestContext as bN, type FarmPluginIntegrationContext as bO, type FarmPluginLifecycle as bP, type FarmRequestPluginContext as bQ, type FarmRequestStore as bR, type FarmPluginRuntimeKind as bS, type FarmPluginRouteRuntimePayload as bT, type FarmPluginSetupContext as bU, type FarmPluginStateContext as bV, type FarmPluginRuntimeBaseEvent as bW, type FarmPluginRuntimeContextEvent as bX, type FarmPluginRuntimeEndpoint as bY, type FarmPluginRuntimeEndpointEvent as bZ, type FarmPluginRuntimeBeforeEvent as b_, resolveConfig as ba, loadConfig as bb, resolveDeployConfig as bc, resolveMigrationsConfig as bd, resolveDeployOutputPath as be, normalizeDeployTarget as bf, getDeployTargetForPreset as bg, getPresetForDeployTarget as bh, type FarmLayerConfig as bi, type FarmPerformanceConfig as bj, type FarmPreloadMode as bk, type FarmPreloadUserConfig as bl, type ResolvedFarmPreloadConfig as bm, type FarmCspConfig as bn, type FarmCspDirectives as bo, type FarmCspDirectiveValue as bp, type FarmCspOptions as bq, type FarmSecurityConfig as br, type ResolvedFarmCspConfig as bs, MetadataRoute as bt, type MetadataRouteContext as bu, type FarmAuthConfig as bv, type FarmAuthDatabaseConfig as bw, type FarmAuthEmailAndPasswordConfig as bx, type FarmAuthSessionConfig as by, type FarmAuthUserConfig as bz, type FarmRedirectSignal as c, type FarmIntegrationRouteInputSchemas as c$, type FarmPluginRuntimeErrorEvent as c0, type FarmPluginRuntimeStartEvent as c1, type FarmPluginRuntimeCloseEvent as c2, type FarmPluginRuntimeHooks as c3, type FarmPluginRuntimeRequestOptions as c4, type FarmPluginRuntimeRequestHandler as c5, type FarmPluginRuntimeSession as c6, type FarmPluginDiscoveredRoute as c7, type FarmPluginRouterHooks as c8, type FarmPluginRenderHooks as c9, describeSchemaReference as cA, collectSchemaModels as cB, generateSqlStatements as cC, renderSqlSchemaFile as cD, getSqlColumnType as cE, getSqlDefaultExpression as cF, isNullableField as cG, quoteSqlIdentifier as cH, toSnakeCase as cI, toPascalCase as cJ, toCamelCase as cK, escapeSqlString as cL, resolveSchemaModels as cM, type ResolvedSchemaModel as cN, type FarmIntegrationCategory as cO, type FarmIntegrationSlot as cP, type FarmIntegrationRouteParamValue as cQ, type FarmIntegrationRouteParams as cR, type FarmIntegrationRouteMethod as cS, type FarmIntegrationRouteInputSource as cT, type FarmIntegrationValidationPathSegment as cU, type FarmIntegrationRouteInput as cV, type FarmIntegrationValidationIssue as cW, type FarmIntegrationValidationErrorLike as cX, type FarmIntegrationValidationResult as cY, type FarmIntegrationStandardValidationResult as cZ, type FarmIntegrationInputSchema as c_, type FarmPluginBuildHooks as ca, type FarmPluginDevHooks as cb, type FarmPluginClientConfig as cc, type RouteDiscoveredPayload as cd, type RoutesGeneratedPayload as ce, type MiddlewareDiscoveredPayload as cf, type APIRouteDiscoveredPayload as cg, type RouteMatchPayload as ch, type RouteMatchResultPayload as ci, type RenderLifecyclePayload as cj, type APIHandlerLifecyclePayload as ck, type ErrorLifecyclePayload as cl, type HMRUpdatePayload as cm, type BundleLifecyclePayload as cn, type NitroBuildLifecyclePayload as co, type ShutdownPayload as cp, type ResolvedFarmConfig as cq, type RedirectConfig as cr, type HeaderConfig as cs, type RewriteConfig as ct, type ImageConfig as cu, type I18nConfig as cv, type MiddlewareConfig as cw, type FarmDeployConfig as cx, type ResolvedFarmDeployConfig as cy, type FarmDeployTarget as cz, type FarmRedirectStatus as d, getRegisteredIntegrationSchemas as d$, type FarmIntegrationRequestContextStore as d0, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as d1, FARM_INTEGRATION_SET_COOKIES_KEY as d2, forwardIntegrationSetCookies as d3, type FarmIntegrationRouteDb as d4, type FarmIntegrationRouteStorageArgs as d5, type FarmIntegrationRouteArgs as d6, type FarmIntegrationConfigContext as d7, type FarmIntegrationConfigDefinition as d8, type FarmIntegrationConfigInput as d9, type FarmIntegrationLogPhase as dA, type FarmIntegrationLogEvent as dB, type FarmIntegrationLogger as dC, type FarmIntegrationPluginOwner as dD, type FarmIntegrationContributedPlugin as dE, type FarmIntegrationsUserConfig as dF, getFarmIntegrationPluginServerRuntime as dG, getFarmIntegrationPluginOwner as dH, type FarmIntegrationRouteFactory as dI, type FarmIntegrationRoutesFactoryContext as dJ, type FarmIntegrationRoutesFactory as dK, type FarmIntegrationEndpointValue as dL, type FarmIntegrationEndpoints as dM, type FarmIntegrationEndpointsFactoryContext as dN, type FarmIntegrationEndpointsFactory as dO, createIntegrationRoute as dP, integrationRoute as dQ, type DefinedIntegration as dR, defineIntegration as dS, isFarmIntegration as dT, resolveIntegrationPlugins as dU, getIntegrationProviders as dV, isFarmIntegrationProviderComponentReference as dW, getIntegrationDocumentNavigationMatchers as dX, getIntegrationSchemas as dY, getRegisteredIntegrationRuntime as dZ, getRegisteredIntegrations as d_, type FarmIntegrationLifecycleLogLevel as da, type FarmIntegrationLifecycleLogger as db, type FarmIntegrationLifecycleContext as dc, type FarmIntegrationLifecycleHook as dd, type FarmIntegrationData as de, type FarmIntegrationHandlerContext as df, type FarmIntegrationRouteHookContext as dg, type FarmIntegrationRouteHook as dh, type FarmIntegrationRoute as di, type FarmTypedIntegrationRoute as dj, type FarmIntegrationRouteMiddleware as dk, type FarmIntegrationMiddleware as dl, type FarmIntegrationProviderProps as dm, type FarmIntegrationProviderComponentReference as dn, type FarmIntegrationProvider as dp, type FarmIntegrationDocumentNavigation as dq, type FarmIntegrationSchemaFieldType as dr, type FarmIntegrationSchemaReference as ds, type FarmIntegrationSchemaField as dt, type FarmIntegrationSchemaConstraint as du, type FarmIntegrationSchemaModel as dv, type FarmIntegrationSchemaModelExtension as dw, type FarmIntegrationSchemaModelOverride as dx, type FarmIntegrationSchema as dy, defineIntegrationSchema as dz, type FarmRequest as e, createFarmRouteRuntimeKey as e$, matchIntegrationRoute as e0, matchRegisteredIntegrationRoute as e1, getRegisteredIntegrationAPIManifest as e2, dispatchIntegrationRequest as e3, dispatchIntegrationRequests as e4, describeIntegrationOriginRejection as e5, resolveIntegrationAllowedOrigins as e6, validateIntegrationRequestOrigin as e7, type IntegrationOriginPolicy as e8, type IntegrationOriginRejection as e9, type CookieJar as eA, type CookieOptions as eB, type RateLimitConfig as eC, type RateLimitIncrementResult as eD, type RateLimitStorage as eE, type RateLimitStatus as eF, type MemoryRateLimitStorageOptions as eG, type NextFunction as eH, type MiddlewareResult as eI, type FarmRouteRuleRenderMode as eJ, type FarmRouteRuleRedirect as eK, type FarmRouteRuleCors as eL, type FarmRouteRule as eM, type FarmRouteRules as eN, normalizeRouteRules as eO, routeRulesToRedirects as eP, routeRulesToHeaders as eQ, routeRulesToNitroRouteRules as eR, type FarmRouteRuntimeEntryKind as eS, type FarmRouteRenderingMode as eT, type FarmRouteRuntimeManifestEntry as eU, type FarmRouteRuntimeManifest as eV, normalizeFarmRouteRuntimeConfig as eW, mergeFarmRouteRuntimeConfigs as eX, resolveFarmRouteRuntimeConfig as eY, hasFarmRouteRuntimeControls as eZ, getFarmRouteRuntimeConfig as e_, type IntegrationOriginResult as ea, type FarmIntegrationOrmSchema as eb, type FarmIntegrationOrmClient as ec, type InferFarmIntegrationOrmField as ed, type InferFarmIntegrationOrmFields as ee, type InferFarmIntegrationOrmSchema as ef, type InferFarmIntegrationOrmClient as eg, type CreateIntegrationOrmOptions as eh, createIntegrationOrm as ei, resolveIntegrationOrmRuntimeClient as ej, farmIntegrationSchemaToOrmSchema as ek, type IntegrationOrmModelNames as el, DEFAULT_FARM_API_BASE_PATH as em, type FarmAPIConfigResolverContext as en, type FarmAPIConfigValue as eo, type FarmAPIConfig as ep, resolveFarmAPIConfig as eq, normalizeFarmAPIConfig as er, normalizeFarmAPIBasePath as es, getFarmAPIBaseURL as et, resolveFarmAPIRequestURL as eu, type MiddlewareFunction as ev, type RequestMiddleware as ew, type RequestMiddlewareContext as ex, type MiddlewareStore as ey, type MiddlewareChain as ez, type FarmResponse as f, resolveFarmRouteRuleRuntimeConfig as f0, farmRouteRuleMatches as f1, DEFAULT_FARM_DEVTOOLS_SHORTCUT as f2, FARM_DEVTOOLS_PATH as f3, FARM_DEVTOOLS_LAUNCH_PARAM as f4, type FarmDevtoolsConfig as f5, type FarmDevtoolsUserConfig as f6, resolveFarmDevtoolsConfig as f7, type FarmBuildActivityPosition as f8, type FarmDevIndicatorsConfig as f9, resolveFarmDevIndicatorsConfig as fa, generateFarmDevIndicatorsClientRuntime as fb, farmI18nClientBridgePlugin as fc, farmServerOnlyEntriesPlugin as fd, withFarmRequestTracing as fe, rewriteEarlySsrRelativeImports as ff, transformIsolatedClientBoundaryModule as fg, shouldEmitFarmClientRootHmr as fh, generateClientCachePersistenceCode as fi, resolveFarmClientCacheAdapterEntry as fj, type ClientCachePersistenceEntryCode as fk, FARM_NODE_RESPONSE_END_PENDING as fl, loadFarmDevModule as fm, FarmDevEnvironmentError as fn, type FarmDevModuleServer as fo, getFarmRedirectError as g, type FarmPluginContext as h, isFarmNotFoundError as i, type FarmRouteRuntime as j, type FarmRouteRegions as k, type FarmRouteMaxDuration as l, type FarmAppContext as m, notFound as n, type PageProps as o, permanentRedirect as p, type PluginContextProps as q, redirect as r, type RouteModule as s, type FarmMdxComponents as t, type FarmMdxResolvedConfig as u, resolveFarmMdxComponentsModulePath as v, resolveMdxConfig as w, type FarmMdxComponent as x, type FarmMdxUserConfig as y, type FarmUserConfig as z };
3439
+ export { type ErrorProps as $, createFarmMarkdownErrorBody as A, farmRequestWantsMarkdown as B, type FarmUserConfig as C, type FarmAgentJsonLd as D, type FarmContextFactory as E, type FarmRouteRuntimeConfig as F, type MiddlewareProps as G, type BundleResultPayload as H, type FarmIntegration as I, type FarmConfig as J, farmPlugin as K, type LayoutProps as L, type Metadata as M, defineConfig as N, type FarmComponentType as O, type ParsedRoute as P, type AppRoutePattern as Q, type RouteSegment as R, type PageRouteParams as S, type NitroPreset as T, type FarmMigrationCommand as U, type FarmMigrationsConfig as V, type FarmMigrationsUserConfig as W, type ResolvedFarmMigrationsConfig as X, type FarmContextFactoryInput as Y, type FarmIsolatedClientHydrationMode as Z, type LoadingProps as _, type FarmPlugin as a, type CollectedSchemaModel as a$, type PagePropsWithMiddleware as a0, type MetadataProps as a1, type LayoutMetadataProps as a2, type Page as a3, type Layout as a4, type Loading as a5, type ErrorBoundary as a6, type StaticPathPrimitive as a7, type StaticPathParams as a8, type StaticRouteParams as a9, _publishFarmMCPCatalog as aA, type ResolvedFarmRouteRuntimeConfig as aB, type ApplicationMetadataRouteKind as aC, type ResolvedFarmAPIConfig as aD, type FarmMarkdownResolvedConfig as aE, type ResolvedFarmDevtoolsConfig as aF, type ResolvedFarmDevIndicatorsConfig as aG, type ResolvedFarmAuthConfig as aH, type ResolvedFarmPerformanceConfig as aI, type ResolvedFarmSecurityConfig as aJ, type APIRequestRuntime as aK, createFarmMetadataRouteResponse as aL, createFarmAgentRobots as aM, collectFarmLlmsTxtPages as aN, createFarmDefaultLlmsTxt as aO, createFarmLlmsMarkdownReader as aP, renderFarmLlmsFullTxt as aQ, createFarmLlmsFullRenderer as aR, manageFarmDocumentPreloads as aS, manageFarmHtmlPreloads as aT, manageFarmLinkHeaderPreloads as aU, reportFarmPreloadWarnings as aV, applyFarmCspNonceToResponse as aW, resolveFarmSecurityConfig as aX, type ResolvedSchemaField as aY, type FarmSqlDialect as aZ, type FarmSqlStatement as a_, type GenerateStaticParams as aa, type LayoutModule as ab, type MetadataJsonLd as ac, type ServerAction as ad, type BuildOptions as ae, type SSGPage as af, type SSGCollectionResult as ag, type MetadataRobotsDirectives as ah, type MetadataRobots as ai, type FarmLayerEntry as aj, type ResolvedFarmLayer as ak, type FarmSourceRoot as al, type ResolveFarmLayersOptions as am, type FarmLayerResolution as an, resolveFarmLayers as ao, getFarmSourceRoots as ap, getFarmAppDirectories as aq, getFarmLayerAliases as ar, createFarmConfigResolutionPlugin as as, loadFarmConfigFile as at, type ReadonlyMiddlewareStore as au, type FarmMiddlewareConfig as av, type MiddlewareModule as aw, type MiddlewareConfig$1 as ax, type MiddlewareContext as ay, _findFarmMCPEndpointTool as az, isFarmRedirectError as b, type FarmPluginIntegrationContext as b$, type FarmSchemaMigrationStep as b0, type OpenAPIConfig as b1, type FarmAgentUserConfig as b2, type FarmAgentCrawlers as b3, type FarmCrawlerPolicy as b4, definePlugin as b5, FarmRuntimeShutdownError as b6, PluginManager as b7, type FarmPluginDatabase as b8, type FarmPluginDefinition as b9, type MetadataRouteContext as bA, type FarmMCPEndpointTool as bB, type FarmAuthConfig as bC, type FarmAuthDatabaseConfig as bD, type FarmAuthEmailAndPasswordConfig as bE, type FarmAuthSessionConfig as bF, type FarmAuthUserConfig as bG, type FarmMCPAuthorization as bH, type FarmMCPEndpoint as bI, type FarmMCPServerFunction as bJ, type FarmMCPToolDefinition as bK, type FarmMCPStandaloneTool as bL, type FarmMCPExecuteContext as bM, type FarmMCPTool as bN, type FarmMCPServer as bO, type FarmMCPAuthorizeContext as bP, type FarmMCPConfig as bQ, type FarmMCPOAuthConfig as bR, type FarmMCPPrompt as bS, type FarmMCPPromptMessage as bT, type FarmMCPResource as bU, type FarmMCPResourceContent as bV, type FarmMCPResourceContext as bW, type FarmMCPResourceListing as bX, type FarmMCPUserConfig as bY, type ResolvedFarmMCPConfig as bZ, type PluginRequestContext as b_, FarmPluginOptionsError as ba, type FarmPluginFactory as bb, type FarmPluginOptionsIssue as bc, type FarmPluginOptionsSchema as bd, type InferPluginOptionsInput as be, type InferPluginOptionsOutput as bf, resolveConfig as bg, loadConfig as bh, resolveDeployConfig as bi, resolveMigrationsConfig as bj, resolveDeployOutputPath as bk, normalizeDeployTarget as bl, getDeployTargetForPreset as bm, getPresetForDeployTarget as bn, type FarmLayerConfig as bo, type FarmPerformanceConfig as bp, type FarmPreloadMode as bq, type FarmPreloadUserConfig as br, type ResolvedFarmPreloadConfig as bs, type FarmCspConfig as bt, type FarmCspDirectives as bu, type FarmCspDirectiveValue as bv, type FarmCspOptions as bw, type FarmSecurityConfig as bx, type ResolvedFarmCspConfig as by, MetadataRoute as bz, type FarmRedirectSignal as c, type ResolvedSchemaModel as c$, type FarmPluginLifecycle as c0, type FarmRequestPluginContext as c1, type FarmRequestStore as c2, type FarmPluginRuntimeKind as c3, type FarmPluginRouteRuntimePayload as c4, type FarmPluginSetupContext as c5, type FarmPluginStateContext as c6, type FarmPluginRuntimeBaseEvent as c7, type FarmPluginRuntimeContextEvent as c8, type FarmPluginRuntimeEndpoint as c9, type BundleLifecyclePayload as cA, type NitroBuildLifecyclePayload as cB, type ShutdownPayload as cC, type ResolvedFarmConfig as cD, type RedirectConfig as cE, type HeaderConfig as cF, type RewriteConfig as cG, type ImageConfig as cH, type I18nConfig as cI, type MiddlewareConfig as cJ, type FarmDeployConfig as cK, type ResolvedFarmDeployConfig as cL, type FarmDeployTarget as cM, type FarmMarkdownUserConfig as cN, describeSchemaReference as cO, collectSchemaModels as cP, generateSqlStatements as cQ, renderSqlSchemaFile as cR, getSqlColumnType as cS, getSqlDefaultExpression as cT, isNullableField as cU, quoteSqlIdentifier as cV, toSnakeCase as cW, toPascalCase as cX, toCamelCase as cY, escapeSqlString as cZ, resolveSchemaModels as c_, type FarmPluginRuntimeEndpointEvent as ca, type FarmPluginRuntimeBeforeEvent as cb, type FarmPluginRuntimeAfterEvent as cc, type FarmPluginRuntimeErrorEvent as cd, type FarmPluginRuntimeStartEvent as ce, type FarmPluginRuntimeCloseEvent as cf, type FarmPluginRuntimeHooks as cg, type FarmPluginRuntimeRequestOptions as ch, type FarmPluginRuntimeRequestHandler as ci, type FarmPluginRuntimeSession as cj, type FarmPluginDiscoveredRoute as ck, type FarmPluginRouterHooks as cl, type FarmPluginRenderHooks as cm, type FarmPluginBuildHooks as cn, type FarmPluginDevHooks as co, type FarmPluginClientConfig as cp, type RouteDiscoveredPayload as cq, type RoutesGeneratedPayload as cr, type MiddlewareDiscoveredPayload as cs, type APIRouteDiscoveredPayload as ct, type RouteMatchPayload as cu, type RouteMatchResultPayload as cv, type RenderLifecyclePayload as cw, type APIHandlerLifecyclePayload as cx, type ErrorLifecyclePayload as cy, type HMRUpdatePayload as cz, type FarmRedirectStatus as d, type FarmIntegrationEndpointsFactoryContext as d$, type FarmIntegrationCategory as d0, type FarmIntegrationSlot as d1, type FarmIntegrationRouteParamValue as d2, type FarmIntegrationRouteParams as d3, type FarmIntegrationRouteMethod as d4, type FarmIntegrationRouteInputSource as d5, type FarmIntegrationValidationPathSegment as d6, type FarmIntegrationRouteInput as d7, type FarmIntegrationValidationIssue as d8, type FarmIntegrationValidationErrorLike as d9, type FarmIntegrationMiddleware as dA, type FarmIntegrationProviderProps as dB, type FarmIntegrationProviderComponentReference as dC, type FarmIntegrationProvider as dD, type FarmIntegrationDocumentNavigation as dE, type FarmIntegrationSchemaFieldType as dF, type FarmIntegrationSchemaReference as dG, type FarmIntegrationSchemaField as dH, type FarmIntegrationSchemaConstraint as dI, type FarmIntegrationSchemaModel as dJ, type FarmIntegrationSchemaModelExtension as dK, type FarmIntegrationSchemaModelOverride as dL, type FarmIntegrationSchema as dM, defineIntegrationSchema as dN, type FarmIntegrationLogPhase as dO, type FarmIntegrationLogEvent as dP, type FarmIntegrationLogger as dQ, type FarmIntegrationPluginOwner as dR, type FarmIntegrationContributedPlugin as dS, type FarmIntegrationsUserConfig as dT, getFarmIntegrationPluginServerRuntime as dU, getFarmIntegrationPluginOwner as dV, type FarmIntegrationRouteFactory as dW, type FarmIntegrationRoutesFactoryContext as dX, type FarmIntegrationRoutesFactory as dY, type FarmIntegrationEndpointValue as dZ, type FarmIntegrationEndpoints as d_, type FarmIntegrationValidationResult as da, type FarmIntegrationStandardValidationResult as db, type FarmIntegrationInputSchema as dc, type FarmIntegrationRouteInputSchemas as dd, type FarmIntegrationRequestContextStore as de, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as df, FARM_INTEGRATION_SET_COOKIES_KEY as dg, forwardIntegrationSetCookies as dh, type FarmIntegrationRouteDb as di, type FarmIntegrationRouteStorageArgs as dj, type FarmIntegrationRouteArgs as dk, type FarmIntegrationConfigContext as dl, type FarmIntegrationConfigDefinition as dm, type FarmIntegrationConfigInput as dn, type FarmIntegrationLifecycleLogLevel as dp, type FarmIntegrationLifecycleLogger as dq, type FarmIntegrationLifecycleContext as dr, type FarmIntegrationLifecycleHook as ds, type FarmIntegrationData as dt, type FarmIntegrationHandlerContext as du, type FarmIntegrationRouteHookContext as dv, type FarmIntegrationRouteHook as dw, type FarmIntegrationRoute as dx, type FarmTypedIntegrationRoute as dy, type FarmIntegrationRouteMiddleware as dz, type FarmRequest as e, type FarmRouteRules as e$, type FarmIntegrationEndpointsFactory as e0, createIntegrationRoute as e1, integrationRoute as e2, type DefinedIntegration as e3, defineIntegration as e4, isFarmIntegration as e5, resolveIntegrationPlugins as e6, getIntegrationProviders as e7, isFarmIntegrationProviderComponentReference as e8, getIntegrationDocumentNavigationMatchers as e9, DEFAULT_FARM_API_BASE_PATH as eA, type FarmAPIConfigResolverContext as eB, type FarmAPIConfigValue as eC, type FarmAPIConfig as eD, resolveFarmAPIConfig as eE, normalizeFarmAPIConfig as eF, normalizeFarmAPIBasePath as eG, getFarmAPIBaseURL as eH, resolveFarmAPIRequestURL as eI, type MiddlewareFunction as eJ, type RequestMiddleware as eK, type RequestMiddlewareContext as eL, type MiddlewareStore as eM, type MiddlewareChain as eN, type CookieJar as eO, type CookieOptions as eP, type RateLimitConfig as eQ, type RateLimitIncrementResult as eR, type RateLimitStorage as eS, type RateLimitStatus as eT, type MemoryRateLimitStorageOptions as eU, type NextFunction as eV, type MiddlewareResult as eW, type FarmRouteRuleRenderMode as eX, type FarmRouteRuleRedirect as eY, type FarmRouteRuleCors as eZ, type FarmRouteRule as e_, getIntegrationSchemas as ea, getRegisteredIntegrationRuntime as eb, getRegisteredIntegrations as ec, getRegisteredIntegrationSchemas as ed, matchIntegrationRoute as ee, matchRegisteredIntegrationRoute as ef, getRegisteredIntegrationAPIManifest as eg, dispatchIntegrationRequest as eh, dispatchIntegrationRequests as ei, describeIntegrationOriginRejection as ej, resolveIntegrationAllowedOrigins as ek, validateIntegrationRequestOrigin as el, type IntegrationOriginPolicy as em, type IntegrationOriginRejection as en, type IntegrationOriginResult as eo, type FarmIntegrationOrmSchema as ep, type FarmIntegrationOrmClient as eq, type InferFarmIntegrationOrmField as er, type InferFarmIntegrationOrmFields as es, type InferFarmIntegrationOrmSchema as et, type InferFarmIntegrationOrmClient as eu, type CreateIntegrationOrmOptions as ev, createIntegrationOrm as ew, resolveIntegrationOrmRuntimeClient as ex, farmIntegrationSchemaToOrmSchema as ey, type IntegrationOrmModelNames as ez, type FarmResponse as f, normalizeRouteRules as f0, routeRulesToRedirects as f1, routeRulesToHeaders as f2, routeRulesToNitroRouteRules as f3, type FarmRouteRuntimeEntryKind as f4, type FarmRouteRenderingMode as f5, type FarmRouteRuntimeManifestEntry as f6, type FarmRouteRuntimeManifest as f7, normalizeFarmRouteRuntimeConfig as f8, mergeFarmRouteRuntimeConfigs as f9, type FarmPageFormAction as fA, extractFarmPageActions as fB, DEFAULT_FARM_DEVTOOLS_SHORTCUT as fC, FARM_DEVTOOLS_PATH as fD, FARM_DEVTOOLS_LAUNCH_PARAM as fE, type FarmDevtoolsConfig as fF, type FarmDevtoolsUserConfig as fG, resolveFarmDevtoolsConfig as fH, type FarmBuildActivityPosition as fI, type FarmDevIndicatorsConfig as fJ, resolveFarmDevIndicatorsConfig as fK, generateFarmDevIndicatorsClientRuntime as fL, farmI18nClientBridgePlugin as fM, farmServerOnlyEntriesPlugin as fN, withFarmRequestTracing as fO, rewriteEarlySsrRelativeImports as fP, transformIsolatedClientBoundaryModule as fQ, shouldEmitFarmClientRootHmr as fR, generateClientCachePersistenceCode as fS, resolveFarmClientCacheAdapterEntry as fT, type ClientCachePersistenceEntryCode as fU, FARM_NODE_RESPONSE_END_PENDING as fV, loadFarmDevModule as fW, FarmDevEnvironmentError as fX, type FarmDevModuleServer as fY, resolveFarmRouteRuntimeConfig as fa, hasFarmRouteRuntimeControls as fb, getFarmRouteRuntimeConfig as fc, createFarmRouteRuntimeKey as fd, resolveFarmRouteRuleRuntimeConfig as fe, farmRouteRuleMatches as ff, type FarmMarkdownRouteInput as fg, type FarmMarkdownResolvedRoute as fh, type FarmMarkdownMirrorTarget as fi, type ResolveMarkdownMirrorTargetOptions as fj, type CreateMarkdownMirrorResponseOptions as fk, type ApplyMarkdownNegotiationHeadersOptions as fl, resolveMarkdownConfig as fm, resolveMarkdownMirrorTarget as fn, createMarkdownMirrorResponse as fo, applyMarkdownNegotiationHeaders as fp, htmlToMarkdown as fq, farmAcceptQuality as fr, requestAcceptsMarkdown as fs, getFarmMarkdownMirrorPath as ft, getFarmMarkdownAlternatePath as fu, isFarmMarkdownMirrorExposed as fv, matchesFarmMarkdownRoutePattern as fw, type FarmPageFormOption as fx, type FarmPageFormField as fy, type FarmPageFormSubmit as fz, getFarmRedirectError as g, type FarmPluginContext as h, isFarmNotFoundError as i, type FarmRouteRuntime as j, type FarmRouteRegions as k, type FarmRouteMaxDuration as l, type FarmAppContext as m, notFound as n, type PageProps as o, permanentRedirect as p, type PluginContextProps as q, redirect as r, type RouteModule as s, type FarmMdxComponents as t, type FarmMdxResolvedConfig as u, resolveFarmMdxComponentsModulePath as v, resolveMdxConfig as w, type FarmMdxComponent as x, type FarmMdxUserConfig as y, FARM_MARKDOWN_CONTENT_TYPE as z };