@farm.js/core 0.1.45 → 0.1.47

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 (191) hide show
  1. package/dist/{agent-mcp-EnzWYv_X.d.ts → agent-mcp-BtK_KZ1m.d.ts} +2 -2
  2. package/dist/{agent-mcp-CWI-awqd.d.mts → agent-mcp-Cc-ypyNi.d.mts} +2 -2
  3. package/dist/agent-runtime.d.mts +10 -10
  4. package/dist/agent-runtime.d.ts +10 -10
  5. package/dist/api/client.d.mts +3 -3
  6. package/dist/api/client.d.ts +3 -3
  7. package/dist/api/route-manager.d.mts +16 -16
  8. package/dist/api/route-manager.d.ts +16 -16
  9. package/dist/api/runtime.d.mts +12 -12
  10. package/dist/api/runtime.d.ts +12 -12
  11. package/dist/{api-client-Dk9QOLwr.d.mts → api-client-CFdv-Xgh.d.mts} +3 -3
  12. package/dist/{api-client-BJv9mTbO.d.ts → api-client-CvI5oOBE.d.ts} +3 -3
  13. package/dist/api.d.mts +17 -17
  14. package/dist/api.d.ts +17 -17
  15. package/dist/{app-DG3dE8v5.d.mts → app-2SBLAaNq.d.mts} +8 -8
  16. package/dist/{app-CAN_2Cqo.d.ts → app-BlXGEpdA.d.ts} +8 -8
  17. package/dist/{app-manifest-DazjgQya.d.ts → app-manifest-D1Tgp8ya.d.ts} +1 -1
  18. package/dist/{app-manifest-8x5VjZ0L.d.mts → app-manifest-nZHIvS3a.d.mts} +1 -1
  19. package/dist/app-markdown.d.mts +11 -11
  20. package/dist/app-markdown.d.ts +11 -11
  21. package/dist/{base-path-BU16ETmo.d.mts → base-path-leyrqXbX.d.mts} +1 -1
  22. package/dist/{base-path-BU16ETmo.d.ts → base-path-leyrqXbX.d.ts} +1 -1
  23. package/dist/{chunk-I5IO3ASU.cjs → chunk-2DZFF7F7.cjs} +268 -140
  24. package/dist/{chunk-YAD64RWI.cjs → chunk-2NROIAA6.cjs} +50 -50
  25. package/dist/{chunk-K5DHVEXC.mjs → chunk-2SLWGLZ7.mjs} +2 -2
  26. package/dist/{chunk-FHQZJJQR.mjs → chunk-3HEQSCVV.mjs} +1 -1
  27. package/dist/{chunk-VR64PHNT.mjs → chunk-7P475T2X.mjs} +206 -78
  28. package/dist/{chunk-2NCY6O6Q.mjs → chunk-FQUKOELE.mjs} +3 -3
  29. package/dist/{chunk-X6YOWNDZ.mjs → chunk-KQANE4Q4.mjs} +1 -1
  30. package/dist/{chunk-KVN3YEFF.cjs → chunk-NFME7OKZ.cjs} +6 -6
  31. package/dist/{chunk-2DZOABRK.cjs → chunk-OF4TXHM4.cjs} +1 -1
  32. package/dist/{chunk-SIVK2SRR.cjs → chunk-Q5F32A26.cjs} +43 -43
  33. package/dist/{chunk-FDCV5OCT.mjs → chunk-QSG2IX4A.mjs} +1 -1
  34. package/dist/{chunk-UN4B2TXC.cjs → chunk-XIZO5VDA.cjs} +2 -2
  35. package/dist/{client-plugins-nQ0tYt4l.d.mts → client-plugins-DEmIQo5R.d.mts} +1438 -1438
  36. package/dist/{client-plugins-BGS0wqzc.d.ts → client-plugins-br48Hpmk.d.ts} +1438 -1438
  37. package/dist/client-plugins.d.mts +10 -10
  38. package/dist/client-plugins.d.ts +10 -10
  39. package/dist/client.d.mts +17 -17
  40. package/dist/client.d.ts +17 -17
  41. package/dist/config.d.mts +10 -10
  42. package/dist/config.d.ts +10 -10
  43. package/dist/docs.d.mts +11 -11
  44. package/dist/docs.d.ts +11 -11
  45. package/dist/{endpoint-BOE0IAaG.d.ts → endpoint-BgHn0lhl.d.ts} +1 -1
  46. package/dist/{endpoint-DGZRZHux.d.mts → endpoint-BkMSCRf6.d.mts} +1 -1
  47. package/dist/environment/vite.d.mts +1 -1
  48. package/dist/environment/vite.d.ts +1 -1
  49. package/dist/i18n/client.d.mts +2 -2
  50. package/dist/i18n/client.d.ts +2 -2
  51. package/dist/i18n/index.d.mts +3 -3
  52. package/dist/i18n/index.d.ts +3 -3
  53. package/dist/i18n/server.d.mts +5 -5
  54. package/dist/i18n/server.d.ts +5 -5
  55. package/dist/image/server.d.mts +1 -1
  56. package/dist/image/server.d.ts +1 -1
  57. package/dist/image/sharp.d.mts +1 -1
  58. package/dist/image/sharp.d.ts +1 -1
  59. package/dist/{image-config-BpH1q5R8.d.ts → image-config-CeDgNyX4.d.mts} +1 -1
  60. package/dist/{image-config-BpH1q5R8.d.mts → image-config-CeDgNyX4.d.ts} +1 -1
  61. package/dist/image.d.mts +1 -1
  62. package/dist/image.d.ts +1 -1
  63. package/dist/{index-BJJfLxJo.d.mts → index-Cl3akY5U.d.mts} +2 -2
  64. package/dist/{index-Cy26isrh.d.ts → index-CyD9Rfso.d.ts} +2 -2
  65. package/dist/{index-CwoOP-MW.d.ts → index-MocnSP3a.d.ts} +2 -2
  66. package/dist/{index-y1jgR74U.d.mts → index-_nhUt_dh.d.mts} +2 -2
  67. package/dist/index.cjs +6 -6
  68. package/dist/index.d.mts +32 -32
  69. package/dist/index.d.ts +32 -32
  70. package/dist/index.mjs +5 -5
  71. package/dist/{instrumentation-runtime-CE06JLHZ.d.mts → instrumentation-runtime-CX9Zh-16.d.mts} +1 -1
  72. package/dist/{instrumentation-runtime-CE06JLHZ.d.ts → instrumentation-runtime-CX9Zh-16.d.ts} +1 -1
  73. package/dist/instrumentation.d.mts +2 -2
  74. package/dist/instrumentation.d.ts +2 -2
  75. package/dist/integrations.d.mts +10 -10
  76. package/dist/integrations.d.ts +10 -10
  77. package/dist/internal/app-markdown-runtime.d.mts +11 -11
  78. package/dist/internal/app-markdown-runtime.d.ts +11 -11
  79. package/dist/internal/build-runtime.cjs +6 -6
  80. package/dist/internal/build-runtime.d.mts +12 -12
  81. package/dist/internal/build-runtime.d.ts +12 -12
  82. package/dist/internal/build-runtime.mjs +5 -5
  83. package/dist/internal/client-error-overlay.cjs +4 -4
  84. package/dist/internal/client-error-overlay.mjs +1 -1
  85. package/dist/internal/client-runtime.d.mts +1 -1
  86. package/dist/internal/client-runtime.d.ts +1 -1
  87. package/dist/internal/compression-runtime.d.mts +10 -10
  88. package/dist/internal/compression-runtime.d.ts +10 -10
  89. package/dist/internal/config-runtime.d.mts +11 -11
  90. package/dist/internal/config-runtime.d.ts +11 -11
  91. package/dist/internal/form-actions.d.mts +1 -1
  92. package/dist/internal/form-actions.d.ts +1 -1
  93. package/dist/internal/islx-client.d.mts +4 -0
  94. package/dist/internal/islx-client.d.ts +4 -0
  95. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  96. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  97. package/dist/internal/production-runtime.cjs +4 -4
  98. package/dist/internal/production-runtime.d.mts +25 -25
  99. package/dist/internal/production-runtime.d.ts +25 -25
  100. package/dist/internal/production-runtime.mjs +3 -3
  101. package/dist/{layers-CM5i6T7z.d.mts → layers-D9fbe-rz.d.mts} +1 -1
  102. package/dist/{layers-CM5i6T7z.d.ts → layers-D9fbe-rz.d.ts} +1 -1
  103. package/dist/markdown.d.mts +10 -10
  104. package/dist/markdown.d.ts +10 -10
  105. package/dist/middleware.d.mts +12 -12
  106. package/dist/middleware.d.ts +12 -12
  107. package/dist/navigation.d.mts +13 -13
  108. package/dist/navigation.d.ts +13 -13
  109. package/dist/{observability-CoXunYhS.d.mts → observability-B2363jB6.d.mts} +1 -1
  110. package/dist/{observability-CoXunYhS.d.ts → observability-B2363jB6.d.ts} +1 -1
  111. package/dist/observability.d.mts +1 -1
  112. package/dist/observability.d.ts +1 -1
  113. package/dist/og.d.mts +0 -5
  114. package/dist/og.d.ts +0 -5
  115. package/dist/plugin.cjs +5 -5
  116. package/dist/plugin.d.mts +12 -12
  117. package/dist/plugin.d.ts +12 -12
  118. package/dist/plugin.mjs +4 -4
  119. package/dist/{production-runtime-ClFA_1KQ.d.mts → production-runtime-BEbIyIUe.d.mts} +4 -4
  120. package/dist/{production-runtime-BVMDgHrA.d.ts → production-runtime-DsHjccVI.d.ts} +4 -4
  121. package/dist/{ssg-XnMHCyEc.d.ts → programmatic-routes-client-DlMKstmL.d.ts} +57 -57
  122. package/dist/{ssg-ByrOVYdM.d.mts → programmatic-routes-client-Dqr6tHND.d.mts} +57 -57
  123. package/dist/{render-plan-CoSovy_O.d.mts → render-plan-Bu6XOxNg.d.mts} +1 -1
  124. package/dist/{render-plan-y2DefWf8.d.ts → render-plan-MefW_fLC.d.ts} +1 -1
  125. package/dist/renderer/react/server.d.mts +1 -1
  126. package/dist/renderer/react/server.d.ts +1 -1
  127. package/dist/renderer-client.d.mts +12 -12
  128. package/dist/renderer-client.d.ts +12 -12
  129. package/dist/{request-cNM09Q7e.d.mts → request-BBe1B8Bk.d.mts} +1 -1
  130. package/dist/{request-aG5Wovm5.d.ts → request-CMsRJQK3.d.ts} +1 -1
  131. package/dist/request.d.mts +11 -11
  132. package/dist/request.d.ts +11 -11
  133. package/dist/{resolver-khasx3fU.d.mts → resolver-C2G-3Tm6.d.mts} +1 -1
  134. package/dist/{resolver-DadfRL6F.d.ts → resolver-DC57A4vz.d.ts} +1 -1
  135. package/dist/{integration-api-DWyMmvrR.d.mts → route-2_yXC6gv.d.mts} +100 -100
  136. package/dist/{integration-api-BuPHMeKz.d.ts → route-DFhZj6jN.d.ts} +100 -100
  137. package/dist/{route-pattern-W-SsJGSp.d.mts → route-pattern-CVsVbq5n.d.mts} +1 -1
  138. package/dist/{route-pattern-W-SsJGSp.d.ts → route-pattern-CVsVbq5n.d.ts} +1 -1
  139. package/dist/{route-rendering-EyInfsjI.d.mts → route-rendering-DTLNruPw.d.ts} +1 -1
  140. package/dist/{route-rendering-B3uQmCWX.d.ts → route-rendering-Do8tuYgh.d.mts} +1 -1
  141. package/dist/{router-DNUf-Bg1.d.ts → router-BJreOZ-k.d.ts} +2 -2
  142. package/dist/{router-Devibh4r.d.mts → router-o2mZB9Y4.d.mts} +2 -2
  143. package/dist/routes.d.mts +11 -11
  144. package/dist/routes.d.ts +11 -11
  145. package/dist/{runtime-BgDQzBiu.d.ts → runtime-B9HmxiZc.d.ts} +2 -2
  146. package/dist/{runtime-CV2UCV-5.d.mts → runtime-CCxTmGuf.d.mts} +2 -2
  147. package/dist/{runtime-CLr9P5kn.d.ts → runtime-Cp5YZNz4.d.mts} +5 -5
  148. package/dist/{runtime-9KZb8AI5.d.mts → runtime-Da57KD8F.d.ts} +5 -5
  149. package/dist/server-action-security.d.mts +1 -1
  150. package/dist/server-action-security.d.ts +1 -1
  151. package/dist/server-fn-client.d.mts +4 -4
  152. package/dist/server-fn-client.d.ts +4 -4
  153. package/dist/{server-fn-error-DDh14a0V.d.mts → server-fn-error-DrcH9cc1.d.mts} +1 -1
  154. package/dist/{server-fn-error-DDh14a0V.d.ts → server-fn-error-DrcH9cc1.d.ts} +1 -1
  155. package/dist/server-fn.d.mts +3 -3
  156. package/dist/server-fn.d.ts +3 -3
  157. package/dist/server-plugins.d.mts +11 -11
  158. package/dist/server-plugins.d.ts +11 -11
  159. package/dist/server-query-client.d.mts +2 -2
  160. package/dist/server-query-client.d.ts +2 -2
  161. package/dist/server-query.d.mts +2 -2
  162. package/dist/server-query.d.ts +2 -2
  163. package/dist/server.cjs +14 -14
  164. package/dist/server.d.mts +20 -20
  165. package/dist/server.d.ts +20 -20
  166. package/dist/server.mjs +4 -4
  167. package/dist/{spa-router-Ds6R_oe-.d.ts → spa-router-CN2vc0GY.d.ts} +4 -4
  168. package/dist/{spa-router-BIxh4IY-.d.mts → spa-router-COZLIB7k.d.mts} +4 -4
  169. package/dist/storage.d.mts +3 -3
  170. package/dist/storage.d.ts +3 -3
  171. package/dist/testing.d.mts +12 -12
  172. package/dist/testing.d.ts +12 -12
  173. package/dist/theme/server.d.mts +1 -1
  174. package/dist/theme/server.d.ts +1 -1
  175. package/dist/{types-CnH8DOqo.d.mts → types--Wh02r5_.d.mts} +1 -1
  176. package/dist/{types-CnH8DOqo.d.ts → types--Wh02r5_.d.ts} +1 -1
  177. package/dist/{types-Cc8l9IqS.d.ts → types-BnIqOn9w.d.mts} +1 -1
  178. package/dist/{types-Cc8l9IqS.d.mts → types-BnIqOn9w.d.ts} +1 -1
  179. package/dist/{utils-BN70ueSN.d.ts → utils-BAtVIHfw.d.mts} +2 -2
  180. package/dist/{utils-BrjR5xRs.d.mts → utils-Y8MZrj4b.d.ts} +2 -2
  181. package/dist/version.cjs +2 -2
  182. package/dist/version.mjs +1 -1
  183. package/dist/vite.cjs +5 -5
  184. package/dist/vite.d.mts +14 -14
  185. package/dist/vite.d.ts +14 -14
  186. package/dist/vite.mjs +4 -4
  187. package/dist/{workflows-IWP1ddBm.d.mts → workflows-Df1C_7OG.d.mts} +1 -1
  188. package/dist/{workflows-IWP1ddBm.d.ts → workflows-Df1C_7OG.d.ts} +1 -1
  189. package/dist/workflows.d.mts +1 -1
  190. package/dist/workflows.d.ts +1 -1
  191. package/package.json +3 -3
@@ -1,29 +1,65 @@
1
1
  import { n as FarmClientPlugin } from './lifecycle-DK06VuKP.mjs';
2
- import { b as PluginRoutes, c as PluginRoutesFactory, d as RouteMethod, F as FarmIntegrationAPI, i as FarmIntegrationAPIMethod, h as FarmIntegrationAPIBodyFormat, j as FarmIntegrationAPIOperation, k as FarmIntegrationAPIResponseFormat, l as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes } from './integration-api-DWyMmvrR.mjs';
2
+ import { b as PluginRoutes, c as PluginRoutesFactory, d as RouteMethod, F as FarmIntegrationAPI, f as FarmIntegrationAPIMethod, e as FarmIntegrationAPIBodyFormat, h as FarmIntegrationAPIResponseFormat, g as FarmIntegrationAPIOperation, i as FarmIntegrationRouteOperationCarrier, I as InferIntegrationAPIFromRoutes } from './route-2_yXC6gv.mjs';
3
3
  import { FarmRenderer } from './renderer.mjs';
4
4
  import { IncomingMessage, ServerResponse } from 'http';
5
- import { T as TypedEndpoint, E as EndpointMCPMetadata, R as RouteSchema, d as RouteSchemaOutput, e as RouteSchemaInput, Y as OpenAPISecurityMode } from './endpoint-DGZRZHux.mjs';
5
+ import { E as EndpointMCPMetadata, T as TypedEndpoint, R as RouteSchema, d as RouteSchemaOutput, e as RouteSchemaInput, Y as OpenAPISecurityMode } from './endpoint-BkMSCRf6.mjs';
6
6
  import { ServerFn } from './server-fn.mjs';
7
7
  import { ServerQuery } from './server-query.mjs';
8
- import { d as FarmStorageUserConfig } from './types-Cc8l9IqS.mjs';
9
- import { FarmSchemaField, FarmSchema, FarmSchemaModel, FarmSchemaReference, FarmSchemaFieldType, FarmSchemaConstraint, FarmSchemaModelExtension, FarmSchemaModelOverride, defineSchema, FarmSchemaConfig } from './schema.mjs';
8
+ import { F as FarmStorageUserConfig } from './types-BnIqOn9w.mjs';
9
+ import { FarmSchemaModel, FarmSchemaField, FarmSchema, FarmSchemaReference, FarmSchemaConfig, FarmSchemaConstraint, FarmSchemaFieldType, FarmSchemaModelExtension, FarmSchemaModelOverride, defineSchema } from './schema.mjs';
10
10
  import React__default, { ComponentType, ReactNode } from 'react';
11
11
  import { OrmClient, SchemaDefinition, ModelDefinition, FieldBuilder, JsonValue, AnyModelDefinition, SchemaModels } from '@farming-labs/orm';
12
12
  import { DocsConfig } from '@farming-labs/docs';
13
- import { I as FarmObservabilityUserConfig } from './observability-CoXunYhS.mjs';
13
+ import { p as FarmObservabilityUserConfig } from './observability-B2363jB6.mjs';
14
14
  import * as vite from 'vite';
15
15
  import { ViteDevServer, UserConfig } from 'vite';
16
- import { f as FarmWorkflowsUserConfig, a as FarmServerConfig, F as FarmWorkflowsResolvedConfig, R as ResolvedFarmServerConfig } from './workflows-IWP1ddBm.mjs';
16
+ import { n as FarmWorkflowsUserConfig, f as FarmServerConfig, F as FarmWorkflowsResolvedConfig, R as ResolvedFarmServerConfig } from './workflows-Df1C_7OG.mjs';
17
17
  import { FarmCronUserConfig, FarmCronResolvedConfig } from './cron.mjs';
18
18
  import { ResolvedFarmEnv, FarmEnvConfig } from './env.mjs';
19
19
  import { FarmServerActionsConfig, ResolvedFarmServerActionsConfig } from './server-action-security.mjs';
20
- import { F as FarmLayerEntry, R as ResolvedFarmLayer } from './layers-CM5i6T7z.mjs';
21
- import { F as FarmImageConfig, R as ResolvedFarmImageConfig } from './image-config-BpH1q5R8.mjs';
22
- import { k as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.mjs';
20
+ import { F as FarmLayerEntry, R as ResolvedFarmLayer } from './layers-D9fbe-rz.mjs';
21
+ import { a as FarmImageConfig, R as ResolvedFarmImageConfig } from './image-config-CeDgNyX4.mjs';
22
+ import { k as FarmI18nUserConfig, R as ResolvedFarmI18nConfig } from './types--Wh02r5_.mjs';
23
23
  import { FarmCacheUserConfig } from './cache.mjs';
24
24
  import { R as ResolvedFarmThemeConfig, d as FarmThemeConfig } from './types-DQnyD3VD.mjs';
25
25
  import { FarmLayoutFonts } from './font.mjs';
26
26
 
27
+ /**
28
+ * Integration auth routes accept ordinary form posts, which browsers send
29
+ * cross-site without a CORS preflight. Without an origin check, a third-party
30
+ * page can submit credentials to an app's own sign-in route and plant an
31
+ * attacker-controlled session in the victim's browser (login CSRF), or drive a
32
+ * forced sign-out. This mirrors the server-action origin contract so both
33
+ * entry points reject the same requests.
34
+ */
35
+ type IntegrationOriginRejection = "missing-origin" | "opaque-origin" | "invalid-origin" | "cross-site";
36
+ type IntegrationOriginResult = {
37
+ ok: true;
38
+ } | {
39
+ ok: false;
40
+ reason: IntegrationOriginRejection;
41
+ };
42
+ interface IntegrationOriginPolicy {
43
+ /** Extra trusted origins, using the `serverActions.allowedOrigins` pattern syntax. */
44
+ allowedOrigins?: readonly string[];
45
+ /**
46
+ * Whether a request carrying no origin metadata at all must be rejected.
47
+ *
48
+ * Form posts always carry an Origin header in supported browsers, so
49
+ * state-changing POSTs default to rejecting (`true`). Top-level GET
50
+ * navigations legitimately arrive with no Origin and no Referer — a typed
51
+ * URL or a bookmark — so GET callers pass `false` to avoid breaking them.
52
+ */
53
+ requireOriginMetadata?: boolean;
54
+ }
55
+ /**
56
+ * Resolve configured origin patterns once, at integration construction, so an
57
+ * invalid pattern fails loudly at startup instead of per request.
58
+ */
59
+ declare function resolveIntegrationAllowedOrigins(values: readonly string[] | undefined, label: string): readonly string[];
60
+ declare function validateIntegrationRequestOrigin(request: Request, policy?: IntegrationOriginPolicy): IntegrationOriginResult;
61
+ declare function describeIntegrationOriginRejection(reason: IntegrationOriginRejection): string;
62
+
27
63
  /**
28
64
  * `experimental.serverComponents`: which engine renders server components.
29
65
  *
@@ -1665,1543 +1701,951 @@ interface ResolvedFarmAgentConfig {
1665
1701
  mcp: boolean;
1666
1702
  }
1667
1703
 
1668
- /**
1669
- * Integration auth routes accept ordinary form posts, which browsers send
1670
- * cross-site without a CORS preflight. Without an origin check, a third-party
1671
- * page can submit credentials to an app's own sign-in route and plant an
1672
- * attacker-controlled session in the victim's browser (login CSRF), or drive a
1673
- * forced sign-out. This mirrors the server-action origin contract so both
1674
- * entry points reject the same requests.
1675
- */
1676
- type IntegrationOriginRejection = "missing-origin" | "opaque-origin" | "invalid-origin" | "cross-site";
1677
- type IntegrationOriginResult = {
1678
- ok: true;
1679
- } | {
1680
- ok: false;
1681
- reason: IntegrationOriginRejection;
1682
- };
1683
- interface IntegrationOriginPolicy {
1684
- /** Extra trusted origins, using the `serverActions.allowedOrigins` pattern syntax. */
1685
- allowedOrigins?: readonly string[];
1704
+ interface FarmDocsAdapterDescriptor {
1705
+ id: string;
1706
+ protocol: number;
1707
+ server: string;
1708
+ react?: string;
1709
+ vite?: string;
1686
1710
  /**
1687
- * Whether a request carrying no origin metadata at all must be rejected.
1688
- *
1689
- * Form posts always carry an Origin header in supported browsers, so
1690
- * state-changing POSTs default to rejecting (`true`). Top-level GET
1691
- * navigations legitimately arrive with no Origin and no Referer — a typed
1692
- * URL or a bookmark — so GET callers pass `false` to avoid breaking them.
1711
+ * Build-time entry that compiles the adapter's docs runtime into Farm's
1712
+ * serializable edge manifest. Older Farm releases safely ignore it.
1693
1713
  */
1694
- requireOriginMetadata?: boolean;
1714
+ edgeCompiler?: string;
1695
1715
  }
1696
- /**
1697
- * Resolve configured origin patterns once, at integration construction, so an
1698
- * invalid pattern fails loudly at startup instead of per request.
1699
- */
1700
- declare function resolveIntegrationAllowedOrigins(values: readonly string[] | undefined, label: string): readonly string[];
1701
- declare function validateIntegrationRequestOrigin(request: Request, policy?: IntegrationOriginPolicy): IntegrationOriginResult;
1702
- declare function describeIntegrationOriginRejection(reason: IntegrationOriginRejection): string;
1703
-
1704
- type RuntimeClientFactory<TClient> = () => TClient | Promise<TClient>;
1705
- type FarmIntegrationOrmSchema = SchemaDefinition<Record<string, AnyModelDefinition>>;
1706
- type FarmIntegrationOrmClient<TSchema extends FarmIntegrationOrmSchema> = OrmClient<TSchema>;
1707
- type FarmIntegrationOrmFieldKind<TField extends FarmIntegrationSchemaField> = TField extends {
1708
- primaryKey: true;
1709
- } ? TField["type"] extends "id" | "uuid" | "string" | "integer" ? "id" : never : TField["type"] extends "id" | "uuid" | "text" ? "string" : TField["type"] extends "number" ? "decimal" : Extract<TField["type"], "string" | "boolean" | "integer" | "datetime" | "json" | "enum">;
1710
- type FarmIntegrationOrmFieldNullable<TField extends FarmIntegrationSchemaField> = TField extends {
1711
- nullable: true;
1712
- } ? true : TField extends {
1713
- required: false;
1714
- } ? true : false;
1715
- type FarmIntegrationOrmEnumValue<TField extends FarmIntegrationSchemaField> = TField extends {
1716
- values: readonly (infer TValue extends string)[];
1717
- } ? TValue : string;
1718
- type FarmIntegrationOrmFieldValue<TField extends FarmIntegrationSchemaField> = TField["type"] extends "id" | "uuid" | "string" | "text" ? string : TField["type"] extends "boolean" ? boolean : TField["type"] extends "integer" ? number : TField["type"] extends "number" ? string : TField["type"] extends "datetime" ? Date : TField["type"] extends "json" ? JsonValue : TField["type"] extends "enum" ? FarmIntegrationOrmEnumValue<TField> : never;
1719
- type InferFarmIntegrationOrmField<TField extends FarmIntegrationSchemaField> = FieldBuilder<FarmIntegrationOrmFieldKind<TField>, FarmIntegrationOrmFieldNullable<TField>, FarmIntegrationOrmFieldValue<TField>>;
1720
- type FarmIntegrationOrmModelShape = {
1721
- fields: Record<string, unknown>;
1722
- };
1723
- type InferFarmIntegrationOrmFields<TModel extends FarmIntegrationOrmModelShape> = {
1724
- [TFieldKey in keyof TModel["fields"] & string]: InferFarmIntegrationOrmField<Extract<TModel["fields"][TFieldKey], FarmIntegrationSchemaField>>;
1725
- };
1726
- type ReplaceRecord<TBase, TReplacement> = Omit<TBase, keyof TReplacement> & TReplacement;
1727
- type SchemaExtensions<TSchema extends FarmIntegrationSchema> = NonNullable<TSchema["extend"]>;
1728
- type SchemaOverrides<TSchema extends FarmIntegrationSchema> = NonNullable<TSchema["override"]>;
1729
- type SchemaModelFields<TModel> = TModel extends {
1730
- fields: infer TFields;
1731
- } ? TFields : TModel extends {
1732
- fields?: infer TFields;
1733
- } ? NonNullable<TFields> : {};
1734
- type ExtendedSchemaModelFields<TSchema extends FarmIntegrationSchema, TModelKey extends PropertyKey> = ReplaceRecord<TModelKey extends keyof TSchema["models"] ? SchemaModelFields<TSchema["models"][TModelKey]> : {}, TModelKey extends keyof SchemaExtensions<TSchema> ? SchemaModelFields<SchemaExtensions<TSchema>[TModelKey]> : {}>;
1735
- type OverrideSchemaModelFields<TSchema extends FarmIntegrationSchema, TModelKey extends PropertyKey> = TModelKey extends keyof SchemaOverrides<TSchema> ? SchemaModelFields<SchemaOverrides<TSchema>[TModelKey]> : {};
1736
- type ResolvedSchemaModelFields<TSchema extends FarmIntegrationSchema, TModelKey extends PropertyKey, TExtendedFields = ExtendedSchemaModelFields<TSchema, TModelKey>, TOverrideFields = OverrideSchemaModelFields<TSchema, TModelKey>> = {
1737
- [TFieldKey in keyof TExtendedFields | keyof TOverrideFields]: TFieldKey extends keyof TOverrideFields ? TFieldKey extends keyof TExtendedFields ? ReplaceRecord<TExtendedFields[TFieldKey], TOverrideFields[TFieldKey]> : TOverrideFields[TFieldKey] : TFieldKey extends keyof TExtendedFields ? TExtendedFields[TFieldKey] : never;
1716
+ interface FarmDocsSidebarItem {
1717
+ label?: string;
1718
+ title?: string;
1719
+ slug?: string;
1720
+ href?: string;
1721
+ icon?: string;
1722
+ children?: FarmDocsSidebarItem[];
1723
+ items?: FarmDocsSidebarItem[];
1724
+ }
1725
+ interface FarmDocsNavigationConfig {
1726
+ sidebar?: FarmDocsSidebarItem[];
1727
+ }
1728
+ interface FarmDocsSocialImageConfig {
1729
+ /** Generate a page-specific 1200×630 social image. Defaults to true. */
1730
+ enabled?: boolean;
1731
+ /** Absolute public origin used in social metadata, e.g. https://example.com. */
1732
+ baseUrl?: string;
1733
+ /** Site name shown in Open Graph metadata. Defaults to the docs navigation title. */
1734
+ siteName?: string;
1735
+ /** Short brand label drawn in the image header. Defaults to siteName. */
1736
+ brand?: string;
1737
+ /** Optional WOFF2 URLs or data URLs embedded into the generated SVG. */
1738
+ fonts?: FarmDocsSocialImageFonts;
1739
+ }
1740
+ interface FarmDocsSocialImageFonts {
1741
+ /** Display face used for page titles. */
1742
+ display?: string;
1743
+ /** Sans-serif face used for descriptions. */
1744
+ sans?: string;
1745
+ /** Monospace face used for labels, routes, and diagrams. */
1746
+ mono?: string;
1747
+ }
1748
+ type FarmDocsRuntimeConfig = Partial<DocsConfig> & {
1749
+ /**
1750
+ * Public favicon URL used by the standalone docs renderer.
1751
+ * Set this explicitly when docs should share the host application's icon.
1752
+ */
1753
+ favicon?: string;
1754
+ /**
1755
+ * Optional serializable navigation tree used by Farm's docs runtime.
1756
+ * Icon values reference keys from `icons`.
1757
+ */
1758
+ navigation?: FarmDocsNavigationConfig;
1759
+ /**
1760
+ * Automatic page-specific Open Graph and X images for Markdown docs.
1761
+ * Enabled by default. Set false to opt out for the complete docs tree.
1762
+ */
1763
+ socialImage?: boolean | FarmDocsSocialImageConfig;
1738
1764
  };
1739
- type ResolvedFarmIntegrationSchemaModels<TSchema extends FarmIntegrationSchema> = {
1740
- [TModelKey in (keyof TSchema["models"] | keyof SchemaExtensions<TSchema>) & string]: {
1741
- fields: ResolvedSchemaModelFields<TSchema, TModelKey>;
1742
- };
1765
+ type FarmDocsConfigInput = FarmDocsRuntimeConfig & {
1766
+ /**
1767
+ * Versioned runtime descriptor supplied by an external docs adapter.
1768
+ * Set false to pin the embedded renderer and disable framework
1769
+ * auto-detection.
1770
+ */
1771
+ adapter?: FarmDocsAdapterDescriptor | false;
1772
+ /**
1773
+ * Farm public route for docs, e.g. "/docs". When passed through
1774
+ * `config`, this is converted to the docs package's folder-style `entry`.
1775
+ */
1776
+ entry?: string;
1777
+ /** Explicit public route prefix. Defaults to `entry`. */
1778
+ docsPath?: string;
1779
+ /** Source content directory, relative to the project root. */
1780
+ contentDir?: string;
1781
+ /** Set to false to opt out even when a docs config file exists. */
1782
+ enabled?: boolean;
1783
+ /** Inline @farming-labs/docs config object. */
1784
+ config?: FarmDocsRuntimeConfig;
1785
+ /** Path to docs.config.* or docs.json. */
1786
+ configPath?: string;
1743
1787
  };
1744
- type InferFarmIntegrationOrmSchema<TSchema extends FarmIntegrationSchema> = SchemaDefinition<{
1745
- [TModelKey in keyof ResolvedFarmIntegrationSchemaModels<TSchema> & string]: ModelDefinition<InferFarmIntegrationOrmFields<Extract<ResolvedFarmIntegrationSchemaModels<TSchema>[TModelKey], FarmIntegrationOrmModelShape>>, {}>;
1746
- }>;
1747
- type InferFarmIntegrationOrmClient<TSchema extends FarmIntegrationSchema | undefined> = TSchema extends FarmIntegrationSchema ? OrmClient<InferFarmIntegrationOrmSchema<TSchema>> : never;
1748
- interface CreateIntegrationOrmOptions<TClient = unknown, TSchema extends FarmIntegrationSchema = FarmIntegrationSchema> {
1749
- schema: TSchema;
1750
- config?: Pick<FarmConfig, "storage">;
1751
- storage?: FarmStorageUserConfig;
1752
- client?: TClient | RuntimeClientFactory<TClient>;
1788
+ type FarmDocsUserConfig = boolean | FarmDocsConfigInput;
1789
+ interface FarmDocsResolvedConfig {
1790
+ enabled: boolean;
1791
+ entry: string;
1792
+ adapter?: FarmDocsAdapterDescriptor;
1793
+ contentDir?: string;
1794
+ configPath?: string;
1795
+ config: FarmDocsRuntimeConfig & Pick<DocsConfig, "entry">;
1796
+ /**
1797
+ * `config` before it was made serializable: icons and other React elements, MDX
1798
+ * components, and callbacks intact. Only the in-process adapter runtime reads it;
1799
+ * whatever Farm serializes uses `config`.
1800
+ */
1801
+ runtimeConfig?: FarmDocsRuntimeConfig & Pick<DocsConfig, "entry">;
1802
+ /** The serializable docs settings from `farm.config.ts`, applied over the config file. */
1803
+ configOverrides?: Partial<DocsConfig>;
1753
1804
  }
1754
- declare function createIntegrationOrm<TClient = unknown, TSchema extends FarmIntegrationSchema = FarmIntegrationSchema>(options: CreateIntegrationOrmOptions<TClient, TSchema>): Promise<InferFarmIntegrationOrmClient<TSchema>>;
1755
- declare function resolveIntegrationOrmRuntimeClient<TClient = unknown>(options: Omit<CreateIntegrationOrmOptions<TClient>, "schema">): Promise<TClient | unknown | undefined>;
1756
- declare function farmIntegrationSchemaToOrmSchema(schema: FarmIntegrationSchema): Promise<FarmIntegrationOrmSchema>;
1757
- type IntegrationOrmModelNames<TSchema extends FarmIntegrationOrmSchema> = keyof SchemaModels<TSchema> & string;
1758
1805
 
1759
- declare function isFarmIntegration(value: unknown): value is FarmIntegration;
1806
+ type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
1807
+ type FarmMdxComponents = Record<string, FarmMdxComponent>;
1808
+ interface FarmMdxUserConfig {
1809
+ /**
1810
+ * Component map or module path that exports `components` or a default component map.
1811
+ * Relative paths resolve from the project root.
1812
+ */
1813
+ components?: string | FarmMdxComponents;
1814
+ /**
1815
+ * Serve source-authored markdown pages at `/route.md`.
1816
+ * Enabled by default for `page.md` and `page.mdx`.
1817
+ */
1818
+ markdownRoutes?: boolean;
1819
+ /** Class name used for the wrapper around rendered markdown content. */
1820
+ className?: string;
1821
+ }
1822
+ interface FarmMdxResolvedConfig {
1823
+ components?: string | FarmMdxComponents;
1824
+ markdownRoutes: boolean;
1825
+ className: string;
1826
+ }
1827
+ declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
1760
1828
  /**
1761
- * @internal Whether an integration's middleware matcher (a `protectedRoutes` guard, say)
1762
- * covers `pathname`, a route path without the base path. With `catchAllProbe`, a path no
1763
- * route uses, only matchers naming particular paths count: middleware without a matcher,
1764
- * or one that also meets the probe, covers every path and is left out.
1829
+ * The MDX components module a Markdown page renders from, as an absolute path. Undefined when
1830
+ * the components are an inline object, which cannot be analyzed for client components.
1765
1831
  */
1766
- declare function integrationMiddlewareMayHandlePath(integrations: FarmIntegrationsUserConfig | undefined, pathname: string, catchAllProbe?: string): boolean;
1832
+ declare function resolveFarmMdxComponentsModulePath(config: FarmMdxResolvedConfig | undefined, root: string): string | undefined;
1833
+
1767
1834
  /**
1768
- * @internal Runtime config key holding the app's same-origin API path. The built server keeps the
1769
- * user's raw `api` config, whose values may be resolver functions, so the build records the
1770
- * resolved path here; development configs carry the resolved `api` itself.
1835
+ * Farm.js Middleware System
1836
+ *
1837
+ * Type definitions for the middleware system
1771
1838
  */
1772
- declare const FARM_INTEGRATION_API_BASE_PATH_KEY = "__farmAPIServerBasePath";
1773
1839
 
1774
- type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
1775
- /** @deprecated Use FarmIntegrationCategory instead. */
1776
- type FarmIntegrationSlot = FarmIntegrationCategory;
1777
- type FarmIntegrationRouteParamValue = string | string[];
1778
- type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
1779
- type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
1780
- type FarmIntegrationRouteInputSource = "body" | "query";
1781
- type MaybePromise<T> = T | Promise<T>;
1782
- type FarmIntegrationValidationPathSegment = PropertyKey | {
1783
- readonly key: PropertyKey;
1784
- };
1785
- interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
1786
- body?: TBody;
1787
- query?: TQuery;
1788
- }
1789
- interface FarmIntegrationValidationIssue {
1790
- source: FarmIntegrationRouteInputSource;
1791
- path?: readonly (string | number)[];
1792
- code?: string;
1793
- message: string;
1794
- }
1795
- interface FarmIntegrationValidationErrorLike {
1796
- issues?: readonly {
1797
- path?: readonly FarmIntegrationValidationPathSegment[];
1798
- code?: string;
1799
- message?: string;
1800
- }[];
1801
- message?: string;
1840
+ /**
1841
+ * Next function type for middleware chain
1842
+ */
1843
+ type MiddlewareResult = void | Response;
1844
+ type NextFunction = () => Promise<MiddlewareResult>;
1845
+ type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
1846
+ /**
1847
+ * A typed view over the request-scoped maps used by middleware.
1848
+ */
1849
+ interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
1850
+ readonly size: number;
1851
+ get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
1852
+ has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
1853
+ entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
1854
+ keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
1855
+ values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
1856
+ forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
1857
+ [Symbol.iterator](): IterableIterator<[
1858
+ MiddlewareStoreKey<TValues>,
1859
+ TValues[MiddlewareStoreKey<TValues>]
1860
+ ]>;
1802
1861
  }
1803
- type FarmIntegrationValidationResult<TValue> = {
1804
- success: true;
1805
- data: TValue;
1806
- } | {
1807
- success: false;
1808
- error: FarmIntegrationValidationErrorLike;
1809
- };
1810
- type FarmIntegrationStandardValidationResult<TValue> = {
1811
- value: TValue;
1812
- } | {
1813
- issues: readonly {
1814
- path?: readonly FarmIntegrationValidationPathSegment[];
1815
- code?: string;
1816
- message: string;
1817
- }[];
1818
- };
1819
- interface FarmIntegrationInputSchema<TValue = unknown> {
1820
- _output?: TValue;
1821
- parse?(value: unknown): MaybePromise<TValue>;
1822
- safeParse?(value: unknown): MaybePromise<FarmIntegrationValidationResult<TValue>>;
1823
- safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
1824
- "~standard"?: {
1825
- validate(value: unknown): MaybePromise<FarmIntegrationStandardValidationResult<TValue>>;
1826
- types?: {
1827
- output: TValue;
1828
- };
1829
- };
1862
+ interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
1863
+ clear(): void;
1864
+ delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
1865
+ set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
1830
1866
  }
1831
- interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
1832
- body?: FarmIntegrationInputSchema<TBody>;
1833
- query?: FarmIntegrationInputSchema<TQuery>;
1867
+ /**
1868
+ * Middleware function signature
1869
+ */
1870
+ type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
1871
+ /**
1872
+ * Context passed to a named, request-first middleware export.
1873
+ * `locals` and the get/set helpers stay on the server. `data` can be exposed
1874
+ * through page props and should contain only serializable, client-safe values.
1875
+ */
1876
+ interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
1877
+ readonly url: URL;
1878
+ readonly pathname: string;
1879
+ /** The pathname the router matches: decoded once, without basePath or locale. */
1880
+ readonly routePathname: string;
1881
+ readonly searchParams: URLSearchParams;
1882
+ readonly method: string;
1883
+ readonly params: Record<string, string>;
1884
+ readonly route: string;
1885
+ readonly locals: MiddlewareStore<TLocals>;
1886
+ readonly data: MiddlewareStore<TData>;
1887
+ readonly headers: Map<string, string>;
1888
+ readonly cookies: CookieJar;
1889
+ get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
1890
+ has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
1891
+ set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
1892
+ delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
1893
+ redirect(url: string, status?: number): void;
1894
+ rewrite(url: string): void;
1895
+ json(data: any, status?: number): void;
1896
+ text(content: string, status?: number): void;
1897
+ html(content: string, status?: number): void;
1834
1898
  }
1835
- /** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
1836
- type FarmIntegrationRequestContextStore = FarmRequestStore;
1837
- declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
1899
+ 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>;
1838
1900
  /**
1839
- * Request-context key under which an integration middleware can hand
1840
- * `Set-Cookie` values to the runtime when it returns `void` (i.e. lets the
1841
- * request continue to the downstream route/page handler). The runtime reads
1842
- * this key back after a `void` middleware return and forwards the cookies onto
1843
- * the response it ultimately sends, so a server-side session refresh (or any
1844
- * other cookie rotation) reaches the browser instead of being dropped.
1901
+ * Cookie options
1845
1902
  */
1846
- declare const FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
1903
+ interface CookieOptions {
1904
+ maxAge?: number;
1905
+ expires?: Date;
1906
+ path?: string;
1907
+ domain?: string;
1908
+ secure?: boolean;
1909
+ httpOnly?: boolean;
1910
+ sameSite?: "strict" | "lax" | "none";
1911
+ }
1847
1912
  /**
1848
- * Forward `Set-Cookie` values from an integration middleware that returns
1849
- * `void` (the authenticated/passthrough branch) to the runtime, so they are
1850
- * merged onto the response the runtime sends for the matched route. This is
1851
- * the passthrough counterpart to appending `Set-Cookie` to a `Response` the
1852
- * middleware returns directly (e.g. a failure redirect): both paths can rotate
1853
- * auth cookies, and both must be able to reach the browser.
1913
+ * Cookie management interface
1854
1914
  */
1855
- declare function forwardIntegrationSetCookies(context: Pick<FarmIntegrationHandlerContext, "req">, cookies: string[]): void;
1856
- type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
1857
- interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1858
- getClient(): Promise<unknown | undefined>;
1859
- getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
1915
+ interface CookieJar {
1916
+ get(name: string): string | undefined;
1917
+ set(name: string, value: string, options?: CookieOptions): void;
1918
+ /**
1919
+ * Remove a cookie. Pass the `path`/`domain` it was set with; a tombstone only
1920
+ * matches a cookie with the same scope.
1921
+ */
1922
+ delete(name: string, options?: CookieOptions): void;
1923
+ getAll(): Record<string, string>;
1860
1924
  }
1861
- interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1862
- db: FarmIntegrationRouteDb<TSchema>;
1863
- getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
1864
- storage: FarmIntegrationRouteStorageArgs<TSchema>;
1925
+ interface RateLimitIncrementResult {
1926
+ count: number;
1927
+ /** Unix epoch timestamp in milliseconds when the fixed window resets. */
1928
+ resetAt: number;
1865
1929
  }
1866
- interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1867
- key: string;
1868
- integration: FarmIntegration<TSchema, any>;
1869
- appConfig: FarmPluginContext["config"];
1870
- /** Alias for appConfig. */
1871
- config: FarmPluginContext["config"];
1872
- args: FarmIntegrationRouteArgs<TSchema>;
1873
- env: Record<string, string | undefined>;
1874
- isDev: boolean;
1875
- isProd: boolean;
1930
+ interface RateLimitStorage {
1931
+ /** Atomically increment a key and create or retain its fixed expiry window. */
1932
+ increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
1933
+ /** Optional inspection support used by getRateLimitStatus(). */
1934
+ get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
1876
1935
  }
1877
- interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1878
- schema?: FarmIntegrationInputSchema<TConfig>;
1879
- env?: Record<string, string | readonly string[]>;
1880
- defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
1881
- input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
1882
- resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise<TConfig | Partial<TConfig> | undefined>;
1936
+ interface MemoryRateLimitStorageOptions {
1937
+ /** Maximum number of active keys retained by this process. */
1938
+ maxEntries?: number;
1883
1939
  }
1884
- type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
1885
- type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
1886
- interface FarmIntegrationLifecycleLogger {
1887
- info(message: string, meta?: Record<string, unknown>): void;
1888
- warn(message: string, meta?: Record<string, unknown>): void;
1889
- error(message: string, meta?: Record<string, unknown>): void;
1940
+ interface RateLimitConfig {
1941
+ requests: number;
1942
+ window: string;
1943
+ keyGenerator?: (ctx: MiddlewareContext) => string;
1944
+ onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
1945
+ storage?: RateLimitStorage;
1890
1946
  }
1891
- interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
1892
- integration: FarmIntegration<TSchema, TConfig>;
1893
- integrationConfig: TConfig;
1894
- log: FarmIntegrationLifecycleLogger;
1895
- reason?: string;
1896
- cleanup(callback?: () => MaybePromise<void>): Promise<void>;
1947
+ interface RateLimitStatus {
1948
+ requests: number;
1949
+ limit: number;
1950
+ remaining: number;
1951
+ resetIn: number | null;
1952
+ resetAt: Date | null;
1953
+ isLimited: boolean;
1897
1954
  }
1898
- type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise<void>;
1899
1955
  /**
1900
- * Small per-call integration metadata. Values received over HTTP are
1901
- * client-controlled and should be validated before authorization decisions.
1956
+ * Middleware configuration
1902
1957
  */
1903
- type FarmIntegrationData = Record<string, unknown>;
1904
- interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1905
- request: Request;
1906
- requestId: string;
1958
+ type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
1959
+ interface MiddlewareConfig$1 {
1960
+ matcher?: MiddlewareMatcher | MiddlewareMatcher[];
1961
+ exclude?: (string | RegExp)[];
1962
+ runtime?: "nodejs" | "edge";
1963
+ /**
1964
+ * Whether a response this middleware lets through may be stored by a shared cache (a CDN).
1965
+ * Farm cannot tell a guard from harmless middleware, and a CDN serves its copy without
1966
+ * running either, so by default (`"private"`) the response is sent with
1967
+ * `Cache-Control: private, no-store`. Set `"public"` only on middleware that never decides
1968
+ * who may read the response, such as logging or response headers.
1969
+ */
1970
+ cache?: "private" | "public";
1971
+ }
1972
+ interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
1973
+ handler?: MiddlewareFunction;
1974
+ handlers?: MiddlewareFunction[];
1975
+ }
1976
+ type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
1977
+ /**
1978
+ * Middleware context - the main object passed to middleware functions
1979
+ */
1980
+ interface MiddlewareContext {
1981
+ request: IncomingMessage;
1982
+ response: ServerResponse;
1907
1983
  url: URL;
1984
+ /** Request pathname as received: still percent-encoded and carrying basePath/locale. */
1908
1985
  pathname: string;
1986
+ /**
1987
+ * The pathname the router matches: decoded once, without basePath or locale. String matchers
1988
+ * compare this value; compare it in path checks too. Updated by `rewrite()`.
1989
+ */
1990
+ readonly routePathname: string;
1991
+ searchParams: URLSearchParams;
1909
1992
  method: string;
1910
- params: FarmIntegrationRouteParams;
1911
- input: FarmIntegrationRouteInput<TBody, TQuery>;
1912
- args: FarmIntegrationRouteArgs<TSchema>;
1913
- data: FarmIntegrationData;
1914
- integration: {
1915
- category: FarmIntegrationCategory;
1916
- /** @deprecated Use category instead. */
1917
- slot: FarmIntegrationCategory;
1918
- type: string;
1919
- instance: unknown;
1993
+ params: Record<string, string>;
1994
+ route: string;
1995
+ parent?: {
1996
+ data: Map<string, any>;
1997
+ locals?: Map<string, any>;
1998
+ headers: Record<string, string>;
1920
1999
  };
1921
- route: {
1922
- kind: "route" | "middleware";
1923
- path: string;
1924
- methods: readonly string[];
2000
+ vite: {
2001
+ isDev: boolean;
2002
+ hmr: boolean;
2003
+ server?: ViteDevServer;
1925
2004
  };
1926
- req: FarmRequestStore;
1927
- /** @deprecated Use `req` instead. */
1928
- requestContext: FarmRequestStore;
1929
- config: FarmPluginContext["config"];
1930
- isDev: boolean;
1931
- isProd: boolean;
2005
+ data: Map<string, any>;
2006
+ locals: Map<string, any>;
2007
+ headers: Map<string, string>;
2008
+ cookies: CookieJar;
2009
+ _handled: boolean;
2010
+ _redirectUrl?: string;
2011
+ _rewriteUrl?: string;
2012
+ redirect(url: string, status?: number): void;
2013
+ rewrite(url: string): void;
2014
+ json(data: any, status?: number): void;
2015
+ text(content: string, status?: number): void;
2016
+ html(content: string, status?: number): void;
1932
2017
  }
1933
- interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
1934
- response?: Response;
2018
+ /**
2019
+ * Middleware chain interface
2020
+ */
2021
+ interface MiddlewareChain {
2022
+ use(fn: MiddlewareFunction): MiddlewareChain;
2023
+ /**
2024
+ * Conditionally run middleware based on a condition.
2025
+ * Supports boolean values or functions that evaluate to boolean.
2026
+ *
2027
+ * @example
2028
+ * .when(true, (ctx, next) => { ... }) // Always run
2029
+ * .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
2030
+ */
2031
+ when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
2032
+ rateLimit(config: RateLimitConfig): MiddlewareChain;
2033
+ redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
2034
+ /**
2035
+ * Rewrite the current route to a new destination.
2036
+ * In route-specific middleware, this rewrites the middleware's route.
2037
+ *
2038
+ * @param destination - The destination path to rewrite to
2039
+ * @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
2040
+ *
2041
+ * @example
2042
+ * // In /contact/middleware.ts
2043
+ * .rewrite('/about') // Always rewrites /contact to /about
2044
+ * .rewrite('/about', true) // Always rewrites
2045
+ * .rewrite('/about', false) // Never rewrites
2046
+ * .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
2047
+ */
2048
+ rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
2049
+ build(): {
2050
+ handlers: MiddlewareFunction[];
2051
+ config?: MiddlewareConfig$1;
2052
+ };
1935
2053
  }
1936
- type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
1937
- bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
1938
- }["bivarianceHack"];
1939
- interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1940
- path: string;
1941
- method?: FarmIntegrationRouteMethod;
1942
- methods?: readonly FarmIntegrationRouteMethod[];
1943
- middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
1944
- before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
1945
- after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
1946
- rawBody?: boolean;
1947
- bodyFormat?: FarmIntegrationAPIBodyFormat;
1948
- body?: FarmIntegrationInputSchema<TBody>;
1949
- query?: FarmIntegrationInputSchema<TQuery>;
1950
- input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
1951
- handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
2054
+ /**
2055
+ * Middleware module export
2056
+ */
2057
+ interface MiddlewareModule {
2058
+ default?: MiddlewareChain | MiddlewareFunction;
2059
+ middleware?: RequestMiddleware;
2060
+ config?: MiddlewareConfig$1;
1952
2061
  }
1953
- 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> {
1954
- path: TPath;
1955
- method: TMethod;
1956
- __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
2062
+
2063
+ type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
2064
+ interface FarmRedirectSignal {
2065
+ url: string;
2066
+ status: FarmRedirectStatus;
1957
2067
  }
1958
- interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1959
- handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
2068
+ declare function redirect(url: string, status?: FarmRedirectStatus): never;
2069
+ declare function permanentRedirect(url: string): never;
2070
+ declare function notFound(): never;
2071
+ declare function isFarmRedirectError(error: unknown): boolean;
2072
+ declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
2073
+ declare function isFarmNotFoundError(error: unknown): boolean;
2074
+
2075
+ type FarmBuildActivityPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
2076
+ interface FarmDevIndicatorsConfig {
2077
+ /** Show build and HMR activity in the browser during development. */
2078
+ buildActivity?: boolean;
2079
+ /** Corner used by the build activity indicator. */
2080
+ buildActivityPosition?: FarmBuildActivityPosition;
1960
2081
  }
1961
- interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
1962
- matcher?: string | string[];
1963
- handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
2082
+ interface ResolvedFarmDevIndicatorsConfig {
2083
+ buildActivity: boolean;
2084
+ buildActivityPosition: FarmBuildActivityPosition;
1964
2085
  }
1965
- interface FarmIntegrationProviderProps {
1966
- children: ReactNode;
2086
+ declare function resolveFarmDevIndicatorsConfig(config: FarmDevIndicatorsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevIndicatorsConfig;
2087
+ declare function generateFarmDevIndicatorsClientRuntime(config: ResolvedFarmDevIndicatorsConfig): string;
2088
+
2089
+ interface FarmAuthEmailAndPasswordConfig {
2090
+ /** Require a verified email before creating a session. @default false */
2091
+ requireEmailVerification?: boolean;
2092
+ /** Smallest accepted password length. @default 8 */
2093
+ minPasswordLength?: number;
2094
+ /** Largest accepted password length. @default 128 */
2095
+ maxPasswordLength?: number;
1967
2096
  }
1968
- interface FarmIntegrationProviderComponentReference {
1969
- /** Client-safe module specifier using `@/`, a path relative to the app root, or a package. */
1970
- module: string;
1971
- /** Named export to use. Defaults to the module's default export. */
1972
- export?: string;
2097
+ interface FarmAuthSessionConfig {
2098
+ /** Session lifetime in seconds. @default 604800 */
2099
+ expiresIn?: number;
2100
+ /** Session refresh interval in seconds. @default 86400 */
2101
+ updateAge?: number;
1973
2102
  }
1974
- interface FarmIntegrationProvider {
1975
- name: string;
1976
- type: string;
1977
- props?: Record<string, unknown>;
2103
+ interface FarmAuthDatabaseConfig {
1978
2104
  /**
1979
- * The provider can be instantiated independently around each isolated
1980
- * client root without relying on context or state owned by the route root.
1981
- * Providers are treated as route-wide unless they explicitly opt in.
2105
+ * Postgres connection string. Defaults to DATABASE_URL.
2106
+ * Local development falls back to SQLite when no URL is present.
1982
2107
  */
1983
- supportsIsolatedHydration?: boolean;
1984
- component?: ComponentType<FarmIntegrationProviderProps> | FarmIntegrationProviderComponentReference;
2108
+ url?: string;
2109
+ /** Local SQLite path. @default ".farm/auth.sqlite" */
2110
+ path?: string;
2111
+ /** Automatically update the auth schema in development. @default true */
2112
+ migrateInDevelopment?: boolean;
1985
2113
  }
1986
- interface FarmIntegrationDocumentNavigation {
1987
- matcher: string | readonly string[];
2114
+ interface FarmAuthConfig {
2115
+ /** Set false to disable auth without removing its configuration. @default true */
2116
+ enabled?: boolean;
2117
+ /** Display name used by authentication emails and metadata. */
2118
+ appName?: string;
2119
+ /** Route prefix for the auth endpoints. @default "/api/auth" */
2120
+ basePath?: string;
2121
+ /**
2122
+ * Email/password authentication. It is enabled by default; set false to
2123
+ * disable it when adding another sign-in method.
2124
+ */
2125
+ emailAndPassword?: boolean | FarmAuthEmailAndPasswordConfig;
2126
+ session?: FarmAuthSessionConfig;
2127
+ database?: FarmAuthDatabaseConfig;
1988
2128
  }
1989
- /** @deprecated Use `FarmSchemaFieldType`. */
1990
- type FarmIntegrationSchemaFieldType = FarmSchemaFieldType;
1991
- /** @deprecated Use `FarmSchemaReference`. */
1992
- type FarmIntegrationSchemaReference = FarmSchemaReference;
1993
- /** @deprecated Use `FarmSchemaField`. */
1994
- type FarmIntegrationSchemaField = FarmSchemaField;
1995
- /** @deprecated Use `FarmSchemaConstraint`. */
1996
- type FarmIntegrationSchemaConstraint = FarmSchemaConstraint;
1997
- /** @deprecated Use `FarmSchemaModel`. */
1998
- type FarmIntegrationSchemaModel = FarmSchemaModel;
1999
- /** @deprecated Use `FarmSchemaModelExtension`. */
2000
- type FarmIntegrationSchemaModelExtension = FarmSchemaModelExtension;
2001
- /** @deprecated Use `FarmSchemaModelOverride`. */
2002
- type FarmIntegrationSchemaModelOverride = FarmSchemaModelOverride;
2003
- /** @deprecated Use `FarmSchema`. */
2004
- type FarmIntegrationSchema = FarmSchema;
2005
- /** @deprecated Use `defineSchema`. This is an exact alias, not a wrapper. */
2006
- declare const defineIntegrationSchema: typeof defineSchema;
2007
- type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
2008
- interface FarmIntegrationLogEvent {
2009
- category: FarmIntegrationCategory;
2010
- /** @deprecated Use category instead. */
2011
- slot: FarmIntegrationCategory;
2012
- type: string;
2013
- phase: FarmIntegrationLogPhase;
2014
- route?: {
2015
- kind: "route" | "middleware";
2129
+ type FarmAuthUserConfig = boolean | FarmAuthConfig;
2130
+ interface ResolvedFarmAuthConfig {
2131
+ enabled: boolean;
2132
+ appName?: string;
2133
+ basePath: string;
2134
+ emailAndPassword: {
2135
+ enabled: boolean;
2136
+ requireEmailVerification: boolean;
2137
+ minPasswordLength: number;
2138
+ maxPasswordLength: number;
2139
+ };
2140
+ session: {
2141
+ expiresIn: number;
2142
+ updateAge: number;
2143
+ };
2144
+ database: {
2145
+ url?: string;
2016
2146
  path: string;
2017
- methods: readonly string[];
2147
+ migrateInDevelopment: boolean;
2018
2148
  };
2019
- requestId?: string;
2020
- request?: Request;
2021
- response?: Response;
2022
- error?: unknown;
2023
- durationMs?: number;
2024
- level?: FarmIntegrationLifecycleLogLevel;
2025
- message?: string;
2026
- meta?: Record<string, unknown>;
2027
- context: Map<string, unknown>;
2028
2149
  }
2029
- type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
2030
- interface FarmIntegrationPluginOwner {
2031
- key: string;
2032
- category: FarmIntegrationCategory;
2033
- type: string;
2034
- source: "lifecycle" | "contribution";
2035
- serverRuntime: boolean;
2150
+
2151
+ type FarmPreloadMode = "warn" | "enforce";
2152
+ interface FarmPreloadUserConfig {
2153
+ /** Report excess hints or remove the lower-priority hints. @default "enforce" */
2154
+ mode?: FarmPreloadMode;
2155
+ /** Maximum image preload hints per document. @default 1 */
2156
+ maxImages?: number;
2157
+ /** Maximum font preload hints per document. @default 2 */
2158
+ maxFonts?: number;
2036
2159
  }
2037
- /** A normal plugin or an integration-bound plugin compatible with the shared instance. */
2038
- type FarmIntegrationContributedPlugin<TInstance = unknown> = FarmPlugin<any, any, any, any, unknown, false> | FarmPlugin<any, any, any, any, TInstance, true>;
2039
- interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> {
2040
- readonly kind: "farm-integration";
2041
- category: FarmIntegrationCategory;
2042
- /** @deprecated Use category instead. */
2043
- slot?: FarmIntegrationCategory;
2044
- type: string;
2045
- instance: TInstance;
2046
- /** Set to false when a platform adapter owns this integration's production routes. */
2047
- serverRuntime?: boolean;
2048
- api?: FarmIntegrationAPI;
2049
- schema?: TSchema;
2050
- config?: FarmIntegrationConfigInput<TConfig, TSchema>;
2051
- validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2052
- setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2053
- ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2054
- dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
2055
- log?: FarmIntegrationLogger;
2056
- routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
2057
- endpoints?: FarmIntegrationEndpoints<TSchema>;
2058
- middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
2059
- providers?: readonly FarmIntegrationProvider[];
2060
- documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
2061
- /** Additional Farm plugins owned and configured by this integration. */
2062
- plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
2160
+ interface ResolvedFarmPreloadConfig {
2161
+ mode: FarmPreloadMode;
2162
+ maxImages: number;
2163
+ maxFonts: number;
2063
2164
  }
2064
- type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any, any> | undefined>;
2065
- /** @internal Identifies plugins owned by platform-managed integrations. */
2066
- declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
2067
- /** Returns the integration that contributed a normalized plugin, when applicable. */
2068
- declare function getFarmIntegrationPluginOwner(plugin: FarmPlugin): Readonly<FarmIntegrationPluginOwner> | undefined;
2069
- type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
2070
- middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
2071
- before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2072
- after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
2073
- rawBody?: boolean;
2074
- headers?: Record<string, string>;
2075
- credentials?: RequestCredentials;
2076
- bodyFormat?: FarmIntegrationAPIBodyFormat;
2077
- responseFormat?: FarmIntegrationAPIResponseFormat;
2078
- isServer?: TServer;
2079
- body?: FarmIntegrationInputSchema<TBody>;
2080
- query?: FarmIntegrationInputSchema<TQuery>;
2081
- input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
2082
- handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
2083
- };
2084
- interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2085
- 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>;
2086
- 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>;
2087
- 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>;
2088
- 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>;
2089
- 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>;
2090
- 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>;
2091
- 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>;
2092
- 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>;
2165
+ interface FarmPerformanceConfig {
2166
+ preload?: FarmPreloadUserConfig;
2093
2167
  }
2094
- interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
2095
- route: FarmIntegrationRouteFactory<TSchema>;
2096
- integrationRoute: FarmIntegrationRouteFactory<TSchema>;
2168
+ interface ResolvedFarmPerformanceConfig {
2169
+ preload: ResolvedFarmPreloadConfig;
2097
2170
  }
2098
- type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
2099
- type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
2100
- readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
2101
- };
2102
- type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
2103
- readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
2104
- };
2105
- interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
2106
- endpoint: FarmIntegrationRouteFactory<TSchema>;
2171
+ type FarmPreloadKind = "image" | "font";
2172
+ interface FarmPreloadBudgetWarning {
2173
+ kind: FarmPreloadKind;
2174
+ count: number;
2175
+ budget: number;
2176
+ removed: number;
2177
+ }
2178
+ interface FarmManagedPreloads {
2179
+ value: string;
2180
+ warnings: FarmPreloadBudgetWarning[];
2181
+ }
2182
+ interface FarmManagedDocumentPreloads {
2183
+ html: string;
2184
+ linkHeader: string;
2185
+ warnings: FarmPreloadBudgetWarning[];
2107
2186
  }
2108
- type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
2109
- declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
2110
- declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
2111
- type RegisteredIntegrationRuntime = {
2112
- integration: FarmIntegration;
2113
- config: FarmPluginContext["config"];
2114
- isDev: boolean;
2115
- isProd: boolean;
2116
- };
2117
- type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
2118
- type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
2119
- 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"> & {
2120
- instance: TInstance;
2121
- config?: FarmIntegrationConfigInput<TConfig, TSchema>;
2122
- routes?: FarmIntegrationRoutesInput<TSchema>;
2123
- endpoints?: FarmIntegrationEndpointsInput<TSchema>;
2124
- plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
2125
- } & ({
2126
- category: FarmIntegrationCategory;
2127
- slot?: FarmIntegrationCategory;
2128
- } | {
2129
- category?: FarmIntegrationCategory;
2130
- slot: FarmIntegrationCategory;
2131
- });
2132
- type FarmIntegrationCategoryInput = {
2133
- category: FarmIntegrationCategory;
2134
- slot?: FarmIntegrationCategory;
2135
- } | {
2136
- category?: FarmIntegrationCategory;
2137
- slot: FarmIntegrationCategory;
2138
- };
2139
- type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
2140
- api?: FarmIntegrationAPI;
2141
- schema?: FarmIntegrationSchema;
2142
- config?: unknown;
2143
- routes?: unknown;
2144
- endpoints?: unknown;
2145
- };
2146
- type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
2147
- schema: infer TSchema extends FarmIntegrationSchema;
2148
- } ? TSchema : undefined;
2149
- type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
2150
- type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
2151
- type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
2152
- type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
2153
- type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
2154
- type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
2155
- routes: infer TRoutes;
2156
- } ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
2157
- endpoints: infer TEndpoints;
2158
- } ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
2159
- type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
2160
- type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
2161
- endpoints: infer TEndpoints;
2162
- } ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
2163
- type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
2164
- type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
2165
- category: infer TCategory extends FarmIntegrationCategory;
2166
- } ? TCategory : TIntegration extends {
2167
- slot: infer TSlot extends FarmIntegrationCategory;
2168
- } ? TSlot : FarmIntegrationCategory;
2169
- type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
2170
- api: infer TAPI extends FarmIntegrationAPI;
2171
- } ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
2172
- type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
2173
- readonly kind: "farm-integration";
2174
- category: ExtractIntegrationCategory<TIntegration>;
2175
- slot: ExtractIntegrationCategory<TIntegration>;
2176
- routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
2177
- endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
2178
- api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
2179
- };
2180
- 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>;
2181
- declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
2182
- declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): FarmIntegrationProvider[];
2183
- declare function isFarmIntegrationProviderComponentReference(value: FarmIntegrationProvider["component"]): value is FarmIntegrationProviderComponentReference;
2184
- declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
2185
- declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
2186
- declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
2187
- declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
2188
- declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
2189
- declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
2190
- pathname: string;
2191
- method?: string;
2192
- }): {
2193
- key: string;
2194
- integration: FarmIntegration;
2195
- route: {
2196
- path: string;
2197
- methods: readonly string[];
2198
- };
2199
- params: FarmIntegrationRouteParams;
2200
- } | null;
2201
- declare function matchRegisteredIntegrationRoute(input: {
2202
- pathname: string;
2203
- method?: string;
2204
- }): {
2205
- key: string;
2206
- integration: FarmIntegration;
2207
- route: {
2208
- path: string;
2209
- methods: readonly string[];
2210
- };
2211
- params: FarmIntegrationRouteParams;
2212
- } | null;
2213
- declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
2214
- declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
2215
- currentRequest?: Request;
2216
- data?: FarmIntegrationData;
2217
- internal?: boolean;
2218
- /**
2219
- * Receives `Set-Cookie` values that a middleware forwarded via
2220
- * forwardIntegrationSetCookies while returning `void`, when this dispatch
2221
- * ends without a Response of its own. The request continues downstream, so
2222
- * the caller owns merging them onto whatever response it finally produces.
2223
- * Only called on the `null` return path: a Response returned from here has
2224
- * already had the forwarded cookies appended.
2225
- */
2226
- onForwardedCookies?: (cookies: string[]) => void;
2227
- /**
2228
- * Middleware entries that already ran for this request, shared across dispatches. A
2229
- * `ctx.rewrite()` target is guarded by a second dispatch, which skips these so each guard runs
2230
- * at most once per request, as app middleware does.
2231
- */
2232
- ranMiddleware?: Set<object>;
2233
- /** The peer address the server adapter reports, used unless `server.trustProxy` applies. */
2234
- clientAddress?: string;
2235
- }): Promise<Response | null>;
2236
2187
  /**
2237
- * Run every configured integration's middleware and routes for one request.
2238
- *
2239
- * Integration middleware is not route scoped: it is the mechanism behind
2240
- * `protectedRoutes` guards and provider session refresh, so it has to run for
2241
- * ordinary page and API requests that match no integration route at all. That
2242
- * makes this, not `matchIntegrationRoute`, the correct entry point for a
2243
- * runtime dispatching integrations for every request.
2244
- *
2245
- * The first integration that produces a Response short-circuits the rest.
2246
- * `Set-Cookie` values forwarded by middleware that returned `void` are
2247
- * collected: they ride the short-circuiting Response when there is one, and are
2248
- * otherwise handed back so the caller can merge them onto the downstream
2249
- * response.
2188
+ * Apply image and font budgets to HTML preload elements. High-priority image
2189
+ * hints are retained before ordinary hints, making an explicitly preloaded LCP
2190
+ * image the winner when a document contains too many React-generated hints.
2250
2191
  */
2251
- declare function dispatchIntegrationRequests(integrations: FarmIntegrationsUserConfig | undefined, runtime: Omit<RegisteredIntegrationRuntime, "integration">, request: Request, options?: {
2252
- currentRequest?: Request;
2253
- ranMiddleware?: Set<object>;
2254
- clientAddress?: string;
2255
- }): Promise<{
2256
- response: Response | null;
2257
- setCookies: string[];
2258
- }>;
2192
+ declare function manageFarmHtmlPreloads(html: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
2193
+ /** Apply the same budgets to HTTP Link preload hints, including Farm fonts. */
2194
+ declare function manageFarmLinkHeaderPreloads(value: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
2195
+ /** Apply a single document budget across HTML and HTTP Link header hints. */
2196
+ declare function manageFarmDocumentPreloads(html: string, linkHeader: string, config: ResolvedFarmPreloadConfig): FarmManagedDocumentPreloads;
2197
+ /** Rate-limit identical route-and-budget warnings within a server process. */
2198
+ declare function reportFarmPreloadWarnings(warnings: FarmPreloadBudgetWarning[], context?: string): void;
2259
2199
 
2260
- interface FarmDocsAdapterDescriptor {
2261
- id: string;
2262
- protocol: number;
2263
- server: string;
2264
- react?: string;
2265
- vite?: string;
2266
- /**
2267
- * Build-time entry that compiles the adapter's docs runtime into Farm's
2268
- * serializable edge manifest. Older Farm releases safely ignore it.
2269
- */
2270
- edgeCompiler?: string;
2271
- }
2272
- interface FarmDocsSidebarItem {
2273
- label?: string;
2274
- title?: string;
2275
- slug?: string;
2276
- href?: string;
2277
- icon?: string;
2278
- children?: FarmDocsSidebarItem[];
2279
- items?: FarmDocsSidebarItem[];
2280
- }
2281
- interface FarmDocsNavigationConfig {
2282
- sidebar?: FarmDocsSidebarItem[];
2283
- }
2284
- interface FarmDocsSocialImageConfig {
2285
- /** Generate a page-specific 1200×630 social image. Defaults to true. */
2286
- enabled?: boolean;
2287
- /** Absolute public origin used in social metadata, e.g. https://example.com. */
2288
- baseUrl?: string;
2289
- /** Site name shown in Open Graph metadata. Defaults to the docs navigation title. */
2290
- siteName?: string;
2291
- /** Short brand label drawn in the image header. Defaults to siteName. */
2292
- brand?: string;
2293
- /** Optional WOFF2 URLs or data URLs embedded into the generated SVG. */
2294
- fonts?: FarmDocsSocialImageFonts;
2295
- }
2296
- interface FarmDocsSocialImageFonts {
2297
- /** Display face used for page titles. */
2298
- display?: string;
2299
- /** Sans-serif face used for descriptions. */
2300
- sans?: string;
2301
- /** Monospace face used for labels, routes, and diagrams. */
2302
- mono?: string;
2303
- }
2304
- type FarmDocsRuntimeConfig = Partial<DocsConfig> & {
2305
- /**
2306
- * Public favicon URL used by the standalone docs renderer.
2307
- * Set this explicitly when docs should share the host application's icon.
2308
- */
2309
- favicon?: string;
2310
- /**
2311
- * Optional serializable navigation tree used by Farm's docs runtime.
2312
- * Icon values reference keys from `icons`.
2313
- */
2314
- navigation?: FarmDocsNavigationConfig;
2315
- /**
2316
- * Automatic page-specific Open Graph and X images for Markdown docs.
2317
- * Enabled by default. Set false to opt out for the complete docs tree.
2318
- */
2319
- socialImage?: boolean | FarmDocsSocialImageConfig;
2320
- };
2321
- type FarmDocsConfigInput = FarmDocsRuntimeConfig & {
2322
- /**
2323
- * Versioned runtime descriptor supplied by an external docs adapter.
2324
- * Set false to pin the embedded renderer and disable framework
2325
- * auto-detection.
2326
- */
2327
- adapter?: FarmDocsAdapterDescriptor | false;
2328
- /**
2329
- * Farm public route for docs, e.g. "/docs". When passed through
2330
- * `config`, this is converted to the docs package's folder-style `entry`.
2331
- */
2332
- entry?: string;
2333
- /** Explicit public route prefix. Defaults to `entry`. */
2334
- docsPath?: string;
2335
- /** Source content directory, relative to the project root. */
2336
- contentDir?: string;
2337
- /** Set to false to opt out even when a docs config file exists. */
2338
- enabled?: boolean;
2339
- /** Inline @farming-labs/docs config object. */
2340
- config?: FarmDocsRuntimeConfig;
2341
- /** Path to docs.config.* or docs.json. */
2342
- configPath?: string;
2343
- };
2344
- type FarmDocsUserConfig = boolean | FarmDocsConfigInput;
2345
- interface FarmDocsResolvedConfig {
2346
- enabled: boolean;
2347
- entry: string;
2348
- adapter?: FarmDocsAdapterDescriptor;
2349
- contentDir?: string;
2350
- configPath?: string;
2351
- config: FarmDocsRuntimeConfig & Pick<DocsConfig, "entry">;
2352
- /**
2353
- * `config` before it was made serializable: icons and other React elements, MDX
2354
- * components, and callbacks intact. Only the in-process adapter runtime reads it;
2355
- * whatever Farm serializes uses `config`.
2356
- */
2357
- runtimeConfig?: FarmDocsRuntimeConfig & Pick<DocsConfig, "entry">;
2358
- /** The serializable docs settings from `farm.config.ts`, applied over the config file. */
2359
- configOverrides?: Partial<DocsConfig>;
2360
- }
2361
-
2362
- type FarmMdxComponent = React__default.ComponentType<any> | keyof React__default.JSX.IntrinsicElements;
2363
- type FarmMdxComponents = Record<string, FarmMdxComponent>;
2364
- interface FarmMdxUserConfig {
2365
- /**
2366
- * Component map or module path that exports `components` or a default component map.
2367
- * Relative paths resolve from the project root.
2368
- */
2369
- components?: string | FarmMdxComponents;
2200
+ type FarmCspDirectiveValue = string | readonly string[] | boolean | null | undefined;
2201
+ type FarmCspDirectives = Readonly<Record<string, FarmCspDirectiveValue>>;
2202
+ interface FarmCspOptions {
2203
+ /** A pre-serialized CSP value. Cannot be combined with directives. */
2204
+ policy?: string;
2205
+ /** CSP directives using camelCase or kebab-case names. */
2206
+ directives?: FarmCspDirectives;
2207
+ /** Emit Content-Security-Policy-Report-Only instead of enforcing the policy. */
2208
+ reportOnly?: boolean;
2370
2209
  /**
2371
- * Serve source-authored markdown pages at `/route.md`.
2372
- * Enabled by default for `page.md` and `page.mdx`.
2210
+ * Generate a fresh nonce for every dynamic HTML response and per-page
2211
+ * script hashes for prerendered HTML. Farm adds the matching sources to the
2212
+ * governing script directive. Only Farm's own scripts, the renderer's
2213
+ * streaming scripts, and scripts the app gives `getCspNonce()` carry the
2214
+ * nonce (or get a hash); every other script element loses its nonce.
2373
2215
  */
2374
- markdownRoutes?: boolean;
2375
- /** Class name used for the wrapper around rendered markdown content. */
2376
- className?: string;
2216
+ nonce?: boolean;
2377
2217
  }
2378
- interface FarmMdxResolvedConfig {
2379
- components?: string | FarmMdxComponents;
2380
- markdownRoutes: boolean;
2381
- className: string;
2218
+ type FarmCspConfig = string | FarmCspOptions;
2219
+ interface FarmSecurityConfig {
2220
+ /** App-wide CSP for dynamic responses and prerendered output. */
2221
+ csp?: FarmCspConfig | false;
2222
+ /** @deprecated Use csp. */
2223
+ contentSecurityPolicy?: never;
2382
2224
  }
2383
- declare function resolveMdxConfig(config: FarmMdxUserConfig | undefined): FarmMdxResolvedConfig;
2384
- /**
2385
- * The MDX components module a Markdown page renders from, as an absolute path. Undefined when
2386
- * the components are an inline object, which cannot be analyzed for client components.
2387
- */
2388
- declare function resolveFarmMdxComponentsModulePath(config: FarmMdxResolvedConfig | undefined, root: string): string | undefined;
2389
-
2390
- /**
2391
- * Farm.js Middleware System
2392
- *
2393
- * Type definitions for the middleware system
2394
- */
2395
-
2396
- /**
2397
- * Next function type for middleware chain
2398
- */
2399
- type MiddlewareResult = void | Response;
2400
- type NextFunction = () => Promise<MiddlewareResult>;
2401
- type MiddlewareStoreKey<TValues extends Record<string, any>> = Extract<keyof TValues, string>;
2402
- /**
2403
- * A typed view over the request-scoped maps used by middleware.
2404
- */
2405
- interface ReadonlyMiddlewareStore<TValues extends Record<string, any> = Record<string, any>> {
2406
- readonly size: number;
2407
- get<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): TValues[TKey] | undefined;
2408
- has<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
2409
- entries(): IterableIterator<[MiddlewareStoreKey<TValues>, TValues[MiddlewareStoreKey<TValues>]]>;
2410
- keys(): IterableIterator<MiddlewareStoreKey<TValues>>;
2411
- values(): IterableIterator<TValues[MiddlewareStoreKey<TValues>]>;
2412
- forEach(callback: (value: TValues[MiddlewareStoreKey<TValues>], key: MiddlewareStoreKey<TValues>, store: ReadonlyMiddlewareStore<TValues>) => void, thisArg?: any): void;
2413
- [Symbol.iterator](): IterableIterator<[
2414
- MiddlewareStoreKey<TValues>,
2415
- TValues[MiddlewareStoreKey<TValues>]
2416
- ]>;
2225
+ interface ResolvedFarmCspConfig {
2226
+ value: string;
2227
+ reportOnly: boolean;
2228
+ nonce: boolean;
2417
2229
  }
2418
- interface MiddlewareStore<TValues extends Record<string, any> = Record<string, any>> extends ReadonlyMiddlewareStore<TValues> {
2419
- clear(): void;
2420
- delete<TKey extends MiddlewareStoreKey<TValues>>(key: TKey): boolean;
2421
- set<TKey extends MiddlewareStoreKey<TValues>>(key: TKey, value: TValues[TKey]): this;
2230
+ interface ResolvedFarmSecurityConfig {
2231
+ csp: ResolvedFarmCspConfig | false;
2422
2232
  }
2233
+ declare function resolveFarmSecurityConfig(input: FarmSecurityConfig | ResolvedFarmSecurityConfig | undefined): ResolvedFarmSecurityConfig;
2234
+ declare function createFarmCspNonce(security: ResolvedFarmSecurityConfig): string | undefined;
2423
2235
  /**
2424
- * Middleware function signature
2425
- */
2426
- type MiddlewareFunction = (ctx: MiddlewareContext, next: NextFunction) => MiddlewareResult | Promise<MiddlewareResult>;
2427
- /**
2428
- * Context passed to a named, request-first middleware export.
2429
- * `locals` and the get/set helpers stay on the server. `data` can be exposed
2430
- * through page props and should contain only serializable, client-safe values.
2236
+ * Stamp the nonce of the response being rendered on Farm-generated `html`.
2237
+ * Returns `html` unchanged outside nonce mode.
2431
2238
  */
2432
- interface RequestMiddlewareContext<TLocals extends Record<string, any> = Record<string, any>, TData extends Record<string, any> = Record<string, any>> {
2433
- readonly url: URL;
2434
- readonly pathname: string;
2435
- /** The pathname the router matches: decoded once, without basePath or locale. */
2436
- readonly routePathname: string;
2437
- readonly searchParams: URLSearchParams;
2438
- readonly method: string;
2439
- readonly params: Record<string, string>;
2440
- readonly route: string;
2441
- readonly locals: MiddlewareStore<TLocals>;
2442
- readonly data: MiddlewareStore<TData>;
2443
- readonly headers: Map<string, string>;
2444
- readonly cookies: CookieJar;
2445
- get<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): TLocals[TKey] | undefined;
2446
- has<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
2447
- set<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey, value: TLocals[TKey]): void;
2448
- delete<TKey extends MiddlewareStoreKey<TLocals>>(key: TKey): boolean;
2449
- redirect(url: string, status?: number): void;
2450
- rewrite(url: string): void;
2451
- json(data: any, status?: number): void;
2452
- text(content: string, status?: number): void;
2453
- html(content: string, status?: number): void;
2454
- }
2455
- 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>;
2239
+ declare function stampFarmCspNonce(html: string, nonce?: string | undefined): string;
2456
2240
  /**
2457
- * Cookie options
2241
+ * Send `response` with the nonce policy. `nonce` is the one the response was
2242
+ * rendered with: script elements that carry it keep it, and every other
2243
+ * script element loses its nonce attribute, so markup injected into the page
2244
+ * can never run under the policy.
2458
2245
  */
2459
- interface CookieOptions {
2460
- maxAge?: number;
2461
- expires?: Date;
2462
- path?: string;
2463
- domain?: string;
2464
- secure?: boolean;
2465
- httpOnly?: boolean;
2466
- sameSite?: "strict" | "lax" | "none";
2246
+ declare function applyFarmCspNonceToResponse(response: Response, security: ResolvedFarmSecurityConfig, nonce?: string | undefined): Response;
2247
+
2248
+ declare const DEFAULT_FARM_API_BASE_PATH = "/api";
2249
+ interface FarmAPIConfigResolverContext {
2250
+ root: string;
2251
+ mode: "development" | "production";
2252
+ env: ResolvedFarmEnv;
2467
2253
  }
2468
- /**
2469
- * Cookie management interface
2470
- */
2471
- interface CookieJar {
2472
- get(name: string): string | undefined;
2473
- set(name: string, value: string, options?: CookieOptions): void;
2254
+ type FarmAPIConfigValue = string | undefined | ((context: FarmAPIConfigResolverContext) => string | undefined | Promise<string | undefined>);
2255
+ interface FarmAPIConfig {
2474
2256
  /**
2475
- * Remove a cookie. Pass the `path`/`domain` it was set with; a tombstone only
2476
- * matches a cookie with the same scope.
2257
+ * Public API root. An origin-only URL is joined with `basePath`; a URL that
2258
+ * already has a path is used as-is. May be resolved from deployment context.
2477
2259
  */
2478
- delete(name: string, options?: CookieOptions): void;
2479
- getAll(): Record<string, string>;
2260
+ baseURL?: FarmAPIConfigValue;
2261
+ /** Public API path and same-origin server mount used when `baseURL` has no path. @default "/api" */
2262
+ basePath?: FarmAPIConfigValue;
2480
2263
  }
2481
- interface RateLimitIncrementResult {
2482
- count: number;
2483
- /** Unix epoch timestamp in milliseconds when the fixed window resets. */
2484
- resetAt: number;
2264
+ interface ResolvedFarmAPIConfig {
2265
+ /** Fully resolved public API root, either absolute or root-relative. */
2266
+ baseURL: string;
2267
+ /** Effective pathname of `baseURL`. */
2268
+ basePath: string;
2485
2269
  }
2486
- interface RateLimitStorage {
2487
- /** Atomically increment a key and create or retain its fixed expiry window. */
2488
- increment(key: string, windowMs: number): Promise<RateLimitIncrementResult> | RateLimitIncrementResult;
2489
- /** Optional inspection support used by getRateLimitStatus(). */
2490
- get?(key: string): Promise<RateLimitIncrementResult | null> | RateLimitIncrementResult | null;
2491
- }
2492
- interface MemoryRateLimitStorageOptions {
2493
- /** Maximum number of active keys retained by this process. */
2494
- maxEntries?: number;
2270
+ declare function resolveFarmAPIConfig(config: FarmAPIConfig | undefined, context: FarmAPIConfigResolverContext): Promise<ResolvedFarmAPIConfig>;
2271
+ /** Normalize already-resolved API strings. */
2272
+ declare function normalizeFarmAPIConfig(config: {
2273
+ baseURL?: string;
2274
+ basePath?: string;
2275
+ } | undefined): ResolvedFarmAPIConfig;
2276
+ declare function normalizeFarmAPIBasePath(value: string): string;
2277
+ /** Read the API root embedded by Farm's Vite build. */
2278
+ declare function getFarmAPIBaseURL(): string;
2279
+ /** Resolve a canonical Farm route such as `/api/users` against an API root. */
2280
+ declare function resolveFarmAPIRequestURL(routePath: string, baseURL?: string, fallbackOrigin?: string): URL;
2281
+
2282
+ declare const FARM_RESOLVED_CUSTOM_CONTEXT: unique symbol;
2283
+
2284
+ interface RedirectConfig {
2285
+ source: string;
2286
+ destination: string;
2287
+ permanent?: boolean;
2288
+ statusCode?: FarmRedirectStatus;
2495
2289
  }
2496
- interface RateLimitConfig {
2497
- requests: number;
2498
- window: string;
2499
- keyGenerator?: (ctx: MiddlewareContext) => string;
2500
- onLimit?: (ctx: MiddlewareContext) => void | Response | Promise<void | Response>;
2501
- storage?: RateLimitStorage;
2290
+ interface HeaderConfig {
2291
+ source: string;
2292
+ headers: Array<{
2293
+ key: string;
2294
+ value: string;
2295
+ }>;
2502
2296
  }
2503
- interface RateLimitStatus {
2504
- requests: number;
2505
- limit: number;
2506
- remaining: number;
2507
- resetIn: number | null;
2508
- resetAt: Date | null;
2509
- isLimited: boolean;
2297
+ interface RewriteConfig {
2298
+ source: string;
2299
+ destination: string;
2510
2300
  }
2511
- /**
2512
- * Middleware configuration
2513
- */
2514
- type MiddlewareMatcher = string | RegExp | ((ctx: MiddlewareContext) => boolean);
2515
- interface MiddlewareConfig$1 {
2516
- matcher?: MiddlewareMatcher | MiddlewareMatcher[];
2517
- exclude?: (string | RegExp)[];
2518
- runtime?: "nodejs" | "edge";
2301
+ /** @deprecated Use FarmImageConfig. */
2302
+ type ImageConfig = FarmImageConfig;
2303
+ /** @deprecated Use FarmI18nUserConfig. */
2304
+ type I18nConfig = FarmI18nUserConfig;
2305
+ interface OpenAPIConfig {
2306
+ enabled?: boolean;
2307
+ route?: string;
2519
2308
  /**
2520
- * Whether a response this middleware lets through may be stored by a shared cache (a CDN).
2521
- * Farm cannot tell a guard from harmless middleware, and a CDN serves its copy without
2522
- * running either, so by default (`"private"`) the response is sent with
2523
- * `Cache-Control: private, no-store`. Set `"public"` only on middleware that never decides
2524
- * who may read the response, such as logging or response headers.
2309
+ * Path where the raw OpenAPI spec is served as JSON, so agents and API tools
2310
+ * can fetch it at a predictable URL. Set to `false` to disable.
2311
+ *
2312
+ * @default "/openapi.json"
2525
2313
  */
2526
- cache?: "private" | "public";
2314
+ specRoute?: string | false;
2315
+ title?: string;
2316
+ description?: string;
2317
+ version?: string;
2318
+ /** Default authentication requirement for operations without an endpoint override. */
2319
+ security?: OpenAPISecurityMode;
2320
+ servers?: Array<{
2321
+ url: string;
2322
+ description?: string;
2323
+ }>;
2324
+ contact?: {
2325
+ name?: string;
2326
+ email?: string;
2327
+ url?: string;
2328
+ };
2329
+ license?: {
2330
+ name: string;
2331
+ url?: string;
2332
+ };
2527
2333
  }
2528
- interface MiddlewareConfigEntry extends MiddlewareConfig$1 {
2529
- handler?: MiddlewareFunction;
2530
- handlers?: MiddlewareFunction[];
2334
+ type MiddlewareConfig = FarmMiddlewareConfig;
2335
+ interface NotFoundConfig {
2336
+ /** Path to a custom 404 page component (e.g., "./src/app/not-found.tsx") */
2337
+ component?: string;
2531
2338
  }
2532
- type FarmMiddlewareConfig = MiddlewareConfig$1 | MiddlewareConfigEntry | MiddlewareConfigEntry[];
2533
- /**
2534
- * Middleware context - the main object passed to middleware functions
2535
- */
2536
- interface MiddlewareContext {
2537
- request: IncomingMessage;
2538
- response: ServerResponse;
2539
- url: URL;
2540
- /** Request pathname as received: still percent-encoded and carrying basePath/locale. */
2541
- pathname: string;
2339
+ type FarmDeployTarget = "vercel" | "cloudflare" | "netlify" | "node" | string;
2340
+ interface FarmDeployConfig {
2542
2341
  /**
2543
- * The pathname the router matches: decoded once, without basePath or locale. String matchers
2544
- * compare this value; compare it in path checks too. Updated by `rewrite()`.
2342
+ * Deployment platform. When present, Farm picks the matching Nitro preset and
2343
+ * output directory unless explicitly overridden.
2545
2344
  */
2546
- readonly routePathname: string;
2547
- searchParams: URLSearchParams;
2548
- method: string;
2549
- params: Record<string, string>;
2550
- route: string;
2551
- parent?: {
2552
- data: Map<string, any>;
2553
- locals?: Map<string, any>;
2554
- headers: Record<string, string>;
2345
+ target?: FarmDeployTarget;
2346
+ /** Nitro preset override. Usually inferred from target. */
2347
+ preset?: FarmConfig["preset"];
2348
+ /** Deployable output directory, relative to project root unless absolute. */
2349
+ outputDir?: string;
2350
+ /** Alias for outputDir for terser config. */
2351
+ output?: string;
2352
+ /** Cloudflare Pages project name used by `farm deploy --cloudflare`. */
2353
+ projectName?: string;
2354
+ vercel?: {
2355
+ outputDirectory?: string;
2356
+ buildCommand?: string;
2357
+ installCommand?: string;
2358
+ framework?: string | null;
2555
2359
  };
2556
- vite: {
2557
- isDev: boolean;
2558
- hmr: boolean;
2559
- server?: ViteDevServer;
2360
+ cloudflare?: {
2361
+ outputDir?: string;
2362
+ projectName?: string;
2560
2363
  };
2561
- data: Map<string, any>;
2562
- locals: Map<string, any>;
2563
- headers: Map<string, string>;
2564
- cookies: CookieJar;
2565
- _handled: boolean;
2566
- _redirectUrl?: string;
2567
- _rewriteUrl?: string;
2568
- redirect(url: string, status?: number): void;
2569
- rewrite(url: string): void;
2570
- json(data: any, status?: number): void;
2571
- text(content: string, status?: number): void;
2572
- html(content: string, status?: number): void;
2573
- }
2574
- /**
2575
- * Middleware chain interface
2576
- */
2577
- interface MiddlewareChain {
2578
- use(fn: MiddlewareFunction): MiddlewareChain;
2579
- /**
2580
- * Conditionally run middleware based on a condition.
2581
- * Supports boolean values or functions that evaluate to boolean.
2582
- *
2583
- * @example
2584
- * .when(true, (ctx, next) => { ... }) // Always run
2585
- * .when((ctx) => ctx.data.get('flag'), (ctx, next) => { ... }) // Conditional
2586
- */
2587
- when(condition: boolean | ((ctx: MiddlewareContext) => boolean), fn: MiddlewareFunction | ((chain: MiddlewareChain) => void)): MiddlewareChain;
2588
- rateLimit(config: RateLimitConfig): MiddlewareChain;
2589
- redirect(source: string, destination: string, permanent?: boolean): MiddlewareChain;
2590
- /**
2591
- * Rewrite the current route to a new destination.
2592
- * In route-specific middleware, this rewrites the middleware's route.
2593
- *
2594
- * @param destination - The destination path to rewrite to
2595
- * @param condition - Optional boolean or function that evaluates to boolean. If false, rewrite is skipped.
2596
- *
2597
- * @example
2598
- * // In /contact/middleware.ts
2599
- * .rewrite('/about') // Always rewrites /contact to /about
2600
- * .rewrite('/about', true) // Always rewrites
2601
- * .rewrite('/about', false) // Never rewrites
2602
- * .rewrite('/about', (ctx) => ctx.data.get('shouldRewrite')) // Conditional rewrite
2603
- */
2604
- rewrite(destination: string, condition?: boolean | ((ctx: MiddlewareContext) => boolean)): MiddlewareChain;
2605
- build(): {
2606
- handlers: MiddlewareFunction[];
2607
- config?: MiddlewareConfig$1;
2364
+ netlify?: {
2365
+ outputDir?: string;
2366
+ site?: string;
2608
2367
  };
2609
2368
  }
2610
- /**
2611
- * Middleware module export
2612
- */
2613
- interface MiddlewareModule {
2614
- default?: MiddlewareChain | MiddlewareFunction;
2615
- middleware?: RequestMiddleware;
2616
- config?: MiddlewareConfig$1;
2617
- }
2618
-
2619
- type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
2620
- interface FarmRedirectSignal {
2621
- url: string;
2622
- status: FarmRedirectStatus;
2623
- }
2624
- declare function redirect(url: string, status?: FarmRedirectStatus): never;
2625
- declare function permanentRedirect(url: string): never;
2626
- declare function notFound(): never;
2627
- declare function isFarmRedirectError(error: unknown): boolean;
2628
- declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
2629
- declare function isFarmNotFoundError(error: unknown): boolean;
2630
-
2631
- type FarmBuildActivityPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
2632
- interface FarmDevIndicatorsConfig {
2633
- /** Show build and HMR activity in the browser during development. */
2634
- buildActivity?: boolean;
2635
- /** Corner used by the build activity indicator. */
2636
- buildActivityPosition?: FarmBuildActivityPosition;
2637
- }
2638
- interface ResolvedFarmDevIndicatorsConfig {
2639
- buildActivity: boolean;
2640
- buildActivityPosition: FarmBuildActivityPosition;
2641
- }
2642
- declare function resolveFarmDevIndicatorsConfig(config: FarmDevIndicatorsConfig | undefined, mode?: "development" | "production"): ResolvedFarmDevIndicatorsConfig;
2643
- declare function generateFarmDevIndicatorsClientRuntime(config: ResolvedFarmDevIndicatorsConfig): string;
2644
-
2645
- interface FarmAuthEmailAndPasswordConfig {
2646
- /** Require a verified email before creating a session. @default false */
2647
- requireEmailVerification?: boolean;
2648
- /** Smallest accepted password length. @default 8 */
2649
- minPasswordLength?: number;
2650
- /** Largest accepted password length. @default 128 */
2651
- maxPasswordLength?: number;
2652
- }
2653
- interface FarmAuthSessionConfig {
2654
- /** Session lifetime in seconds. @default 604800 */
2655
- expiresIn?: number;
2656
- /** Session refresh interval in seconds. @default 86400 */
2657
- updateAge?: number;
2369
+ interface ResolvedFarmDeployConfig extends Omit<FarmDeployConfig, "output"> {
2370
+ target?: FarmDeployTarget;
2371
+ preset: FarmConfig["preset"];
2372
+ outputDir: string;
2658
2373
  }
2659
- interface FarmAuthDatabaseConfig {
2374
+ interface FarmUserConfig extends Omit<FarmConfig, "vite" | "docs" | "env" | "layers"> {
2375
+ /** Reusable Farm directories or installed packages, applied from left to right. */
2376
+ extends?: readonly FarmLayerEntry[];
2377
+ /** Global plugins. Integration-bound plugins must be contributed through an integration. */
2378
+ plugins?: FarmPlugin<any, any, any, any, unknown, false>[];
2379
+ integrations?: FarmIntegrationsUserConfig;
2660
2380
  /**
2661
- * Postgres connection string. Defaults to DATABASE_URL.
2662
- * Local development falls back to SQLite when no URL is present.
2663
- */
2664
- url?: string;
2665
- /** Local SQLite path. @default ".farm/auth.sqlite" */
2666
- path?: string;
2667
- /** Automatically update the auth schema in development. @default true */
2668
- migrateInDevelopment?: boolean;
2669
- }
2670
- interface FarmAuthConfig {
2671
- /** Set false to disable auth without removing its configuration. @default true */
2672
- enabled?: boolean;
2673
- /** Display name used by authentication emails and metadata. */
2674
- appName?: string;
2675
- /** Route prefix for the auth endpoints. @default "/api/auth" */
2676
- basePath?: string;
2677
- /**
2678
- * Email/password authentication. It is enabled by default; set false to
2679
- * disable it when adding another sign-in method.
2381
+ * Farm-native authentication. `true` enables email/password auth with
2382
+ * server helpers from `@farm.js/auth/server` and React APIs from
2383
+ * `@farm.js/auth/client`.
2680
2384
  */
2681
- emailAndPassword?: boolean | FarmAuthEmailAndPasswordConfig;
2682
- session?: FarmAuthSessionConfig;
2683
- database?: FarmAuthDatabaseConfig;
2385
+ auth?: FarmAuthUserConfig;
2386
+ /** Compose opted-in API routes and standalone tools through an authenticated MCP transport. */
2387
+ mcp?: FarmMCPUserConfig;
2388
+ /** Shared application data, route, ISR, and PPR cache. */
2389
+ cache?: FarmCacheUserConfig;
2390
+ migrations?: FarmMigrationsUserConfig;
2391
+ /** Map portable cron schedules to ordinary GET API routes. */
2392
+ cron?: FarmCronUserConfig | FarmCronResolvedConfig | false;
2393
+ workflows?: FarmWorkflowsUserConfig | boolean;
2394
+ preset?: FarmConfig["preset"];
2395
+ deploy?: FarmDeployConfig;
2396
+ docs?: FarmDocsUserConfig;
2397
+ md?: FarmMarkdownUserConfig | boolean;
2398
+ mdx?: FarmMdxUserConfig;
2399
+ observability?: FarmObservabilityUserConfig;
2400
+ trailingSlash?: boolean;
2401
+ redirects?: () => Promise<RedirectConfig[]> | RedirectConfig[];
2402
+ rewrites?: () => Promise<RewriteConfig[]> | RewriteConfig[];
2403
+ headers?: () => Promise<HeaderConfig[]> | HeaderConfig[];
2404
+ images?: ImageConfig;
2405
+ publicDir?: string;
2406
+ i18n?: FarmI18nUserConfig | false;
2407
+ openapi?: OpenAPIConfig;
2408
+ middleware?: FarmMiddlewareConfig;
2409
+ routeRules?: FarmRouteRules;
2410
+ context?: FarmConfig["context"];
2411
+ /** Server ingress and trusted-proxy policy. */
2412
+ server?: FarmServerConfig;
2413
+ serverActions?: FarmServerActionsConfig;
2414
+ /** Build identifier used to detect and recover from deployment version skew. */
2415
+ deploymentId?: string;
2416
+ notFound?: NotFoundConfig;
2417
+ distDir?: string;
2418
+ generateBuildId?: () => string | Promise<string>;
2419
+ compress?: boolean;
2420
+ devIndicators?: FarmDevIndicatorsConfig;
2421
+ serverRuntimeConfig?: Record<string, any>;
2422
+ publicRuntimeConfig?: Record<string, any>;
2423
+ env?: FarmEnvConfig<any, any>;
2424
+ vite?: UserConfig | ((config: UserConfig) => UserConfig);
2425
+ [key: string]: any;
2684
2426
  }
2685
- type FarmAuthUserConfig = boolean | FarmAuthConfig;
2686
- interface ResolvedFarmAuthConfig {
2687
- enabled: boolean;
2688
- appName?: string;
2689
- basePath: string;
2690
- emailAndPassword: {
2691
- enabled: boolean;
2692
- requireEmailVerification: boolean;
2693
- minPasswordLength: number;
2694
- maxPasswordLength: number;
2695
- };
2696
- session: {
2697
- expiresIn: number;
2698
- updateAge: number;
2699
- };
2700
- database: {
2701
- url?: string;
2702
- path: string;
2703
- migrateInDevelopment: boolean;
2704
- };
2427
+ interface ResolvedFarmConfig extends Required<Omit<FarmUserConfig, "extends" | "plugins" | "vite" | "deploy" | "docs" | "md" | "mdx" | "migrations" | "cron" | "workflows" | "api" | "env" | "server" | "serverActions" | "devtools" | "devIndicators" | "images" | "i18n" | "auth" | "mcp" | "performance" | "security" | "theme" | "renderer" | "agent">> {
2428
+ agent: ResolvedFarmAgentConfig;
2429
+ /** @internal Tracks whether `context` came from user/layer config instead of the default noop. */
2430
+ [FARM_RESOLVED_CUSTOM_CONTEXT]?: boolean;
2431
+ root: string;
2432
+ extends: readonly FarmLayerEntry[];
2433
+ layers: ResolvedFarmLayer[];
2434
+ plugins: FarmPlugin[];
2435
+ vite: UserConfig;
2436
+ deploy: ResolvedFarmDeployConfig;
2437
+ docs: FarmDocsResolvedConfig;
2438
+ md: FarmMarkdownResolvedConfig;
2439
+ mdx: FarmMdxResolvedConfig;
2440
+ migrations: ResolvedFarmMigrationsConfig;
2441
+ cron: FarmCronResolvedConfig;
2442
+ workflows: FarmWorkflowsResolvedConfig;
2443
+ api: ResolvedFarmAPIConfig;
2444
+ env: ResolvedFarmEnv;
2445
+ server: ResolvedFarmServerConfig;
2446
+ serverActions: ResolvedFarmServerActionsConfig;
2447
+ devtools: ResolvedFarmDevtoolsConfig;
2448
+ devIndicators: ResolvedFarmDevIndicatorsConfig;
2449
+ images: ResolvedFarmImageConfig;
2450
+ i18n: ResolvedFarmI18nConfig;
2451
+ auth: ResolvedFarmAuthConfig;
2452
+ mcp: ResolvedFarmMCPConfig;
2453
+ performance: ResolvedFarmPerformanceConfig;
2454
+ security: ResolvedFarmSecurityConfig;
2455
+ theme: ResolvedFarmThemeConfig;
2456
+ renderer: FarmRenderer;
2457
+ routeRules: FarmRouteRules;
2458
+ notFound: NotFoundConfig;
2705
2459
  }
2460
+ type FarmLayerConfig = Omit<FarmUserConfig, "root" | "outDir" | "distDir" | "deploy" | "preset" | "publicDir" | "generateBuildId" | "deploymentId">;
2706
2461
 
2707
- type FarmPreloadMode = "warn" | "enforce";
2708
- interface FarmPreloadUserConfig {
2709
- /** Report excess hints or remove the lower-priority hints. @default "enforce" */
2710
- mode?: FarmPreloadMode;
2711
- /** Maximum image preload hints per document. @default 1 */
2712
- maxImages?: number;
2713
- /** Maximum font preload hints per document. @default 2 */
2714
- maxFonts?: number;
2715
- }
2716
- interface ResolvedFarmPreloadConfig {
2717
- mode: FarmPreloadMode;
2718
- maxImages: number;
2719
- maxFonts: number;
2720
- }
2721
- interface FarmPerformanceConfig {
2722
- preload?: FarmPreloadUserConfig;
2723
- }
2724
- interface ResolvedFarmPerformanceConfig {
2725
- preload: ResolvedFarmPreloadConfig;
2726
- }
2727
- type FarmPreloadKind = "image" | "font";
2728
- interface FarmPreloadBudgetWarning {
2729
- kind: FarmPreloadKind;
2730
- count: number;
2731
- budget: number;
2732
- removed: number;
2733
- }
2734
- interface FarmManagedPreloads {
2735
- value: string;
2736
- warnings: FarmPreloadBudgetWarning[];
2737
- }
2738
- interface FarmManagedDocumentPreloads {
2739
- html: string;
2740
- linkHeader: string;
2741
- warnings: FarmPreloadBudgetWarning[];
2742
- }
2743
- /**
2744
- * Apply image and font budgets to HTML preload elements. High-priority image
2745
- * hints are retained before ordinary hints, making an explicitly preloaded LCP
2746
- * image the winner when a document contains too many React-generated hints.
2747
- */
2748
- declare function manageFarmHtmlPreloads(html: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
2749
- /** Apply the same budgets to HTTP Link preload hints, including Farm fonts. */
2750
- declare function manageFarmLinkHeaderPreloads(value: string, config: ResolvedFarmPreloadConfig): FarmManagedPreloads;
2751
- /** Apply a single document budget across HTML and HTTP Link header hints. */
2752
- declare function manageFarmDocumentPreloads(html: string, linkHeader: string, config: ResolvedFarmPreloadConfig): FarmManagedDocumentPreloads;
2753
- /** Rate-limit identical route-and-budget warnings within a server process. */
2754
- declare function reportFarmPreloadWarnings(warnings: FarmPreloadBudgetWarning[], context?: string): void;
2462
+ declare function normalizeDeployTarget(target?: FarmDeployTarget): FarmDeployTarget | undefined;
2463
+ declare function getPresetForDeployTarget(target?: FarmDeployTarget): FarmConfig["preset"] | undefined;
2464
+ declare function getDeployTargetForPreset(preset?: string): FarmDeployTarget | undefined;
2465
+ declare function resolveDeployOutputPath(root: string, outputDir: string): string;
2466
+ declare function resolveDeployConfig(config: Pick<FarmUserConfig, "deploy" | "preset" | "distDir">, overrides?: {
2467
+ target?: FarmDeployTarget;
2468
+ preset?: FarmConfig["preset"];
2469
+ outputDir?: string;
2470
+ /** Build environment consulted for platform detection. Tests inject this. */
2471
+ env?: NodeJS.ProcessEnv;
2472
+ }): ResolvedFarmDeployConfig;
2473
+ declare function resolveMigrationsConfig(migrations: FarmMigrationsUserConfig | undefined): ResolvedFarmMigrationsConfig;
2474
+ declare function resolveConfig(userConfig: FarmUserConfig, mode: "development" | "production"): Promise<ResolvedFarmConfig>;
2475
+ declare function loadConfig(rootDir?: string, configPath?: string, mode?: string, loadEnvironment?: (typeof vite)["loadEnv"]): Promise<FarmUserConfig | undefined>;
2755
2476
 
2756
- type FarmCspDirectiveValue = string | readonly string[] | boolean | null | undefined;
2757
- type FarmCspDirectives = Readonly<Record<string, FarmCspDirectiveValue>>;
2758
- interface FarmCspOptions {
2759
- /** A pre-serialized CSP value. Cannot be combined with directives. */
2760
- policy?: string;
2761
- /** CSP directives using camelCase or kebab-case names. */
2762
- directives?: FarmCspDirectives;
2763
- /** Emit Content-Security-Policy-Report-Only instead of enforcing the policy. */
2764
- reportOnly?: boolean;
2765
- /**
2766
- * Generate a fresh nonce for every dynamic HTML response and per-page
2767
- * script hashes for prerendered HTML. Farm adds the matching sources to the
2768
- * governing script directive. Only Farm's own scripts, the renderer's
2769
- * streaming scripts, and scripts the app gives `getCspNonce()` carry the
2770
- * nonce (or get a hash); every other script element loses its nonce.
2771
- */
2772
- nonce?: boolean;
2477
+ type FarmRouteRuntime = "auto" | "node" | "edge";
2478
+ type FarmRouteRegions = "auto" | readonly string[];
2479
+ type FarmRouteMaxDuration = "auto" | number;
2480
+ /** Portable execution controls shared by file, programmatic, and config routes. */
2481
+ interface FarmRouteRuntimeConfig {
2482
+ runtime?: FarmRouteRuntime;
2483
+ regions?: FarmRouteRegions;
2484
+ maxDuration?: FarmRouteMaxDuration;
2773
2485
  }
2774
- type FarmCspConfig = string | FarmCspOptions;
2775
- interface FarmSecurityConfig {
2776
- /** App-wide CSP for dynamic responses and prerendered output. */
2777
- csp?: FarmCspConfig | false;
2778
- /** @deprecated Use csp. */
2779
- contentSecurityPolicy?: never;
2486
+ interface ResolvedFarmRouteRuntimeConfig {
2487
+ runtime: FarmRouteRuntime;
2488
+ regions?: string[];
2489
+ maxDuration?: number;
2780
2490
  }
2781
- interface ResolvedFarmCspConfig {
2782
- value: string;
2783
- reportOnly: boolean;
2784
- nonce: boolean;
2491
+ type FarmRouteRuntimeEntryKind = "page" | "api" | "metadata" | "rule";
2492
+ type FarmRouteRenderingMode = "static" | "dynamic";
2493
+ interface FarmRouteRuntimeManifestEntry extends ResolvedFarmRouteRuntimeConfig {
2494
+ kind: FarmRouteRuntimeEntryKind;
2495
+ pattern: string;
2496
+ rendering: FarmRouteRenderingMode;
2497
+ source?: string;
2785
2498
  }
2786
- interface ResolvedFarmSecurityConfig {
2787
- csp: ResolvedFarmCspConfig | false;
2499
+ interface FarmRouteRuntimeManifest {
2500
+ version: 1;
2501
+ routes: FarmRouteRuntimeManifestEntry[];
2788
2502
  }
2789
- declare function resolveFarmSecurityConfig(input: FarmSecurityConfig | ResolvedFarmSecurityConfig | undefined): ResolvedFarmSecurityConfig;
2790
- declare function createFarmCspNonce(security: ResolvedFarmSecurityConfig): string | undefined;
2791
- /**
2792
- * Stamp the nonce of the response being rendered on Farm-generated `html`.
2793
- * Returns `html` unchanged outside nonce mode.
2794
- */
2795
- declare function stampFarmCspNonce(html: string, nonce?: string | undefined): string;
2796
- /**
2797
- * Send `response` with the nonce policy. `nonce` is the one the response was
2798
- * rendered with: script elements that carry it keep it, and every other
2799
- * script element loses its nonce attribute, so markup injected into the page
2800
- * can never run under the policy.
2801
- */
2802
- declare function applyFarmCspNonceToResponse(response: Response, security: ResolvedFarmSecurityConfig, nonce?: string | undefined): Response;
2503
+ declare function normalizeFarmRouteRuntimeConfig(value: FarmRouteRuntimeConfig | null | undefined, source?: string): FarmRouteRuntimeConfig;
2504
+ /** Merge from lowest to highest precedence. Explicit "auto" values reset inherited hints. */
2505
+ declare function mergeFarmRouteRuntimeConfigs(...configs: Array<FarmRouteRuntimeConfig | null | undefined>): FarmRouteRuntimeConfig;
2506
+ declare function resolveFarmRouteRuntimeConfig(config: FarmRouteRuntimeConfig | null | undefined, source?: string): ResolvedFarmRouteRuntimeConfig;
2507
+ declare function hasFarmRouteRuntimeControls(config: FarmRouteRuntimeConfig | null | undefined): boolean;
2508
+ declare function getFarmRouteRuntimeConfig(value: unknown): FarmRouteRuntimeConfig;
2509
+ declare function createFarmRouteRuntimeKey(config: ResolvedFarmRouteRuntimeConfig): string;
2510
+ /** Resolve matching route rules from broadest to most specific. */
2511
+ declare function resolveFarmRouteRuleRuntimeConfig(pathname: string, routeRules: Record<string, FarmRouteRuntimeConfig> | null | undefined): FarmRouteRuntimeConfig;
2512
+ declare function farmRouteRuleMatches(pattern: string, pathname: string): boolean;
2803
2513
 
2804
- declare const DEFAULT_FARM_API_BASE_PATH = "/api";
2805
- interface FarmAPIConfigResolverContext {
2806
- root: string;
2807
- mode: "development" | "production";
2808
- env: ResolvedFarmEnv;
2809
- }
2810
- type FarmAPIConfigValue = string | undefined | ((context: FarmAPIConfigResolverContext) => string | undefined | Promise<string | undefined>);
2811
- interface FarmAPIConfig {
2812
- /**
2813
- * Public API root. An origin-only URL is joined with `basePath`; a URL that
2814
- * already has a path is used as-is. May be resolved from deployment context.
2815
- */
2816
- baseURL?: FarmAPIConfigValue;
2817
- /** Public API path and same-origin server mount used when `baseURL` has no path. @default "/api" */
2818
- basePath?: FarmAPIConfigValue;
2819
- }
2820
- interface ResolvedFarmAPIConfig {
2821
- /** Fully resolved public API root, either absolute or root-relative. */
2822
- baseURL: string;
2823
- /** Effective pathname of `baseURL`. */
2824
- basePath: string;
2514
+ type FarmRouteRuleRenderMode = "static" | "dynamic";
2515
+ type FarmRouteRuleRedirect = string | {
2516
+ to: string;
2517
+ statusCode?: FarmRedirectStatus;
2518
+ permanent?: boolean;
2519
+ };
2520
+ type FarmRouteRuleCors = boolean | {
2521
+ origin?: string;
2522
+ methods?: string | readonly string[];
2523
+ headers?: string | readonly string[];
2524
+ };
2525
+ interface FarmRouteRule extends FarmRouteRuntimeConfig {
2526
+ prerender?: boolean;
2527
+ render?: FarmRouteRuleRenderMode;
2528
+ ssr?: boolean;
2529
+ swr?: boolean | number;
2530
+ isr?: boolean | number;
2531
+ cors?: FarmRouteRuleCors;
2532
+ headers?: Record<string, string>;
2533
+ redirect?: FarmRouteRuleRedirect;
2825
2534
  }
2826
- declare function resolveFarmAPIConfig(config: FarmAPIConfig | undefined, context: FarmAPIConfigResolverContext): Promise<ResolvedFarmAPIConfig>;
2827
- /** Normalize already-resolved API strings. */
2828
- declare function normalizeFarmAPIConfig(config: {
2829
- baseURL?: string;
2830
- basePath?: string;
2831
- } | undefined): ResolvedFarmAPIConfig;
2832
- declare function normalizeFarmAPIBasePath(value: string): string;
2833
- /** Read the API root embedded by Farm's Vite build. */
2834
- declare function getFarmAPIBaseURL(): string;
2835
- /** Resolve a canonical Farm route such as `/api/users` against an API root. */
2836
- declare function resolveFarmAPIRequestURL(routePath: string, baseURL?: string, fallbackOrigin?: string): URL;
2837
-
2838
- declare const FARM_RESOLVED_CUSTOM_CONTEXT: unique symbol;
2535
+ type FarmRouteRules = Record<string, FarmRouteRule>;
2536
+ declare function normalizeRouteRules(routeRules: FarmRouteRules | undefined): FarmRouteRules;
2537
+ declare function routeRulesToRedirects(routeRules: FarmRouteRules): RedirectConfig[];
2538
+ declare function routeRulesToHeaders(routeRules: FarmRouteRules): HeaderConfig[];
2539
+ declare function routeRulesToNitroRouteRules(routeRules: FarmRouteRules): Record<string, any>;
2839
2540
 
2840
- interface RedirectConfig {
2841
- source: string;
2842
- destination: string;
2843
- permanent?: boolean;
2844
- statusCode?: FarmRedirectStatus;
2541
+ declare global {
2542
+ namespace FarmJS {
2543
+ /** @internal Application route patterns registered by generated types. */
2544
+ interface RouteRegistry {
2545
+ }
2546
+ }
2845
2547
  }
2846
- interface HeaderConfig {
2847
- source: string;
2848
- headers: Array<{
2849
- key: string;
2850
- value: string;
2851
- }>;
2548
+ /** A renderer-neutral component accepted by Farm's file-system router. */
2549
+ type FarmComponentType<TProps = Record<string, unknown>> = ((props: TProps) => any) | (new (props: TProps) => any);
2550
+ /** All generated route module patterns for the current application. */
2551
+ type AppRoutePattern = FarmJS.RouteRegistry extends {
2552
+ pattern: infer TPattern extends string;
2553
+ } ? TPattern : string;
2554
+ type FarmRoutePropsDefault = never;
2555
+ type FarmRoutePropsTarget = AppRoutePattern;
2556
+ type StripPageRouteSuffix<TRoute extends string> = TRoute extends `${infer TPath}?${string}` ? StripPageRouteSuffix<TPath> : TRoute extends `${infer TPath}#${string}` ? StripPageRouteSuffix<TPath> : TRoute;
2557
+ type SimplifyPageRouteParams<TValue> = {
2558
+ [TKey in keyof TValue]: TValue[TKey];
2559
+ } & {};
2560
+ type PageRouteSegmentParams<TSegment extends string> = TSegment extends `[[...${infer TParam}]]` ? {
2561
+ [TKey in TParam]?: string;
2562
+ } : TSegment extends `[...${infer TParam}]` ? {
2563
+ [TKey in TParam]: string;
2564
+ } : TSegment extends `[${infer TParam}]` ? {
2565
+ [TKey in TParam]: string;
2566
+ } : {};
2567
+ type ExtractPageRouteParams<TRoute extends string> = TRoute extends `${infer TSegment}/${infer TRest}` ? PageRouteSegmentParams<TSegment> & ExtractPageRouteParams<TRest> : PageRouteSegmentParams<TRoute>;
2568
+ /** Infer the decoded params received by a page from a route pattern. */
2569
+ type PageRouteParams<TRoute extends string> = string extends TRoute ? Record<string, string> : TRoute extends string ? SimplifyPageRouteParams<ExtractPageRouteParams<StripPageRouteSuffix<TRoute>>> : never;
2570
+ type ResolvePageRouteParams<TRoute extends FarmRoutePropsTarget> = [TRoute] extends [never] ? Record<string, string> : TRoute extends string ? PageRouteParams<TRoute> : Record<string, string>;
2571
+ type NitroPreset = "node-server" | "vercel" | "cloudflare" | "cloudflare-pages" | "netlify" | "netlify-edge" | "bun" | "deno" | "azure" | "aws-lambda" | "firebase" | "custom" | "self-host" | "farm" | string;
2572
+ type FarmMigrationCommand = string | {
2573
+ /** Shell command to run for this migration step. */
2574
+ command: string;
2575
+ /** Optional label printed by the CLI before running the command. */
2576
+ name?: string;
2577
+ /** Working directory for this command, relative to the project root unless absolute. */
2578
+ cwd?: string;
2579
+ /** Additional environment variables for this command. */
2580
+ env?: Record<string, string | undefined>;
2581
+ /** Skip this command without removing it from config. */
2582
+ skip?: boolean;
2583
+ };
2584
+ interface FarmMigrationsConfig {
2585
+ /** One-shot commands that create or update app/integration schemas. */
2586
+ commands?: FarmMigrationCommand[];
2852
2587
  }
2853
- interface RewriteConfig {
2854
- source: string;
2855
- destination: string;
2588
+ type FarmMigrationsUserConfig = FarmMigrationsConfig | FarmMigrationCommand[];
2589
+ interface ResolvedFarmMigrationsConfig {
2590
+ commands: FarmMigrationCommand[];
2856
2591
  }
2857
- /** @deprecated Use FarmImageConfig. */
2858
- type ImageConfig = FarmImageConfig;
2859
- /** @deprecated Use FarmI18nUserConfig. */
2860
- type I18nConfig = FarmI18nUserConfig;
2861
- interface OpenAPIConfig {
2862
- enabled?: boolean;
2863
- route?: string;
2864
- /**
2865
- * Path where the raw OpenAPI spec is served as JSON, so agents and API tools
2866
- * can fetch it at a predictable URL. Set to `false` to disable.
2867
- *
2868
- * @default "/openapi.json"
2869
- */
2870
- specRoute?: string | false;
2871
- title?: string;
2872
- description?: string;
2873
- version?: string;
2874
- /** Default authentication requirement for operations without an endpoint override. */
2875
- security?: OpenAPISecurityMode;
2876
- servers?: Array<{
2877
- url: string;
2878
- description?: string;
2879
- }>;
2880
- contact?: {
2881
- name?: string;
2882
- email?: string;
2883
- url?: string;
2884
- };
2885
- license?: {
2886
- name: string;
2887
- url?: string;
2888
- };
2592
+ interface FarmContextFactoryInput {
2593
+ request: Request;
2594
+ rawRequest?: FarmRequest;
2595
+ params: Record<string, string>;
2596
+ search: Record<string, string | string[] | undefined>;
2597
+ path: string;
2889
2598
  }
2890
- type MiddlewareConfig = FarmMiddlewareConfig;
2891
- interface NotFoundConfig {
2892
- /** Path to a custom 404 page component (e.g., "./src/app/not-found.tsx") */
2893
- component?: string;
2599
+ type FarmContextFactory<TContext = unknown> = (input: FarmContextFactoryInput) => TContext | Promise<TContext>;
2600
+ interface FarmAppContext {
2894
2601
  }
2895
- type FarmDeployTarget = "vercel" | "cloudflare" | "netlify" | "node" | string;
2896
- interface FarmDeployConfig {
2602
+ interface FarmConfig {
2603
+ root?: string;
2604
+ /** App source directory. @default "src" */
2605
+ srcDir?: string;
2606
+ extends?: readonly FarmLayerEntry[];
2607
+ /** Resolved layer graph. Populated by config resolution. */
2608
+ layers?: readonly ResolvedFarmLayer[];
2609
+ outDir?: string;
2610
+ basePath?: string;
2611
+ /** Generate and canonicalize non-root application page URLs with a trailing slash. */
2612
+ trailingSlash?: boolean;
2897
2613
  /**
2898
- * Deployment platform. When present, Farm picks the matching Nitro preset and
2899
- * output directory unless explicitly overridden.
2614
+ * Component renderer used for JSX compilation, SSR, and browser hydration.
2615
+ * React is used when omitted.
2900
2616
  */
2901
- target?: FarmDeployTarget;
2902
- /** Nitro preset override. Usually inferred from target. */
2903
- preset?: FarmConfig["preset"];
2904
- /** Deployable output directory, relative to project root unless absolute. */
2905
- outputDir?: string;
2906
- /** Alias for outputDir for terser config. */
2907
- output?: string;
2908
- /** Cloudflare Pages project name used by `farm deploy --cloudflare`. */
2909
- projectName?: string;
2910
- vercel?: {
2911
- outputDirectory?: string;
2912
- buildCommand?: string;
2913
- installCommand?: string;
2914
- framework?: string | null;
2915
- };
2916
- cloudflare?: {
2617
+ renderer?: FarmRenderer;
2618
+ preset?: NitroPreset;
2619
+ deploy?: {
2620
+ target?: "vercel" | "cloudflare" | "netlify" | "node" | string;
2621
+ preset?: NitroPreset;
2917
2622
  outputDir?: string;
2623
+ output?: string;
2918
2624
  projectName?: string;
2625
+ vercel?: {
2626
+ outputDirectory?: string;
2627
+ buildCommand?: string;
2628
+ installCommand?: string;
2629
+ framework?: string | null;
2630
+ };
2631
+ cloudflare?: {
2632
+ outputDir?: string;
2633
+ projectName?: string;
2634
+ };
2635
+ netlify?: {
2636
+ outputDir?: string;
2637
+ site?: string;
2638
+ };
2919
2639
  };
2920
- netlify?: {
2921
- outputDir?: string;
2922
- site?: string;
2923
- };
2924
- }
2925
- interface ResolvedFarmDeployConfig extends Omit<FarmDeployConfig, "output"> {
2926
- target?: FarmDeployTarget;
2927
- preset: FarmConfig["preset"];
2928
- outputDir: string;
2929
- }
2930
- interface FarmUserConfig extends Omit<FarmConfig, "vite" | "docs" | "env" | "layers"> {
2931
- /** Reusable Farm directories or installed packages, applied from left to right. */
2932
- extends?: readonly FarmLayerEntry[];
2933
- /** Global plugins. Integration-bound plugins must be contributed through an integration. */
2934
- plugins?: FarmPlugin<any, any, any, any, unknown, false>[];
2935
- integrations?: FarmIntegrationsUserConfig;
2936
- /**
2937
- * Farm-native authentication. `true` enables email/password auth with
2938
- * server helpers from `@farm.js/auth/server` and React APIs from
2939
- * `@farm.js/auth/client`.
2940
- */
2941
- auth?: FarmAuthUserConfig;
2942
- /** Compose opted-in API routes and standalone tools through an authenticated MCP transport. */
2943
- mcp?: FarmMCPUserConfig;
2640
+ storage?: FarmStorageUserConfig;
2641
+ /** Rules for the tables plugins and integrations declare, such as which app tables they may add columns to. */
2642
+ schema?: FarmSchemaConfig;
2944
2643
  /** Shared application data, route, ISR, and PPR cache. */
2945
2644
  cache?: FarmCacheUserConfig;
2946
- migrations?: FarmMigrationsUserConfig;
2947
- /** Map portable cron schedules to ordinary GET API routes. */
2948
- cron?: FarmCronUserConfig | FarmCronResolvedConfig | false;
2949
- workflows?: FarmWorkflowsUserConfig | boolean;
2950
- preset?: FarmConfig["preset"];
2951
- deploy?: FarmDeployConfig;
2952
- docs?: FarmDocsUserConfig;
2953
- md?: FarmMarkdownUserConfig | boolean;
2954
- mdx?: FarmMdxUserConfig;
2955
- observability?: FarmObservabilityUserConfig;
2956
- trailingSlash?: boolean;
2957
- redirects?: () => Promise<RedirectConfig[]> | RedirectConfig[];
2958
- rewrites?: () => Promise<RewriteConfig[]> | RewriteConfig[];
2959
- headers?: () => Promise<HeaderConfig[]> | HeaderConfig[];
2960
- images?: ImageConfig;
2961
- publicDir?: string;
2962
- i18n?: FarmI18nUserConfig | false;
2963
- openapi?: OpenAPIConfig;
2964
- middleware?: FarmMiddlewareConfig;
2965
- routeRules?: FarmRouteRules;
2966
- context?: FarmConfig["context"];
2967
- /** Server ingress and trusted-proxy policy. */
2968
- server?: FarmServerConfig;
2969
- serverActions?: FarmServerActionsConfig;
2970
- /** Build identifier used to detect and recover from deployment version skew. */
2971
- deploymentId?: string;
2972
- notFound?: NotFoundConfig;
2973
- distDir?: string;
2974
- generateBuildId?: () => string | Promise<string>;
2975
- compress?: boolean;
2976
- devIndicators?: FarmDevIndicatorsConfig;
2977
- serverRuntimeConfig?: Record<string, any>;
2978
- publicRuntimeConfig?: Record<string, any>;
2979
- env?: FarmEnvConfig<any, any>;
2980
- vite?: UserConfig | ((config: UserConfig) => UserConfig);
2981
- [key: string]: any;
2982
- }
2983
- interface ResolvedFarmConfig extends Required<Omit<FarmUserConfig, "extends" | "plugins" | "vite" | "deploy" | "docs" | "md" | "mdx" | "migrations" | "cron" | "workflows" | "api" | "env" | "server" | "serverActions" | "devtools" | "devIndicators" | "images" | "i18n" | "auth" | "mcp" | "performance" | "security" | "theme" | "renderer" | "agent">> {
2984
- agent: ResolvedFarmAgentConfig;
2985
- /** @internal Tracks whether `context` came from user/layer config instead of the default noop. */
2986
- [FARM_RESOLVED_CUSTOM_CONTEXT]?: boolean;
2987
- root: string;
2988
- extends: readonly FarmLayerEntry[];
2989
- layers: ResolvedFarmLayer[];
2990
- plugins: FarmPlugin[];
2991
- vite: UserConfig;
2992
- deploy: ResolvedFarmDeployConfig;
2993
- docs: FarmDocsResolvedConfig;
2994
- md: FarmMarkdownResolvedConfig;
2995
- mdx: FarmMdxResolvedConfig;
2996
- migrations: ResolvedFarmMigrationsConfig;
2997
- cron: FarmCronResolvedConfig;
2998
- workflows: FarmWorkflowsResolvedConfig;
2999
- api: ResolvedFarmAPIConfig;
3000
- env: ResolvedFarmEnv;
3001
- server: ResolvedFarmServerConfig;
3002
- serverActions: ResolvedFarmServerActionsConfig;
3003
- devtools: ResolvedFarmDevtoolsConfig;
3004
- devIndicators: ResolvedFarmDevIndicatorsConfig;
3005
- images: ResolvedFarmImageConfig;
3006
- i18n: ResolvedFarmI18nConfig;
3007
- auth: ResolvedFarmAuthConfig;
3008
- mcp: ResolvedFarmMCPConfig;
3009
- performance: ResolvedFarmPerformanceConfig;
3010
- security: ResolvedFarmSecurityConfig;
3011
- theme: ResolvedFarmThemeConfig;
3012
- renderer: FarmRenderer;
3013
- routeRules: FarmRouteRules;
3014
- notFound: NotFoundConfig;
3015
- }
3016
- type FarmLayerConfig = Omit<FarmUserConfig, "root" | "outDir" | "distDir" | "deploy" | "preset" | "publicDir" | "generateBuildId" | "deploymentId">;
3017
-
3018
- declare function normalizeDeployTarget(target?: FarmDeployTarget): FarmDeployTarget | undefined;
3019
- declare function getPresetForDeployTarget(target?: FarmDeployTarget): FarmConfig["preset"] | undefined;
3020
- declare function getDeployTargetForPreset(preset?: string): FarmDeployTarget | undefined;
3021
- declare function resolveDeployOutputPath(root: string, outputDir: string): string;
3022
- declare function resolveDeployConfig(config: Pick<FarmUserConfig, "deploy" | "preset" | "distDir">, overrides?: {
3023
- target?: FarmDeployTarget;
3024
- preset?: FarmConfig["preset"];
3025
- outputDir?: string;
3026
- /** Build environment consulted for platform detection. Tests inject this. */
3027
- env?: NodeJS.ProcessEnv;
3028
- }): ResolvedFarmDeployConfig;
3029
- declare function resolveMigrationsConfig(migrations: FarmMigrationsUserConfig | undefined): ResolvedFarmMigrationsConfig;
3030
- declare function resolveConfig(userConfig: FarmUserConfig, mode: "development" | "production"): Promise<ResolvedFarmConfig>;
3031
- declare function loadConfig(rootDir?: string, configPath?: string, mode?: string, loadEnvironment?: (typeof vite)["loadEnv"]): Promise<FarmUserConfig | undefined>;
3032
-
3033
- type FarmRouteRuntime = "auto" | "node" | "edge";
3034
- type FarmRouteRegions = "auto" | readonly string[];
3035
- type FarmRouteMaxDuration = "auto" | number;
3036
- /** Portable execution controls shared by file, programmatic, and config routes. */
3037
- interface FarmRouteRuntimeConfig {
3038
- runtime?: FarmRouteRuntime;
3039
- regions?: FarmRouteRegions;
3040
- maxDuration?: FarmRouteMaxDuration;
3041
- }
3042
- interface ResolvedFarmRouteRuntimeConfig {
3043
- runtime: FarmRouteRuntime;
3044
- regions?: string[];
3045
- maxDuration?: number;
3046
- }
3047
- type FarmRouteRuntimeEntryKind = "page" | "api" | "metadata" | "rule";
3048
- type FarmRouteRenderingMode = "static" | "dynamic";
3049
- interface FarmRouteRuntimeManifestEntry extends ResolvedFarmRouteRuntimeConfig {
3050
- kind: FarmRouteRuntimeEntryKind;
3051
- pattern: string;
3052
- rendering: FarmRouteRenderingMode;
3053
- source?: string;
3054
- }
3055
- interface FarmRouteRuntimeManifest {
3056
- version: 1;
3057
- routes: FarmRouteRuntimeManifestEntry[];
3058
- }
3059
- declare function normalizeFarmRouteRuntimeConfig(value: FarmRouteRuntimeConfig | null | undefined, source?: string): FarmRouteRuntimeConfig;
3060
- /** Merge from lowest to highest precedence. Explicit "auto" values reset inherited hints. */
3061
- declare function mergeFarmRouteRuntimeConfigs(...configs: Array<FarmRouteRuntimeConfig | null | undefined>): FarmRouteRuntimeConfig;
3062
- declare function resolveFarmRouteRuntimeConfig(config: FarmRouteRuntimeConfig | null | undefined, source?: string): ResolvedFarmRouteRuntimeConfig;
3063
- declare function hasFarmRouteRuntimeControls(config: FarmRouteRuntimeConfig | null | undefined): boolean;
3064
- declare function getFarmRouteRuntimeConfig(value: unknown): FarmRouteRuntimeConfig;
3065
- declare function createFarmRouteRuntimeKey(config: ResolvedFarmRouteRuntimeConfig): string;
3066
- /** Resolve matching route rules from broadest to most specific. */
3067
- declare function resolveFarmRouteRuleRuntimeConfig(pathname: string, routeRules: Record<string, FarmRouteRuntimeConfig> | null | undefined): FarmRouteRuntimeConfig;
3068
- declare function farmRouteRuleMatches(pattern: string, pathname: string): boolean;
3069
-
3070
- type FarmRouteRuleRenderMode = "static" | "dynamic";
3071
- type FarmRouteRuleRedirect = string | {
3072
- to: string;
3073
- statusCode?: FarmRedirectStatus;
3074
- permanent?: boolean;
3075
- };
3076
- type FarmRouteRuleCors = boolean | {
3077
- origin?: string;
3078
- methods?: string | readonly string[];
3079
- headers?: string | readonly string[];
3080
- };
3081
- interface FarmRouteRule extends FarmRouteRuntimeConfig {
3082
- prerender?: boolean;
3083
- render?: FarmRouteRuleRenderMode;
3084
- ssr?: boolean;
3085
- swr?: boolean | number;
3086
- isr?: boolean | number;
3087
- cors?: FarmRouteRuleCors;
3088
- headers?: Record<string, string>;
3089
- redirect?: FarmRouteRuleRedirect;
3090
- }
3091
- type FarmRouteRules = Record<string, FarmRouteRule>;
3092
- declare function normalizeRouteRules(routeRules: FarmRouteRules | undefined): FarmRouteRules;
3093
- declare function routeRulesToRedirects(routeRules: FarmRouteRules): RedirectConfig[];
3094
- declare function routeRulesToHeaders(routeRules: FarmRouteRules): HeaderConfig[];
3095
- declare function routeRulesToNitroRouteRules(routeRules: FarmRouteRules): Record<string, any>;
3096
-
3097
- declare global {
3098
- namespace FarmJS {
3099
- /** @internal Application route patterns registered by generated types. */
3100
- interface RouteRegistry {
3101
- }
3102
- }
3103
- }
3104
- /** A renderer-neutral component accepted by Farm's file-system router. */
3105
- type FarmComponentType<TProps = Record<string, unknown>> = ((props: TProps) => any) | (new (props: TProps) => any);
3106
- /** All generated route module patterns for the current application. */
3107
- type AppRoutePattern = FarmJS.RouteRegistry extends {
3108
- pattern: infer TPattern extends string;
3109
- } ? TPattern : string;
3110
- type FarmRoutePropsDefault = never;
3111
- type FarmRoutePropsTarget = AppRoutePattern;
3112
- type StripPageRouteSuffix<TRoute extends string> = TRoute extends `${infer TPath}?${string}` ? StripPageRouteSuffix<TPath> : TRoute extends `${infer TPath}#${string}` ? StripPageRouteSuffix<TPath> : TRoute;
3113
- type SimplifyPageRouteParams<TValue> = {
3114
- [TKey in keyof TValue]: TValue[TKey];
3115
- } & {};
3116
- type PageRouteSegmentParams<TSegment extends string> = TSegment extends `[[...${infer TParam}]]` ? {
3117
- [TKey in TParam]?: string;
3118
- } : TSegment extends `[...${infer TParam}]` ? {
3119
- [TKey in TParam]: string;
3120
- } : TSegment extends `[${infer TParam}]` ? {
3121
- [TKey in TParam]: string;
3122
- } : {};
3123
- type ExtractPageRouteParams<TRoute extends string> = TRoute extends `${infer TSegment}/${infer TRest}` ? PageRouteSegmentParams<TSegment> & ExtractPageRouteParams<TRest> : PageRouteSegmentParams<TRoute>;
3124
- /** Infer the decoded params received by a page from a route pattern. */
3125
- type PageRouteParams<TRoute extends string> = string extends TRoute ? Record<string, string> : TRoute extends string ? SimplifyPageRouteParams<ExtractPageRouteParams<StripPageRouteSuffix<TRoute>>> : never;
3126
- type ResolvePageRouteParams<TRoute extends FarmRoutePropsTarget> = [TRoute] extends [never] ? Record<string, string> : TRoute extends string ? PageRouteParams<TRoute> : Record<string, string>;
3127
- type NitroPreset = "node-server" | "vercel" | "cloudflare" | "cloudflare-pages" | "netlify" | "netlify-edge" | "bun" | "deno" | "azure" | "aws-lambda" | "firebase" | "custom" | "self-host" | "farm" | string;
3128
- type FarmMigrationCommand = string | {
3129
- /** Shell command to run for this migration step. */
3130
- command: string;
3131
- /** Optional label printed by the CLI before running the command. */
3132
- name?: string;
3133
- /** Working directory for this command, relative to the project root unless absolute. */
3134
- cwd?: string;
3135
- /** Additional environment variables for this command. */
3136
- env?: Record<string, string | undefined>;
3137
- /** Skip this command without removing it from config. */
3138
- skip?: boolean;
3139
- };
3140
- interface FarmMigrationsConfig {
3141
- /** One-shot commands that create or update app/integration schemas. */
3142
- commands?: FarmMigrationCommand[];
3143
- }
3144
- type FarmMigrationsUserConfig = FarmMigrationsConfig | FarmMigrationCommand[];
3145
- interface ResolvedFarmMigrationsConfig {
3146
- commands: FarmMigrationCommand[];
3147
- }
3148
- interface FarmContextFactoryInput {
3149
- request: Request;
3150
- rawRequest?: FarmRequest;
3151
- params: Record<string, string>;
3152
- search: Record<string, string | string[] | undefined>;
3153
- path: string;
3154
- }
3155
- type FarmContextFactory<TContext = unknown> = (input: FarmContextFactoryInput) => TContext | Promise<TContext>;
3156
- interface FarmAppContext {
3157
- }
3158
- interface FarmConfig {
3159
- root?: string;
3160
- /** App source directory. @default "src" */
3161
- srcDir?: string;
3162
- extends?: readonly FarmLayerEntry[];
3163
- /** Resolved layer graph. Populated by config resolution. */
3164
- layers?: readonly ResolvedFarmLayer[];
3165
- outDir?: string;
3166
- basePath?: string;
3167
- /** Generate and canonicalize non-root application page URLs with a trailing slash. */
3168
- trailingSlash?: boolean;
3169
- /**
3170
- * Component renderer used for JSX compilation, SSR, and browser hydration.
3171
- * React is used when omitted.
3172
- */
3173
- renderer?: FarmRenderer;
3174
- preset?: NitroPreset;
3175
- deploy?: {
3176
- target?: "vercel" | "cloudflare" | "netlify" | "node" | string;
3177
- preset?: NitroPreset;
3178
- outputDir?: string;
3179
- output?: string;
3180
- projectName?: string;
3181
- vercel?: {
3182
- outputDirectory?: string;
3183
- buildCommand?: string;
3184
- installCommand?: string;
3185
- framework?: string | null;
3186
- };
3187
- cloudflare?: {
3188
- outputDir?: string;
3189
- projectName?: string;
3190
- };
3191
- netlify?: {
3192
- outputDir?: string;
3193
- site?: string;
3194
- };
3195
- };
3196
- storage?: FarmStorageUserConfig;
3197
- /** Rules for the tables plugins and integrations declare, such as which app tables they may add columns to. */
3198
- schema?: FarmSchemaConfig;
3199
- /** Shared application data, route, ISR, and PPR cache. */
3200
- cache?: FarmCacheUserConfig;
3201
- integrations?: FarmIntegrationsUserConfig;
3202
- /** Farm-native authentication. `true` enables email/password auth. */
3203
- auth?: FarmAuthUserConfig | ResolvedFarmAuthConfig;
3204
- plugins?: FarmPlugin[];
2645
+ integrations?: FarmIntegrationsUserConfig;
2646
+ /** Farm-native authentication. `true` enables email/password auth. */
2647
+ auth?: FarmAuthUserConfig | ResolvedFarmAuthConfig;
2648
+ plugins?: FarmPlugin[];
3205
2649
  migrations?: FarmMigrationsUserConfig;
3206
2650
  /** Map portable cron schedules to ordinary GET API routes. */
3207
2651
  cron?: FarmCronUserConfig | FarmCronResolvedConfig | false;
@@ -3798,4 +3242,560 @@ interface MetadataRobots extends MetadataRobotsDirectives {
3798
3242
  googleBot?: string | MetadataRobotsDirectives;
3799
3243
  }
3800
3244
 
3801
- export { type FarmDevtoolsUserConfig as $, type APIRouteDiscoveredPayload as A, type BundleLifecyclePayload as B, type FarmPluginRuntimeCloseEvent as C, type FarmPluginRuntimeHooks as D, type ErrorLifecyclePayload as E, type FarmRouteRuntimeConfig as F, type FarmPluginRuntimeRequestOptions as G, type HMRUpdatePayload as H, type FarmPluginRuntimeRequestHandler as I, type FarmPluginRuntimeSession as J, type FarmPluginDiscoveredRoute as K, type FarmPluginRouterHooks as L, type MiddlewareDiscoveredPayload as M, type NitroBuildLifecyclePayload as N, type FarmPluginRenderHooks as O, type PluginRequestContext as P, type FarmPluginBuildHooks as Q, type RouteDiscoveredPayload as R, type ShutdownPayload as S, type FarmPluginDevHooks as T, type FarmPluginClientConfig as U, PluginManager as V, type FarmPluginDefinition as W, definePlugin as X, type FarmPluginDatabase as Y, resolveFarmDevtoolsConfig as Z, type ResolvedFarmDevtoolsConfig as _, type FarmPlugin as a, type GenerateStaticParams as a$, getFarmRedirectError as a0, isFarmNotFoundError as a1, isFarmRedirectError as a2, notFound as a3, permanentRedirect as a4, redirect as a5, type FarmRedirectSignal as a6, type FarmRedirectStatus as a7, type ParsedRoute as a8, type RouteSegment as a9, resolveDeployConfig as aA, type FarmConfig as aB, resolveFarmMCPConfig as aC, resolveFarmMCPPlugin as aD, type FarmMCPUserConfig as aE, type FarmComponentType as aF, type AppRoutePattern as aG, type PageRouteParams as aH, type NitroPreset as aI, type FarmMigrationCommand as aJ, type FarmMigrationsConfig as aK, type FarmMigrationsUserConfig as aL, type ResolvedFarmMigrationsConfig as aM, type FarmContextFactoryInput as aN, type FarmIsolatedClientHydrationMode as aO, type LoadingProps as aP, type ErrorProps as aQ, type PagePropsWithMiddleware as aR, type MetadataProps as aS, type LayoutMetadataProps as aT, type Page as aU, type Layout as aV, type Loading as aW, type ErrorBoundary as aX, type StaticPathPrimitive as aY, type StaticPathParams as aZ, type StaticRouteParams as a_, type FarmRequest as aa, type FarmResponse as ab, type LayoutProps as ac, type Metadata as ad, type FarmRouteRuntime as ae, type FarmRouteRegions as af, type FarmRouteMaxDuration as ag, type FarmAppContext as ah, type PageProps as ai, type PluginContextProps as aj, type RouteModule as ak, type FarmMdxComponents as al, type FarmMdxResolvedConfig as am, resolveFarmMdxComponentsModulePath as an, resolveMdxConfig as ao, type FarmMdxComponent as ap, type FarmMdxUserConfig as aq, FARM_MARKDOWN_CONTENT_TYPE as ar, createFarmMarkdownErrorBody as as, farmRequestWantsMarkdown as at, type FarmUserConfig as au, type FarmContextFactory as av, type MiddlewareProps as aw, type FarmIntegration as ax, loadConfig as ay, resolveConfig as az, FARM_NODE_RESPONSE_END_PENDING as b, type FarmSecurityConfig as b$, type LayoutModule as b0, type MetadataJsonLd as b1, type ThemeColorDescriptor as b2, type Viewport as b3, type ServerAction as b4, type BuildOptions as b5, type SSGPage as b6, type SSGCollectionResult as b7, type MetadataRobotsDirectives as b8, type MetadataRobots as b9, type CollectedSchemaModel as bA, type FarmSchemaMigrationStep as bB, type OpenAPIConfig as bC, type FarmAgentUserConfig as bD, type FarmAgentCrawlers as bE, type FarmCrawlerPolicy as bF, type FarmAppManifestConfig as bG, FarmPluginOptionsError as bH, type FarmPluginFactory as bI, type FarmPluginOptionsIssue as bJ, type FarmPluginOptionsSchema as bK, type InferPluginOptionsInput as bL, type InferPluginOptionsOutput as bM, resolveMigrationsConfig as bN, resolveDeployOutputPath as bO, normalizeDeployTarget as bP, getDeployTargetForPreset as bQ, getPresetForDeployTarget as bR, type FarmLayerConfig as bS, type FarmPerformanceConfig as bT, type FarmPreloadMode as bU, type FarmPreloadUserConfig as bV, type ResolvedFarmPreloadConfig as bW, type FarmCspConfig as bX, type FarmCspDirectives as bY, type FarmCspDirectiveValue as bZ, type FarmCspOptions as b_, type FarmMCPCatalogDetails as ba, type ResolvedFarmAppManifestConfig as bb, type ReadonlyMiddlewareStore as bc, type FarmMiddlewareConfig as bd, type MiddlewareModule as be, type MiddlewareConfig$1 as bf, type MiddlewareContext as bg, type FarmServerComponentsMode as bh, type ResolvedFarmConfig as bi, type FarmAgentJsonLd as bj, type FarmMCPServerRegistration as bk, type FarmMarkdownResolvedConfig as bl, _findFarmMCPEndpointTool as bm, _publishFarmMCPCatalog as bn, registerFarmMCPServer as bo, type ResolvedFarmRouteRuntimeConfig as bp, type ApplicationMetadataRouteKind as bq, type ResolvedFarmAPIConfig as br, type FarmDocsResolvedConfig as bs, type ResolvedFarmDevIndicatorsConfig as bt, type ResolvedFarmAuthConfig as bu, type ResolvedFarmPerformanceConfig as bv, type ResolvedFarmSecurityConfig as bw, type ResolvedSchemaField as bx, type FarmSqlDialect as by, type FarmSqlStatement as bz, type FarmPluginIntegrationContext as c, type FarmIntegrationValidationErrorLike as c$, type ResolvedFarmCspConfig as c0, MetadataRoute as c1, type MetadataRouteContext as c2, type FarmMCPEndpointTool as c3, type FarmServerComponentsConfig as c4, type FarmServerComponentsOptions as c5, type FarmAuthConfig as c6, type FarmAuthDatabaseConfig as c7, type FarmAuthEmailAndPasswordConfig as c8, type FarmAuthSessionConfig as c9, type ResolvedFarmDeployConfig as cA, type FarmDeployTarget as cB, type FarmDocsUserConfig as cC, type FarmMarkdownUserConfig as cD, describeSchemaReference as cE, collectSchemaModels as cF, generateSqlStatements as cG, renderSqlSchemaFile as cH, getSqlColumnType as cI, getSqlDefaultExpression as cJ, isNullableField as cK, quoteSqlIdentifier as cL, toSnakeCase as cM, toPascalCase as cN, toCamelCase as cO, escapeSqlString as cP, resolveSchemaModels as cQ, type ResolvedSchemaModel as cR, type FarmIntegrationCategory as cS, type FarmIntegrationSlot as cT, type FarmIntegrationRouteParamValue as cU, type FarmIntegrationRouteParams as cV, type FarmIntegrationRouteMethod as cW, type FarmIntegrationRouteInputSource as cX, type FarmIntegrationValidationPathSegment as cY, type FarmIntegrationRouteInput as cZ, type FarmIntegrationValidationIssue as c_, type FarmAuthUserConfig as ca, type FarmMCPAuthorization as cb, type FarmMCPEndpoint as cc, type FarmMCPServerFunction as cd, type FarmMCPToolDefinition as ce, type FarmMCPStandaloneTool as cf, type FarmMCPExecuteContext as cg, type FarmMCPTool as ch, type FarmMCPServer as ci, type FarmMCPAuthorizeContext as cj, type FarmMCPConfig as ck, type FarmMCPOAuthConfig as cl, type FarmMCPPrompt as cm, type FarmMCPPromptMessage as cn, type FarmMCPResource as co, type FarmMCPResourceContent as cp, type FarmMCPResourceContext as cq, type FarmMCPResourceListing as cr, type ResolvedFarmMCPConfig as cs, type RedirectConfig as ct, type HeaderConfig as cu, type RewriteConfig as cv, type ImageConfig as cw, type I18nConfig as cx, type MiddlewareConfig as cy, type FarmDeployConfig as cz, FarmRuntimeShutdownError as d, getIntegrationSchemas as d$, type FarmIntegrationValidationResult as d0, type FarmIntegrationStandardValidationResult as d1, type FarmIntegrationInputSchema as d2, type FarmIntegrationRouteInputSchemas as d3, type FarmIntegrationRequestContextStore as d4, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as d5, FARM_INTEGRATION_SET_COOKIES_KEY as d6, forwardIntegrationSetCookies as d7, type FarmIntegrationRouteDb as d8, type FarmIntegrationRouteStorageArgs as d9, type FarmIntegrationSchemaModelExtension as dA, type FarmIntegrationSchemaModelOverride as dB, type FarmIntegrationSchema as dC, defineIntegrationSchema as dD, type FarmIntegrationLogPhase as dE, type FarmIntegrationLogEvent as dF, type FarmIntegrationLogger as dG, type FarmIntegrationPluginOwner as dH, type FarmIntegrationContributedPlugin as dI, type FarmIntegrationsUserConfig as dJ, getFarmIntegrationPluginServerRuntime as dK, getFarmIntegrationPluginOwner as dL, type FarmIntegrationRouteFactory as dM, type FarmIntegrationRoutesFactoryContext as dN, type FarmIntegrationRoutesFactory as dO, type FarmIntegrationEndpointValue as dP, type FarmIntegrationEndpoints as dQ, type FarmIntegrationEndpointsFactoryContext as dR, type FarmIntegrationEndpointsFactory as dS, createIntegrationRoute as dT, integrationRoute as dU, type DefinedIntegration as dV, defineIntegration as dW, resolveIntegrationPlugins as dX, getIntegrationProviders as dY, isFarmIntegrationProviderComponentReference as dZ, getIntegrationDocumentNavigationMatchers as d_, type FarmIntegrationRouteArgs as da, type FarmIntegrationConfigContext as db, type FarmIntegrationConfigDefinition as dc, type FarmIntegrationConfigInput as dd, type FarmIntegrationLifecycleLogLevel as de, type FarmIntegrationLifecycleLogger as df, type FarmIntegrationLifecycleContext as dg, type FarmIntegrationLifecycleHook as dh, type FarmIntegrationData as di, type FarmIntegrationHandlerContext as dj, type FarmIntegrationRouteHookContext as dk, type FarmIntegrationRouteHook as dl, type FarmIntegrationRoute as dm, type FarmTypedIntegrationRoute as dn, type FarmIntegrationRouteMiddleware as dp, type FarmIntegrationMiddleware as dq, type FarmIntegrationProviderProps as dr, type FarmIntegrationProviderComponentReference as ds, type FarmIntegrationProvider as dt, type FarmIntegrationDocumentNavigation as du, type FarmIntegrationSchemaFieldType as dv, type FarmIntegrationSchemaReference as dw, type FarmIntegrationSchemaField as dx, type FarmIntegrationSchemaConstraint as dy, type FarmIntegrationSchemaModel as dz, type FarmRequestStore as e, type FarmRouteRuntimeManifest as e$, getRegisteredIntegrationRuntime as e0, getRegisteredIntegrations as e1, getRegisteredIntegrationSchemas as e2, matchIntegrationRoute as e3, matchRegisteredIntegrationRoute as e4, getRegisteredIntegrationAPIManifest as e5, dispatchIntegrationRequest as e6, dispatchIntegrationRequests as e7, describeIntegrationOriginRejection as e8, resolveIntegrationAllowedOrigins as e9, resolveFarmAPIRequestURL as eA, type MiddlewareFunction as eB, type RequestMiddleware as eC, type RequestMiddlewareContext as eD, type MiddlewareStore as eE, type MiddlewareChain as eF, type CookieJar as eG, type CookieOptions as eH, type RateLimitConfig as eI, type RateLimitIncrementResult as eJ, type RateLimitStorage as eK, type RateLimitStatus as eL, type MemoryRateLimitStorageOptions as eM, type NextFunction as eN, type MiddlewareResult as eO, type FarmRouteRuleRenderMode as eP, type FarmRouteRuleRedirect as eQ, type FarmRouteRuleCors as eR, type FarmRouteRule as eS, type FarmRouteRules as eT, normalizeRouteRules as eU, routeRulesToRedirects as eV, routeRulesToHeaders as eW, routeRulesToNitroRouteRules as eX, type FarmRouteRuntimeEntryKind as eY, type FarmRouteRenderingMode as eZ, type FarmRouteRuntimeManifestEntry as e_, validateIntegrationRequestOrigin as ea, type IntegrationOriginPolicy as eb, type IntegrationOriginRejection as ec, type IntegrationOriginResult as ed, FARM_INTEGRATION_API_BASE_PATH_KEY as ee, integrationMiddlewareMayHandlePath as ef, isFarmIntegration as eg, type FarmIntegrationOrmSchema as eh, type FarmIntegrationOrmClient as ei, type InferFarmIntegrationOrmField as ej, type InferFarmIntegrationOrmFields as ek, type InferFarmIntegrationOrmSchema as el, type InferFarmIntegrationOrmClient as em, type CreateIntegrationOrmOptions as en, createIntegrationOrm as eo, resolveIntegrationOrmRuntimeClient as ep, farmIntegrationSchemaToOrmSchema as eq, type IntegrationOrmModelNames as er, DEFAULT_FARM_API_BASE_PATH as es, type FarmAPIConfigResolverContext as et, type FarmAPIConfigValue as eu, type FarmAPIConfig as ev, resolveFarmAPIConfig as ew, normalizeFarmAPIConfig as ex, normalizeFarmAPIBasePath as ey, getFarmAPIBaseURL as ez, type FarmPluginContext as f, createFarmCspNonce as f$, normalizeFarmRouteRuntimeConfig as f0, mergeFarmRouteRuntimeConfigs as f1, resolveFarmRouteRuntimeConfig as f2, hasFarmRouteRuntimeControls as f3, getFarmRouteRuntimeConfig as f4, createFarmRouteRuntimeKey as f5, resolveFarmRouteRuleRuntimeConfig as f6, farmRouteRuleMatches as f7, type FarmDocsConfigInput as f8, type FarmDocsNavigationConfig 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 FarmBuildActivityPosition as fG, type FarmDevIndicatorsConfig as fH, resolveFarmDevIndicatorsConfig as fI, generateFarmDevIndicatorsClientRuntime as fJ, type FarmLlmsTxtLink as fK, createFarmMetadataRouteResponse as fL, createFarmAgentRobots as fM, createFarmDefaultSitemap as fN, collectFarmLlmsTxtPages as fO, createFarmDefaultLlmsTxt as fP, createFarmLlmsMarkdownReader as fQ, renderFarmLlmsFullTxt as fR, createFarmLlmsFullRenderer as fS, resolveFarmLlmsTxtConfig as fT, type FarmLlmsTxtUserConfig as fU, type ResolvedFarmLlmsTxtConfig as fV, manageFarmDocumentPreloads as fW, manageFarmHtmlPreloads as fX, manageFarmLinkHeaderPreloads as fY, reportFarmPreloadWarnings as fZ, applyFarmCspNonceToResponse as f_, type FarmDocsSocialImageConfig as fa, type FarmDocsSocialImageFonts as fb, type FarmDocsSidebarItem as fc, FARM_MARKDOWN_PAGE_CHECK_HEADER as fd, _getFarmMarkdownPageCheckToken as fe, _isFarmMarkdownPageCheck 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, type FarmPluginLifecycle as g, resolveFarmSecurityConfig as g0, stampFarmCspNonce as g1, type FarmRequestPluginContext as h, type RoutesGeneratedPayload as i, type RouteMatchPayload as j, type RouteMatchResultPayload as k, type RenderLifecyclePayload as l, type APIHandlerLifecyclePayload as m, type BundleResultPayload as n, type FarmPluginRuntimeKind as o, type FarmPluginRouteRuntimePayload as p, type FarmPluginSetupContext as q, type FarmPluginStateContext as r, type FarmPluginRuntimeBaseEvent as s, type FarmPluginRuntimeContextEvent as t, type FarmPluginRuntimeEndpointEvent as u, type FarmPluginRuntimeEndpoint as v, type FarmPluginRuntimeBeforeEvent as w, type FarmPluginRuntimeAfterEvent as x, type FarmPluginRuntimeErrorEvent as y, type FarmPluginRuntimeStartEvent as z };
3245
+ type RuntimeClientFactory<TClient> = () => TClient | Promise<TClient>;
3246
+ type FarmIntegrationOrmSchema = SchemaDefinition<Record<string, AnyModelDefinition>>;
3247
+ type FarmIntegrationOrmClient<TSchema extends FarmIntegrationOrmSchema> = OrmClient<TSchema>;
3248
+ type FarmIntegrationOrmFieldKind<TField extends FarmIntegrationSchemaField> = TField extends {
3249
+ primaryKey: true;
3250
+ } ? TField["type"] extends "id" | "uuid" | "string" | "integer" ? "id" : never : TField["type"] extends "id" | "uuid" | "text" ? "string" : TField["type"] extends "number" ? "decimal" : Extract<TField["type"], "string" | "boolean" | "integer" | "datetime" | "json" | "enum">;
3251
+ type FarmIntegrationOrmFieldNullable<TField extends FarmIntegrationSchemaField> = TField extends {
3252
+ nullable: true;
3253
+ } ? true : TField extends {
3254
+ required: false;
3255
+ } ? true : false;
3256
+ type FarmIntegrationOrmEnumValue<TField extends FarmIntegrationSchemaField> = TField extends {
3257
+ values: readonly (infer TValue extends string)[];
3258
+ } ? TValue : string;
3259
+ type FarmIntegrationOrmFieldValue<TField extends FarmIntegrationSchemaField> = TField["type"] extends "id" | "uuid" | "string" | "text" ? string : TField["type"] extends "boolean" ? boolean : TField["type"] extends "integer" ? number : TField["type"] extends "number" ? string : TField["type"] extends "datetime" ? Date : TField["type"] extends "json" ? JsonValue : TField["type"] extends "enum" ? FarmIntegrationOrmEnumValue<TField> : never;
3260
+ type InferFarmIntegrationOrmField<TField extends FarmIntegrationSchemaField> = FieldBuilder<FarmIntegrationOrmFieldKind<TField>, FarmIntegrationOrmFieldNullable<TField>, FarmIntegrationOrmFieldValue<TField>>;
3261
+ type FarmIntegrationOrmModelShape = {
3262
+ fields: Record<string, unknown>;
3263
+ };
3264
+ type InferFarmIntegrationOrmFields<TModel extends FarmIntegrationOrmModelShape> = {
3265
+ [TFieldKey in keyof TModel["fields"] & string]: InferFarmIntegrationOrmField<Extract<TModel["fields"][TFieldKey], FarmIntegrationSchemaField>>;
3266
+ };
3267
+ type ReplaceRecord<TBase, TReplacement> = Omit<TBase, keyof TReplacement> & TReplacement;
3268
+ type SchemaExtensions<TSchema extends FarmIntegrationSchema> = NonNullable<TSchema["extend"]>;
3269
+ type SchemaOverrides<TSchema extends FarmIntegrationSchema> = NonNullable<TSchema["override"]>;
3270
+ type SchemaModelFields<TModel> = TModel extends {
3271
+ fields: infer TFields;
3272
+ } ? TFields : TModel extends {
3273
+ fields?: infer TFields;
3274
+ } ? NonNullable<TFields> : {};
3275
+ type ExtendedSchemaModelFields<TSchema extends FarmIntegrationSchema, TModelKey extends PropertyKey> = ReplaceRecord<TModelKey extends keyof TSchema["models"] ? SchemaModelFields<TSchema["models"][TModelKey]> : {}, TModelKey extends keyof SchemaExtensions<TSchema> ? SchemaModelFields<SchemaExtensions<TSchema>[TModelKey]> : {}>;
3276
+ type OverrideSchemaModelFields<TSchema extends FarmIntegrationSchema, TModelKey extends PropertyKey> = TModelKey extends keyof SchemaOverrides<TSchema> ? SchemaModelFields<SchemaOverrides<TSchema>[TModelKey]> : {};
3277
+ type ResolvedSchemaModelFields<TSchema extends FarmIntegrationSchema, TModelKey extends PropertyKey, TExtendedFields = ExtendedSchemaModelFields<TSchema, TModelKey>, TOverrideFields = OverrideSchemaModelFields<TSchema, TModelKey>> = {
3278
+ [TFieldKey in keyof TExtendedFields | keyof TOverrideFields]: TFieldKey extends keyof TOverrideFields ? TFieldKey extends keyof TExtendedFields ? ReplaceRecord<TExtendedFields[TFieldKey], TOverrideFields[TFieldKey]> : TOverrideFields[TFieldKey] : TFieldKey extends keyof TExtendedFields ? TExtendedFields[TFieldKey] : never;
3279
+ };
3280
+ type ResolvedFarmIntegrationSchemaModels<TSchema extends FarmIntegrationSchema> = {
3281
+ [TModelKey in (keyof TSchema["models"] | keyof SchemaExtensions<TSchema>) & string]: {
3282
+ fields: ResolvedSchemaModelFields<TSchema, TModelKey>;
3283
+ };
3284
+ };
3285
+ type InferFarmIntegrationOrmSchema<TSchema extends FarmIntegrationSchema> = SchemaDefinition<{
3286
+ [TModelKey in keyof ResolvedFarmIntegrationSchemaModels<TSchema> & string]: ModelDefinition<InferFarmIntegrationOrmFields<Extract<ResolvedFarmIntegrationSchemaModels<TSchema>[TModelKey], FarmIntegrationOrmModelShape>>, {}>;
3287
+ }>;
3288
+ type InferFarmIntegrationOrmClient<TSchema extends FarmIntegrationSchema | undefined> = TSchema extends FarmIntegrationSchema ? OrmClient<InferFarmIntegrationOrmSchema<TSchema>> : never;
3289
+ interface CreateIntegrationOrmOptions<TClient = unknown, TSchema extends FarmIntegrationSchema = FarmIntegrationSchema> {
3290
+ schema: TSchema;
3291
+ config?: Pick<FarmConfig, "storage">;
3292
+ storage?: FarmStorageUserConfig;
3293
+ client?: TClient | RuntimeClientFactory<TClient>;
3294
+ }
3295
+ declare function createIntegrationOrm<TClient = unknown, TSchema extends FarmIntegrationSchema = FarmIntegrationSchema>(options: CreateIntegrationOrmOptions<TClient, TSchema>): Promise<InferFarmIntegrationOrmClient<TSchema>>;
3296
+ declare function resolveIntegrationOrmRuntimeClient<TClient = unknown>(options: Omit<CreateIntegrationOrmOptions<TClient>, "schema">): Promise<TClient | unknown | undefined>;
3297
+ declare function farmIntegrationSchemaToOrmSchema(schema: FarmIntegrationSchema): Promise<FarmIntegrationOrmSchema>;
3298
+ type IntegrationOrmModelNames<TSchema extends FarmIntegrationOrmSchema> = keyof SchemaModels<TSchema> & string;
3299
+
3300
+ declare function isFarmIntegration(value: unknown): value is FarmIntegration;
3301
+ /**
3302
+ * @internal Whether an integration's middleware matcher (a `protectedRoutes` guard, say)
3303
+ * covers `pathname`, a route path without the base path. With `catchAllProbe`, a path no
3304
+ * route uses, only matchers naming particular paths count: middleware without a matcher,
3305
+ * or one that also meets the probe, covers every path and is left out.
3306
+ */
3307
+ declare function integrationMiddlewareMayHandlePath(integrations: FarmIntegrationsUserConfig | undefined, pathname: string, catchAllProbe?: string): boolean;
3308
+ /**
3309
+ * @internal Runtime config key holding the app's same-origin API path. The built server keeps the
3310
+ * user's raw `api` config, whose values may be resolver functions, so the build records the
3311
+ * resolved path here; development configs carry the resolved `api` itself.
3312
+ */
3313
+ declare const FARM_INTEGRATION_API_BASE_PATH_KEY = "__farmAPIServerBasePath";
3314
+
3315
+ type FarmIntegrationCategory = "auth" | "payment" | "monitoring" | "logging" | (string & {});
3316
+ /** @deprecated Use FarmIntegrationCategory instead. */
3317
+ type FarmIntegrationSlot = FarmIntegrationCategory;
3318
+ type FarmIntegrationRouteParamValue = string | string[];
3319
+ type FarmIntegrationRouteParams = Record<string, FarmIntegrationRouteParamValue>;
3320
+ type FarmIntegrationRouteMethod = FarmIntegrationAPIMethod | Lowercase<FarmIntegrationAPIMethod> | "ALL" | "all";
3321
+ type FarmIntegrationRouteInputSource = "body" | "query";
3322
+ type MaybePromise<T> = T | Promise<T>;
3323
+ type FarmIntegrationValidationPathSegment = PropertyKey | {
3324
+ readonly key: PropertyKey;
3325
+ };
3326
+ interface FarmIntegrationRouteInput<TBody = unknown, TQuery = unknown> {
3327
+ body?: TBody;
3328
+ query?: TQuery;
3329
+ }
3330
+ interface FarmIntegrationValidationIssue {
3331
+ source: FarmIntegrationRouteInputSource;
3332
+ path?: readonly (string | number)[];
3333
+ code?: string;
3334
+ message: string;
3335
+ }
3336
+ interface FarmIntegrationValidationErrorLike {
3337
+ issues?: readonly {
3338
+ path?: readonly FarmIntegrationValidationPathSegment[];
3339
+ code?: string;
3340
+ message?: string;
3341
+ }[];
3342
+ message?: string;
3343
+ }
3344
+ type FarmIntegrationValidationResult<TValue> = {
3345
+ success: true;
3346
+ data: TValue;
3347
+ } | {
3348
+ success: false;
3349
+ error: FarmIntegrationValidationErrorLike;
3350
+ };
3351
+ type FarmIntegrationStandardValidationResult<TValue> = {
3352
+ value: TValue;
3353
+ } | {
3354
+ issues: readonly {
3355
+ path?: readonly FarmIntegrationValidationPathSegment[];
3356
+ code?: string;
3357
+ message: string;
3358
+ }[];
3359
+ };
3360
+ interface FarmIntegrationInputSchema<TValue = unknown> {
3361
+ _output?: TValue;
3362
+ parse?(value: unknown): MaybePromise<TValue>;
3363
+ safeParse?(value: unknown): MaybePromise<FarmIntegrationValidationResult<TValue>>;
3364
+ safeParseAsync?(value: unknown): Promise<FarmIntegrationValidationResult<TValue>>;
3365
+ "~standard"?: {
3366
+ validate(value: unknown): MaybePromise<FarmIntegrationStandardValidationResult<TValue>>;
3367
+ types?: {
3368
+ output: TValue;
3369
+ };
3370
+ };
3371
+ }
3372
+ interface FarmIntegrationRouteInputSchemas<TBody = unknown, TQuery = unknown> {
3373
+ body?: FarmIntegrationInputSchema<TBody>;
3374
+ query?: FarmIntegrationInputSchema<TQuery>;
3375
+ }
3376
+ /** @deprecated Use `FarmRequestStore` and access it through `ctx.req`. */
3377
+ type FarmIntegrationRequestContextStore = FarmRequestStore;
3378
+ declare const FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
3379
+ /**
3380
+ * Request-context key under which an integration middleware can hand
3381
+ * `Set-Cookie` values to the runtime when it returns `void` (i.e. lets the
3382
+ * request continue to the downstream route/page handler). The runtime reads
3383
+ * this key back after a `void` middleware return and forwards the cookies onto
3384
+ * the response it ultimately sends, so a server-side session refresh (or any
3385
+ * other cookie rotation) reaches the browser instead of being dropped.
3386
+ */
3387
+ declare const FARM_INTEGRATION_SET_COOKIES_KEY = "farm:integration:set-cookies";
3388
+ /**
3389
+ * Forward `Set-Cookie` values from an integration middleware that returns
3390
+ * `void` (the authenticated/passthrough branch) to the runtime, so they are
3391
+ * merged onto the response the runtime sends for the matched route. This is
3392
+ * the passthrough counterpart to appending `Set-Cookie` to a `Response` the
3393
+ * middleware returns directly (e.g. a failure redirect): both paths can rotate
3394
+ * auth cookies, and both must be able to reach the browser.
3395
+ */
3396
+ declare function forwardIntegrationSetCookies(context: Pick<FarmIntegrationHandlerContext, "req">, cookies: string[]): void;
3397
+ type FarmIntegrationRouteDb<TSchema extends FarmIntegrationSchema | undefined> = InferFarmIntegrationOrmClient<TSchema>;
3398
+ interface FarmIntegrationRouteStorageArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3399
+ getClient(): Promise<unknown | undefined>;
3400
+ getOrm(): Promise<FarmIntegrationRouteDb<TSchema>>;
3401
+ }
3402
+ interface FarmIntegrationRouteArgs<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3403
+ db: FarmIntegrationRouteDb<TSchema>;
3404
+ getDb(): Promise<FarmIntegrationRouteDb<TSchema>>;
3405
+ storage: FarmIntegrationRouteStorageArgs<TSchema>;
3406
+ }
3407
+ interface FarmIntegrationConfigContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3408
+ key: string;
3409
+ integration: FarmIntegration<TSchema, any>;
3410
+ appConfig: FarmPluginContext["config"];
3411
+ /** Alias for appConfig. */
3412
+ config: FarmPluginContext["config"];
3413
+ args: FarmIntegrationRouteArgs<TSchema>;
3414
+ env: Record<string, string | undefined>;
3415
+ isDev: boolean;
3416
+ isProd: boolean;
3417
+ }
3418
+ interface FarmIntegrationConfigDefinition<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3419
+ schema?: FarmIntegrationInputSchema<TConfig>;
3420
+ env?: Record<string, string | readonly string[]>;
3421
+ defaults?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
3422
+ input?: Partial<TConfig> | ((context: FarmIntegrationConfigContext<TSchema>) => MaybePromise<Partial<TConfig>>);
3423
+ resolve?(context: FarmIntegrationConfigContext<TSchema>): MaybePromise<TConfig | Partial<TConfig> | undefined>;
3424
+ }
3425
+ type FarmIntegrationConfigInput<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationInputSchema<TConfig> | FarmIntegrationConfigDefinition<TConfig, TSchema>;
3426
+ type FarmIntegrationLifecycleLogLevel = "info" | "warn" | "error";
3427
+ interface FarmIntegrationLifecycleLogger {
3428
+ info(message: string, meta?: Record<string, unknown>): void;
3429
+ warn(message: string, meta?: Record<string, unknown>): void;
3430
+ error(message: string, meta?: Record<string, unknown>): void;
3431
+ }
3432
+ interface FarmIntegrationLifecycleContext<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationConfigContext<TSchema> {
3433
+ integration: FarmIntegration<TSchema, TConfig>;
3434
+ integrationConfig: TConfig;
3435
+ log: FarmIntegrationLifecycleLogger;
3436
+ reason?: string;
3437
+ cleanup(callback?: () => MaybePromise<void>): Promise<void>;
3438
+ }
3439
+ type FarmIntegrationLifecycleHook<TConfig = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationLifecycleContext<TConfig, TSchema>) => MaybePromise<void>;
3440
+ /**
3441
+ * Small per-call integration metadata. Values received over HTTP are
3442
+ * client-controlled and should be validated before authorization decisions.
3443
+ */
3444
+ type FarmIntegrationData = Record<string, unknown>;
3445
+ interface FarmIntegrationHandlerContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3446
+ request: Request;
3447
+ requestId: string;
3448
+ url: URL;
3449
+ pathname: string;
3450
+ method: string;
3451
+ params: FarmIntegrationRouteParams;
3452
+ input: FarmIntegrationRouteInput<TBody, TQuery>;
3453
+ args: FarmIntegrationRouteArgs<TSchema>;
3454
+ data: FarmIntegrationData;
3455
+ integration: {
3456
+ category: FarmIntegrationCategory;
3457
+ /** @deprecated Use category instead. */
3458
+ slot: FarmIntegrationCategory;
3459
+ type: string;
3460
+ instance: unknown;
3461
+ };
3462
+ route: {
3463
+ kind: "route" | "middleware";
3464
+ path: string;
3465
+ methods: readonly string[];
3466
+ };
3467
+ req: FarmRequestStore;
3468
+ /** @deprecated Use `req` instead. */
3469
+ requestContext: FarmRequestStore;
3470
+ config: FarmPluginContext["config"];
3471
+ isDev: boolean;
3472
+ isProd: boolean;
3473
+ }
3474
+ interface FarmIntegrationRouteHookContext<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationHandlerContext<TBody, TQuery, TSchema> {
3475
+ response?: Response;
3476
+ }
3477
+ type FarmIntegrationRouteHook<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
3478
+ bivarianceHack(request: Request, context: FarmIntegrationRouteHookContext<TBody, TQuery, TSchema>): Promise<Response | void> | Response | void;
3479
+ }["bivarianceHack"];
3480
+ interface FarmIntegrationRoute<TBody = unknown, TQuery = unknown, TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3481
+ path: string;
3482
+ method?: FarmIntegrationRouteMethod;
3483
+ methods?: readonly FarmIntegrationRouteMethod[];
3484
+ middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
3485
+ before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
3486
+ after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
3487
+ rawBody?: boolean;
3488
+ bodyFormat?: FarmIntegrationAPIBodyFormat;
3489
+ body?: FarmIntegrationInputSchema<TBody>;
3490
+ query?: FarmIntegrationInputSchema<TQuery>;
3491
+ input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
3492
+ handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
3493
+ }
3494
+ 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> {
3495
+ path: TPath;
3496
+ method: TMethod;
3497
+ __operation: FarmIntegrationAPIOperation<TBody, TQuery, TResponse, TServer, TMethod>;
3498
+ }
3499
+ interface FarmIntegrationRouteMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3500
+ handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
3501
+ }
3502
+ interface FarmIntegrationMiddleware<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3503
+ matcher?: string | string[];
3504
+ handler(request: Request, context: FarmIntegrationHandlerContext<unknown, unknown, TSchema>): Promise<Response | void> | Response | void;
3505
+ }
3506
+ interface FarmIntegrationProviderProps {
3507
+ children: ReactNode;
3508
+ }
3509
+ interface FarmIntegrationProviderComponentReference {
3510
+ /** Client-safe module specifier using `@/`, a path relative to the app root, or a package. */
3511
+ module: string;
3512
+ /** Named export to use. Defaults to the module's default export. */
3513
+ export?: string;
3514
+ }
3515
+ interface FarmIntegrationProvider {
3516
+ name: string;
3517
+ type: string;
3518
+ props?: Record<string, unknown>;
3519
+ /**
3520
+ * The provider can be instantiated independently around each isolated
3521
+ * client root without relying on context or state owned by the route root.
3522
+ * Providers are treated as route-wide unless they explicitly opt in.
3523
+ */
3524
+ supportsIsolatedHydration?: boolean;
3525
+ component?: ComponentType<FarmIntegrationProviderProps> | FarmIntegrationProviderComponentReference;
3526
+ }
3527
+ interface FarmIntegrationDocumentNavigation {
3528
+ matcher: string | readonly string[];
3529
+ }
3530
+ /** @deprecated Use `FarmSchemaFieldType`. */
3531
+ type FarmIntegrationSchemaFieldType = FarmSchemaFieldType;
3532
+ /** @deprecated Use `FarmSchemaReference`. */
3533
+ type FarmIntegrationSchemaReference = FarmSchemaReference;
3534
+ /** @deprecated Use `FarmSchemaField`. */
3535
+ type FarmIntegrationSchemaField = FarmSchemaField;
3536
+ /** @deprecated Use `FarmSchemaConstraint`. */
3537
+ type FarmIntegrationSchemaConstraint = FarmSchemaConstraint;
3538
+ /** @deprecated Use `FarmSchemaModel`. */
3539
+ type FarmIntegrationSchemaModel = FarmSchemaModel;
3540
+ /** @deprecated Use `FarmSchemaModelExtension`. */
3541
+ type FarmIntegrationSchemaModelExtension = FarmSchemaModelExtension;
3542
+ /** @deprecated Use `FarmSchemaModelOverride`. */
3543
+ type FarmIntegrationSchemaModelOverride = FarmSchemaModelOverride;
3544
+ /** @deprecated Use `FarmSchema`. */
3545
+ type FarmIntegrationSchema = FarmSchema;
3546
+ /** @deprecated Use `defineSchema`. This is an exact alias, not a wrapper. */
3547
+ declare const defineIntegrationSchema: typeof defineSchema;
3548
+ type FarmIntegrationLogPhase = "registered" | "validate" | "setup" | "ready" | "dispose" | "request:start" | "request:end" | "request:error";
3549
+ interface FarmIntegrationLogEvent {
3550
+ category: FarmIntegrationCategory;
3551
+ /** @deprecated Use category instead. */
3552
+ slot: FarmIntegrationCategory;
3553
+ type: string;
3554
+ phase: FarmIntegrationLogPhase;
3555
+ route?: {
3556
+ kind: "route" | "middleware";
3557
+ path: string;
3558
+ methods: readonly string[];
3559
+ };
3560
+ requestId?: string;
3561
+ request?: Request;
3562
+ response?: Response;
3563
+ error?: unknown;
3564
+ durationMs?: number;
3565
+ level?: FarmIntegrationLifecycleLogLevel;
3566
+ message?: string;
3567
+ meta?: Record<string, unknown>;
3568
+ context: Map<string, unknown>;
3569
+ }
3570
+ type FarmIntegrationLogger = (event: FarmIntegrationLogEvent) => void | Promise<void>;
3571
+ interface FarmIntegrationPluginOwner {
3572
+ key: string;
3573
+ category: FarmIntegrationCategory;
3574
+ type: string;
3575
+ source: "lifecycle" | "contribution";
3576
+ serverRuntime: boolean;
3577
+ }
3578
+ /** A normal plugin or an integration-bound plugin compatible with the shared instance. */
3579
+ type FarmIntegrationContributedPlugin<TInstance = unknown> = FarmPlugin<any, any, any, any, unknown, false> | FarmPlugin<any, any, any, any, TInstance, true>;
3580
+ interface FarmIntegration<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined, TConfig = unknown, TInstance = unknown> {
3581
+ readonly kind: "farm-integration";
3582
+ category: FarmIntegrationCategory;
3583
+ /** @deprecated Use category instead. */
3584
+ slot?: FarmIntegrationCategory;
3585
+ type: string;
3586
+ instance: TInstance;
3587
+ /** Set to false when a platform adapter owns this integration's production routes. */
3588
+ serverRuntime?: boolean;
3589
+ api?: FarmIntegrationAPI;
3590
+ schema?: TSchema;
3591
+ config?: FarmIntegrationConfigInput<TConfig, TSchema>;
3592
+ validate?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
3593
+ setup?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
3594
+ ready?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
3595
+ dispose?: FarmIntegrationLifecycleHook<TConfig, TSchema>;
3596
+ log?: FarmIntegrationLogger;
3597
+ routes?: readonly FarmIntegrationRoute<any, any, TSchema>[];
3598
+ endpoints?: FarmIntegrationEndpoints<TSchema>;
3599
+ middleware?: readonly FarmIntegrationMiddleware<TSchema>[];
3600
+ providers?: readonly FarmIntegrationProvider[];
3601
+ documentNavigations?: readonly FarmIntegrationDocumentNavigation[];
3602
+ /** Additional Farm plugins owned and configured by this integration. */
3603
+ plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
3604
+ }
3605
+ type FarmIntegrationsUserConfig = Record<string, FarmIntegration<any, any, any> | undefined>;
3606
+ /** @internal Identifies plugins owned by platform-managed integrations. */
3607
+ declare function getFarmIntegrationPluginServerRuntime(plugin: FarmPlugin): boolean | undefined;
3608
+ /** Returns the integration that contributed a normalized plugin, when applicable. */
3609
+ declare function getFarmIntegrationPluginOwner(plugin: FarmPlugin): Readonly<FarmIntegrationPluginOwner> | undefined;
3610
+ type IntegrationRouteBuilderOptions<TBody, TQuery, TServer extends boolean, TSchema extends FarmIntegrationSchema | undefined> = {
3611
+ middleware?: readonly FarmIntegrationRouteMiddleware<TSchema>[];
3612
+ before?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
3613
+ after?: readonly FarmIntegrationRouteHook<TBody, TQuery, TSchema>[];
3614
+ rawBody?: boolean;
3615
+ headers?: Record<string, string>;
3616
+ credentials?: RequestCredentials;
3617
+ bodyFormat?: FarmIntegrationAPIBodyFormat;
3618
+ responseFormat?: FarmIntegrationAPIResponseFormat;
3619
+ isServer?: TServer;
3620
+ body?: FarmIntegrationInputSchema<TBody>;
3621
+ query?: FarmIntegrationInputSchema<TQuery>;
3622
+ input?: FarmIntegrationRouteInputSchemas<TBody, TQuery>;
3623
+ handler(request: Request, context: FarmIntegrationHandlerContext<TBody, TQuery, TSchema>): Promise<Response> | Response;
3624
+ };
3625
+ interface FarmIntegrationRouteFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3626
+ 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>;
3627
+ 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>;
3628
+ 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>;
3629
+ 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>;
3630
+ 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>;
3631
+ 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>;
3632
+ 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>;
3633
+ 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>;
3634
+ }
3635
+ interface FarmIntegrationRoutesFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> {
3636
+ route: FarmIntegrationRouteFactory<TSchema>;
3637
+ integrationRoute: FarmIntegrationRouteFactory<TSchema>;
3638
+ }
3639
+ type FarmIntegrationRoutesFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationRoutesFactoryContext<TSchema>) => readonly FarmIntegrationRoute<any, any, TSchema>[];
3640
+ type FarmIntegrationEndpointValue<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationRoute<any, any, TSchema> | readonly FarmIntegrationEndpointValue<TSchema>[] | {
3641
+ readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
3642
+ };
3643
+ type FarmIntegrationEndpoints<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = {
3644
+ readonly [key: string]: FarmIntegrationEndpointValue<TSchema> | undefined;
3645
+ };
3646
+ interface FarmIntegrationEndpointsFactoryContext<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> extends FarmIntegrationRoutesFactoryContext<TSchema> {
3647
+ endpoint: FarmIntegrationRouteFactory<TSchema>;
3648
+ }
3649
+ type FarmIntegrationEndpointsFactory<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = (context: FarmIntegrationEndpointsFactoryContext<TSchema>) => FarmIntegrationEndpoints<TSchema>;
3650
+ declare function createIntegrationRoute<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined>(_schema?: TSchema): FarmIntegrationRouteFactory<TSchema>;
3651
+ declare const integrationRoute: FarmIntegrationRouteFactory<undefined>;
3652
+ type RegisteredIntegrationRuntime = {
3653
+ integration: FarmIntegration;
3654
+ config: FarmPluginContext["config"];
3655
+ isDev: boolean;
3656
+ isProd: boolean;
3657
+ };
3658
+ type FarmIntegrationRoutesInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = readonly FarmIntegrationRoute<any, any, TSchema>[] | FarmIntegrationRoutesFactory<TSchema>;
3659
+ type FarmIntegrationEndpointsInput<TSchema extends FarmIntegrationSchema | undefined = FarmIntegrationSchema | undefined> = FarmIntegrationEndpoints<TSchema> | FarmIntegrationEndpointsFactory<TSchema>;
3660
+ 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"> & {
3661
+ instance: TInstance;
3662
+ config?: FarmIntegrationConfigInput<TConfig, TSchema>;
3663
+ routes?: FarmIntegrationRoutesInput<TSchema>;
3664
+ endpoints?: FarmIntegrationEndpointsInput<TSchema>;
3665
+ plugins?: readonly FarmIntegrationContributedPlugin<NoInfer<TInstance>>[];
3666
+ } & ({
3667
+ category: FarmIntegrationCategory;
3668
+ slot?: FarmIntegrationCategory;
3669
+ } | {
3670
+ category?: FarmIntegrationCategory;
3671
+ slot: FarmIntegrationCategory;
3672
+ });
3673
+ type FarmIntegrationCategoryInput = {
3674
+ category: FarmIntegrationCategory;
3675
+ slot?: FarmIntegrationCategory;
3676
+ } | {
3677
+ category?: FarmIntegrationCategory;
3678
+ slot: FarmIntegrationCategory;
3679
+ };
3680
+ type FarmIntegrationShapeForInference = FarmIntegrationCategoryInput & {
3681
+ api?: FarmIntegrationAPI;
3682
+ schema?: FarmIntegrationSchema;
3683
+ config?: unknown;
3684
+ routes?: unknown;
3685
+ endpoints?: unknown;
3686
+ };
3687
+ type ExtractIntegrationSchema<TIntegration> = TIntegration extends {
3688
+ schema: infer TSchema extends FarmIntegrationSchema;
3689
+ } ? TSchema : undefined;
3690
+ type ResolveIntegrationRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = TRoutes extends FarmIntegrationRoutesFactory<TSchema> ? ReturnType<TRoutes> : TRoutes;
3691
+ type ResolveIntegrationEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = TEndpoints extends FarmIntegrationEndpointsFactory<TSchema> ? ReturnType<TEndpoints> : TEndpoints;
3692
+ type ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema extends FarmIntegrationSchema | undefined> = ResolveIntegrationRoutesInput<TRoutes, TSchema> extends readonly (infer TRoute)[] ? TRoute : never;
3693
+ type ExtractIntegrationRoutesFromEndpointValue<TValue> = TValue extends FarmIntegrationRouteOperationCarrier<string, any> ? TValue : TValue extends readonly (infer TItem)[] ? ExtractIntegrationRoutesFromEndpointValue<TItem> : TValue extends object ? ExtractIntegrationRoutesFromEndpointValue<TValue[keyof TValue]> : never;
3694
+ type ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema extends FarmIntegrationSchema | undefined> = ExtractIntegrationRoutesFromEndpointValue<ResolveIntegrationEndpointsInput<TEndpoints, TSchema>>;
3695
+ type ExtractIntegrationRouteUnion<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = (TIntegration extends {
3696
+ routes: infer TRoutes;
3697
+ } ? ExtractIntegrationRoutesFromRoutesInput<TRoutes, TSchema> : never) | (TIntegration extends {
3698
+ endpoints: infer TEndpoints;
3699
+ } ? ExtractIntegrationRoutesFromEndpointsInput<TEndpoints, TSchema> : never);
3700
+ type ExtractDefinedIntegrationRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = [ExtractIntegrationRouteUnion<TIntegration, TSchema>] extends [never] ? undefined : readonly ExtractIntegrationRouteUnion<TIntegration, TSchema>[];
3701
+ type ExtractDefinedIntegrationEndpoints<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = TIntegration extends {
3702
+ endpoints: infer TEndpoints;
3703
+ } ? ResolveIntegrationEndpointsInput<TEndpoints, TSchema> : undefined;
3704
+ type ExtractIntegrationAPIRoutes<TIntegration, TSchema extends FarmIntegrationSchema | undefined> = Extract<ExtractIntegrationRouteUnion<TIntegration, TSchema>, FarmIntegrationRouteOperationCarrier<string, any>>;
3705
+ type ExtractIntegrationCategory<TIntegration extends FarmIntegrationCategoryInput> = TIntegration extends {
3706
+ category: infer TCategory extends FarmIntegrationCategory;
3707
+ } ? TCategory : TIntegration extends {
3708
+ slot: infer TSlot extends FarmIntegrationCategory;
3709
+ } ? TSlot : FarmIntegrationCategory;
3710
+ type ExtractDerivedIntegrationAPI<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = TIntegration extends {
3711
+ api: infer TAPI extends FarmIntegrationAPI;
3712
+ } ? TAPI : [ExtractIntegrationAPIRoutes<TIntegration, TSchema>] extends [never] ? FarmIntegrationAPI | undefined : InferIntegrationAPIFromRoutes<readonly ExtractIntegrationAPIRoutes<TIntegration, TSchema>[]>;
3713
+ type DefinedIntegration<TIntegration extends FarmIntegrationShapeForInference, TSchema extends FarmIntegrationSchema | undefined = ExtractIntegrationSchema<TIntegration>> = Omit<TIntegration, "kind" | "category" | "slot" | "api" | "routes" | "endpoints"> & {
3714
+ readonly kind: "farm-integration";
3715
+ category: ExtractIntegrationCategory<TIntegration>;
3716
+ slot: ExtractIntegrationCategory<TIntegration>;
3717
+ routes: ExtractDefinedIntegrationRoutes<TIntegration, TSchema>;
3718
+ endpoints: ExtractDefinedIntegrationEndpoints<TIntegration, TSchema>;
3719
+ api: ExtractDerivedIntegrationAPI<TIntegration, TSchema>;
3720
+ };
3721
+ 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>;
3722
+ declare function resolveIntegrationPlugins(integrations: FarmIntegrationsUserConfig | undefined): FarmPlugin[];
3723
+ declare function getIntegrationProviders(integrations: FarmIntegrationsUserConfig | undefined): FarmIntegrationProvider[];
3724
+ declare function isFarmIntegrationProviderComponentReference(value: FarmIntegrationProvider["component"]): value is FarmIntegrationProviderComponentReference;
3725
+ declare function getIntegrationDocumentNavigationMatchers(integrations: FarmIntegrationsUserConfig | undefined): string[];
3726
+ declare function getIntegrationSchemas(integrations: FarmIntegrationsUserConfig | undefined): Record<string, FarmIntegrationSchema>;
3727
+ declare function getRegisteredIntegrationRuntime(key: string): RegisteredIntegrationRuntime | undefined;
3728
+ declare function getRegisteredIntegrations(): Record<string, FarmIntegration>;
3729
+ declare function getRegisteredIntegrationSchemas(): Record<string, FarmIntegrationSchema>;
3730
+ declare function matchIntegrationRoute(integrations: FarmIntegrationsUserConfig | undefined, input: {
3731
+ pathname: string;
3732
+ method?: string;
3733
+ }): {
3734
+ key: string;
3735
+ integration: FarmIntegration;
3736
+ route: {
3737
+ path: string;
3738
+ methods: readonly string[];
3739
+ };
3740
+ params: FarmIntegrationRouteParams;
3741
+ } | null;
3742
+ declare function matchRegisteredIntegrationRoute(input: {
3743
+ pathname: string;
3744
+ method?: string;
3745
+ }): {
3746
+ key: string;
3747
+ integration: FarmIntegration;
3748
+ route: {
3749
+ path: string;
3750
+ methods: readonly string[];
3751
+ };
3752
+ params: FarmIntegrationRouteParams;
3753
+ } | null;
3754
+ declare function getRegisteredIntegrationAPIManifest(): Record<string, FarmIntegrationAPI>;
3755
+ declare function dispatchIntegrationRequest(runtime: RegisteredIntegrationRuntime, request: Request, options?: {
3756
+ currentRequest?: Request;
3757
+ data?: FarmIntegrationData;
3758
+ internal?: boolean;
3759
+ /**
3760
+ * Receives `Set-Cookie` values that a middleware forwarded via
3761
+ * forwardIntegrationSetCookies while returning `void`, when this dispatch
3762
+ * ends without a Response of its own. The request continues downstream, so
3763
+ * the caller owns merging them onto whatever response it finally produces.
3764
+ * Only called on the `null` return path: a Response returned from here has
3765
+ * already had the forwarded cookies appended.
3766
+ */
3767
+ onForwardedCookies?: (cookies: string[]) => void;
3768
+ /**
3769
+ * Middleware entries that already ran for this request, shared across dispatches. A
3770
+ * `ctx.rewrite()` target is guarded by a second dispatch, which skips these so each guard runs
3771
+ * at most once per request, as app middleware does.
3772
+ */
3773
+ ranMiddleware?: Set<object>;
3774
+ /** The peer address the server adapter reports, used unless `server.trustProxy` applies. */
3775
+ clientAddress?: string;
3776
+ }): Promise<Response | null>;
3777
+ /**
3778
+ * Run every configured integration's middleware and routes for one request.
3779
+ *
3780
+ * Integration middleware is not route scoped: it is the mechanism behind
3781
+ * `protectedRoutes` guards and provider session refresh, so it has to run for
3782
+ * ordinary page and API requests that match no integration route at all. That
3783
+ * makes this, not `matchIntegrationRoute`, the correct entry point for a
3784
+ * runtime dispatching integrations for every request.
3785
+ *
3786
+ * The first integration that produces a Response short-circuits the rest.
3787
+ * `Set-Cookie` values forwarded by middleware that returned `void` are
3788
+ * collected: they ride the short-circuiting Response when there is one, and are
3789
+ * otherwise handed back so the caller can merge them onto the downstream
3790
+ * response.
3791
+ */
3792
+ declare function dispatchIntegrationRequests(integrations: FarmIntegrationsUserConfig | undefined, runtime: Omit<RegisteredIntegrationRuntime, "integration">, request: Request, options?: {
3793
+ currentRequest?: Request;
3794
+ ranMiddleware?: Set<object>;
3795
+ clientAddress?: string;
3796
+ }): Promise<{
3797
+ response: Response | null;
3798
+ setCookies: string[];
3799
+ }>;
3800
+
3801
+ export { type FarmPluginRenderHooks as $, isFarmRedirectError as A, type BundleResultPayload as B, notFound as C, permanentRedirect as D, redirect as E, type FarmPlugin as F, loadConfig as G, resolveConfig as H, resolveDeployConfig as I, type APIHandlerLifecyclePayload as J, type APIRouteDiscoveredPayload as K, type LayoutProps as L, type Metadata as M, type BundleLifecyclePayload as N, type ErrorLifecyclePayload as O, type ParsedRoute as P, FARM_NODE_RESPONSE_END_PENDING as Q, type RouteModule as R, type FarmDevtoolsUserConfig as S, type FarmPluginBuildHooks as T, type FarmPluginClientConfig as U, type FarmPluginDatabase as V, type FarmPluginDefinition as W, type FarmPluginDevHooks as X, type FarmPluginDiscoveredRoute as Y, type FarmPluginIntegrationContext as Z, type FarmPluginLifecycle as _, type FarmIntegration as a, type GenerateStaticParams as a$, type FarmPluginRouteRuntimePayload as a0, type FarmPluginRouterHooks as a1, type FarmPluginRuntimeAfterEvent as a2, type FarmPluginRuntimeBaseEvent as a3, type FarmPluginRuntimeBeforeEvent as a4, type FarmPluginRuntimeCloseEvent as a5, type FarmPluginRuntimeContextEvent as a6, type FarmPluginRuntimeEndpoint as a7, type FarmPluginRuntimeEndpointEvent as a8, type FarmPluginRuntimeErrorEvent as a9, type FarmContextFactory as aA, type FarmMCPCatalogDetails as aB, type ResolvedFarmAppManifestConfig as aC, type ReadonlyMiddlewareStore as aD, type FarmMiddlewareConfig as aE, type MiddlewareModule as aF, type MiddlewareConfig$1 as aG, type MiddlewareContext as aH, type FarmServerComponentsMode as aI, type ResolvedFarmConfig as aJ, type SSGCollectionResult as aK, type SSGPage as aL, type FarmAgentJsonLd as aM, type FarmMCPServerRegistration as aN, type FarmMarkdownResolvedConfig as aO, type FarmConfig as aP, type AppRoutePattern as aQ, type BuildOptions as aR, type ErrorBoundary as aS, type ErrorProps as aT, type FarmComponentType as aU, type FarmContextFactoryInput as aV, type FarmIsolatedClientHydrationMode as aW, type FarmMCPUserConfig as aX, type FarmMigrationCommand as aY, type FarmMigrationsConfig as aZ, type FarmMigrationsUserConfig as a_, type FarmPluginRuntimeHooks as aa, type FarmPluginRuntimeKind as ab, type FarmPluginRuntimeRequestHandler as ac, type FarmPluginRuntimeRequestOptions as ad, type FarmPluginRuntimeSession as ae, type FarmPluginRuntimeStartEvent as af, type FarmPluginSetupContext as ag, type FarmPluginStateContext as ah, type FarmRequestPluginContext as ai, type FarmRequestStore as aj, FarmRuntimeShutdownError as ak, type HMRUpdatePayload as al, type MiddlewareDiscoveredPayload as am, type NitroBuildLifecyclePayload as an, PluginManager as ao, type PluginRequestContext as ap, type RenderLifecyclePayload as aq, type ResolvedFarmDevtoolsConfig as ar, type RouteDiscoveredPayload as as, type RouteMatchPayload as at, type RouteMatchResultPayload as au, type RoutesGeneratedPayload as av, type ShutdownPayload as aw, definePlugin as ax, resolveFarmDevtoolsConfig as ay, type MiddlewareProps as az, type FarmRouteRuntimeConfig as b, type FarmAuthUserConfig as b$, type Layout as b0, type LayoutMetadataProps as b1, type LayoutModule as b2, type Loading as b3, type LoadingProps as b4, type MetadataJsonLd as b5, type MetadataProps as b6, type MetadataRobots as b7, type MetadataRobotsDirectives as b8, type NitroPreset as b9, type CollectedSchemaModel as bA, type FarmSchemaMigrationStep as bB, type OpenAPIConfig as bC, type ApplyMarkdownNegotiationHeadersOptions as bD, type CookieJar as bE, type CookieOptions as bF, type CreateIntegrationOrmOptions as bG, type CreateMarkdownMirrorResponseOptions as bH, DEFAULT_FARM_API_BASE_PATH as bI, DEFAULT_FARM_DEVTOOLS_SHORTCUT as bJ, type DefinedIntegration as bK, FARM_DEVTOOLS_LAUNCH_PARAM as bL, FARM_DEVTOOLS_PATH as bM, FARM_INTEGRATION_API_BASE_PATH_KEY as bN, FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY as bO, FARM_INTEGRATION_SET_COOKIES_KEY as bP, FARM_MARKDOWN_PAGE_CHECK_HEADER as bQ, type FarmAPIConfig as bR, type FarmAPIConfigResolverContext as bS, type FarmAPIConfigValue as bT, type FarmAgentCrawlers as bU, type FarmAgentUserConfig as bV, type FarmAppManifestConfig as bW, type FarmAuthConfig as bX, type FarmAuthDatabaseConfig as bY, type FarmAuthEmailAndPasswordConfig as bZ, type FarmAuthSessionConfig as b_, type Page as ba, type PagePropsWithMiddleware as bb, type PageRouteParams as bc, type ResolvedFarmMigrationsConfig as bd, type ServerAction as be, type StaticPathParams as bf, type StaticPathPrimitive as bg, type StaticRouteParams as bh, type ThemeColorDescriptor as bi, type Viewport as bj, resolveFarmMCPConfig as bk, resolveFarmMCPPlugin as bl, _findFarmMCPEndpointTool as bm, _publishFarmMCPCatalog as bn, registerFarmMCPServer as bo, type ResolvedFarmRouteRuntimeConfig as bp, type ApplicationMetadataRouteKind as bq, type ResolvedFarmAPIConfig as br, type FarmDocsResolvedConfig as bs, type ResolvedFarmDevIndicatorsConfig as bt, type ResolvedFarmAuthConfig as bu, type ResolvedFarmPerformanceConfig as bv, type ResolvedFarmSecurityConfig as bw, type ResolvedSchemaField as bx, type FarmSqlStatement as by, type FarmSqlDialect as bz, type FarmMdxComponents as c, type FarmIntegrationSchemaFieldType as c$, type FarmBuildActivityPosition as c0, type FarmCrawlerPolicy as c1, type FarmCspConfig as c2, type FarmCspDirectiveValue as c3, type FarmCspDirectives as c4, type FarmCspOptions as c5, type FarmDeployConfig as c6, type FarmDeployTarget as c7, type FarmDevIndicatorsConfig as c8, type FarmDevtoolsConfig as c9, type FarmIntegrationMiddleware as cA, type FarmIntegrationOrmClient as cB, type FarmIntegrationOrmSchema as cC, type FarmIntegrationPluginOwner as cD, type FarmIntegrationProvider as cE, type FarmIntegrationProviderComponentReference as cF, type FarmIntegrationProviderProps as cG, type FarmIntegrationRequestContextStore as cH, type FarmIntegrationRoute as cI, type FarmIntegrationRouteArgs as cJ, type FarmIntegrationRouteDb as cK, type FarmIntegrationRouteFactory as cL, type FarmIntegrationRouteHook as cM, type FarmIntegrationRouteHookContext as cN, type FarmIntegrationRouteInput as cO, type FarmIntegrationRouteInputSchemas as cP, type FarmIntegrationRouteInputSource as cQ, type FarmIntegrationRouteMethod as cR, type FarmIntegrationRouteMiddleware as cS, type FarmIntegrationRouteParamValue as cT, type FarmIntegrationRouteParams as cU, type FarmIntegrationRouteStorageArgs as cV, type FarmIntegrationRoutesFactory as cW, type FarmIntegrationRoutesFactoryContext as cX, type FarmIntegrationSchema as cY, type FarmIntegrationSchemaConstraint as cZ, type FarmIntegrationSchemaField as c_, type FarmDocsConfigInput as ca, type FarmDocsNavigationConfig as cb, type FarmDocsSidebarItem as cc, type FarmDocsSocialImageConfig as cd, type FarmDocsSocialImageFonts as ce, type FarmDocsUserConfig as cf, type FarmIntegrationCategory as cg, type FarmIntegrationConfigContext as ch, type FarmIntegrationConfigDefinition as ci, type FarmIntegrationConfigInput as cj, type FarmIntegrationContributedPlugin as ck, type FarmIntegrationData as cl, type FarmIntegrationDocumentNavigation as cm, type FarmIntegrationEndpointValue as cn, type FarmIntegrationEndpoints as co, type FarmIntegrationEndpointsFactory as cp, type FarmIntegrationEndpointsFactoryContext as cq, type FarmIntegrationHandlerContext as cr, type FarmIntegrationInputSchema as cs, type FarmIntegrationLifecycleContext as ct, type FarmIntegrationLifecycleHook as cu, type FarmIntegrationLifecycleLogLevel as cv, type FarmIntegrationLifecycleLogger as cw, type FarmIntegrationLogEvent as cx, type FarmIntegrationLogPhase as cy, type FarmIntegrationLogger as cz, type FarmMdxResolvedConfig as d, type InferFarmIntegrationOrmField as d$, type FarmIntegrationSchemaModel as d0, type FarmIntegrationSchemaModelExtension as d1, type FarmIntegrationSchemaModelOverride as d2, type FarmIntegrationSchemaReference as d3, type FarmIntegrationSlot as d4, type FarmIntegrationStandardValidationResult as d5, type FarmIntegrationValidationErrorLike as d6, type FarmIntegrationValidationIssue as d7, type FarmIntegrationValidationPathSegment as d8, type FarmIntegrationValidationResult as d9, type FarmPageFormField as dA, type FarmPageFormOption as dB, type FarmPageFormSubmit as dC, type FarmPerformanceConfig as dD, type FarmPluginFactory as dE, FarmPluginOptionsError as dF, type FarmPluginOptionsIssue as dG, type FarmPluginOptionsSchema as dH, type FarmPreloadMode as dI, type FarmPreloadUserConfig as dJ, type FarmRouteRenderingMode as dK, type FarmRouteRule as dL, type FarmRouteRuleCors as dM, type FarmRouteRuleRedirect as dN, type FarmRouteRuleRenderMode as dO, type FarmRouteRules as dP, type FarmRouteRuntimeEntryKind as dQ, type FarmRouteRuntimeManifest as dR, type FarmRouteRuntimeManifestEntry as dS, type FarmSecurityConfig as dT, type FarmServerComponentsConfig as dU, type FarmServerComponentsOptions as dV, type FarmTypedIntegrationRoute as dW, type HeaderConfig as dX, type I18nConfig as dY, type ImageConfig as dZ, type InferFarmIntegrationOrmClient as d_, type FarmIntegrationsUserConfig as da, type FarmLayerConfig as db, type FarmMCPAuthorization as dc, type FarmMCPAuthorizeContext as dd, type FarmMCPConfig as de, type FarmMCPEndpoint as df, type FarmMCPEndpointTool as dg, type FarmMCPExecuteContext as dh, type FarmMCPOAuthConfig as di, type FarmMCPPrompt as dj, type FarmMCPPromptMessage as dk, type FarmMCPResource as dl, type FarmMCPResourceContent as dm, type FarmMCPResourceContext as dn, type FarmMCPResourceListing as dp, type FarmMCPServer as dq, type FarmMCPServerFunction as dr, type FarmMCPStandaloneTool as ds, type FarmMCPTool as dt, type FarmMCPToolDefinition as du, type FarmMarkdownMirrorTarget as dv, type FarmMarkdownResolvedRoute as dw, type FarmMarkdownRouteInput as dx, type FarmMarkdownUserConfig as dy, type FarmPageFormAction as dz, FARM_MARKDOWN_CONTENT_TYPE as e, getPresetForDeployTarget as e$, type InferFarmIntegrationOrmFields as e0, type InferFarmIntegrationOrmSchema as e1, type InferPluginOptionsInput as e2, type InferPluginOptionsOutput as e3, type IntegrationOriginPolicy as e4, type IntegrationOriginRejection as e5, type IntegrationOriginResult as e6, type IntegrationOrmModelNames as e7, type MemoryRateLimitStorageOptions as e8, MetadataRoute as e9, createIntegrationOrm as eA, createIntegrationRoute as eB, createMarkdownMirrorResponse as eC, defineIntegration as eD, defineIntegrationSchema as eE, describeIntegrationOriginRejection as eF, describeSchemaReference as eG, dispatchIntegrationRequest as eH, dispatchIntegrationRequests as eI, escapeSqlString as eJ, extractFarmPageActions as eK, farmAcceptQuality as eL, farmIntegrationSchemaToOrmSchema as eM, farmRouteRuleMatches as eN, forwardIntegrationSetCookies as eO, generateFarmDevIndicatorsClientRuntime as eP, generateSqlStatements as eQ, getDeployTargetForPreset as eR, getFarmAPIBaseURL as eS, getFarmIntegrationPluginOwner as eT, getFarmIntegrationPluginServerRuntime as eU, getFarmMarkdownAlternatePath as eV, getFarmMarkdownMirrorPath as eW, getFarmRouteRuntimeConfig as eX, getIntegrationDocumentNavigationMatchers as eY, getIntegrationProviders as eZ, getIntegrationSchemas as e_, type MetadataRouteContext as ea, type MiddlewareChain as eb, type MiddlewareConfig as ec, type MiddlewareFunction as ed, type MiddlewareResult as ee, type MiddlewareStore as ef, type NextFunction as eg, type RateLimitConfig as eh, type RateLimitIncrementResult as ei, type RateLimitStatus as ej, type RateLimitStorage as ek, type RedirectConfig as el, type RequestMiddleware as em, type RequestMiddlewareContext as en, type ResolveMarkdownMirrorTargetOptions as eo, type ResolvedFarmCspConfig as ep, type ResolvedFarmDeployConfig as eq, type ResolvedFarmMCPConfig as er, type ResolvedFarmPreloadConfig as es, type ResolvedSchemaModel as et, type RewriteConfig as eu, _getFarmMarkdownPageCheckToken as ev, _isFarmMarkdownPageCheck as ew, applyMarkdownNegotiationHeaders as ex, collectSchemaModels as ey, createFarmRouteRuntimeKey as ez, createFarmMarkdownErrorBody as f, resolveFarmLlmsTxtConfig as f$, getRegisteredIntegrationAPIManifest as f0, getRegisteredIntegrationRuntime as f1, getRegisteredIntegrationSchemas as f2, getRegisteredIntegrations as f3, getSqlColumnType as f4, getSqlDefaultExpression as f5, hasFarmRouteRuntimeControls as f6, htmlToMarkdown as f7, integrationMiddlewareMayHandlePath as f8, integrationRoute as f9, resolveMarkdownMirrorTarget as fA, resolveMigrationsConfig as fB, resolveSchemaModels as fC, routeRulesToHeaders as fD, routeRulesToNitroRouteRules as fE, routeRulesToRedirects as fF, toCamelCase as fG, toPascalCase as fH, toSnakeCase as fI, validateIntegrationRequestOrigin as fJ, type FarmLlmsTxtLink as fK, type FarmLlmsTxtUserConfig as fL, type ResolvedFarmLlmsTxtConfig as fM, applyFarmCspNonceToResponse as fN, collectFarmLlmsTxtPages as fO, createFarmAgentRobots as fP, createFarmCspNonce as fQ, createFarmDefaultLlmsTxt as fR, createFarmDefaultSitemap as fS, createFarmLlmsFullRenderer as fT, createFarmLlmsMarkdownReader as fU, createFarmMetadataRouteResponse as fV, manageFarmDocumentPreloads as fW, manageFarmHtmlPreloads as fX, manageFarmLinkHeaderPreloads as fY, renderFarmLlmsFullTxt as fZ, reportFarmPreloadWarnings as f_, isFarmIntegration as fa, isFarmIntegrationProviderComponentReference as fb, isFarmMarkdownMirrorExposed as fc, isNullableField as fd, matchIntegrationRoute as fe, matchRegisteredIntegrationRoute as ff, matchesFarmMarkdownRoutePattern as fg, mergeFarmRouteRuntimeConfigs as fh, normalizeDeployTarget as fi, normalizeFarmAPIBasePath as fj, normalizeFarmAPIConfig as fk, normalizeFarmRouteRuntimeConfig as fl, normalizeRouteRules as fm, quoteSqlIdentifier as fn, renderSqlSchemaFile as fo, requestAcceptsMarkdown as fp, resolveDeployOutputPath as fq, resolveFarmAPIConfig as fr, resolveFarmAPIRequestURL as fs, resolveFarmDevIndicatorsConfig as ft, resolveFarmRouteRuleRuntimeConfig as fu, resolveFarmRouteRuntimeConfig as fv, resolveIntegrationAllowedOrigins as fw, resolveIntegrationOrmRuntimeClient as fx, resolveIntegrationPlugins as fy, resolveMarkdownConfig as fz, farmRequestWantsMarkdown as g, resolveFarmSecurityConfig as g0, stampFarmCspNonce as g1, type FarmMdxComponent as h, type FarmMdxUserConfig as i, resolveMdxConfig as j, type FarmUserConfig as k, type RouteSegment as l, type FarmRequest as m, type FarmResponse as n, type FarmPluginContext as o, type FarmAppContext as p, type PageProps as q, resolveFarmMdxComponentsModulePath as r, type PluginContextProps as s, type FarmRouteRuntime as t, type FarmRouteRegions as u, type FarmRouteMaxDuration as v, type FarmRedirectSignal as w, type FarmRedirectStatus as x, getFarmRedirectError as y, isFarmNotFoundError as z };