@farm.js/core 0.1.0-beta.11 → 0.1.0-beta.13

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 (237) hide show
  1. package/dist/{chunk-5EVQFRL2.mjs → chunk-3WIRO3N7.mjs} +2 -2
  2. package/dist/chunk-3WIRO3N7.mjs.map +1 -0
  3. package/dist/chunk-53MVSX3R.mjs +168 -0
  4. package/dist/chunk-53MVSX3R.mjs.map +1 -0
  5. package/dist/{chunk-AW6I64AP.mjs → chunk-6ZXIQSXE.mjs} +16 -1
  6. package/dist/chunk-6ZXIQSXE.mjs.map +1 -0
  7. package/dist/chunk-7ZVN3YZI.mjs +333 -0
  8. package/dist/chunk-7ZVN3YZI.mjs.map +1 -0
  9. package/dist/{chunk-7N62DNSO.mjs → chunk-H3TE3LOV.mjs} +2 -2
  10. package/dist/{chunk-QTZZ2ISQ.mjs → chunk-KLA67WKG.mjs} +1 -1
  11. package/dist/chunk-KLA67WKG.mjs.map +1 -0
  12. package/dist/{chunk-K5ZTUF22.mjs → chunk-L2PE36GQ.mjs} +7 -3
  13. package/dist/chunk-L2PE36GQ.mjs.map +1 -0
  14. package/dist/{chunk-4LND3PXF.mjs → chunk-OPHK6OJN.mjs} +513 -48
  15. package/dist/chunk-OPHK6OJN.mjs.map +1 -0
  16. package/dist/chunk-USLFXFFH.mjs +46 -0
  17. package/dist/chunk-USLFXFFH.mjs.map +1 -0
  18. package/dist/{chunk-4677KXB7.mjs → chunk-VSDZEB5M.mjs} +368 -103
  19. package/dist/chunk-VSDZEB5M.mjs.map +1 -0
  20. package/dist/{chunk-77BOAQHI.mjs → chunk-Z3YG4OZT.mjs} +725 -147
  21. package/dist/chunk-Z3YG4OZT.mjs.map +1 -0
  22. package/dist/client.cjs.map +1 -1
  23. package/dist/client.mjs +1 -1
  24. package/dist/{devtools-A22KUJZT.mjs → devtools-GAZ7F3KL.mjs} +4 -3
  25. package/dist/{devtools-A22KUJZT.mjs.map → devtools-GAZ7F3KL.mjs.map} +1 -1
  26. package/dist/docs.cjs +622 -124
  27. package/dist/docs.cjs.map +1 -1
  28. package/dist/docs.mjs +5 -3
  29. package/dist/font.cjs +19 -2
  30. package/dist/font.cjs.map +1 -1
  31. package/dist/font.mjs +7 -3
  32. package/dist/index.cjs +2206 -680
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.mjs +27 -19
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/internal/build-runtime.cjs +2033 -516
  37. package/dist/internal/build-runtime.cjs.map +1 -1
  38. package/dist/internal/build-runtime.mjs +13 -10
  39. package/dist/internal/client-runtime.cjs +169 -2
  40. package/dist/internal/client-runtime.cjs.map +1 -1
  41. package/dist/internal/client-runtime.mjs +170 -2
  42. package/dist/internal/client-runtime.mjs.map +1 -1
  43. package/dist/internal/config-runtime.cjs +22 -0
  44. package/dist/internal/config-runtime.cjs.map +1 -1
  45. package/dist/internal/config-runtime.mjs +3 -2
  46. package/dist/internal/metadata-image-runtime.cjs +199 -0
  47. package/dist/internal/metadata-image-runtime.cjs.map +1 -0
  48. package/dist/internal/metadata-image-runtime.mjs +8 -0
  49. package/dist/internal/metadata-image-runtime.mjs.map +1 -0
  50. package/dist/internal/production-runtime.cjs +310 -0
  51. package/dist/internal/production-runtime.cjs.map +1 -1
  52. package/dist/internal/production-runtime.mjs +10 -0
  53. package/dist/internal/production-runtime.mjs.map +1 -1
  54. package/dist/navigation.cjs.map +1 -1
  55. package/dist/navigation.mjs +2 -2
  56. package/dist/plugin.cjs +1521 -339
  57. package/dist/plugin.cjs.map +1 -1
  58. package/dist/plugin.mjs +9 -5
  59. package/dist/server.cjs +1634 -410
  60. package/dist/server.cjs.map +1 -1
  61. package/dist/server.mjs +17 -19
  62. package/dist/server.mjs.map +1 -1
  63. package/dist/version.cjs +1 -1
  64. package/dist/version.cjs.map +1 -1
  65. package/dist/version.mjs +1 -1
  66. package/dist/vite.cjs +1575 -349
  67. package/dist/vite.cjs.map +1 -1
  68. package/dist/vite.mjs +9 -5
  69. package/package.json +10 -1
  70. package/dist/after.d.mts +0 -25
  71. package/dist/after.d.ts +0 -25
  72. package/dist/agent-runtime.d.mts +0 -94
  73. package/dist/agent-runtime.d.ts +0 -94
  74. package/dist/api/route-manager.d.mts +0 -66
  75. package/dist/api/route-manager.d.ts +0 -66
  76. package/dist/api/runtime.d.mts +0 -3
  77. package/dist/api/runtime.d.ts +0 -3
  78. package/dist/api.d.mts +0 -48
  79. package/dist/api.d.ts +0 -48
  80. package/dist/app-BNE2FoZ4.d.mts +0 -302
  81. package/dist/app-DRGUmJ3s.d.ts +0 -302
  82. package/dist/app-markdown.d.mts +0 -22
  83. package/dist/app-markdown.d.ts +0 -22
  84. package/dist/cache.d.mts +0 -192
  85. package/dist/cache.d.ts +0 -192
  86. package/dist/chunk-4677KXB7.mjs.map +0 -1
  87. package/dist/chunk-4LND3PXF.mjs.map +0 -1
  88. package/dist/chunk-5EVQFRL2.mjs.map +0 -1
  89. package/dist/chunk-77BOAQHI.mjs.map +0 -1
  90. package/dist/chunk-AW6I64AP.mjs.map +0 -1
  91. package/dist/chunk-K5ZTUF22.mjs.map +0 -1
  92. package/dist/chunk-QM746KUO.mjs +0 -56
  93. package/dist/chunk-QM746KUO.mjs.map +0 -1
  94. package/dist/chunk-QTZZ2ISQ.mjs.map +0 -1
  95. package/dist/client-BT1mFQas.d.mts +0 -447
  96. package/dist/client-Nn0q4eO4.d.ts +0 -447
  97. package/dist/client-cache-CIlyBlmx.d.ts +0 -6
  98. package/dist/client-cache-D-EZ7XVW.d.mts +0 -6
  99. package/dist/client-plugins-Bc5jHcNr.d.ts +0 -1927
  100. package/dist/client-plugins-jsk-ZLzJ.d.mts +0 -1927
  101. package/dist/client-plugins.d.mts +0 -22
  102. package/dist/client-plugins.d.ts +0 -22
  103. package/dist/client.d.mts +0 -447
  104. package/dist/client.d.ts +0 -447
  105. package/dist/config.d.mts +0 -29
  106. package/dist/config.d.ts +0 -29
  107. package/dist/cron.d.mts +0 -78
  108. package/dist/cron.d.ts +0 -78
  109. package/dist/deferred.d.mts +0 -42
  110. package/dist/deferred.d.ts +0 -42
  111. package/dist/deployment.d.mts +0 -34
  112. package/dist/deployment.d.ts +0 -34
  113. package/dist/docs.d.mts +0 -69
  114. package/dist/docs.d.ts +0 -69
  115. package/dist/env-types.d.mts +0 -12
  116. package/dist/env-types.d.ts +0 -12
  117. package/dist/env.d.mts +0 -45
  118. package/dist/env.d.ts +0 -45
  119. package/dist/environment/vite.d.mts +0 -22
  120. package/dist/environment/vite.d.ts +0 -22
  121. package/dist/environment.d.mts +0 -18
  122. package/dist/environment.d.ts +0 -18
  123. package/dist/font.d.mts +0 -70
  124. package/dist/font.d.ts +0 -70
  125. package/dist/headers.d.mts +0 -22
  126. package/dist/headers.d.ts +0 -22
  127. package/dist/i18n/client.d.mts +0 -32
  128. package/dist/i18n/client.d.ts +0 -32
  129. package/dist/i18n/index.d.mts +0 -20
  130. package/dist/i18n/index.d.ts +0 -20
  131. package/dist/i18n/server.d.mts +0 -30
  132. package/dist/i18n/server.d.ts +0 -30
  133. package/dist/image/server.d.mts +0 -37
  134. package/dist/image/server.d.ts +0 -37
  135. package/dist/image/sharp.d.mts +0 -7
  136. package/dist/image/sharp.d.ts +0 -7
  137. package/dist/image-config-Duob7wER.d.mts +0 -50
  138. package/dist/image-config-Duob7wER.d.ts +0 -50
  139. package/dist/image.d.mts +0 -39
  140. package/dist/image.d.ts +0 -39
  141. package/dist/index.d.mts +0 -455
  142. package/dist/index.d.ts +0 -455
  143. package/dist/integration-api-CHT2OKAf.d.mts +0 -93
  144. package/dist/integration-api-CHT2OKAf.d.ts +0 -93
  145. package/dist/integrations.d.mts +0 -22
  146. package/dist/integrations.d.ts +0 -22
  147. package/dist/internal/build-runtime.d.mts +0 -39
  148. package/dist/internal/build-runtime.d.ts +0 -39
  149. package/dist/internal/client-runtime.d.mts +0 -2
  150. package/dist/internal/client-runtime.d.ts +0 -2
  151. package/dist/internal/config-runtime.d.mts +0 -39
  152. package/dist/internal/config-runtime.d.ts +0 -39
  153. package/dist/internal/production-node-env.d.mts +0 -12
  154. package/dist/internal/production-node-env.d.ts +0 -12
  155. package/dist/internal/production-runtime.d.mts +0 -41
  156. package/dist/internal/production-runtime.d.ts +0 -41
  157. package/dist/markdown.d.mts +0 -60
  158. package/dist/markdown.d.ts +0 -60
  159. package/dist/metadata-7ffpT3jr.d.mts +0 -22
  160. package/dist/metadata-JHn-8eht.d.ts +0 -22
  161. package/dist/middleware.d.mts +0 -164
  162. package/dist/middleware.d.ts +0 -164
  163. package/dist/navigation-errors-Dvwpzaer.d.mts +0 -13
  164. package/dist/navigation-errors-Dvwpzaer.d.ts +0 -13
  165. package/dist/navigation.d.mts +0 -14
  166. package/dist/navigation.d.ts +0 -14
  167. package/dist/observability.d.mts +0 -335
  168. package/dist/observability.d.ts +0 -335
  169. package/dist/params-BALtrRim.d.ts +0 -15
  170. package/dist/params-ry-lxqmy.d.mts +0 -15
  171. package/dist/plugin-BJDf43dc.d.mts +0 -165
  172. package/dist/plugin-BJDf43dc.d.ts +0 -165
  173. package/dist/plugin.d.mts +0 -22
  174. package/dist/plugin.d.ts +0 -22
  175. package/dist/production-runtime-9KG7GuvW.d.ts +0 -79
  176. package/dist/production-runtime-B-fweKts.d.mts +0 -79
  177. package/dist/production-runtime-C_B79w2P.d.mts +0 -28
  178. package/dist/production-runtime-DDEM1D2q.d.ts +0 -28
  179. package/dist/query/client.d.mts +0 -61
  180. package/dist/query/client.d.ts +0 -61
  181. package/dist/query/index.d.mts +0 -90
  182. package/dist/query/index.d.ts +0 -90
  183. package/dist/query/parsers.d.mts +0 -25
  184. package/dist/query/parsers.d.ts +0 -25
  185. package/dist/query/server.d.mts +0 -55
  186. package/dist/query/server.d.ts +0 -55
  187. package/dist/request-Dsq4kGW0.d.mts +0 -6
  188. package/dist/request-udtobOLv.d.ts +0 -6
  189. package/dist/request.d.mts +0 -2
  190. package/dist/request.d.ts +0 -2
  191. package/dist/resolver-DJqjLMg_.d.mts +0 -14
  192. package/dist/resolver-IH4RmPEl.d.ts +0 -14
  193. package/dist/route-runtime-DoOHzCAD.d.mts +0 -38
  194. package/dist/route-runtime-DoOHzCAD.d.ts +0 -38
  195. package/dist/router.d.mts +0 -36
  196. package/dist/router.d.ts +0 -36
  197. package/dist/routes.d.mts +0 -224
  198. package/dist/routes.d.ts +0 -224
  199. package/dist/runtime-9nQjVM7X.d.mts +0 -206
  200. package/dist/runtime-Cxpq6xZN.d.mts +0 -27
  201. package/dist/runtime-DgeS2skB.d.ts +0 -206
  202. package/dist/runtime-bv63eUiO.d.ts +0 -27
  203. package/dist/server-action-security.d.mts +0 -43
  204. package/dist/server-action-security.d.ts +0 -43
  205. package/dist/server-fn-client.d.mts +0 -32
  206. package/dist/server-fn-client.d.ts +0 -32
  207. package/dist/server-fn.d.mts +0 -93
  208. package/dist/server-fn.d.ts +0 -93
  209. package/dist/server-plugins.d.mts +0 -55
  210. package/dist/server-plugins.d.ts +0 -55
  211. package/dist/server-query-client.d.mts +0 -50
  212. package/dist/server-query-client.d.ts +0 -50
  213. package/dist/server-query.d.mts +0 -36
  214. package/dist/server-query.d.ts +0 -36
  215. package/dist/server.d.mts +0 -48
  216. package/dist/server.d.ts +0 -48
  217. package/dist/storage.d.mts +0 -52
  218. package/dist/storage.d.ts +0 -52
  219. package/dist/testing.d.mts +0 -101
  220. package/dist/testing.d.ts +0 -101
  221. package/dist/transport-BmbGTXA5.d.mts +0 -49
  222. package/dist/transport-BmbGTXA5.d.ts +0 -49
  223. package/dist/types-BMxWr97v.d.mts +0 -81
  224. package/dist/types-BMxWr97v.d.ts +0 -81
  225. package/dist/types-C9N-nk5R.d.mts +0 -53
  226. package/dist/types-C9N-nk5R.d.ts +0 -53
  227. package/dist/types-D1A6-XvH.d.mts +0 -73
  228. package/dist/types-D1A6-XvH.d.ts +0 -73
  229. package/dist/utils-CA0z0c-2.d.ts +0 -23
  230. package/dist/utils-mYVkSOt2.d.mts +0 -23
  231. package/dist/version.d.mts +0 -3
  232. package/dist/version.d.ts +0 -3
  233. package/dist/vite.d.mts +0 -22
  234. package/dist/vite.d.ts +0 -22
  235. package/dist/workflows.d.mts +0 -110
  236. package/dist/workflows.d.ts +0 -110
  237. /package/dist/{chunk-7N62DNSO.mjs.map → chunk-H3TE3LOV.mjs.map} +0 -0
@@ -1,164 +0,0 @@
1
- import { cs as MiddlewareChain, cw as RateLimitStorage, cx as RateLimitStatus, cn as MiddlewareContext, Y as FarmMiddlewareConfig, co as MiddlewareFunction, d2 as MiddlewareConfig, M as MiddlewareProps } from './client-plugins-jsk-ZLzJ.mjs';
2
- export { ct as CookieJar, cu as CookieOptions, cz as MiddlewareResult, cr as MiddlewareStore, cy as NextFunction, cv as RateLimitConfig, X as ReadonlyMiddlewareStore, cp as RequestMiddleware, cq as RequestMiddlewareContext } from './client-plugins-jsk-ZLzJ.mjs';
3
- import { IncomingMessage, ServerResponse } from 'http';
4
- import { ViteDevServer, Plugin } from 'vite';
5
- import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.mjs';
6
- export { _ as _runWithMiddlewareContext, b as _runWithMiddlewareData, a as applyProductionMiddlewareHeaders, c as createProductionMiddlewareRunner, g as getMiddlewareContext, d as getMiddlewareData, e as getMiddlewareValue } from './production-runtime-B-fweKts.mjs';
7
- import './plugin-BJDf43dc.mjs';
8
- import 'react';
9
- import './types-D1A6-XvH.mjs';
10
- import 'db0';
11
- import 'unstorage';
12
- import './integration-api-CHT2OKAf.mjs';
13
- import '@farming-labs/orm';
14
- import './types-C9N-nk5R.mjs';
15
- import '@farming-labs/docs';
16
- import './markdown.mjs';
17
- import './observability.mjs';
18
- import './workflows.mjs';
19
- import './cron.mjs';
20
- import './env.mjs';
21
- import './server-action-security.mjs';
22
- import './image-config-Duob7wER.mjs';
23
- import './cache.mjs';
24
- import './route-runtime-DoOHzCAD.mjs';
25
-
26
- /**
27
- * Middleware Chain Builder
28
- */
29
-
30
- /**
31
- * Get rate limit status for a key
32
- * @example
33
- * const status = await getRateLimitStatus('user:123', 100, storage);
34
- */
35
- declare function getRateLimitStatus(key: string, limit: number, storage?: RateLimitStorage): Promise<RateLimitStatus>;
36
- declare function middleware(basePath?: string): MiddlewareChain;
37
-
38
- /**
39
- * Middleware Context Implementation
40
- */
41
-
42
- /**
43
- * Create a middleware context from request/response
44
- */
45
- declare function createContext(req: IncomingMessage, res: ServerResponse, viteServer?: ViteDevServer, parent?: MiddlewareContext["parent"]): MiddlewareContext;
46
-
47
- /**
48
- * Middleware Manager
49
- *
50
- * Discovers and executes middleware files in the file system
51
- */
52
-
53
- interface DiscoveredMiddleware {
54
- path: string;
55
- filePath: string;
56
- handlers: MiddlewareFunction[];
57
- config?: MiddlewareConfig;
58
- source?: "config" | "file";
59
- }
60
- /**
61
- * Middleware Manager - discovers and executes middleware
62
- */
63
- declare class MiddlewareManager {
64
- private middleware;
65
- private configMiddleware;
66
- private globalConfig?;
67
- private viteServer?;
68
- private appDirs;
69
- private i18n?;
70
- constructor(appDir: string | readonly string[], viteServer?: ViteDevServer, config?: FarmMiddlewareConfig, i18n?: ResolvedFarmI18nConfig);
71
- configure(config?: FarmMiddlewareConfig): void;
72
- /**
73
- * Discover all middleware.ts files
74
- */
75
- discover(): Promise<void>;
76
- /**
77
- * Recursively discover middleware files
78
- */
79
- private discoverInDirectory;
80
- /**
81
- * Find middleware file in directory
82
- */
83
- private findMiddlewareFile;
84
- /**
85
- * Load a middleware file
86
- */
87
- private loadMiddleware;
88
- /**
89
- * Execute middleware for a request
90
- */
91
- execute(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
92
- /**
93
- * Check if pathname matches middleware config
94
- */
95
- private matchesConfig;
96
- /**
97
- * Match a pattern against pathname
98
- */
99
- private matchPattern;
100
- /**
101
- * Reload middleware (for HMR)
102
- */
103
- reload(): Promise<void>;
104
- getMiddlewares(): DiscoveredMiddleware[];
105
- hasMiddleware(): boolean;
106
- private matchRoutePath;
107
- private toMatcherList;
108
- private getConfigHandlers;
109
- private toMiddlewareConfig;
110
- private compilePathPattern;
111
- private parseColonParam;
112
- private escapeRegex;
113
- }
114
-
115
- /**
116
- * Middleware helper utilities for pages
117
- */
118
-
119
- /**
120
- * Unwrap middleware data from PageProps
121
- *
122
- * @example
123
- * ```tsx
124
- * export default async function Page(props: PageProps) {
125
- * const { user, stats } = await unwrapMiddleware(props.middleware, {
126
- * user: null,
127
- * stats: { views: 0, clicks: 0 }
128
- * });
129
- *
130
- * return <div>Welcome {user?.name}</div>;
131
- * }
132
- * ```
133
- */
134
- declare function unwrapMiddleware<T extends Record<string, any>>(middleware: MiddlewareProps | undefined, defaults?: Partial<T>): Partial<T>;
135
- /**
136
- * Get a single value from middleware with a default
137
- *
138
- * @example
139
- * ```tsx
140
- * export default async function Page(props: PageProps) {
141
- * const user = await getMiddlewareValue(props.middleware, 'user', null);
142
- * return <div>Welcome {user?.name || 'Guest'}</div>;
143
- * }
144
- * ```
145
- */
146
- declare function getFromMiddleware<T = any>(middleware: MiddlewareProps | undefined, key: string, defaultValue?: T): T | undefined;
147
- /**
148
- * Check if middleware data exists
149
- */
150
- declare function hasMiddlewareData(middleware: MiddlewareProps | undefined): boolean;
151
-
152
- /**
153
- * Standalone Vite middleware support used by Farm's RSC and API plugins.
154
- */
155
-
156
- interface FarmMiddlewarePluginOptions {
157
- /** Source directory (default: `src`). */
158
- srcDir?: string;
159
- /** Enable debug logging. */
160
- debug?: boolean;
161
- }
162
- declare function farmMiddlewarePlugin(options?: FarmMiddlewarePluginOptions): Plugin;
163
-
164
- export { FarmMiddlewareConfig, type FarmMiddlewarePluginOptions, MiddlewareChain, MiddlewareConfig, MiddlewareContext, MiddlewareFunction, MiddlewareManager, RateLimitStatus, RateLimitStorage, createContext, farmMiddlewarePlugin, getFromMiddleware, getRateLimitStatus, hasMiddlewareData, middleware, unwrapMiddleware };
@@ -1,164 +0,0 @@
1
- import { cs as MiddlewareChain, cw as RateLimitStorage, cx as RateLimitStatus, cn as MiddlewareContext, Y as FarmMiddlewareConfig, co as MiddlewareFunction, d2 as MiddlewareConfig, M as MiddlewareProps } from './client-plugins-Bc5jHcNr.js';
2
- export { ct as CookieJar, cu as CookieOptions, cz as MiddlewareResult, cr as MiddlewareStore, cy as NextFunction, cv as RateLimitConfig, X as ReadonlyMiddlewareStore, cp as RequestMiddleware, cq as RequestMiddlewareContext } from './client-plugins-Bc5jHcNr.js';
3
- import { IncomingMessage, ServerResponse } from 'http';
4
- import { ViteDevServer, Plugin } from 'vite';
5
- import { R as ResolvedFarmI18nConfig } from './types-BMxWr97v.js';
6
- export { _ as _runWithMiddlewareContext, b as _runWithMiddlewareData, a as applyProductionMiddlewareHeaders, c as createProductionMiddlewareRunner, g as getMiddlewareContext, d as getMiddlewareData, e as getMiddlewareValue } from './production-runtime-9KG7GuvW.js';
7
- import './plugin-BJDf43dc.js';
8
- import 'react';
9
- import './types-D1A6-XvH.js';
10
- import 'db0';
11
- import 'unstorage';
12
- import './integration-api-CHT2OKAf.js';
13
- import '@farming-labs/orm';
14
- import './types-C9N-nk5R.js';
15
- import '@farming-labs/docs';
16
- import './markdown.js';
17
- import './observability.js';
18
- import './workflows.js';
19
- import './cron.js';
20
- import './env.js';
21
- import './server-action-security.js';
22
- import './image-config-Duob7wER.js';
23
- import './cache.js';
24
- import './route-runtime-DoOHzCAD.js';
25
-
26
- /**
27
- * Middleware Chain Builder
28
- */
29
-
30
- /**
31
- * Get rate limit status for a key
32
- * @example
33
- * const status = await getRateLimitStatus('user:123', 100, storage);
34
- */
35
- declare function getRateLimitStatus(key: string, limit: number, storage?: RateLimitStorage): Promise<RateLimitStatus>;
36
- declare function middleware(basePath?: string): MiddlewareChain;
37
-
38
- /**
39
- * Middleware Context Implementation
40
- */
41
-
42
- /**
43
- * Create a middleware context from request/response
44
- */
45
- declare function createContext(req: IncomingMessage, res: ServerResponse, viteServer?: ViteDevServer, parent?: MiddlewareContext["parent"]): MiddlewareContext;
46
-
47
- /**
48
- * Middleware Manager
49
- *
50
- * Discovers and executes middleware files in the file system
51
- */
52
-
53
- interface DiscoveredMiddleware {
54
- path: string;
55
- filePath: string;
56
- handlers: MiddlewareFunction[];
57
- config?: MiddlewareConfig;
58
- source?: "config" | "file";
59
- }
60
- /**
61
- * Middleware Manager - discovers and executes middleware
62
- */
63
- declare class MiddlewareManager {
64
- private middleware;
65
- private configMiddleware;
66
- private globalConfig?;
67
- private viteServer?;
68
- private appDirs;
69
- private i18n?;
70
- constructor(appDir: string | readonly string[], viteServer?: ViteDevServer, config?: FarmMiddlewareConfig, i18n?: ResolvedFarmI18nConfig);
71
- configure(config?: FarmMiddlewareConfig): void;
72
- /**
73
- * Discover all middleware.ts files
74
- */
75
- discover(): Promise<void>;
76
- /**
77
- * Recursively discover middleware files
78
- */
79
- private discoverInDirectory;
80
- /**
81
- * Find middleware file in directory
82
- */
83
- private findMiddlewareFile;
84
- /**
85
- * Load a middleware file
86
- */
87
- private loadMiddleware;
88
- /**
89
- * Execute middleware for a request
90
- */
91
- execute(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
92
- /**
93
- * Check if pathname matches middleware config
94
- */
95
- private matchesConfig;
96
- /**
97
- * Match a pattern against pathname
98
- */
99
- private matchPattern;
100
- /**
101
- * Reload middleware (for HMR)
102
- */
103
- reload(): Promise<void>;
104
- getMiddlewares(): DiscoveredMiddleware[];
105
- hasMiddleware(): boolean;
106
- private matchRoutePath;
107
- private toMatcherList;
108
- private getConfigHandlers;
109
- private toMiddlewareConfig;
110
- private compilePathPattern;
111
- private parseColonParam;
112
- private escapeRegex;
113
- }
114
-
115
- /**
116
- * Middleware helper utilities for pages
117
- */
118
-
119
- /**
120
- * Unwrap middleware data from PageProps
121
- *
122
- * @example
123
- * ```tsx
124
- * export default async function Page(props: PageProps) {
125
- * const { user, stats } = await unwrapMiddleware(props.middleware, {
126
- * user: null,
127
- * stats: { views: 0, clicks: 0 }
128
- * });
129
- *
130
- * return <div>Welcome {user?.name}</div>;
131
- * }
132
- * ```
133
- */
134
- declare function unwrapMiddleware<T extends Record<string, any>>(middleware: MiddlewareProps | undefined, defaults?: Partial<T>): Partial<T>;
135
- /**
136
- * Get a single value from middleware with a default
137
- *
138
- * @example
139
- * ```tsx
140
- * export default async function Page(props: PageProps) {
141
- * const user = await getMiddlewareValue(props.middleware, 'user', null);
142
- * return <div>Welcome {user?.name || 'Guest'}</div>;
143
- * }
144
- * ```
145
- */
146
- declare function getFromMiddleware<T = any>(middleware: MiddlewareProps | undefined, key: string, defaultValue?: T): T | undefined;
147
- /**
148
- * Check if middleware data exists
149
- */
150
- declare function hasMiddlewareData(middleware: MiddlewareProps | undefined): boolean;
151
-
152
- /**
153
- * Standalone Vite middleware support used by Farm's RSC and API plugins.
154
- */
155
-
156
- interface FarmMiddlewarePluginOptions {
157
- /** Source directory (default: `src`). */
158
- srcDir?: string;
159
- /** Enable debug logging. */
160
- debug?: boolean;
161
- }
162
- declare function farmMiddlewarePlugin(options?: FarmMiddlewarePluginOptions): Plugin;
163
-
164
- export { FarmMiddlewareConfig, type FarmMiddlewarePluginOptions, MiddlewareChain, MiddlewareConfig, MiddlewareContext, MiddlewareFunction, MiddlewareManager, RateLimitStatus, RateLimitStorage, createContext, farmMiddlewarePlugin, getFromMiddleware, getRateLimitStatus, hasMiddlewareData, middleware, unwrapMiddleware };
@@ -1,13 +0,0 @@
1
- type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
2
- interface FarmRedirectSignal {
3
- url: string;
4
- status: FarmRedirectStatus;
5
- }
6
- declare function redirect(url: string, status?: FarmRedirectStatus): never;
7
- declare function permanentRedirect(url: string): never;
8
- declare function notFound(): never;
9
- declare function isFarmRedirectError(error: unknown): boolean;
10
- declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
11
- declare function isFarmNotFoundError(error: unknown): boolean;
12
-
13
- export { type FarmRedirectSignal as F, isFarmRedirectError as a, type FarmRedirectStatus as b, getFarmRedirectError as g, isFarmNotFoundError as i, notFound as n, permanentRedirect as p, redirect as r };
@@ -1,13 +0,0 @@
1
- type FarmRedirectStatus = 301 | 302 | 303 | 307 | 308;
2
- interface FarmRedirectSignal {
3
- url: string;
4
- status: FarmRedirectStatus;
5
- }
6
- declare function redirect(url: string, status?: FarmRedirectStatus): never;
7
- declare function permanentRedirect(url: string): never;
8
- declare function notFound(): never;
9
- declare function isFarmRedirectError(error: unknown): boolean;
10
- declare function getFarmRedirectError(error: unknown): FarmRedirectSignal | null;
11
- declare function isFarmNotFoundError(error: unknown): boolean;
12
-
13
- export { type FarmRedirectSignal as F, isFarmRedirectError as a, type FarmRedirectStatus as b, getFarmRedirectError as g, isFarmNotFoundError as i, notFound as n, permanentRedirect as p, redirect as r };
@@ -1,14 +0,0 @@
1
- export { F as FarmRedirectSignal, b as FarmRedirectStatus, g as getFarmRedirectError, i as isFarmNotFoundError, a as isFarmRedirectError, n as notFound, p as permanentRedirect, r as redirect } from './navigation-errors-Dvwpzaer.mjs';
2
-
3
- declare function useRouter(): {
4
- push: (href: string) => void;
5
- replace: (href: string) => void;
6
- back: () => void;
7
- forward: () => void;
8
- refresh(): void;
9
- prefetch(_href: string): Promise<void>;
10
- };
11
- declare function usePathname(): string;
12
- declare function useSearchParams(): URLSearchParams;
13
-
14
- export { usePathname, useRouter, useSearchParams };
@@ -1,14 +0,0 @@
1
- export { F as FarmRedirectSignal, b as FarmRedirectStatus, g as getFarmRedirectError, i as isFarmNotFoundError, a as isFarmRedirectError, n as notFound, p as permanentRedirect, r as redirect } from './navigation-errors-Dvwpzaer.js';
2
-
3
- declare function useRouter(): {
4
- push: (href: string) => void;
5
- replace: (href: string) => void;
6
- back: () => void;
7
- forward: () => void;
8
- refresh(): void;
9
- prefetch(_href: string): Promise<void>;
10
- };
11
- declare function usePathname(): string;
12
- declare function useSearchParams(): URLSearchParams;
13
-
14
- export { usePathname, useRouter, useSearchParams };