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

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 (184) 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 +94 -0
  4. package/dist/agent-runtime.d.ts +94 -0
  5. package/dist/api/route-manager.d.mts +66 -0
  6. package/dist/api/route-manager.d.ts +66 -0
  7. package/dist/api/runtime.d.mts +3 -0
  8. package/dist/api/runtime.d.ts +3 -0
  9. package/dist/api.d.mts +48 -0
  10. package/dist/api.d.ts +48 -0
  11. package/dist/app-BNE2FoZ4.d.mts +302 -0
  12. package/dist/app-DRGUmJ3s.d.ts +302 -0
  13. package/dist/app-markdown.d.mts +22 -0
  14. package/dist/app-markdown.d.ts +22 -0
  15. package/dist/cache.d.mts +192 -0
  16. package/dist/cache.d.ts +192 -0
  17. package/dist/{chunk-DTOWEQRV.mjs → chunk-4677KXB7.mjs} +2 -2
  18. package/dist/{chunk-3QDB3IA6.mjs → chunk-5EVQFRL2.mjs} +2 -2
  19. package/dist/{chunk-3QDB3IA6.mjs.map → chunk-5EVQFRL2.mjs.map} +1 -1
  20. package/dist/{chunk-E2AI2CW7.mjs → chunk-77BOAQHI.mjs} +4 -3
  21. package/dist/chunk-77BOAQHI.mjs.map +1 -0
  22. package/dist/client-BT1mFQas.d.mts +447 -0
  23. package/dist/client-Nn0q4eO4.d.ts +447 -0
  24. package/dist/client-cache-CIlyBlmx.d.ts +6 -0
  25. package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
  26. package/dist/client-plugins-Bc5jHcNr.d.ts +1927 -0
  27. package/dist/client-plugins-jsk-ZLzJ.d.mts +1927 -0
  28. package/dist/client-plugins.d.mts +22 -0
  29. package/dist/client-plugins.d.ts +22 -0
  30. package/dist/client.d.mts +447 -0
  31. package/dist/client.d.ts +447 -0
  32. package/dist/config.d.mts +29 -0
  33. package/dist/config.d.ts +29 -0
  34. package/dist/cron.d.mts +78 -0
  35. package/dist/cron.d.ts +78 -0
  36. package/dist/deferred.d.mts +42 -0
  37. package/dist/deferred.d.ts +42 -0
  38. package/dist/deployment.d.mts +34 -0
  39. package/dist/deployment.d.ts +34 -0
  40. package/dist/docs.d.mts +69 -0
  41. package/dist/docs.d.ts +69 -0
  42. package/dist/env-types.d.mts +12 -0
  43. package/dist/env-types.d.ts +12 -0
  44. package/dist/env.d.mts +45 -0
  45. package/dist/env.d.ts +45 -0
  46. package/dist/environment/vite.d.mts +22 -0
  47. package/dist/environment/vite.d.ts +22 -0
  48. package/dist/environment.d.mts +18 -0
  49. package/dist/environment.d.ts +18 -0
  50. package/dist/font.d.mts +70 -0
  51. package/dist/font.d.ts +70 -0
  52. package/dist/headers.d.mts +22 -0
  53. package/dist/headers.d.ts +22 -0
  54. package/dist/i18n/client.d.mts +32 -0
  55. package/dist/i18n/client.d.ts +32 -0
  56. package/dist/i18n/index.d.mts +20 -0
  57. package/dist/i18n/index.d.ts +20 -0
  58. package/dist/i18n/server.d.mts +30 -0
  59. package/dist/i18n/server.d.ts +30 -0
  60. package/dist/image/server.d.mts +37 -0
  61. package/dist/image/server.d.ts +37 -0
  62. package/dist/image/sharp.d.mts +7 -0
  63. package/dist/image/sharp.d.ts +7 -0
  64. package/dist/image-config-Duob7wER.d.mts +50 -0
  65. package/dist/image-config-Duob7wER.d.ts +50 -0
  66. package/dist/image.d.mts +39 -0
  67. package/dist/image.d.ts +39 -0
  68. package/dist/index.cjs +3 -2
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.d.mts +455 -0
  71. package/dist/index.d.ts +455 -0
  72. package/dist/index.mjs +3 -3
  73. package/dist/integration-api-CHT2OKAf.d.mts +93 -0
  74. package/dist/integration-api-CHT2OKAf.d.ts +93 -0
  75. package/dist/integrations.d.mts +22 -0
  76. package/dist/integrations.d.ts +22 -0
  77. package/dist/internal/build-runtime.cjs +3 -2
  78. package/dist/internal/build-runtime.cjs.map +1 -1
  79. package/dist/internal/build-runtime.d.mts +39 -0
  80. package/dist/internal/build-runtime.d.ts +39 -0
  81. package/dist/internal/build-runtime.mjs +3 -3
  82. package/dist/internal/client-runtime.d.mts +2 -0
  83. package/dist/internal/client-runtime.d.ts +2 -0
  84. package/dist/internal/config-runtime.d.mts +39 -0
  85. package/dist/internal/config-runtime.d.ts +39 -0
  86. package/dist/internal/production-node-env.d.mts +12 -0
  87. package/dist/internal/production-node-env.d.ts +12 -0
  88. package/dist/internal/production-runtime.d.mts +41 -0
  89. package/dist/internal/production-runtime.d.ts +41 -0
  90. package/dist/markdown.d.mts +60 -0
  91. package/dist/markdown.d.ts +60 -0
  92. package/dist/metadata-7ffpT3jr.d.mts +22 -0
  93. package/dist/metadata-JHn-8eht.d.ts +22 -0
  94. package/dist/middleware.d.mts +164 -0
  95. package/dist/middleware.d.ts +164 -0
  96. package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
  97. package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
  98. package/dist/navigation.d.mts +14 -0
  99. package/dist/navigation.d.ts +14 -0
  100. package/dist/observability.d.mts +335 -0
  101. package/dist/observability.d.ts +335 -0
  102. package/dist/params-BALtrRim.d.ts +15 -0
  103. package/dist/params-ry-lxqmy.d.mts +15 -0
  104. package/dist/plugin-BJDf43dc.d.mts +165 -0
  105. package/dist/plugin-BJDf43dc.d.ts +165 -0
  106. package/dist/plugin.cjs +2 -1
  107. package/dist/plugin.cjs.map +1 -1
  108. package/dist/plugin.d.mts +22 -0
  109. package/dist/plugin.d.ts +22 -0
  110. package/dist/plugin.mjs +2 -2
  111. package/dist/production-runtime-9KG7GuvW.d.ts +79 -0
  112. package/dist/production-runtime-B-fweKts.d.mts +79 -0
  113. package/dist/production-runtime-C_B79w2P.d.mts +28 -0
  114. package/dist/production-runtime-DDEM1D2q.d.ts +28 -0
  115. package/dist/query/client.d.mts +61 -0
  116. package/dist/query/client.d.ts +61 -0
  117. package/dist/query/index.d.mts +90 -0
  118. package/dist/query/index.d.ts +90 -0
  119. package/dist/query/parsers.d.mts +25 -0
  120. package/dist/query/parsers.d.ts +25 -0
  121. package/dist/query/server.d.mts +55 -0
  122. package/dist/query/server.d.ts +55 -0
  123. package/dist/request-Dsq4kGW0.d.mts +6 -0
  124. package/dist/request-udtobOLv.d.ts +6 -0
  125. package/dist/request.d.mts +2 -0
  126. package/dist/request.d.ts +2 -0
  127. package/dist/resolver-DJqjLMg_.d.mts +14 -0
  128. package/dist/resolver-IH4RmPEl.d.ts +14 -0
  129. package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
  130. package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
  131. package/dist/router.d.mts +36 -0
  132. package/dist/router.d.ts +36 -0
  133. package/dist/routes.d.mts +224 -0
  134. package/dist/routes.d.ts +224 -0
  135. package/dist/runtime-9nQjVM7X.d.mts +206 -0
  136. package/dist/runtime-Cxpq6xZN.d.mts +27 -0
  137. package/dist/runtime-DgeS2skB.d.ts +206 -0
  138. package/dist/runtime-bv63eUiO.d.ts +27 -0
  139. package/dist/server-action-security.d.mts +43 -0
  140. package/dist/server-action-security.d.ts +43 -0
  141. package/dist/server-fn-client.d.mts +32 -0
  142. package/dist/server-fn-client.d.ts +32 -0
  143. package/dist/server-fn.d.mts +93 -0
  144. package/dist/server-fn.d.ts +93 -0
  145. package/dist/server-plugins.d.mts +55 -0
  146. package/dist/server-plugins.d.ts +55 -0
  147. package/dist/server-query-client.d.mts +50 -0
  148. package/dist/server-query-client.d.ts +50 -0
  149. package/dist/server-query.d.mts +36 -0
  150. package/dist/server-query.d.ts +36 -0
  151. package/dist/server.cjs +3 -2
  152. package/dist/server.cjs.map +1 -1
  153. package/dist/server.d.mts +48 -0
  154. package/dist/server.d.ts +48 -0
  155. package/dist/server.mjs +2 -2
  156. package/dist/storage.d.mts +52 -0
  157. package/dist/storage.d.ts +52 -0
  158. package/dist/testing.d.mts +101 -0
  159. package/dist/testing.d.ts +101 -0
  160. package/dist/transport-BmbGTXA5.d.mts +49 -0
  161. package/dist/transport-BmbGTXA5.d.ts +49 -0
  162. package/dist/types-BMxWr97v.d.mts +81 -0
  163. package/dist/types-BMxWr97v.d.ts +81 -0
  164. package/dist/types-C9N-nk5R.d.mts +53 -0
  165. package/dist/types-C9N-nk5R.d.ts +53 -0
  166. package/dist/types-D1A6-XvH.d.mts +73 -0
  167. package/dist/types-D1A6-XvH.d.ts +73 -0
  168. package/dist/utils-CA0z0c-2.d.ts +23 -0
  169. package/dist/utils-mYVkSOt2.d.mts +23 -0
  170. package/dist/version.cjs +1 -1
  171. package/dist/version.cjs.map +1 -1
  172. package/dist/version.d.mts +3 -0
  173. package/dist/version.d.ts +3 -0
  174. package/dist/version.mjs +1 -1
  175. package/dist/vite.cjs +3 -2
  176. package/dist/vite.cjs.map +1 -1
  177. package/dist/vite.d.mts +22 -0
  178. package/dist/vite.d.ts +22 -0
  179. package/dist/vite.mjs +2 -2
  180. package/dist/workflows.d.mts +110 -0
  181. package/dist/workflows.d.ts +110 -0
  182. package/package.json +1 -1
  183. package/dist/chunk-E2AI2CW7.mjs.map +0 -1
  184. /package/dist/{chunk-DTOWEQRV.mjs.map → chunk-4677KXB7.mjs.map} +0 -0
@@ -0,0 +1,164 @@
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 };
@@ -0,0 +1,13 @@
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 };
@@ -0,0 +1,13 @@
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 };
@@ -0,0 +1,14 @@
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 };
@@ -0,0 +1,14 @@
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 };
@@ -0,0 +1,335 @@
1
+ type FarmEventLevel = "debug" | "info" | "warn" | "error";
2
+ interface FarmEventBase {
3
+ type: string;
4
+ timestamp: number;
5
+ level: FarmEventLevel;
6
+ requestId?: string;
7
+ route?: string;
8
+ pathname?: string;
9
+ }
10
+ type FarmServerEvent = (FarmEventBase & {
11
+ type: "server.start";
12
+ mode: "dev" | "preview" | "production";
13
+ port?: number;
14
+ }) | (FarmEventBase & {
15
+ type: "server.ready";
16
+ url?: string;
17
+ }) | (FarmEventBase & {
18
+ type: "server.shutdown";
19
+ reason?: string;
20
+ });
21
+ type FarmRouteEvent = (FarmEventBase & {
22
+ type: "route.discovered";
23
+ route: string;
24
+ filePath: string;
25
+ }) | (FarmEventBase & {
26
+ type: "route.matched";
27
+ pathname: string;
28
+ route: string;
29
+ params?: Record<string, string>;
30
+ }) | (FarmEventBase & {
31
+ type: "route.notFound";
32
+ pathname: string;
33
+ }) | (FarmEventBase & {
34
+ type: "route.redirect";
35
+ from: string;
36
+ to: string;
37
+ status?: number;
38
+ }) | (FarmEventBase & {
39
+ type: "route.rewrite";
40
+ from: string;
41
+ to: string;
42
+ });
43
+ type FarmRenderEvent = (FarmEventBase & {
44
+ type: "render.start";
45
+ route: string;
46
+ pathname?: string;
47
+ }) | (FarmEventBase & {
48
+ type: "render.complete";
49
+ route: string;
50
+ durationMs: number;
51
+ status?: number;
52
+ }) | (FarmEventBase & {
53
+ type: "render.error";
54
+ route?: string;
55
+ error: unknown;
56
+ }) | (FarmEventBase & {
57
+ type: "render.stream.start";
58
+ route: string;
59
+ }) | (FarmEventBase & {
60
+ type: "render.stream.shellReady";
61
+ route: string;
62
+ durationMs: number;
63
+ }) | (FarmEventBase & {
64
+ type: "render.stream.complete";
65
+ route: string;
66
+ durationMs: number;
67
+ });
68
+ type FarmCacheEvent = (FarmEventBase & {
69
+ type: "cache.hit";
70
+ key: string;
71
+ route?: string;
72
+ tags?: readonly string[];
73
+ revalidate?: number | false;
74
+ stale?: boolean;
75
+ }) | (FarmEventBase & {
76
+ type: "cache.miss";
77
+ key: string;
78
+ route?: string;
79
+ reason?: string;
80
+ }) | (FarmEventBase & {
81
+ type: "cache.set";
82
+ key: string;
83
+ route?: string;
84
+ tags?: readonly string[];
85
+ revalidate?: number | false;
86
+ }) | (FarmEventBase & {
87
+ type: "cache.dedupe";
88
+ key: string;
89
+ }) | (FarmEventBase & {
90
+ type: "cache.bypass";
91
+ key?: string;
92
+ route?: string;
93
+ reason: string;
94
+ }) | (FarmEventBase & {
95
+ type: "cache.stale";
96
+ key: string;
97
+ route?: string;
98
+ tags?: readonly string[];
99
+ revalidate?: number | false;
100
+ }) | (FarmEventBase & {
101
+ type: "cache.revalidatePath";
102
+ path: string;
103
+ count: number;
104
+ }) | (FarmEventBase & {
105
+ type: "cache.revalidateTag";
106
+ tag: string;
107
+ profile?: unknown;
108
+ count: number;
109
+ }) | (FarmEventBase & {
110
+ type: "cache.updateTag";
111
+ tag: string;
112
+ count: number;
113
+ }) | (FarmEventBase & {
114
+ type: "cache.invalidated";
115
+ key?: string;
116
+ route?: string;
117
+ tag?: string;
118
+ reason?: string;
119
+ count?: number;
120
+ }) | (FarmEventBase & {
121
+ type: "cache.delete";
122
+ key: string;
123
+ deleted: boolean;
124
+ }) | (FarmEventBase & {
125
+ type: "cache.clear";
126
+ count: number;
127
+ }) | (FarmEventBase & {
128
+ type: "cache.error";
129
+ key?: string;
130
+ operation: "get" | "set" | "delete" | "revalidate";
131
+ error: unknown;
132
+ });
133
+ type FarmPPREvent = (FarmEventBase & {
134
+ type: "ppr.shell.hit";
135
+ route: string;
136
+ key: string;
137
+ }) | (FarmEventBase & {
138
+ type: "ppr.shell.miss";
139
+ route: string;
140
+ key: string;
141
+ }) | (FarmEventBase & {
142
+ type: "ppr.shell.cached";
143
+ route: string;
144
+ key: string;
145
+ revalidate?: number;
146
+ }) | (FarmEventBase & {
147
+ type: "ppr.shell.bypass";
148
+ route: string;
149
+ reason: string;
150
+ }) | (FarmEventBase & {
151
+ type: "ppr.shell.invalidated";
152
+ route: string;
153
+ reason?: string;
154
+ count?: number;
155
+ }) | (FarmEventBase & {
156
+ type: "ppr.suspense.holeDetected";
157
+ route: string;
158
+ }) | (FarmEventBase & {
159
+ type: "ppr.refresh.start";
160
+ route: string;
161
+ }) | (FarmEventBase & {
162
+ type: "ppr.refresh.complete";
163
+ route: string;
164
+ durationMs: number;
165
+ }) | (FarmEventBase & {
166
+ type: "ppr.refresh.error";
167
+ route: string;
168
+ error: unknown;
169
+ });
170
+ type FarmAPIEvent = (FarmEventBase & {
171
+ type: "api.request.start";
172
+ route: string;
173
+ method: string;
174
+ }) | (FarmEventBase & {
175
+ type: "api.request.complete";
176
+ route: string;
177
+ method: string;
178
+ status: number;
179
+ durationMs: number;
180
+ }) | (FarmEventBase & {
181
+ type: "api.validation.failed";
182
+ route: string;
183
+ method: string;
184
+ issues?: unknown;
185
+ }) | (FarmEventBase & {
186
+ type: "api.error";
187
+ route: string;
188
+ method: string;
189
+ error: unknown;
190
+ });
191
+ type FarmIntegrationEvent = (FarmEventBase & {
192
+ type: "integration.registered";
193
+ name: string;
194
+ }) | (FarmEventBase & {
195
+ type: "integration.config.validated";
196
+ name: string;
197
+ }) | (FarmEventBase & {
198
+ type: "integration.ready";
199
+ name: string;
200
+ }) | (FarmEventBase & {
201
+ type: "integration.disposed";
202
+ name: string;
203
+ }) | (FarmEventBase & {
204
+ type: "integration.api.call.start";
205
+ integration: string;
206
+ operation: string;
207
+ }) | (FarmEventBase & {
208
+ type: "integration.api.call.complete";
209
+ integration: string;
210
+ operation: string;
211
+ durationMs: number;
212
+ }) | (FarmEventBase & {
213
+ type: "integration.api.call.error";
214
+ integration: string;
215
+ operation: string;
216
+ error: unknown;
217
+ }) | (FarmEventBase & {
218
+ type: "integration.webhook.received";
219
+ integration: string;
220
+ event?: string;
221
+ }) | (FarmEventBase & {
222
+ type: "integration.webhook.verified";
223
+ integration: string;
224
+ event?: string;
225
+ }) | (FarmEventBase & {
226
+ type: "integration.webhook.failed";
227
+ integration: string;
228
+ reason: string;
229
+ });
230
+ type FarmMiddlewareEvent = (FarmEventBase & {
231
+ type: "middleware.start";
232
+ route?: string;
233
+ name?: string;
234
+ }) | (FarmEventBase & {
235
+ type: "middleware.complete";
236
+ route?: string;
237
+ name?: string;
238
+ durationMs: number;
239
+ }) | (FarmEventBase & {
240
+ type: "middleware.shortCircuit";
241
+ route?: string;
242
+ name?: string;
243
+ status?: number;
244
+ }) | (FarmEventBase & {
245
+ type: "middleware.error";
246
+ route?: string;
247
+ name?: string;
248
+ error: unknown;
249
+ });
250
+ type FarmStorageEvent = (FarmEventBase & {
251
+ type: "storage.query.start";
252
+ integration?: string;
253
+ operation: string;
254
+ }) | (FarmEventBase & {
255
+ type: "storage.query.complete";
256
+ integration?: string;
257
+ operation: string;
258
+ durationMs: number;
259
+ }) | (FarmEventBase & {
260
+ type: "storage.query.error";
261
+ integration?: string;
262
+ operation: string;
263
+ error: unknown;
264
+ }) | (FarmEventBase & {
265
+ type: "storage.schema.ready";
266
+ integration?: string;
267
+ }) | (FarmEventBase & {
268
+ type: "storage.schema.error";
269
+ integration?: string;
270
+ error: unknown;
271
+ });
272
+ type FarmBuildEvent = (FarmEventBase & {
273
+ type: "build.start";
274
+ target?: string;
275
+ }) | (FarmEventBase & {
276
+ type: "build.complete";
277
+ target?: string;
278
+ durationMs: number;
279
+ }) | (FarmEventBase & {
280
+ type: "build.error";
281
+ target?: string;
282
+ error: unknown;
283
+ }) | (FarmEventBase & {
284
+ type: "routes.generated";
285
+ pageCount: number;
286
+ apiCount?: number;
287
+ }) | (FarmEventBase & {
288
+ type: "types.generated";
289
+ filePath: string;
290
+ }) | (FarmEventBase & {
291
+ type: "manifest.generated";
292
+ routeCount: number;
293
+ });
294
+ type FarmPluginEvent = (FarmEventBase & {
295
+ type: "plugin.hook.start";
296
+ plugin: string;
297
+ hook: string;
298
+ }) | (FarmEventBase & {
299
+ type: "plugin.hook.complete";
300
+ plugin: string;
301
+ hook: string;
302
+ durationMs: number;
303
+ }) | (FarmEventBase & {
304
+ type: "plugin.hook.error";
305
+ plugin: string;
306
+ hook: string;
307
+ error: unknown;
308
+ });
309
+ type FarmErrorEvent = FarmEventBase & {
310
+ type: "error";
311
+ source: string;
312
+ error: unknown;
313
+ route?: string;
314
+ };
315
+ type FarmEvent = FarmServerEvent | FarmRouteEvent | FarmRenderEvent | FarmCacheEvent | FarmPPREvent | FarmAPIEvent | FarmIntegrationEvent | FarmMiddlewareEvent | FarmStorageEvent | FarmBuildEvent | FarmPluginEvent | FarmErrorEvent;
316
+ type FarmEventType = FarmEvent["type"];
317
+ type FarmEventHandler = (event: FarmEvent) => void | Promise<void>;
318
+ type FarmEventInput = FarmEvent extends infer T ? T extends FarmEvent ? Omit<T, "timestamp" | "level"> & Partial<Pick<T, "timestamp" | "level">> : never : never;
319
+ type FarmObservabilityUserConfig = boolean | {
320
+ logs?: boolean;
321
+ onEvent?: FarmEventHandler | readonly FarmEventHandler[];
322
+ events?: readonly FarmEventType[];
323
+ };
324
+ interface FarmResolvedObservabilityConfig {
325
+ logs: boolean;
326
+ handlers: FarmEventHandler[];
327
+ events?: Set<FarmEventType>;
328
+ }
329
+ declare function configureFarmObservability(config: FarmObservabilityUserConfig | undefined): void;
330
+ declare function normalizeFarmObservabilityConfig(config: FarmObservabilityUserConfig | undefined): FarmResolvedObservabilityConfig;
331
+ declare function onFarmEvent(handler: FarmEventHandler): () => void;
332
+ declare function resetFarmObservability(): void;
333
+ declare function emitFarmEvent(input: FarmEventInput): FarmEvent;
334
+
335
+ export { type FarmAPIEvent, type FarmBuildEvent, type FarmCacheEvent, type FarmErrorEvent, type FarmEvent, type FarmEventBase, type FarmEventHandler, type FarmEventInput, type FarmEventLevel, type FarmEventType, type FarmIntegrationEvent, type FarmMiddlewareEvent, type FarmObservabilityUserConfig, type FarmPPREvent, type FarmPluginEvent, type FarmRenderEvent, type FarmResolvedObservabilityConfig, type FarmRouteEvent, type FarmServerEvent, type FarmStorageEvent, configureFarmObservability, emitFarmEvent, normalizeFarmObservabilityConfig, onFarmEvent, resetFarmObservability };