@farm.js/core 0.1.0-beta.16 → 0.1.0-beta.17

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 (215) 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 +96 -0
  4. package/dist/agent-runtime.d.ts +96 -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-B0tE1I3o.d.ts +306 -0
  12. package/dist/app-Dv2JJb7X.d.mts +306 -0
  13. package/dist/app-markdown.d.mts +24 -0
  14. package/dist/app-markdown.d.ts +24 -0
  15. package/dist/cache.d.mts +192 -0
  16. package/dist/cache.d.ts +192 -0
  17. package/dist/{chunk-AN3PQVKH.mjs → chunk-2FLBZFPG.mjs} +9 -7
  18. package/dist/chunk-2FLBZFPG.mjs.map +1 -0
  19. package/dist/chunk-E257KFBU.mjs +227 -0
  20. package/dist/chunk-E257KFBU.mjs.map +1 -0
  21. package/dist/{chunk-SLDBGSC3.mjs → chunk-JAEAE27K.mjs} +2 -2
  22. package/dist/{chunk-T2KL7VEL.mjs → chunk-PZXBQKCH.mjs} +13 -4
  23. package/dist/chunk-PZXBQKCH.mjs.map +1 -0
  24. package/dist/{chunk-UXUAWNO5.mjs → chunk-RIXKJPGI.mjs} +117 -55
  25. package/dist/chunk-RIXKJPGI.mjs.map +1 -0
  26. package/dist/{chunk-OSWV5IJB.mjs → chunk-T2M5QANG.mjs} +32 -9
  27. package/dist/chunk-T2M5QANG.mjs.map +1 -0
  28. package/dist/{chunk-BWJC5ZOD.mjs → chunk-VFDBC3W7.mjs} +2 -2
  29. package/dist/{chunk-BWJC5ZOD.mjs.map → chunk-VFDBC3W7.mjs.map} +1 -1
  30. package/dist/chunk-recovery-lnQFzcQP.d.mts +26 -0
  31. package/dist/chunk-recovery-lnQFzcQP.d.ts +26 -0
  32. package/dist/client-BT1mFQas.d.mts +447 -0
  33. package/dist/client-Nn0q4eO4.d.ts +447 -0
  34. package/dist/client-cache-CIlyBlmx.d.ts +6 -0
  35. package/dist/client-cache-D-EZ7XVW.d.mts +6 -0
  36. package/dist/client-plugins-278AvYHE.d.mts +2021 -0
  37. package/dist/client-plugins-CTQAkr7R.d.ts +2021 -0
  38. package/dist/client-plugins.d.mts +24 -0
  39. package/dist/client-plugins.d.ts +24 -0
  40. package/dist/client.d.mts +452 -0
  41. package/dist/client.d.ts +452 -0
  42. package/dist/config.d.mts +31 -0
  43. package/dist/config.d.ts +31 -0
  44. package/dist/cron.d.mts +78 -0
  45. package/dist/cron.d.ts +78 -0
  46. package/dist/deferred.d.mts +42 -0
  47. package/dist/deferred.d.ts +42 -0
  48. package/dist/deployment.d.mts +36 -0
  49. package/dist/deployment.d.ts +36 -0
  50. package/dist/{devtools-E4YNCY5J.mjs → devtools-K2ERKGNI.mjs} +3 -3
  51. package/dist/docs.cjs.map +1 -1
  52. package/dist/docs.d.mts +80 -0
  53. package/dist/docs.d.ts +80 -0
  54. package/dist/docs.mjs +3 -3
  55. package/dist/env-types.d.mts +12 -0
  56. package/dist/env-types.d.ts +12 -0
  57. package/dist/env.d.mts +45 -0
  58. package/dist/env.d.ts +45 -0
  59. package/dist/environment/vite.d.mts +22 -0
  60. package/dist/environment/vite.d.ts +22 -0
  61. package/dist/environment.d.mts +18 -0
  62. package/dist/environment.d.ts +18 -0
  63. package/dist/font.d.mts +95 -0
  64. package/dist/font.d.ts +95 -0
  65. package/dist/headers.d.mts +22 -0
  66. package/dist/headers.d.ts +22 -0
  67. package/dist/i18n/client.d.mts +32 -0
  68. package/dist/i18n/client.d.ts +32 -0
  69. package/dist/i18n/index.d.mts +20 -0
  70. package/dist/i18n/index.d.ts +20 -0
  71. package/dist/i18n/server.d.mts +30 -0
  72. package/dist/i18n/server.d.ts +30 -0
  73. package/dist/image/server.d.mts +37 -0
  74. package/dist/image/server.d.ts +37 -0
  75. package/dist/image/sharp.d.mts +7 -0
  76. package/dist/image/sharp.d.ts +7 -0
  77. package/dist/image-config-Duob7wER.d.mts +50 -0
  78. package/dist/image-config-Duob7wER.d.ts +50 -0
  79. package/dist/image.d.mts +39 -0
  80. package/dist/image.d.ts +39 -0
  81. package/dist/index.cjs +293 -58
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.d.mts +477 -0
  84. package/dist/index.d.ts +477 -0
  85. package/dist/index.mjs +22 -18
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/integration-api-CHT2OKAf.d.mts +93 -0
  88. package/dist/integration-api-CHT2OKAf.d.ts +93 -0
  89. package/dist/integrations.d.mts +24 -0
  90. package/dist/integrations.d.ts +24 -0
  91. package/dist/internal/build-runtime.cjs +306 -137
  92. package/dist/internal/build-runtime.cjs.map +1 -1
  93. package/dist/internal/build-runtime.d.mts +41 -0
  94. package/dist/internal/build-runtime.d.ts +41 -0
  95. package/dist/internal/build-runtime.mjs +7 -7
  96. package/dist/internal/client-runtime.d.mts +17 -0
  97. package/dist/internal/client-runtime.d.ts +17 -0
  98. package/dist/internal/config-runtime.cjs +140 -1
  99. package/dist/internal/config-runtime.cjs.map +1 -1
  100. package/dist/internal/config-runtime.d.mts +41 -0
  101. package/dist/internal/config-runtime.d.ts +41 -0
  102. package/dist/internal/config-runtime.mjs +2 -2
  103. package/dist/internal/metadata-image-runtime.d.mts +25 -0
  104. package/dist/internal/metadata-image-runtime.d.ts +25 -0
  105. package/dist/internal/production-node-env.d.mts +12 -0
  106. package/dist/internal/production-node-env.d.ts +12 -0
  107. package/dist/internal/production-runtime.d.mts +44 -0
  108. package/dist/internal/production-runtime.d.ts +44 -0
  109. package/dist/island-CfGru1MO.d.mts +9 -0
  110. package/dist/island-CfGru1MO.d.ts +9 -0
  111. package/dist/markdown.d.mts +60 -0
  112. package/dist/markdown.d.ts +60 -0
  113. package/dist/metadata-DmCudMw_.d.mts +22 -0
  114. package/dist/metadata-xghtOlbR.d.ts +22 -0
  115. package/dist/middleware.cjs +116 -98
  116. package/dist/middleware.cjs.map +1 -1
  117. package/dist/middleware.d.mts +171 -0
  118. package/dist/middleware.d.ts +171 -0
  119. package/dist/middleware.mjs +5 -2
  120. package/dist/navigation-errors-Dvwpzaer.d.mts +13 -0
  121. package/dist/navigation-errors-Dvwpzaer.d.ts +13 -0
  122. package/dist/navigation.d.mts +14 -0
  123. package/dist/navigation.d.ts +14 -0
  124. package/dist/observability.d.mts +335 -0
  125. package/dist/observability.d.ts +335 -0
  126. package/dist/params-BALtrRim.d.ts +15 -0
  127. package/dist/params-ry-lxqmy.d.mts +15 -0
  128. package/dist/plugin-BJDf43dc.d.mts +165 -0
  129. package/dist/plugin-BJDf43dc.d.ts +165 -0
  130. package/dist/plugin.cjs +132 -0
  131. package/dist/plugin.cjs.map +1 -1
  132. package/dist/plugin.d.mts +24 -0
  133. package/dist/plugin.d.ts +24 -0
  134. package/dist/plugin.mjs +4 -4
  135. package/dist/production-runtime-BLxSv9cU.d.ts +79 -0
  136. package/dist/production-runtime-DFN2_RXq.d.mts +79 -0
  137. package/dist/query/client.d.mts +61 -0
  138. package/dist/query/client.d.ts +61 -0
  139. package/dist/query/index.d.mts +90 -0
  140. package/dist/query/index.d.ts +90 -0
  141. package/dist/query/parsers.d.mts +25 -0
  142. package/dist/query/parsers.d.ts +25 -0
  143. package/dist/query/server.d.mts +55 -0
  144. package/dist/query/server.d.ts +55 -0
  145. package/dist/request-Cq5d6qmE.d.mts +6 -0
  146. package/dist/request-LoxDW3lp.d.ts +6 -0
  147. package/dist/request.d.mts +25 -0
  148. package/dist/request.d.ts +25 -0
  149. package/dist/resolver-DJqjLMg_.d.mts +14 -0
  150. package/dist/resolver-IH4RmPEl.d.ts +14 -0
  151. package/dist/route-runtime-DoOHzCAD.d.mts +38 -0
  152. package/dist/route-runtime-DoOHzCAD.d.ts +38 -0
  153. package/dist/router.d.mts +36 -0
  154. package/dist/router.d.ts +36 -0
  155. package/dist/routes.d.mts +226 -0
  156. package/dist/routes.d.ts +226 -0
  157. package/dist/runtime-BA9TOSu1.d.mts +231 -0
  158. package/dist/runtime-Cxpq6xZN.d.mts +27 -0
  159. package/dist/runtime-DTAQ2HDv.d.ts +231 -0
  160. package/dist/runtime-bv63eUiO.d.ts +27 -0
  161. package/dist/server-action-security.d.mts +45 -0
  162. package/dist/server-action-security.d.ts +45 -0
  163. package/dist/server-fn-client.d.mts +33 -0
  164. package/dist/server-fn-client.d.ts +33 -0
  165. package/dist/server-fn-error-DDh14a0V.d.mts +26 -0
  166. package/dist/server-fn-error-DDh14a0V.d.ts +26 -0
  167. package/dist/server-fn.d.mts +121 -0
  168. package/dist/server-fn.d.ts +121 -0
  169. package/dist/server-plugins.d.mts +57 -0
  170. package/dist/server-plugins.d.ts +57 -0
  171. package/dist/server-query-client.d.mts +51 -0
  172. package/dist/server-query-client.d.ts +51 -0
  173. package/dist/server-query.d.mts +37 -0
  174. package/dist/server-query.d.ts +37 -0
  175. package/dist/server.cjs +170 -3
  176. package/dist/server.cjs.map +1 -1
  177. package/dist/server.d.mts +51 -0
  178. package/dist/server.d.ts +51 -0
  179. package/dist/server.mjs +6 -6
  180. package/dist/storage.d.mts +52 -0
  181. package/dist/storage.d.ts +52 -0
  182. package/dist/testing.d.mts +103 -0
  183. package/dist/testing.d.ts +103 -0
  184. package/dist/transport-BmbGTXA5.d.mts +49 -0
  185. package/dist/transport-BmbGTXA5.d.ts +49 -0
  186. package/dist/types-BMxWr97v.d.mts +81 -0
  187. package/dist/types-BMxWr97v.d.ts +81 -0
  188. package/dist/types-D1A6-XvH.d.mts +73 -0
  189. package/dist/types-D1A6-XvH.d.ts +73 -0
  190. package/dist/types-DTzm4TCl.d.mts +78 -0
  191. package/dist/types-DTzm4TCl.d.ts +78 -0
  192. package/dist/utils-B6GaYNJL.d.ts +23 -0
  193. package/dist/utils-CKSHiip6.d.mts +23 -0
  194. package/dist/version.cjs +1 -1
  195. package/dist/version.cjs.map +1 -1
  196. package/dist/version.d.mts +3 -0
  197. package/dist/version.d.ts +3 -0
  198. package/dist/version.mjs +1 -1
  199. package/dist/vite.cjs +140 -2
  200. package/dist/vite.cjs.map +1 -1
  201. package/dist/vite.d.mts +24 -0
  202. package/dist/vite.d.ts +24 -0
  203. package/dist/vite.mjs +4 -4
  204. package/dist/workflows.d.mts +110 -0
  205. package/dist/workflows.d.ts +110 -0
  206. package/package.json +1 -1
  207. package/types/middleware.d.ts +36 -11
  208. package/dist/chunk-AN3PQVKH.mjs.map +0 -1
  209. package/dist/chunk-I4CUBGVF.mjs +0 -93
  210. package/dist/chunk-I4CUBGVF.mjs.map +0 -1
  211. package/dist/chunk-OSWV5IJB.mjs.map +0 -1
  212. package/dist/chunk-T2KL7VEL.mjs.map +0 -1
  213. package/dist/chunk-UXUAWNO5.mjs.map +0 -1
  214. /package/dist/{chunk-SLDBGSC3.mjs.map → chunk-JAEAE27K.mjs.map} +0 -0
  215. /package/dist/{devtools-E4YNCY5J.mjs.map → devtools-K2ERKGNI.mjs.map} +0 -0
@@ -0,0 +1,192 @@
1
+ declare function applyFarmCacheInvalidations(keys: unknown): void;
2
+
3
+ type RevalidateTagProfile = "max" | "default" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | {
4
+ expire?: number;
5
+ };
6
+ interface FarmCacheOptions {
7
+ /**
8
+ * Tag cached data so it can be invalidated with revalidateTag/updateTag.
9
+ */
10
+ tags?: readonly string[];
11
+ /**
12
+ * Path tags let revalidatePath invalidate data tied to a route.
13
+ */
14
+ paths?: readonly string[];
15
+ /**
16
+ * Time in seconds before the entry becomes stale. False means no TTL.
17
+ */
18
+ revalidate?: number | false;
19
+ }
20
+ interface FarmCacheSetOptions extends FarmCacheOptions {
21
+ createdAt?: number;
22
+ }
23
+ type RouteDataCacheKey = string | readonly unknown[];
24
+ type FarmCacheInvalidationTarget = {
25
+ key: RouteDataCacheKey;
26
+ } | {
27
+ path: string;
28
+ } | {
29
+ tag: string;
30
+ };
31
+ declare const FARM_DEFINED_CACHE_KEY_DATA: unique symbol;
32
+ /**
33
+ * A regular Farm cache key carrying the data shape stored under that key.
34
+ *
35
+ * The brand exists only in TypeScript. At runtime the value remains the
36
+ * original string or structured array, so all existing cache APIs continue to
37
+ * accept untyped keys.
38
+ */
39
+ type DefinedCacheKey<TData, TKey extends RouteDataCacheKey = RouteDataCacheKey> = TKey & {
40
+ readonly [FARM_DEFINED_CACHE_KEY_DATA]: TData;
41
+ };
42
+ type CacheKeyFactory<TData, TArguments extends readonly unknown[], TKey extends RouteDataCacheKey = RouteDataCacheKey> = (...args: TArguments) => DefinedCacheKey<TData, TKey>;
43
+ type InferCacheKeyData<TKey> = TKey extends DefinedCacheKey<infer TData, RouteDataCacheKey> ? TData : unknown;
44
+ /**
45
+ * Optionally add a data type to an existing string/array cache-key factory.
46
+ *
47
+ * This helper does not introduce a new runtime key representation. Calling the
48
+ * returned factory produces the exact key returned by `factory`.
49
+ */
50
+ declare function defineCacheKey<TData>(): <const TArguments extends readonly unknown[], const TKey extends RouteDataCacheKey>(factory: (...args: TArguments) => TKey) => CacheKeyFactory<TData, TArguments, TKey>;
51
+ interface FarmCacheEntry<T = unknown> {
52
+ key: string;
53
+ value: T;
54
+ tags: readonly string[];
55
+ /**
56
+ * Adapter tag versions captured before the cached value was produced.
57
+ * A later version makes the entry stale across every server instance.
58
+ */
59
+ tagVersions?: Readonly<Record<string, number>>;
60
+ createdAt: number;
61
+ createdVersion?: number;
62
+ revalidate?: number | false;
63
+ }
64
+ /**
65
+ * Asynchronous persistence contract used by distributed Farm caches.
66
+ *
67
+ * Implementations are responsible for serializing cache entries and making
68
+ * tag version updates atomic when the backing service supports it.
69
+ */
70
+ interface FarmCacheAdapter {
71
+ readonly name?: string;
72
+ get<T = unknown>(key: string): Promise<FarmCacheEntry<T> | null | undefined>;
73
+ set<T = unknown>(key: string, entry: FarmCacheEntry<T>): Promise<void>;
74
+ delete(key: string): Promise<void>;
75
+ clear?(): Promise<void>;
76
+ getTagVersions?(tags: readonly string[]): Promise<Readonly<Record<string, number>>>;
77
+ invalidateTags?(tags: readonly string[]): Promise<void>;
78
+ /** Atomically acquire a short-lived regeneration lease. */
79
+ acquireLease?(key: string, ttlMs: number): Promise<string | null | undefined>;
80
+ /** Release the lease only when the supplied ownership token still matches. */
81
+ releaseLease?(key: string, token: string): Promise<void>;
82
+ }
83
+ interface FarmCacheUserConfig {
84
+ /** Shared cache implementation, for example a Redis-backed adapter. */
85
+ adapter?: FarmCacheAdapter;
86
+ /** Prefix isolating applications and deployments sharing one adapter. */
87
+ namespace?: string;
88
+ /**
89
+ * Coordinate cache fills across processes when the adapter implements
90
+ * acquireLease/releaseLease. Set false to disable.
91
+ */
92
+ lease?: false | {
93
+ ttlMs?: number;
94
+ waitTimeoutMs?: number;
95
+ pollIntervalMs?: number;
96
+ };
97
+ }
98
+ interface FarmCacheStorage {
99
+ getItem<T = unknown>(key: string): Promise<T | null>;
100
+ setItem<T = unknown>(key: string, value: T): Promise<unknown>;
101
+ removeItem(key: string): Promise<unknown>;
102
+ clear?(base?: string): Promise<unknown>;
103
+ }
104
+ interface StorageFarmCacheAdapterOptions {
105
+ /** Prefix used inside the supplied storage client. */
106
+ base?: string;
107
+ }
108
+ /**
109
+ * Adapt a Farm/unstorage-compatible key-value client to the cache contract.
110
+ *
111
+ * This is a portable baseline adapter. Provider-specific adapters should use
112
+ * their atomic increment/transaction primitives for tag invalidation.
113
+ */
114
+ declare function storageCacheAdapter(storage: FarmCacheStorage, options?: StorageFarmCacheAdapterOptions): FarmCacheAdapter;
115
+ interface GetFarmCacheEntryOptions {
116
+ allowStale?: boolean;
117
+ now?: number;
118
+ }
119
+ interface FarmCacheStaleEntry {
120
+ tags: Iterable<string>;
121
+ createdAt: number;
122
+ createdVersion?: number;
123
+ revalidate?: number | false;
124
+ }
125
+ declare class FarmDataCache {
126
+ private entries;
127
+ private inflight;
128
+ private invalidatedTagVersions;
129
+ private version;
130
+ private adapter?;
131
+ private namespace;
132
+ private local;
133
+ private lease;
134
+ constructor(config?: FarmCacheUserConfig);
135
+ configure(config?: FarmCacheUserConfig): void;
136
+ get adapterName(): string;
137
+ get hasAdapter(): boolean;
138
+ get size(): number;
139
+ get<T>(key: string, options?: GetFarmCacheEntryOptions): T | undefined;
140
+ getEntry<T = unknown>(key: string, options?: GetFarmCacheEntryOptions): FarmCacheEntry<T> | undefined;
141
+ getEntryAsync<T = unknown>(key: string, options?: GetFarmCacheEntryOptions): Promise<FarmCacheEntry<T> | undefined>;
142
+ set<T>(key: string, value: T, options?: FarmCacheSetOptions): FarmCacheEntry<T>;
143
+ setAsync<T>(key: string, value: T, options?: FarmCacheSetOptions, tagVersions?: Readonly<Record<string, number>>): Promise<FarmCacheEntry<T>>;
144
+ delete(key: string): boolean;
145
+ deleteAsync(key: string): Promise<boolean>;
146
+ clear(): void;
147
+ clearAsync(): Promise<void>;
148
+ isStale(entry: FarmCacheStaleEntry, now?: number): boolean;
149
+ isStaleAsync(entry: FarmCacheEntry, now?: number): Promise<boolean>;
150
+ revalidateTag(tag: string, options?: {
151
+ source?: "revalidateTag" | "updateTag";
152
+ profile?: RevalidateTagProfile;
153
+ }): number;
154
+ revalidateTagAsync(tag: string, options?: {
155
+ source?: "revalidateTag" | "updateTag";
156
+ profile?: RevalidateTagProfile;
157
+ }): Promise<number>;
158
+ revalidatePath(routePath: string): number;
159
+ revalidatePathAsync(routePath: string): Promise<number>;
160
+ getOrSet<T>(key: string, producer: () => Promise<T> | T, options?: FarmCacheOptions): Promise<T>;
161
+ private fillCacheEntry;
162
+ private waitForAdapterEntry;
163
+ private countEntriesForTag;
164
+ private countEntriesForTags;
165
+ private invalidateTag;
166
+ private toPublicEntry;
167
+ private hydrateLocalEntry;
168
+ private createAdapterKey;
169
+ private createAdapterTag;
170
+ private getAdapterTagVersions;
171
+ private isAdapterEntryStale;
172
+ }
173
+ declare function getFarmDataCache(): FarmDataCache;
174
+ declare function configureFarmCache(config: FarmCacheUserConfig | undefined): void;
175
+ declare function unstable_cache<Args extends unknown[], Result>(fn: (...args: Args) => Result | Promise<Result>, keyParts?: readonly unknown[], options?: FarmCacheOptions): (...args: Args) => Promise<Result>;
176
+ declare function revalidateTag(_tag: string, _profile?: RevalidateTagProfile): void | Promise<void>;
177
+ declare function updateTag(tag: string): void | Promise<void>;
178
+ declare function revalidatePath(routePath: string): void | Promise<void>;
179
+ declare function invalidate(key: RouteDataCacheKey): void | Promise<void>;
180
+ declare function invalidateRouteData(key: RouteDataCacheKey): void | Promise<void>;
181
+ /**
182
+ * Apply a normalized set of invalidation targets and return browser cache keys
183
+ * that should be carried with an action/endpoint response.
184
+ */
185
+ declare function applyFarmCacheInvalidationTargets(targets: readonly FarmCacheInvalidationTarget[]): Promise<readonly string[]>;
186
+ declare function createPathCacheTag(routePath: string): string;
187
+ declare function createRouteDataCacheTag(key: RouteDataCacheKey): string;
188
+ declare function createRouteDataCacheKey(key: RouteDataCacheKey): string;
189
+ declare function normalizeRevalidatePath(routePath: string): string;
190
+ declare function createFarmCacheKey(parts: readonly unknown[]): string;
191
+
192
+ export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
@@ -0,0 +1,192 @@
1
+ declare function applyFarmCacheInvalidations(keys: unknown): void;
2
+
3
+ type RevalidateTagProfile = "max" | "default" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | {
4
+ expire?: number;
5
+ };
6
+ interface FarmCacheOptions {
7
+ /**
8
+ * Tag cached data so it can be invalidated with revalidateTag/updateTag.
9
+ */
10
+ tags?: readonly string[];
11
+ /**
12
+ * Path tags let revalidatePath invalidate data tied to a route.
13
+ */
14
+ paths?: readonly string[];
15
+ /**
16
+ * Time in seconds before the entry becomes stale. False means no TTL.
17
+ */
18
+ revalidate?: number | false;
19
+ }
20
+ interface FarmCacheSetOptions extends FarmCacheOptions {
21
+ createdAt?: number;
22
+ }
23
+ type RouteDataCacheKey = string | readonly unknown[];
24
+ type FarmCacheInvalidationTarget = {
25
+ key: RouteDataCacheKey;
26
+ } | {
27
+ path: string;
28
+ } | {
29
+ tag: string;
30
+ };
31
+ declare const FARM_DEFINED_CACHE_KEY_DATA: unique symbol;
32
+ /**
33
+ * A regular Farm cache key carrying the data shape stored under that key.
34
+ *
35
+ * The brand exists only in TypeScript. At runtime the value remains the
36
+ * original string or structured array, so all existing cache APIs continue to
37
+ * accept untyped keys.
38
+ */
39
+ type DefinedCacheKey<TData, TKey extends RouteDataCacheKey = RouteDataCacheKey> = TKey & {
40
+ readonly [FARM_DEFINED_CACHE_KEY_DATA]: TData;
41
+ };
42
+ type CacheKeyFactory<TData, TArguments extends readonly unknown[], TKey extends RouteDataCacheKey = RouteDataCacheKey> = (...args: TArguments) => DefinedCacheKey<TData, TKey>;
43
+ type InferCacheKeyData<TKey> = TKey extends DefinedCacheKey<infer TData, RouteDataCacheKey> ? TData : unknown;
44
+ /**
45
+ * Optionally add a data type to an existing string/array cache-key factory.
46
+ *
47
+ * This helper does not introduce a new runtime key representation. Calling the
48
+ * returned factory produces the exact key returned by `factory`.
49
+ */
50
+ declare function defineCacheKey<TData>(): <const TArguments extends readonly unknown[], const TKey extends RouteDataCacheKey>(factory: (...args: TArguments) => TKey) => CacheKeyFactory<TData, TArguments, TKey>;
51
+ interface FarmCacheEntry<T = unknown> {
52
+ key: string;
53
+ value: T;
54
+ tags: readonly string[];
55
+ /**
56
+ * Adapter tag versions captured before the cached value was produced.
57
+ * A later version makes the entry stale across every server instance.
58
+ */
59
+ tagVersions?: Readonly<Record<string, number>>;
60
+ createdAt: number;
61
+ createdVersion?: number;
62
+ revalidate?: number | false;
63
+ }
64
+ /**
65
+ * Asynchronous persistence contract used by distributed Farm caches.
66
+ *
67
+ * Implementations are responsible for serializing cache entries and making
68
+ * tag version updates atomic when the backing service supports it.
69
+ */
70
+ interface FarmCacheAdapter {
71
+ readonly name?: string;
72
+ get<T = unknown>(key: string): Promise<FarmCacheEntry<T> | null | undefined>;
73
+ set<T = unknown>(key: string, entry: FarmCacheEntry<T>): Promise<void>;
74
+ delete(key: string): Promise<void>;
75
+ clear?(): Promise<void>;
76
+ getTagVersions?(tags: readonly string[]): Promise<Readonly<Record<string, number>>>;
77
+ invalidateTags?(tags: readonly string[]): Promise<void>;
78
+ /** Atomically acquire a short-lived regeneration lease. */
79
+ acquireLease?(key: string, ttlMs: number): Promise<string | null | undefined>;
80
+ /** Release the lease only when the supplied ownership token still matches. */
81
+ releaseLease?(key: string, token: string): Promise<void>;
82
+ }
83
+ interface FarmCacheUserConfig {
84
+ /** Shared cache implementation, for example a Redis-backed adapter. */
85
+ adapter?: FarmCacheAdapter;
86
+ /** Prefix isolating applications and deployments sharing one adapter. */
87
+ namespace?: string;
88
+ /**
89
+ * Coordinate cache fills across processes when the adapter implements
90
+ * acquireLease/releaseLease. Set false to disable.
91
+ */
92
+ lease?: false | {
93
+ ttlMs?: number;
94
+ waitTimeoutMs?: number;
95
+ pollIntervalMs?: number;
96
+ };
97
+ }
98
+ interface FarmCacheStorage {
99
+ getItem<T = unknown>(key: string): Promise<T | null>;
100
+ setItem<T = unknown>(key: string, value: T): Promise<unknown>;
101
+ removeItem(key: string): Promise<unknown>;
102
+ clear?(base?: string): Promise<unknown>;
103
+ }
104
+ interface StorageFarmCacheAdapterOptions {
105
+ /** Prefix used inside the supplied storage client. */
106
+ base?: string;
107
+ }
108
+ /**
109
+ * Adapt a Farm/unstorage-compatible key-value client to the cache contract.
110
+ *
111
+ * This is a portable baseline adapter. Provider-specific adapters should use
112
+ * their atomic increment/transaction primitives for tag invalidation.
113
+ */
114
+ declare function storageCacheAdapter(storage: FarmCacheStorage, options?: StorageFarmCacheAdapterOptions): FarmCacheAdapter;
115
+ interface GetFarmCacheEntryOptions {
116
+ allowStale?: boolean;
117
+ now?: number;
118
+ }
119
+ interface FarmCacheStaleEntry {
120
+ tags: Iterable<string>;
121
+ createdAt: number;
122
+ createdVersion?: number;
123
+ revalidate?: number | false;
124
+ }
125
+ declare class FarmDataCache {
126
+ private entries;
127
+ private inflight;
128
+ private invalidatedTagVersions;
129
+ private version;
130
+ private adapter?;
131
+ private namespace;
132
+ private local;
133
+ private lease;
134
+ constructor(config?: FarmCacheUserConfig);
135
+ configure(config?: FarmCacheUserConfig): void;
136
+ get adapterName(): string;
137
+ get hasAdapter(): boolean;
138
+ get size(): number;
139
+ get<T>(key: string, options?: GetFarmCacheEntryOptions): T | undefined;
140
+ getEntry<T = unknown>(key: string, options?: GetFarmCacheEntryOptions): FarmCacheEntry<T> | undefined;
141
+ getEntryAsync<T = unknown>(key: string, options?: GetFarmCacheEntryOptions): Promise<FarmCacheEntry<T> | undefined>;
142
+ set<T>(key: string, value: T, options?: FarmCacheSetOptions): FarmCacheEntry<T>;
143
+ setAsync<T>(key: string, value: T, options?: FarmCacheSetOptions, tagVersions?: Readonly<Record<string, number>>): Promise<FarmCacheEntry<T>>;
144
+ delete(key: string): boolean;
145
+ deleteAsync(key: string): Promise<boolean>;
146
+ clear(): void;
147
+ clearAsync(): Promise<void>;
148
+ isStale(entry: FarmCacheStaleEntry, now?: number): boolean;
149
+ isStaleAsync(entry: FarmCacheEntry, now?: number): Promise<boolean>;
150
+ revalidateTag(tag: string, options?: {
151
+ source?: "revalidateTag" | "updateTag";
152
+ profile?: RevalidateTagProfile;
153
+ }): number;
154
+ revalidateTagAsync(tag: string, options?: {
155
+ source?: "revalidateTag" | "updateTag";
156
+ profile?: RevalidateTagProfile;
157
+ }): Promise<number>;
158
+ revalidatePath(routePath: string): number;
159
+ revalidatePathAsync(routePath: string): Promise<number>;
160
+ getOrSet<T>(key: string, producer: () => Promise<T> | T, options?: FarmCacheOptions): Promise<T>;
161
+ private fillCacheEntry;
162
+ private waitForAdapterEntry;
163
+ private countEntriesForTag;
164
+ private countEntriesForTags;
165
+ private invalidateTag;
166
+ private toPublicEntry;
167
+ private hydrateLocalEntry;
168
+ private createAdapterKey;
169
+ private createAdapterTag;
170
+ private getAdapterTagVersions;
171
+ private isAdapterEntryStale;
172
+ }
173
+ declare function getFarmDataCache(): FarmDataCache;
174
+ declare function configureFarmCache(config: FarmCacheUserConfig | undefined): void;
175
+ declare function unstable_cache<Args extends unknown[], Result>(fn: (...args: Args) => Result | Promise<Result>, keyParts?: readonly unknown[], options?: FarmCacheOptions): (...args: Args) => Promise<Result>;
176
+ declare function revalidateTag(_tag: string, _profile?: RevalidateTagProfile): void | Promise<void>;
177
+ declare function updateTag(tag: string): void | Promise<void>;
178
+ declare function revalidatePath(routePath: string): void | Promise<void>;
179
+ declare function invalidate(key: RouteDataCacheKey): void | Promise<void>;
180
+ declare function invalidateRouteData(key: RouteDataCacheKey): void | Promise<void>;
181
+ /**
182
+ * Apply a normalized set of invalidation targets and return browser cache keys
183
+ * that should be carried with an action/endpoint response.
184
+ */
185
+ declare function applyFarmCacheInvalidationTargets(targets: readonly FarmCacheInvalidationTarget[]): Promise<readonly string[]>;
186
+ declare function createPathCacheTag(routePath: string): string;
187
+ declare function createRouteDataCacheTag(key: RouteDataCacheKey): string;
188
+ declare function createRouteDataCacheKey(key: RouteDataCacheKey): string;
189
+ declare function normalizeRevalidatePath(routePath: string): string;
190
+ declare function createFarmCacheKey(parts: readonly unknown[]): string;
191
+
192
+ export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
@@ -9,7 +9,7 @@ import {
9
9
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
10
10
  createFarmDocsLastModifiedManifest,
11
11
  getFarmDocsRouteTypeEntries
12
- } from "./chunk-SLDBGSC3.mjs";
12
+ } from "./chunk-JAEAE27K.mjs";
13
13
  import {
14
14
  generateFarmDocsSearchClientRuntime,
15
15
  isFarmDocsSearchEnabled,
@@ -18,12 +18,13 @@ import {
18
18
  import {
19
19
  hasCustomFarmRouteContext,
20
20
  resolveDeployOutputPath
21
- } from "./chunk-T2KL7VEL.mjs";
21
+ } from "./chunk-PZXBQKCH.mjs";
22
22
  import {
23
23
  PluginManager
24
24
  } from "./chunk-DJSGLHCN.mjs";
25
25
  import {
26
26
  createFarmApp,
27
+ createFarmSourceAlias,
27
28
  farmFontImportsPlugin,
28
29
  generateFarmClientPluginEntryCode,
29
30
  generateFarmTypeArtifacts,
@@ -31,7 +32,7 @@ import {
31
32
  mergeFarmFontCss,
32
33
  mergeFarmViteConfig,
33
34
  resolveRouteRenderingConfigFromFile
34
- } from "./chunk-OSWV5IJB.mjs";
35
+ } from "./chunk-T2M5QANG.mjs";
35
36
  import {
36
37
  farmEnvironmentFunctionsPlugin
37
38
  } from "./chunk-V6WE6JSZ.mjs";
@@ -2783,9 +2784,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
2783
2784
  postcss: postcssConfigDir
2784
2785
  } : void 0,
2785
2786
  resolve: {
2786
- alias: {
2787
- "@": path3.resolve(root, "src")
2788
- },
2787
+ alias: createFarmSourceAlias(root, config.srcDir),
2789
2788
  // Programmatic route wrappers are created inside @farm.js/core. Resolve
2790
2789
  // their React imports from the application so React 18/19 elements and
2791
2790
  // the selected server renderer always share the same runtime instance.
@@ -6399,6 +6398,9 @@ async function createProjectModuleServer(createViteServer, config, root) {
6399
6398
  middlewareMode: true,
6400
6399
  hmr: false
6401
6400
  },
6401
+ resolve: {
6402
+ alias: createFarmSourceAlias(root, config.srcDir)
6403
+ },
6402
6404
  optimizeDeps: {
6403
6405
  noDiscovery: true
6404
6406
  },
@@ -6583,4 +6585,4 @@ __name(buildNitro, "buildNitro");
6583
6585
  export {
6584
6586
  build
6585
6587
  };
6586
- //# sourceMappingURL=chunk-AN3PQVKH.mjs.map
6588
+ //# sourceMappingURL=chunk-2FLBZFPG.mjs.map