@farm.js/core 0.1.0-beta.21 → 0.1.0-beta.23

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 (266) hide show
  1. package/dist/after.d.mts +25 -0
  2. package/dist/after.d.ts +25 -0
  3. package/dist/agent-runtime.d.mts +97 -0
  4. package/dist/agent-runtime.d.ts +97 -0
  5. package/dist/api/route-manager.d.mts +68 -0
  6. package/dist/api/route-manager.d.ts +68 -0
  7. package/dist/api/runtime.d.mts +3 -0
  8. package/dist/api/runtime.d.ts +3 -0
  9. package/dist/api.cjs +22 -19
  10. package/dist/api.cjs.map +1 -1
  11. package/dist/api.d.mts +50 -0
  12. package/dist/api.d.ts +50 -0
  13. package/dist/api.mjs +2 -1
  14. package/dist/app-CTFnOJaI.d.ts +308 -0
  15. package/dist/app-DA6ospIq.d.mts +308 -0
  16. package/dist/app-markdown.d.mts +25 -0
  17. package/dist/app-markdown.d.ts +25 -0
  18. package/dist/cache.d.mts +192 -0
  19. package/dist/cache.d.ts +192 -0
  20. package/dist/{chunk-MIUW47JX.mjs → chunk-2PEJGY5V.mjs} +15 -20
  21. package/dist/chunk-2PEJGY5V.mjs.map +1 -0
  22. package/dist/{chunk-RIXKJPGI.mjs → chunk-42325TLU.mjs} +2 -2
  23. package/dist/chunk-4IVNW5QD.mjs +82 -0
  24. package/dist/chunk-4IVNW5QD.mjs.map +1 -0
  25. package/dist/{chunk-I3UWA2P2.mjs → chunk-5NOVWCFL.mjs} +2 -2
  26. package/dist/chunk-5NOVWCFL.mjs.map +1 -0
  27. package/dist/chunk-D42BNPZH.mjs +79 -0
  28. package/dist/chunk-D42BNPZH.mjs.map +1 -0
  29. package/dist/{chunk-LLPN5SEZ.mjs → chunk-DVPRBMU2.mjs} +2 -2
  30. package/dist/{chunk-VIC7NJ77.mjs → chunk-FJGTYLCO.mjs} +67 -20
  31. package/dist/chunk-FJGTYLCO.mjs.map +1 -0
  32. package/dist/chunk-GIELMNBG.mjs +15 -0
  33. package/dist/chunk-GIELMNBG.mjs.map +1 -0
  34. package/dist/chunk-GQVQESLY.mjs +25 -0
  35. package/dist/chunk-GQVQESLY.mjs.map +1 -0
  36. package/dist/chunk-H53KVQUU.mjs +48 -0
  37. package/dist/chunk-H53KVQUU.mjs.map +1 -0
  38. package/dist/chunk-HCGQYYHI.mjs +1 -0
  39. package/dist/chunk-HCGQYYHI.mjs.map +1 -0
  40. package/dist/{chunk-4EATUJFO.mjs → chunk-ICTGDDV4.mjs} +20 -22
  41. package/dist/chunk-ICTGDDV4.mjs.map +1 -0
  42. package/dist/{chunk-UCYWGN2P.mjs → chunk-OHNSROHS.mjs} +1 -1
  43. package/dist/{chunk-FRPWCMMG.mjs → chunk-SBWOTAX4.mjs} +63 -2
  44. package/dist/chunk-SBWOTAX4.mjs.map +1 -0
  45. package/dist/{chunk-FKKM7HVF.mjs → chunk-TX54PXAJ.mjs} +109 -58
  46. package/dist/chunk-TX54PXAJ.mjs.map +1 -0
  47. package/dist/{chunk-CEVMYGDL.mjs → chunk-YD5IRKVS.mjs} +13 -9
  48. package/dist/chunk-YD5IRKVS.mjs.map +1 -0
  49. package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
  50. package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
  51. package/dist/client-BT1mFQas.d.mts +447 -0
  52. package/dist/client-Nn0q4eO4.d.ts +447 -0
  53. package/dist/client-cache-CIlyBlmx.d.ts +6 -0
  54. package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
  55. package/dist/client-plugins-CCilIb_G.d.mts +2092 -0
  56. package/dist/client-plugins-DuuleQKk.d.ts +2092 -0
  57. package/dist/client-plugins.d.mts +25 -0
  58. package/dist/client-plugins.d.ts +25 -0
  59. package/dist/client.cjs +122 -35
  60. package/dist/client.cjs.map +1 -1
  61. package/dist/client.d.mts +454 -0
  62. package/dist/client.d.ts +454 -0
  63. package/dist/client.mjs +13 -2
  64. package/dist/config.d.mts +32 -0
  65. package/dist/config.d.ts +32 -0
  66. package/dist/cron.d.mts +78 -0
  67. package/dist/cron.d.ts +78 -0
  68. package/dist/deferred.d.mts +42 -0
  69. package/dist/deferred.d.ts +42 -0
  70. package/dist/deployment.d.mts +36 -0
  71. package/dist/deployment.d.ts +36 -0
  72. package/dist/{devtools-52FYXIEK.mjs → devtools-326RBQCN.mjs} +7 -6
  73. package/dist/{devtools-52FYXIEK.mjs.map → devtools-326RBQCN.mjs.map} +1 -1
  74. package/dist/docs.cjs.map +1 -1
  75. package/dist/docs.d.mts +80 -0
  76. package/dist/docs.d.ts +80 -0
  77. package/dist/docs.mjs +6 -5
  78. package/dist/env-types.d.mts +12 -0
  79. package/dist/env-types.d.ts +12 -0
  80. package/dist/env.d.mts +45 -0
  81. package/dist/env.d.ts +45 -0
  82. package/dist/environment/vite.d.mts +22 -0
  83. package/dist/environment/vite.d.ts +22 -0
  84. package/dist/environment.d.mts +18 -0
  85. package/dist/environment.d.ts +18 -0
  86. package/dist/font.d.mts +95 -0
  87. package/dist/font.d.ts +95 -0
  88. package/dist/headers.d.mts +22 -0
  89. package/dist/headers.d.ts +22 -0
  90. package/dist/i18n/client.d.mts +32 -0
  91. package/dist/i18n/client.d.ts +32 -0
  92. package/dist/i18n/index.d.mts +20 -0
  93. package/dist/i18n/index.d.ts +20 -0
  94. package/dist/i18n/server.d.mts +30 -0
  95. package/dist/i18n/server.d.ts +30 -0
  96. package/dist/image/server.d.mts +37 -0
  97. package/dist/image/server.d.ts +37 -0
  98. package/dist/image/sharp.d.mts +7 -0
  99. package/dist/image/sharp.d.ts +7 -0
  100. package/dist/image-config-Duob7wER.d.mts +50 -0
  101. package/dist/image-config-Duob7wER.d.ts +50 -0
  102. package/dist/image.d.mts +39 -0
  103. package/dist/image.d.ts +39 -0
  104. package/dist/index.cjs +496 -123
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.mts +480 -0
  107. package/dist/index.d.ts +480 -0
  108. package/dist/index.mjs +70 -52
  109. package/dist/index.mjs.map +1 -1
  110. package/dist/integration-api-CHT2OKAf.d.mts +93 -0
  111. package/dist/integration-api-CHT2OKAf.d.ts +93 -0
  112. package/dist/integrations.d.mts +25 -0
  113. package/dist/integrations.d.ts +25 -0
  114. package/dist/internal/build-runtime.cjs +386 -83
  115. package/dist/internal/build-runtime.cjs.map +1 -1
  116. package/dist/internal/build-runtime.d.mts +42 -0
  117. package/dist/internal/build-runtime.d.ts +42 -0
  118. package/dist/internal/build-runtime.mjs +17 -13
  119. package/dist/internal/client-runtime.d.mts +17 -0
  120. package/dist/internal/client-runtime.d.ts +17 -0
  121. package/dist/internal/config-runtime.cjs +41 -0
  122. package/dist/internal/config-runtime.cjs.map +1 -1
  123. package/dist/internal/config-runtime.d.mts +42 -0
  124. package/dist/internal/config-runtime.d.ts +42 -0
  125. package/dist/internal/config-runtime.mjs +5 -4
  126. package/dist/internal/metadata-image-runtime.d.mts +25 -0
  127. package/dist/internal/metadata-image-runtime.d.ts +25 -0
  128. package/dist/internal/production-node-env.d.mts +12 -0
  129. package/dist/internal/production-node-env.d.ts +12 -0
  130. package/dist/internal/production-runtime.cjs +178 -0
  131. package/dist/internal/production-runtime.cjs.map +1 -1
  132. package/dist/internal/production-runtime.d.mts +80 -0
  133. package/dist/internal/production-runtime.d.ts +80 -0
  134. package/dist/internal/production-runtime.mjs +13 -1
  135. package/dist/internal/production-runtime.mjs.map +1 -1
  136. package/dist/island-CfGru1MO.d.mts +9 -0
  137. package/dist/island-CfGru1MO.d.ts +9 -0
  138. package/dist/markdown.d.mts +60 -0
  139. package/dist/markdown.d.ts +60 -0
  140. package/dist/metadata-DyPRG0wX.d.ts +22 -0
  141. package/dist/metadata-_GHcAySx.d.mts +22 -0
  142. package/dist/middleware.cjs +17 -17
  143. package/dist/middleware.cjs.map +1 -1
  144. package/dist/middleware.d.mts +172 -0
  145. package/dist/middleware.d.ts +172 -0
  146. package/dist/middleware.mjs +3 -2
  147. package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
  148. package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
  149. package/dist/navigation.d.mts +14 -0
  150. package/dist/navigation.d.ts +14 -0
  151. package/dist/observability.d.mts +335 -0
  152. package/dist/observability.d.ts +335 -0
  153. package/dist/params-BALtrRim.d.ts +15 -0
  154. package/dist/params-ry-lxqmy.d.mts +15 -0
  155. package/dist/plugin-BJDf43dc.d.mts +165 -0
  156. package/dist/plugin-BJDf43dc.d.ts +165 -0
  157. package/dist/plugin.cjs +261 -62
  158. package/dist/plugin.cjs.map +1 -1
  159. package/dist/plugin.d.mts +25 -0
  160. package/dist/plugin.d.ts +25 -0
  161. package/dist/plugin.mjs +13 -9
  162. package/dist/production-runtime-C4cO3esK.d.mts +81 -0
  163. package/dist/production-runtime-DrEy8kBO.d.ts +81 -0
  164. package/dist/query/client.d.mts +61 -0
  165. package/dist/query/client.d.ts +61 -0
  166. package/dist/query/index.d.mts +90 -0
  167. package/dist/query/index.d.ts +90 -0
  168. package/dist/query/parsers.d.mts +25 -0
  169. package/dist/query/parsers.d.ts +25 -0
  170. package/dist/query/server.d.mts +55 -0
  171. package/dist/query/server.d.ts +55 -0
  172. package/dist/request-B2PpOxYK.d.mts +6 -0
  173. package/dist/request-D40lt6aN.d.ts +6 -0
  174. package/dist/request.d.mts +26 -0
  175. package/dist/request.d.ts +26 -0
  176. package/dist/resolver-DJqjLMg_.d.mts +14 -0
  177. package/dist/resolver-IH4RmPEl.d.ts +14 -0
  178. package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
  179. package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
  180. package/dist/router.d.mts +36 -0
  181. package/dist/router.d.ts +36 -0
  182. package/dist/routes.d.mts +227 -0
  183. package/dist/routes.d.ts +227 -0
  184. package/dist/runtime-Bpp-c28k.d.ts +231 -0
  185. package/dist/runtime-Cxpq6xZN.d.mts +27 -0
  186. package/dist/runtime-Q3u74Nbq.d.mts +231 -0
  187. package/dist/runtime-bv63eUiO.d.ts +27 -0
  188. package/dist/server-action-security.d.mts +45 -0
  189. package/dist/server-action-security.d.ts +45 -0
  190. package/dist/server-fn-client.d.mts +33 -0
  191. package/dist/server-fn-client.d.ts +33 -0
  192. package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
  193. package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
  194. package/dist/server-fn.d.mts +121 -0
  195. package/dist/server-fn.d.ts +121 -0
  196. package/dist/server-plugins.d.mts +58 -0
  197. package/dist/server-plugins.d.ts +58 -0
  198. package/dist/server-query-client.d.mts +51 -0
  199. package/dist/server-query-client.d.ts +51 -0
  200. package/dist/server-query.d.mts +37 -0
  201. package/dist/server-query.d.ts +37 -0
  202. package/dist/server.cjs +285 -85
  203. package/dist/server.cjs.map +1 -1
  204. package/dist/server.d.mts +53 -0
  205. package/dist/server.d.ts +53 -0
  206. package/dist/server.mjs +26 -31
  207. package/dist/server.mjs.map +1 -1
  208. package/dist/storage.d.mts +52 -0
  209. package/dist/storage.d.ts +52 -0
  210. package/dist/testing.d.mts +104 -0
  211. package/dist/testing.d.ts +104 -0
  212. package/dist/theme/client.cjs +115 -0
  213. package/dist/theme/client.cjs.map +1 -0
  214. package/dist/theme/client.d.mts +17 -0
  215. package/dist/theme/client.d.ts +17 -0
  216. package/dist/theme/client.mjs +16 -0
  217. package/dist/theme/client.mjs.map +1 -0
  218. package/dist/theme/index.cjs +71 -0
  219. package/dist/theme/index.cjs.map +1 -0
  220. package/dist/theme/index.d.mts +6 -0
  221. package/dist/theme/index.d.ts +6 -0
  222. package/dist/theme/index.mjs +9 -0
  223. package/dist/theme/index.mjs.map +1 -0
  224. package/dist/theme/server.cjs +191 -0
  225. package/dist/theme/server.cjs.map +1 -0
  226. package/dist/theme/server.d.mts +8 -0
  227. package/dist/theme/server.d.ts +8 -0
  228. package/dist/theme/server.mjs +18 -0
  229. package/dist/theme/server.mjs.map +1 -0
  230. package/dist/transport-BmbGTXA5.d.mts +49 -0
  231. package/dist/transport-BmbGTXA5.d.ts +49 -0
  232. package/dist/types-BMxWr97v.d.mts +81 -0
  233. package/dist/types-BMxWr97v.d.ts +81 -0
  234. package/dist/types-CsR8fpgF.d.mts +30 -0
  235. package/dist/types-CsR8fpgF.d.ts +30 -0
  236. package/dist/types-D1A6-XvH.d.mts +73 -0
  237. package/dist/types-D1A6-XvH.d.ts +73 -0
  238. package/dist/types-DTzm4TCl.d.mts +78 -0
  239. package/dist/types-DTzm4TCl.d.ts +78 -0
  240. package/dist/utils-3sQgfkya.d.ts +23 -0
  241. package/dist/utils-Bop7bly-.d.mts +23 -0
  242. package/dist/version.cjs +1 -1
  243. package/dist/version.cjs.map +1 -1
  244. package/dist/version.d.mts +3 -0
  245. package/dist/version.d.ts +3 -0
  246. package/dist/version.mjs +1 -1
  247. package/dist/vite.cjs +285 -64
  248. package/dist/vite.cjs.map +1 -1
  249. package/dist/vite.d.mts +25 -0
  250. package/dist/vite.d.ts +25 -0
  251. package/dist/vite.mjs +13 -9
  252. package/dist/workflows-CusFV6mn.d.mts +153 -0
  253. package/dist/workflows-CusFV6mn.d.ts +153 -0
  254. package/dist/workflows.d.mts +1 -0
  255. package/dist/workflows.d.ts +1 -0
  256. package/package.json +25 -1
  257. package/dist/chunk-4EATUJFO.mjs.map +0 -1
  258. package/dist/chunk-CEVMYGDL.mjs.map +0 -1
  259. package/dist/chunk-FKKM7HVF.mjs.map +0 -1
  260. package/dist/chunk-FRPWCMMG.mjs.map +0 -1
  261. package/dist/chunk-I3UWA2P2.mjs.map +0 -1
  262. package/dist/chunk-MIUW47JX.mjs.map +0 -1
  263. package/dist/chunk-VIC7NJ77.mjs.map +0 -1
  264. /package/dist/{chunk-RIXKJPGI.mjs.map → chunk-42325TLU.mjs.map} +0 -0
  265. /package/dist/{chunk-LLPN5SEZ.mjs.map → chunk-DVPRBMU2.mjs.map} +0 -0
  266. /package/dist/{chunk-UCYWGN2P.mjs.map → chunk-OHNSROHS.mjs.map} +0 -0
package/dist/api.d.mts ADDED
@@ -0,0 +1,50 @@
1
+ export { A as APIRouteMatch, c as APIRouteParamValue, b as APIRouteParams, s as AnyEndpointMiddleware, D as DELETE, f as EndpointErrorContracts, d as EndpointErrorDefinition, e as EndpointErrorDefinitions, g as EndpointErrorHandler, E as EndpointErrorSchema, h as EndpointFail, j as EndpointFailure, x as EndpointHandler, u as EndpointInvalidationContext, t as EndpointInvalidationTarget, v as EndpointInvalidations, r as EndpointMiddleware, p as EndpointMiddlewareContext, q as EndpointMiddlewareResult, w as EndpointOptions, l as EndpointParamValue, o as EndpointParams, G as GET, H as HEAD, I as InferEndpointMiddlewareContext, O as OPTIONS, B as PATCH, P as POST, z as PUT, T as TypedEndpoint, y as createEndpoint, i as invokeAPIRouteEndpoint, k as isEndpointFailure, a as isWebResponse, m as matchAPIRoute, n as normalizeRouteResponse } from './runtime-Q3u74Nbq.mjs';
2
+ export { APIRoute, APIRouteManager, APIRouteManagerOptions, API_ROUTE_METHODS } from './api/route-manager.mjs';
3
+ export { r as APIClient, h as APIClientError, b as APIClientOptions, i as APIClientSystemError, c as APIClientWithoutIntegrationsOptions, g as APIResult, A as APIRouteRefMetadata, C as CacheKey, l as CacheOptions, k as CachePolicy, p as ClientOptions, a as FARM_API_ROUTE_META_SYMBOL, F as FARM_API_ROUTE_REF_SYMBOL, n as InvalidateOptions, I as InvalidateTarget, o as OptimisticOptions, O as OptimisticUpdate, R as RequestEvent, j as ResponseEvent, m as RetryOptions, q as RouteAPIClient, s as ServerAPIClient, S as ServerAPIClientOptions, d as ServerAPIClientWithoutIntegrationsOptions, f as StatusEvent, e as StatusPhase, t as createAPIClient, w as createServerAPIClient, v as getAPIRouteRefMetadata, u as isAPIRouteRef } from './client-BT1mFQas.mjs';
4
+ export { F as FarmAPIStream, c as FarmStreamResponse, a as MultipartField, M as MultipartSchema, b as MultipartValues, T as TypedFormData, e as isFarmAPIStream, d as isJSONStreamResponse, i as isMultipartSchema, j as jsonStream, m as multipart, r as readJSONStream, t as toFormData } from './transport-BmbGTXA5.mjs';
5
+ import { Plugin } from 'vite';
6
+ import './cache.mjs';
7
+ import './route-runtime-DoOHzCAD.mjs';
8
+ import './types-BMxWr97v.mjs';
9
+ import './runtime-Cxpq6xZN.mjs';
10
+ import './resolver-DJqjLMg_.mjs';
11
+ import './integration-api-CHT2OKAf.mjs';
12
+ import './client-cache-D-EZ7XVW.mjs';
13
+
14
+ /**
15
+ * Farm.js API Routes Vite Plugin
16
+ *
17
+ * Standalone API route support that works with any Vite setup.
18
+ * Discovers and handles route.ts files in the api directory.
19
+ * Also supports root routes.ts for custom route definitions.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { farmApiPlugin } from '@farm.js/core'
24
+ *
25
+ * export default defineConfig({
26
+ * plugins: [farmApiPlugin({ srcDir: 'src' })],
27
+ * })
28
+ * ```
29
+ */
30
+
31
+ interface FarmApiPluginOptions {
32
+ /** Source directory containing the api folder (default: 'src') */
33
+ srcDir?: string;
34
+ /** Enable debug logging */
35
+ debug?: boolean;
36
+ /** Maximum request body size, for example `"10mb"`. */
37
+ bodySizeLimit?: number | string;
38
+ }
39
+ interface ApiRoute {
40
+ path: string;
41
+ filePath: string;
42
+ methods: string[];
43
+ endpoints: Record<string, any>;
44
+ }
45
+ /**
46
+ * Farm.js API Routes Vite Plugin
47
+ */
48
+ declare function farmApiPlugin(options?: FarmApiPluginOptions): Plugin;
49
+
50
+ export { type ApiRoute, type FarmApiPluginOptions, farmApiPlugin };
package/dist/api.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ export { A as APIRouteMatch, c as APIRouteParamValue, b as APIRouteParams, s as AnyEndpointMiddleware, D as DELETE, f as EndpointErrorContracts, d as EndpointErrorDefinition, e as EndpointErrorDefinitions, g as EndpointErrorHandler, E as EndpointErrorSchema, h as EndpointFail, j as EndpointFailure, x as EndpointHandler, u as EndpointInvalidationContext, t as EndpointInvalidationTarget, v as EndpointInvalidations, r as EndpointMiddleware, p as EndpointMiddlewareContext, q as EndpointMiddlewareResult, w as EndpointOptions, l as EndpointParamValue, o as EndpointParams, G as GET, H as HEAD, I as InferEndpointMiddlewareContext, O as OPTIONS, B as PATCH, P as POST, z as PUT, T as TypedEndpoint, y as createEndpoint, i as invokeAPIRouteEndpoint, k as isEndpointFailure, a as isWebResponse, m as matchAPIRoute, n as normalizeRouteResponse } from './runtime-Bpp-c28k.js';
2
+ export { APIRoute, APIRouteManager, APIRouteManagerOptions, API_ROUTE_METHODS } from './api/route-manager.js';
3
+ export { r as APIClient, h as APIClientError, b as APIClientOptions, i as APIClientSystemError, c as APIClientWithoutIntegrationsOptions, g as APIResult, A as APIRouteRefMetadata, C as CacheKey, l as CacheOptions, k as CachePolicy, p as ClientOptions, a as FARM_API_ROUTE_META_SYMBOL, F as FARM_API_ROUTE_REF_SYMBOL, n as InvalidateOptions, I as InvalidateTarget, o as OptimisticOptions, O as OptimisticUpdate, R as RequestEvent, j as ResponseEvent, m as RetryOptions, q as RouteAPIClient, s as ServerAPIClient, S as ServerAPIClientOptions, d as ServerAPIClientWithoutIntegrationsOptions, f as StatusEvent, e as StatusPhase, t as createAPIClient, w as createServerAPIClient, v as getAPIRouteRefMetadata, u as isAPIRouteRef } from './client-Nn0q4eO4.js';
4
+ export { F as FarmAPIStream, c as FarmStreamResponse, a as MultipartField, M as MultipartSchema, b as MultipartValues, T as TypedFormData, e as isFarmAPIStream, d as isJSONStreamResponse, i as isMultipartSchema, j as jsonStream, m as multipart, r as readJSONStream, t as toFormData } from './transport-BmbGTXA5.js';
5
+ import { Plugin } from 'vite';
6
+ import './cache.js';
7
+ import './route-runtime-DoOHzCAD.js';
8
+ import './types-BMxWr97v.js';
9
+ import './runtime-bv63eUiO.js';
10
+ import './resolver-IH4RmPEl.js';
11
+ import './integration-api-CHT2OKAf.js';
12
+ import './client-cache-CIlyBlmx.js';
13
+
14
+ /**
15
+ * Farm.js API Routes Vite Plugin
16
+ *
17
+ * Standalone API route support that works with any Vite setup.
18
+ * Discovers and handles route.ts files in the api directory.
19
+ * Also supports root routes.ts for custom route definitions.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { farmApiPlugin } from '@farm.js/core'
24
+ *
25
+ * export default defineConfig({
26
+ * plugins: [farmApiPlugin({ srcDir: 'src' })],
27
+ * })
28
+ * ```
29
+ */
30
+
31
+ interface FarmApiPluginOptions {
32
+ /** Source directory containing the api folder (default: 'src') */
33
+ srcDir?: string;
34
+ /** Enable debug logging */
35
+ debug?: boolean;
36
+ /** Maximum request body size, for example `"10mb"`. */
37
+ bodySizeLimit?: number | string;
38
+ }
39
+ interface ApiRoute {
40
+ path: string;
41
+ filePath: string;
42
+ methods: string[];
43
+ endpoints: Record<string, any>;
44
+ }
45
+ /**
46
+ * Farm.js API Routes Vite Plugin
47
+ */
48
+ declare function farmApiPlugin(options?: FarmApiPluginOptions): Plugin;
49
+
50
+ export { type ApiRoute, type FarmApiPluginOptions, farmApiPlugin };
package/dist/api.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  farmApiPlugin
3
- } from "./chunk-4EATUJFO.mjs";
3
+ } from "./chunk-ICTGDDV4.mjs";
4
4
  import {
5
5
  APIClientError,
6
6
  FARM_API_ROUTE_META_SYMBOL,
@@ -12,6 +12,7 @@ import {
12
12
  } from "./chunk-W2CRQFF6.mjs";
13
13
  import "./chunk-TQAEEJB4.mjs";
14
14
  import "./chunk-E6EPN5BT.mjs";
15
+ import "./chunk-GIELMNBG.mjs";
15
16
  import "./chunk-QGOHVJ6J.mjs";
16
17
  import {
17
18
  APIRouteManager,
@@ -0,0 +1,308 @@
1
+ import { F as FarmConfig, C as ParsedRoute, s as RouteModule, v as LayoutModule, I as SSGCollectionResult, x as FarmRequest, y as FarmResponse, a4 as FarmMdxResolvedConfig, a5 as ResolvedFarmDevtoolsConfig, a6 as ResolvedFarmAuthConfig, a7 as ResolvedFarmPerformanceConfig, a8 as ResolvedFarmSecurityConfig } from './client-plugins-DuuleQKk.js';
2
+ import { F as FarmDocsResolvedConfig } from './types-DTzm4TCl.js';
3
+ import { FarmMarkdownResolvedConfig } from './markdown.js';
4
+ import { F as FarmWorkflowsResolvedConfig } from './workflows-CusFV6mn.js';
5
+ import { FarmCronResolvedConfig } from './cron.js';
6
+ import { R as ResolvedFarmImageConfig } from './image-config-Duob7wER.js';
7
+ import { ProgrammaticRedirectRoute, ProgrammaticRouteSearchClientOptions } from './routes.js';
8
+ import { ViteDevServer } from 'vite';
9
+ import { M as MetadataImageKind } from './metadata-DyPRG0wX.js';
10
+ import { F as FarmIslandStrategy } from './island-CfGru1MO.js';
11
+ import { R as ResolvedFarmRouteRuntimeConfig } from './route-runtime-DoOHzCAD.js';
12
+ import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.js';
13
+ import { F as FarmI18nRuntime } from './runtime-bv63eUiO.js';
14
+ import { R as ResolvedFarmThemeConfig } from './types-CsR8fpgF.js';
15
+
16
+ declare const STATIC_METADATA_IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp"];
17
+ type StaticMetadataImageExtension = (typeof STATIC_METADATA_IMAGE_EXTENSIONS)[number];
18
+ interface StaticMetadataImageInfo {
19
+ extension: StaticMetadataImageExtension;
20
+ contentType: string;
21
+ width: number;
22
+ height: number;
23
+ alt?: string;
24
+ hash: string;
25
+ byteLength: number;
26
+ }
27
+
28
+ interface RouteEntry {
29
+ route: ParsedRoute;
30
+ modulePath: string;
31
+ markdownSourcePath?: string;
32
+ pattern: string;
33
+ source?: "file" | "programmatic";
34
+ sourceRoot: string;
35
+ }
36
+ interface RouteSlotEntry extends RouteEntry {
37
+ name: string;
38
+ ownerPattern: string;
39
+ interception: boolean;
40
+ fallback: boolean;
41
+ containerId: string;
42
+ }
43
+ interface MatchedRouteSlot {
44
+ name: string;
45
+ ownerPattern: string;
46
+ containerId: string;
47
+ interception: boolean;
48
+ fallback: boolean;
49
+ route: RouteSlotEntry;
50
+ params: Record<string, string>;
51
+ }
52
+ interface MetadataImageEntry extends RouteEntry {
53
+ kind: MetadataImageKind;
54
+ fileName: "opengraph-image" | "twitter-image";
55
+ sourceType: "module" | "static";
56
+ staticInfo?: StaticMetadataImageInfo;
57
+ }
58
+ /**
59
+ * Manages route discovery and matching for the Farm.js application
60
+ */
61
+ declare class RouteManager {
62
+ private config;
63
+ private routes;
64
+ private layouts;
65
+ private routeSlots;
66
+ private loadings;
67
+ private errors;
68
+ private metadataImages;
69
+ private redirects;
70
+ private programmaticPages;
71
+ private programmaticLayouts;
72
+ private viteServer?;
73
+ constructor(config: Required<FarmConfig>, viteServer?: ViteDevServer);
74
+ /**
75
+ * Discover all routes in the app directory
76
+ */
77
+ discoverRoutes(): Promise<void>;
78
+ /**
79
+ * Find matching route for a given URL path
80
+ */
81
+ matchRoute(pathname: string, options?: {
82
+ interceptFrom?: string;
83
+ }): {
84
+ route: RouteEntry | null;
85
+ params: Record<string, string>;
86
+ layouts: RouteEntry[];
87
+ slots: MatchedRouteSlot[];
88
+ };
89
+ /**
90
+ * Get all registered routes
91
+ */
92
+ getRoutes(): Map<string, RouteEntry>;
93
+ /**
94
+ * Get all registered layouts
95
+ */
96
+ getLayouts(): Map<string, RouteEntry>;
97
+ getRouteSlots(): Map<string, RouteSlotEntry>;
98
+ /** Resolve route rules, inherited layouts, and the page export in precedence order. */
99
+ resolveRouteRuntimeConfig(pattern: string): Promise<ResolvedFarmRouteRuntimeConfig>;
100
+ /**
101
+ * Get all route-level loading boundaries.
102
+ */
103
+ getLoadings(): Map<string, RouteEntry>;
104
+ /**
105
+ * Get all route-level error boundaries.
106
+ */
107
+ getErrors(): Map<string, RouteEntry>;
108
+ getMetadataImages(): Map<string, MetadataImageEntry>;
109
+ getRedirects(): ProgrammaticRedirectRoute[];
110
+ matchRedirect(pathname: string): {
111
+ redirect: ProgrammaticRedirectRoute;
112
+ destination: string;
113
+ statusCode: number;
114
+ params: Record<string, string>;
115
+ } | null;
116
+ /**
117
+ * Return the nearest matching loading boundary for a pathname.
118
+ */
119
+ getMatchingLoading(pathname: string): RouteEntry | null;
120
+ /**
121
+ * Return the nearest matching error boundary for a pathname.
122
+ */
123
+ getMatchingError(pathname: string): RouteEntry | null;
124
+ matchMetadataImage(pathname: string): {
125
+ image: MetadataImageEntry;
126
+ params: Record<string, string>;
127
+ pagePath: string;
128
+ } | null;
129
+ getMatchingMetadataImage(pathname: string, kind: MetadataImageKind): {
130
+ image: MetadataImageEntry;
131
+ params: Record<string, string>;
132
+ } | null;
133
+ resolveMetadataImagePath(image: MetadataImageEntry, params?: Record<string, string>): string;
134
+ /**
135
+ * Generate a client-side route manifest for SPA navigation
136
+ * This eliminates the need for server requests during navigation
137
+ */
138
+ generateClientManifest(projectRoot: string): {
139
+ routes: Array<{
140
+ pattern: string;
141
+ modulePath: string;
142
+ shouldHydrate: boolean;
143
+ isClientComponent: boolean;
144
+ islandStrategy: FarmIslandStrategy | null;
145
+ search?: ProgrammaticRouteSearchClientOptions;
146
+ segments: Array<{
147
+ segment: string;
148
+ isDynamic: boolean;
149
+ isCatchAll?: boolean;
150
+ isOptional?: boolean;
151
+ }>;
152
+ }>;
153
+ layouts: Array<{
154
+ pattern: string;
155
+ modulePath: string;
156
+ }>;
157
+ slots: Array<{
158
+ name: string;
159
+ ownerPattern: string;
160
+ pattern: string;
161
+ modulePath: string;
162
+ containerId: string;
163
+ interception: boolean;
164
+ fallback: boolean;
165
+ shouldHydrate: boolean;
166
+ isClientComponent: boolean;
167
+ segments: RouteEntry["route"]["segments"];
168
+ }>;
169
+ };
170
+ /**
171
+ * Load a route module dynamically
172
+ */
173
+ loadRouteModule(modulePath: string): Promise<RouteModule>;
174
+ /**
175
+ * Load a layout module dynamically
176
+ */
177
+ loadLayoutModule(modulePath: string): Promise<LayoutModule>;
178
+ /**
179
+ * Create a route pattern from parsed route
180
+ */
181
+ private createRoutePattern;
182
+ private discoverFileRoutes;
183
+ private discoverProgrammaticRoutes;
184
+ private loadProgrammaticRoutesModule;
185
+ /**
186
+ * Find all layouts that should wrap a given path
187
+ */
188
+ private findMatchingLayouts;
189
+ private findMatchingRouteSlots;
190
+ private matchesRoutePrefix;
191
+ private findNearestBoundary;
192
+ /**
193
+ * Log discovered routes for debugging
194
+ */
195
+ private logRoutes;
196
+ /**
197
+ * Collect SSG pages for static generation
198
+ *
199
+ * Returns all pages marked with `export const ssg = true` along with
200
+ * their pre-computed paths (for dynamic routes using getStaticPaths)
201
+ */
202
+ collectSSGPages(): Promise<SSGCollectionResult>;
203
+ private toRoutePathname;
204
+ private localizeRedirectDestination;
205
+ private getI18nConfig;
206
+ /**
207
+ * Check if a route is SSG
208
+ */
209
+ isRouteSSG(modulePath: string): Promise<boolean>;
210
+ /**
211
+ * Check if a route has ISR (Incremental Static Regeneration)
212
+ */
213
+ hasRouteISR(modulePath: string): Promise<boolean>;
214
+ /**
215
+ * Get revalidation interval for a route
216
+ */
217
+ getRouteRevalidateInterval(modulePath: string): Promise<number | undefined>;
218
+ }
219
+
220
+ declare class ServerRenderer {
221
+ private config;
222
+ private routeManager;
223
+ private ssgManifest;
224
+ private dataCache;
225
+ private i18nRuntime?;
226
+ constructor(config: Required<FarmConfig>, routeManager: RouteManager, i18nRuntime?: FarmI18nRuntime);
227
+ runWithRequestContext<T>(request: Request, fn: () => T | Promise<T>): Promise<T>;
228
+ resolveRouteContext(input: {
229
+ request: Request;
230
+ rawRequest?: FarmRequest;
231
+ params: Record<string, string>;
232
+ search: Record<string, string | string[] | undefined>;
233
+ path: string;
234
+ }): Promise<unknown>;
235
+ /**
236
+ * Load SSG manifest from build output
237
+ */
238
+ private loadSSGManifest;
239
+ /**
240
+ * Check if a path should be served from SSG cache
241
+ */
242
+ private shouldServeSSG;
243
+ private getSSGCacheKey;
244
+ private getPPRCacheKey;
245
+ private getCachedSSGPage;
246
+ private cacheSSGPage;
247
+ private getCachedPPRShell;
248
+ private cachePPRShell;
249
+ private getPPRShellBypassReason;
250
+ private getPPRHeaders;
251
+ private serveCachedPPRShell;
252
+ /**
253
+ * Regenerate an SSG page in the background (ISR)
254
+ */
255
+ private regenerateSSGPage;
256
+ /**
257
+ * Serve a pre-rendered SSG page
258
+ */
259
+ private serveSSGPage;
260
+ renderPage(req: FarmRequest, res: FarmResponse): Promise<void>;
261
+ private renderPageInContext;
262
+ private wrapWithIntegrationProviders;
263
+ private resolveRouteMetadata;
264
+ private resolveMetadataImageReference;
265
+ private renderMetadataImage;
266
+ private writeMetadataImageResponse;
267
+ private writeStaticMetadataImageResponse;
268
+ private renderRouteErrorBoundary;
269
+ private renderWithSSR;
270
+ private render404;
271
+ private render500;
272
+ private createFullHTML;
273
+ private applyDeploymentHeaders;
274
+ private getDeploymentId;
275
+ }
276
+
277
+ type NormalizedFarmConfig = Omit<Required<FarmConfig>, "devtools" | "images" | "i18n" | "performance" | "security" | "theme"> & {
278
+ docs: FarmDocsResolvedConfig;
279
+ md: FarmMarkdownResolvedConfig;
280
+ mdx: FarmMdxResolvedConfig;
281
+ cron: FarmCronResolvedConfig;
282
+ workflows: FarmWorkflowsResolvedConfig;
283
+ devtools: ResolvedFarmDevtoolsConfig;
284
+ images: ResolvedFarmImageConfig;
285
+ i18n: ResolvedFarmI18nConfig;
286
+ auth: ResolvedFarmAuthConfig;
287
+ performance: ResolvedFarmPerformanceConfig;
288
+ security: ResolvedFarmSecurityConfig;
289
+ theme: ResolvedFarmThemeConfig;
290
+ };
291
+ declare class FarmApp {
292
+ private config;
293
+ private routeManager;
294
+ private serverRenderer;
295
+ private i18nRuntime;
296
+ private viteServer?;
297
+ constructor(config?: FarmConfig, viteServer?: ViteDevServer);
298
+ initialize(): Promise<void>;
299
+ getRouteManager(): RouteManager;
300
+ getServerRenderer(): ServerRenderer;
301
+ getI18nRuntime(): FarmI18nRuntime;
302
+ getConfig(): NormalizedFarmConfig;
303
+ private normalizeConfig;
304
+ private verifyAppStructure;
305
+ }
306
+ declare function createFarmApp(config?: FarmConfig, viteServer?: ViteDevServer): FarmApp;
307
+
308
+ export { FarmApp as F, RouteManager as R, ServerRenderer as S, createFarmApp as c };