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

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 (238) hide show
  1. package/dist/chunk-53MVSX3R.mjs +168 -0
  2. package/dist/chunk-53MVSX3R.mjs.map +1 -0
  3. package/dist/{chunk-AW6I64AP.mjs → chunk-6ZXIQSXE.mjs} +16 -1
  4. package/dist/chunk-6ZXIQSXE.mjs.map +1 -0
  5. package/dist/chunk-7ZVN3YZI.mjs +333 -0
  6. package/dist/chunk-7ZVN3YZI.mjs.map +1 -0
  7. package/dist/{chunk-5EVQFRL2.mjs → chunk-ARCGE2VT.mjs} +2 -2
  8. package/dist/chunk-ARCGE2VT.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-77BOAQHI.mjs → chunk-PNFQQSRA.mjs} +754 -156
  17. package/dist/chunk-PNFQQSRA.mjs.map +1 -0
  18. package/dist/chunk-USLFXFFH.mjs +46 -0
  19. package/dist/chunk-USLFXFFH.mjs.map +1 -0
  20. package/dist/{chunk-4677KXB7.mjs → chunk-VUL55IAX.mjs} +368 -103
  21. package/dist/chunk-VUL55IAX.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 +2235 -689
  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 +2062 -525
  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 +1550 -348
  57. package/dist/plugin.cjs.map +1 -1
  58. package/dist/plugin.mjs +9 -5
  59. package/dist/server.cjs +1663 -419
  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 +1604 -358
  67. package/dist/vite.cjs.map +1 -1
  68. package/dist/vite.mjs +9 -5
  69. package/package.json +10 -1
  70. package/types/client.d.ts +115 -4
  71. package/dist/after.d.mts +0 -25
  72. package/dist/after.d.ts +0 -25
  73. package/dist/agent-runtime.d.mts +0 -94
  74. package/dist/agent-runtime.d.ts +0 -94
  75. package/dist/api/route-manager.d.mts +0 -66
  76. package/dist/api/route-manager.d.ts +0 -66
  77. package/dist/api/runtime.d.mts +0 -3
  78. package/dist/api/runtime.d.ts +0 -3
  79. package/dist/api.d.mts +0 -48
  80. package/dist/api.d.ts +0 -48
  81. package/dist/app-BNE2FoZ4.d.mts +0 -302
  82. package/dist/app-DRGUmJ3s.d.ts +0 -302
  83. package/dist/app-markdown.d.mts +0 -22
  84. package/dist/app-markdown.d.ts +0 -22
  85. package/dist/cache.d.mts +0 -192
  86. package/dist/cache.d.ts +0 -192
  87. package/dist/chunk-4677KXB7.mjs.map +0 -1
  88. package/dist/chunk-4LND3PXF.mjs.map +0 -1
  89. package/dist/chunk-5EVQFRL2.mjs.map +0 -1
  90. package/dist/chunk-77BOAQHI.mjs.map +0 -1
  91. package/dist/chunk-AW6I64AP.mjs.map +0 -1
  92. package/dist/chunk-K5ZTUF22.mjs.map +0 -1
  93. package/dist/chunk-QM746KUO.mjs +0 -56
  94. package/dist/chunk-QM746KUO.mjs.map +0 -1
  95. package/dist/chunk-QTZZ2ISQ.mjs.map +0 -1
  96. package/dist/client-BT1mFQas.d.mts +0 -447
  97. package/dist/client-Nn0q4eO4.d.ts +0 -447
  98. package/dist/client-cache-CIlyBlmx.d.ts +0 -6
  99. package/dist/client-cache-D-EZ7XVW.d.mts +0 -6
  100. package/dist/client-plugins-Bc5jHcNr.d.ts +0 -1927
  101. package/dist/client-plugins-jsk-ZLzJ.d.mts +0 -1927
  102. package/dist/client-plugins.d.mts +0 -22
  103. package/dist/client-plugins.d.ts +0 -22
  104. package/dist/client.d.mts +0 -447
  105. package/dist/client.d.ts +0 -447
  106. package/dist/config.d.mts +0 -29
  107. package/dist/config.d.ts +0 -29
  108. package/dist/cron.d.mts +0 -78
  109. package/dist/cron.d.ts +0 -78
  110. package/dist/deferred.d.mts +0 -42
  111. package/dist/deferred.d.ts +0 -42
  112. package/dist/deployment.d.mts +0 -34
  113. package/dist/deployment.d.ts +0 -34
  114. package/dist/docs.d.mts +0 -69
  115. package/dist/docs.d.ts +0 -69
  116. package/dist/env-types.d.mts +0 -12
  117. package/dist/env-types.d.ts +0 -12
  118. package/dist/env.d.mts +0 -45
  119. package/dist/env.d.ts +0 -45
  120. package/dist/environment/vite.d.mts +0 -22
  121. package/dist/environment/vite.d.ts +0 -22
  122. package/dist/environment.d.mts +0 -18
  123. package/dist/environment.d.ts +0 -18
  124. package/dist/font.d.mts +0 -70
  125. package/dist/font.d.ts +0 -70
  126. package/dist/headers.d.mts +0 -22
  127. package/dist/headers.d.ts +0 -22
  128. package/dist/i18n/client.d.mts +0 -32
  129. package/dist/i18n/client.d.ts +0 -32
  130. package/dist/i18n/index.d.mts +0 -20
  131. package/dist/i18n/index.d.ts +0 -20
  132. package/dist/i18n/server.d.mts +0 -30
  133. package/dist/i18n/server.d.ts +0 -30
  134. package/dist/image/server.d.mts +0 -37
  135. package/dist/image/server.d.ts +0 -37
  136. package/dist/image/sharp.d.mts +0 -7
  137. package/dist/image/sharp.d.ts +0 -7
  138. package/dist/image-config-Duob7wER.d.mts +0 -50
  139. package/dist/image-config-Duob7wER.d.ts +0 -50
  140. package/dist/image.d.mts +0 -39
  141. package/dist/image.d.ts +0 -39
  142. package/dist/index.d.mts +0 -455
  143. package/dist/index.d.ts +0 -455
  144. package/dist/integration-api-CHT2OKAf.d.mts +0 -93
  145. package/dist/integration-api-CHT2OKAf.d.ts +0 -93
  146. package/dist/integrations.d.mts +0 -22
  147. package/dist/integrations.d.ts +0 -22
  148. package/dist/internal/build-runtime.d.mts +0 -39
  149. package/dist/internal/build-runtime.d.ts +0 -39
  150. package/dist/internal/client-runtime.d.mts +0 -2
  151. package/dist/internal/client-runtime.d.ts +0 -2
  152. package/dist/internal/config-runtime.d.mts +0 -39
  153. package/dist/internal/config-runtime.d.ts +0 -39
  154. package/dist/internal/production-node-env.d.mts +0 -12
  155. package/dist/internal/production-node-env.d.ts +0 -12
  156. package/dist/internal/production-runtime.d.mts +0 -41
  157. package/dist/internal/production-runtime.d.ts +0 -41
  158. package/dist/markdown.d.mts +0 -60
  159. package/dist/markdown.d.ts +0 -60
  160. package/dist/metadata-7ffpT3jr.d.mts +0 -22
  161. package/dist/metadata-JHn-8eht.d.ts +0 -22
  162. package/dist/middleware.d.mts +0 -164
  163. package/dist/middleware.d.ts +0 -164
  164. package/dist/navigation-errors-Dvwpzaer.d.mts +0 -13
  165. package/dist/navigation-errors-Dvwpzaer.d.ts +0 -13
  166. package/dist/navigation.d.mts +0 -14
  167. package/dist/navigation.d.ts +0 -14
  168. package/dist/observability.d.mts +0 -335
  169. package/dist/observability.d.ts +0 -335
  170. package/dist/params-BALtrRim.d.ts +0 -15
  171. package/dist/params-ry-lxqmy.d.mts +0 -15
  172. package/dist/plugin-BJDf43dc.d.mts +0 -165
  173. package/dist/plugin-BJDf43dc.d.ts +0 -165
  174. package/dist/plugin.d.mts +0 -22
  175. package/dist/plugin.d.ts +0 -22
  176. package/dist/production-runtime-9KG7GuvW.d.ts +0 -79
  177. package/dist/production-runtime-B-fweKts.d.mts +0 -79
  178. package/dist/production-runtime-C_B79w2P.d.mts +0 -28
  179. package/dist/production-runtime-DDEM1D2q.d.ts +0 -28
  180. package/dist/query/client.d.mts +0 -61
  181. package/dist/query/client.d.ts +0 -61
  182. package/dist/query/index.d.mts +0 -90
  183. package/dist/query/index.d.ts +0 -90
  184. package/dist/query/parsers.d.mts +0 -25
  185. package/dist/query/parsers.d.ts +0 -25
  186. package/dist/query/server.d.mts +0 -55
  187. package/dist/query/server.d.ts +0 -55
  188. package/dist/request-Dsq4kGW0.d.mts +0 -6
  189. package/dist/request-udtobOLv.d.ts +0 -6
  190. package/dist/request.d.mts +0 -2
  191. package/dist/request.d.ts +0 -2
  192. package/dist/resolver-DJqjLMg_.d.mts +0 -14
  193. package/dist/resolver-IH4RmPEl.d.ts +0 -14
  194. package/dist/route-runtime-DoOHzCAD.d.mts +0 -38
  195. package/dist/route-runtime-DoOHzCAD.d.ts +0 -38
  196. package/dist/router.d.mts +0 -36
  197. package/dist/router.d.ts +0 -36
  198. package/dist/routes.d.mts +0 -224
  199. package/dist/routes.d.ts +0 -224
  200. package/dist/runtime-9nQjVM7X.d.mts +0 -206
  201. package/dist/runtime-Cxpq6xZN.d.mts +0 -27
  202. package/dist/runtime-DgeS2skB.d.ts +0 -206
  203. package/dist/runtime-bv63eUiO.d.ts +0 -27
  204. package/dist/server-action-security.d.mts +0 -43
  205. package/dist/server-action-security.d.ts +0 -43
  206. package/dist/server-fn-client.d.mts +0 -32
  207. package/dist/server-fn-client.d.ts +0 -32
  208. package/dist/server-fn.d.mts +0 -93
  209. package/dist/server-fn.d.ts +0 -93
  210. package/dist/server-plugins.d.mts +0 -55
  211. package/dist/server-plugins.d.ts +0 -55
  212. package/dist/server-query-client.d.mts +0 -50
  213. package/dist/server-query-client.d.ts +0 -50
  214. package/dist/server-query.d.mts +0 -36
  215. package/dist/server-query.d.ts +0 -36
  216. package/dist/server.d.mts +0 -48
  217. package/dist/server.d.ts +0 -48
  218. package/dist/storage.d.mts +0 -52
  219. package/dist/storage.d.ts +0 -52
  220. package/dist/testing.d.mts +0 -101
  221. package/dist/testing.d.ts +0 -101
  222. package/dist/transport-BmbGTXA5.d.mts +0 -49
  223. package/dist/transport-BmbGTXA5.d.ts +0 -49
  224. package/dist/types-BMxWr97v.d.mts +0 -81
  225. package/dist/types-BMxWr97v.d.ts +0 -81
  226. package/dist/types-C9N-nk5R.d.mts +0 -53
  227. package/dist/types-C9N-nk5R.d.ts +0 -53
  228. package/dist/types-D1A6-XvH.d.mts +0 -73
  229. package/dist/types-D1A6-XvH.d.ts +0 -73
  230. package/dist/utils-CA0z0c-2.d.ts +0 -23
  231. package/dist/utils-mYVkSOt2.d.mts +0 -23
  232. package/dist/version.d.mts +0 -3
  233. package/dist/version.d.ts +0 -3
  234. package/dist/vite.d.mts +0 -22
  235. package/dist/vite.d.ts +0 -22
  236. package/dist/workflows.d.mts +0 -110
  237. package/dist/workflows.d.ts +0 -110
  238. /package/dist/{chunk-7N62DNSO.mjs.map → chunk-H3TE3LOV.mjs.map} +0 -0
package/dist/cache.d.mts DELETED
@@ -1,192 +0,0 @@
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 };
package/dist/cache.d.ts DELETED
@@ -1,192 +0,0 @@
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 };