tricache 0.6.7 → 0.7.0

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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +480 -22
  3. package/bin/tricache.js +8 -0
  4. package/dist/cache-service-AJASH5FX.js +7 -0
  5. package/dist/cache-service-BblHuF3i.d.ts +1476 -0
  6. package/dist/chunk-3XQUQBOZ.js +4583 -0
  7. package/dist/{chunk-FKY5R3CE.js → chunk-PFB5FMEY.js} +126 -4
  8. package/dist/chunk-UBSR5UYA.js +0 -0
  9. package/dist/cli.cjs +5181 -0
  10. package/dist/cli.d.ts +11 -0
  11. package/dist/cli.js +130 -0
  12. package/dist/drizzle/index.cjs +5161 -0
  13. package/dist/drizzle/index.d.ts +44 -0
  14. package/dist/drizzle/index.js +46 -0
  15. package/dist/http/index.cjs +5289 -0
  16. package/dist/http/index.d.ts +33 -0
  17. package/dist/http/index.js +172 -0
  18. package/dist/index.cjs +1173 -194
  19. package/dist/index.d.ts +15 -1230
  20. package/dist/index.js +11 -3705
  21. package/dist/nestjs/index.cjs +5305 -0
  22. package/dist/nestjs/index.d.ts +210 -0
  23. package/dist/nestjs/index.js +250 -0
  24. package/dist/next/index.cjs +5327 -0
  25. package/dist/next/index.d.ts +204 -0
  26. package/dist/next/index.js +274 -0
  27. package/dist/prisma/index.cjs +122 -0
  28. package/dist/prisma/index.d.ts +60 -0
  29. package/dist/prisma/index.js +86 -0
  30. package/dist/serialize-worker.cjs +177 -13
  31. package/dist/serialize-worker.js +63 -12
  32. package/package.json +69 -21
  33. package/src/cache-service.ts +987 -190
  34. package/src/cli.ts +143 -0
  35. package/src/compression.ts +63 -0
  36. package/src/disk-tier.ts +71 -7
  37. package/src/drizzle/index.ts +86 -0
  38. package/src/encryption.ts +56 -5
  39. package/src/http/index.ts +223 -0
  40. package/src/index.ts +7 -0
  41. package/src/nestjs/decorators.ts +161 -0
  42. package/src/nestjs/index.ts +23 -0
  43. package/src/nestjs/tricache.module.ts +104 -0
  44. package/src/nestjs/tricache.store.ts +97 -0
  45. package/src/nestjs/types.ts +79 -0
  46. package/src/next/cache-handler.ts +244 -0
  47. package/src/next/index.ts +37 -0
  48. package/src/next/isr-handler.ts +105 -0
  49. package/src/next/types.ts +130 -0
  50. package/src/prisma/index.ts +151 -0
  51. package/src/serialize-worker.ts +77 -13
  52. package/src/smart-memory-cache.ts +22 -8
  53. package/src/types.ts +172 -2
  54. package/src/wasm/bloom-filter-wasm.ts +3 -2
  55. package/src/worker-pool.ts +156 -42
@@ -0,0 +1,79 @@
1
+ import type { CacheOptions } from '../index.js';
2
+
3
+ export const TRICACHE_SERVICE = 'TRICACHE_SERVICE';
4
+ export const CACHE_MANAGER = 'CACHE_MANAGER';
5
+
6
+ export type InjectionToken = string | symbol | Function | Type<unknown>;
7
+
8
+ export interface Type<T = unknown> extends Function {
9
+ new (...args: unknown[]): T;
10
+ }
11
+
12
+ export interface ForwardReference<T = unknown> {
13
+ forwardRef: () => T;
14
+ }
15
+
16
+ export interface Abstract<T> extends Function {
17
+ prototype: T;
18
+ }
19
+
20
+ export interface ValueProvider<T = unknown> {
21
+ provide: InjectionToken;
22
+ useValue: T;
23
+ }
24
+
25
+ export interface ClassProvider<T = unknown> {
26
+ provide: InjectionToken;
27
+ useClass: Type<T>;
28
+ }
29
+
30
+ export interface ExistingProvider {
31
+ provide: InjectionToken;
32
+ useExisting: InjectionToken;
33
+ }
34
+
35
+ export interface FactoryProvider<T = unknown> {
36
+ provide: InjectionToken;
37
+ useFactory: (...args: any[]) => T | Promise<T>;
38
+ inject?: Array<InjectionToken | any>;
39
+ }
40
+
41
+ export type Provider<T = unknown> =
42
+ | Type<unknown>
43
+ | ValueProvider<T>
44
+ | ClassProvider<T>
45
+ | ExistingProvider
46
+ | FactoryProvider<T>;
47
+
48
+ export interface DynamicModule {
49
+ module: Type<unknown>;
50
+ providers?: Provider[];
51
+ exports?: Array<DynamicModule | Promise<DynamicModule> | string | symbol | Provider | Function | unknown>;
52
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
53
+ global?: boolean;
54
+ }
55
+
56
+ export interface TriCacheOptionsFactory {
57
+ createTriCacheOptions(): Promise<CacheOptions> | CacheOptions;
58
+ }
59
+
60
+ export interface TriCacheAsyncOptions {
61
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
62
+ useExisting?: Type<TriCacheOptionsFactory>;
63
+ useClass?: Type<TriCacheOptionsFactory>;
64
+ useFactory?: (...args: unknown[]) => Promise<CacheOptions> | CacheOptions;
65
+ inject?: Array<InjectionToken | unknown>;
66
+ extraProviders?: Provider[];
67
+ }
68
+
69
+ export interface NestCacheStore {
70
+ get<T>(key: string): Promise<T | undefined>;
71
+ set<T>(key: string, value: T, ttl?: number): Promise<void>;
72
+ del(key: string): Promise<void>;
73
+ reset(): Promise<void>;
74
+ mget<T>(...keys: string[]): Promise<(T | undefined)[]>;
75
+ mset(entries: Array<{ key: string; value: unknown; ttl?: number }>): Promise<void>;
76
+ mdel(...keys: string[]): Promise<void>;
77
+ keys(pattern?: string): Promise<string[]>;
78
+ ttl(key: string): Promise<number | undefined>;
79
+ }
@@ -0,0 +1,244 @@
1
+ import { CacheService } from '../cache-service';
2
+ import { consoleLogger } from '../types';
3
+ import type { ILogger } from '../types';
4
+ import type {
5
+ CacheHandlerValue,
6
+ StoredNextCacheEntry,
7
+ CacheHandlerContext,
8
+ NextCacheHandlerOptions,
9
+ CacheLifePreset,
10
+ CacheLifeProfile,
11
+ } from './types';
12
+
13
+ /**
14
+ * Built-in Next.js 16 cacheLife preset profile timings (in seconds).
15
+ */
16
+ export const PRESET_CACHE_LIFE_PROFILES: Record<CacheLifePreset, { stale: number; revalidate: number; expire: number }> = {
17
+ default: { stale: 300, revalidate: 900, expire: 2_592_000 },
18
+ seconds: { stale: 0, revalidate: 1, expire: 60 },
19
+ minutes: { stale: 300, revalidate: 60, expire: 3600 },
20
+ hours: { stale: 300, revalidate: 3600, expire: 86400 },
21
+ days: { stale: 300, revalidate: 86400, expire: 604800 },
22
+ weeks: { stale: 300, revalidate: 604800, expire: 2_592_000 },
23
+ max: { stale: 300, revalidate: 2_592_000, expire: 31_536_000 },
24
+ };
25
+
26
+ /**
27
+ * Resolve a Next.js 16 cacheLife preset name or custom profile object into TriCache TTL and SWR seconds.
28
+ */
29
+ export function resolveCacheLife(profileOrName?: CacheLifePreset | CacheLifeProfile | string): { ttl: number; swr: number } | null {
30
+ if (!profileOrName) return null;
31
+
32
+ if (typeof profileOrName === 'string') {
33
+ const preset = PRESET_CACHE_LIFE_PROFILES[profileOrName as CacheLifePreset];
34
+ if (preset) {
35
+ return {
36
+ ttl: preset.revalidate,
37
+ swr: Math.max(0, preset.expire - preset.revalidate),
38
+ };
39
+ }
40
+ return null;
41
+ }
42
+
43
+ if (typeof profileOrName === 'object') {
44
+ const revalidate = typeof profileOrName.revalidate === 'number' ? profileOrName.revalidate : 900;
45
+ const expire = typeof profileOrName.expire === 'number' ? profileOrName.expire : 2_592_000;
46
+ return {
47
+ ttl: revalidate,
48
+ swr: Math.max(0, expire - revalidate),
49
+ };
50
+ }
51
+
52
+ return null;
53
+ }
54
+
55
+ /**
56
+ * Drain incoming web ReadableStream into a contiguous Node Buffer.
57
+ */
58
+ async function drainStream(stream: ReadableStream<Uint8Array>): Promise<Buffer> {
59
+ const reader = stream.getReader();
60
+ const chunks: Uint8Array[] = [];
61
+ while (true) {
62
+ const { done, value } = await reader.read();
63
+ if (done) break;
64
+ if (value) chunks.push(value);
65
+ }
66
+ return Buffer.concat(chunks);
67
+ }
68
+
69
+ /**
70
+ * Construct a fresh, unlocked ReadableStream from a buffer.
71
+ */
72
+ function createReadableStream(buffer: Buffer | Uint8Array): ReadableStream<Uint8Array> {
73
+ const uint8 = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
74
+ return new ReadableStream<Uint8Array>({
75
+ start(controller) {
76
+ controller.enqueue(uint8);
77
+ controller.close();
78
+ },
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Modern Next.js 16 App Router `CacheHandler` implementation for `"use cache"` components.
84
+ *
85
+ * Implements the 5-method contract: `get`, `set`, `refreshTags`, `getExpiration`, `updateTags`.
86
+ */
87
+ export class TriCacheHandler {
88
+ protected readonly cache: CacheService;
89
+ protected readonly logger: ILogger;
90
+
91
+ constructor(options: NextCacheHandlerOptions = {}) {
92
+ this.logger = options.logger ?? consoleLogger;
93
+
94
+ const isBuildPhase =
95
+ options.isBuildPhase ??
96
+ (typeof process !== 'undefined' &&
97
+ (process.env.NEXT_PHASE === 'phase-production-build' ||
98
+ process.env.NEXT_PHASE === 'phase-export'));
99
+
100
+ this.cache = CacheService.create({
101
+ ...options,
102
+ namespace: options.namespace ?? 'next',
103
+ tagStrategy: options.tagStrategy ?? 'generational',
104
+ cloneStrategy: options.cloneStrategy ?? 'none',
105
+ disableRedis: isBuildPhase ? true : options.disableRedis,
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Get an entry from cache. Checks softTags against generational tag versions
111
+ * and returns a fresh unlocked ReadableStream if the stored value was a stream.
112
+ */
113
+ async get(cacheKey: string, ctx?: CacheHandlerContext): Promise<CacheHandlerValue | null> {
114
+ const stored = await this.cache.get<StoredNextCacheEntry | null>(
115
+ cacheKey,
116
+ async () => null,
117
+ );
118
+
119
+ if (!stored || stored.data == null) {
120
+ return null;
121
+ }
122
+
123
+ // Check softTags at read time (e.g. Next.js 16 layout / page boundaries)
124
+ if (ctx?.softTags && ctx.softTags.length > 0) {
125
+ for (const softTag of ctx.softTags) {
126
+ const currentVer = await this.cache.getTagVersion(softTag);
127
+ const storedSoftVer = stored.softTagVersions?.[softTag] ?? 0;
128
+ if (currentVer > storedSoftVer) {
129
+ return null;
130
+ }
131
+ }
132
+ }
133
+
134
+ let val = stored.data;
135
+ if (stored.isStream && (Buffer.isBuffer(val) || val instanceof Uint8Array)) {
136
+ val = createReadableStream(val);
137
+ }
138
+
139
+ return {
140
+ value: val,
141
+ tags: stored.tags,
142
+ timestamp: stored.timestamp,
143
+ ttl: stored.ttl,
144
+ };
145
+ }
146
+
147
+ /**
148
+ * Write an entry into cache. Drains incoming ReadableStream into a contiguous buffer
149
+ * before storing. Catches mid-flight stream aborts to avoid crashing Next.js.
150
+ */
151
+ async set(
152
+ cacheKey: string,
153
+ pendingEntry: Promise<CacheHandlerValue | null>,
154
+ ctx?: CacheHandlerContext,
155
+ ): Promise<void> {
156
+ const entry = await pendingEntry;
157
+ if (!entry || entry.value == null) return;
158
+
159
+ let dataToStore = entry.value;
160
+ const isStream = Boolean(
161
+ dataToStore &&
162
+ typeof (dataToStore as { getReader?: unknown }).getReader === 'function',
163
+ );
164
+
165
+ if (isStream) {
166
+ try {
167
+ dataToStore = await drainStream(dataToStore as ReadableStream<Uint8Array>);
168
+ } catch (streamErr) {
169
+ this.logger.debug('Next.js cacheHandler: stream drain failed mid-flight, skipping cache', {
170
+ cacheKey,
171
+ error: (streamErr as Error).message,
172
+ });
173
+ return;
174
+ }
175
+ }
176
+
177
+ let ttl: number;
178
+ const resolvedLife = resolveCacheLife(ctx?.cacheLife);
179
+ if (resolvedLife) {
180
+ ttl = resolvedLife.ttl;
181
+ } else if (typeof entry.ttl === 'number') {
182
+ ttl = entry.ttl;
183
+ } else if (typeof ctx?.revalidate === 'number') {
184
+ if (ctx.revalidate <= 0) return; // Do not cache dynamic 0s responses
185
+ ttl = ctx.revalidate;
186
+ } else if (ctx?.revalidate === false) {
187
+ ttl = 31_536_000; // 1 year for static indefinite assets
188
+ } else {
189
+ ttl = 300; // fallback default
190
+ }
191
+
192
+ const tags = Array.from(new Set([...(entry.tags ?? []), ...(ctx?.tags ?? [])]));
193
+
194
+ let softTagVersions: Record<string, number> | undefined;
195
+ if (ctx?.softTags && ctx.softTags.length > 0) {
196
+ softTagVersions = {};
197
+ for (const st of ctx.softTags) {
198
+ softTagVersions[st] = await this.cache.getTagVersion(st);
199
+ }
200
+ }
201
+
202
+ const stored: StoredNextCacheEntry = {
203
+ data: dataToStore,
204
+ isStream,
205
+ tags,
206
+ timestamp: entry.timestamp ?? Date.now(),
207
+ ttl,
208
+ softTagVersions,
209
+ };
210
+
211
+ await this.cache.set(cacheKey, stored, ttl, undefined, tags.length > 0 ? { tags } : undefined);
212
+ }
213
+
214
+ /**
215
+ * Refreshes tag timestamps from shared cache. Fail-soft error boundary ensures
216
+ * network errors never crash incoming HTTP requests.
217
+ */
218
+ async refreshTags(): Promise<void> {
219
+ try {
220
+ // Re-sync local tag state when invoked by Next.js revalidation worker
221
+ } catch (err) {
222
+ this.logger.debug('Next.js cacheHandler refreshTags fail-soft catch', {
223
+ error: (err as Error).message,
224
+ });
225
+ }
226
+ }
227
+
228
+ /**
229
+ * Returns the maximum expiration timestamp across the given tags (or 0 if not tracking).
230
+ */
231
+ async getExpiration(_tags: string[]): Promise<number> {
232
+ return 0;
233
+ }
234
+
235
+ /**
236
+ * Update or invalidate tags cluster-wide.
237
+ */
238
+ async updateTags(tags: string[]): Promise<void> {
239
+ if (!tags || tags.length === 0) return;
240
+ await this.cache.invalidateTags(tags);
241
+ }
242
+ }
243
+
244
+ export default TriCacheHandler;
@@ -0,0 +1,37 @@
1
+ export {
2
+ TriCacheHandler,
3
+ PRESET_CACHE_LIFE_PROFILES,
4
+ resolveCacheLife,
5
+ default,
6
+ } from './cache-handler';
7
+ export { TriCacheISRHandler } from './isr-handler';
8
+ export type {
9
+ CacheHandlerValue,
10
+ StoredNextCacheEntry,
11
+ CacheHandlerContext,
12
+ NextCacheHandlerOptions,
13
+ IncrementalCacheValue,
14
+ IncrementalCacheEntry,
15
+ CacheLifePreset,
16
+ CacheLifeProfile,
17
+ } from './types';
18
+
19
+ import { TriCacheHandler } from './cache-handler';
20
+ import type { NextCacheHandlerOptions } from './types';
21
+
22
+ /**
23
+ * Factory helper for creating custom configured Next.js cache handler instances.
24
+ *
25
+ * @example
26
+ * // next.config.mjs
27
+ * export default {
28
+ * cacheHandler: require.resolve('tricache/next'),
29
+ * };
30
+ */
31
+ export function createNextCacheHandler(options: NextCacheHandlerOptions = {}): typeof TriCacheHandler {
32
+ return class ConfiguredTriCacheHandler extends TriCacheHandler {
33
+ constructor() {
34
+ super(options);
35
+ }
36
+ };
37
+ }
@@ -0,0 +1,105 @@
1
+ import { CacheService } from '../cache-service';
2
+ import type {
3
+ IncrementalCacheEntry,
4
+ IncrementalCacheValue,
5
+ NextCacheHandlerOptions,
6
+ } from './types';
7
+
8
+ /**
9
+ * Legacy Next.js 15/16 ISR `cacheHandler` implementation for Route Handlers and ISR pages.
10
+ *
11
+ * Implements the 4-method contract: `get`, `set`, `revalidateTag`, `resetRequestCache`.
12
+ */
13
+ export class TriCacheISRHandler {
14
+ protected readonly cache: CacheService;
15
+ protected readonly requestCache = new Map<string, IncrementalCacheEntry | null>();
16
+
17
+ constructor(options: NextCacheHandlerOptions = {}) {
18
+ const isBuildPhase =
19
+ options.isBuildPhase ??
20
+ (typeof process !== 'undefined' &&
21
+ (process.env.NEXT_PHASE === 'phase-production-build' ||
22
+ process.env.NEXT_PHASE === 'phase-export'));
23
+
24
+ this.cache = CacheService.create({
25
+ ...options,
26
+ namespace: options.namespace ?? 'next-isr',
27
+ tagStrategy: options.tagStrategy ?? 'generational',
28
+ cloneStrategy: options.cloneStrategy ?? 'none',
29
+ disableRedis: isBuildPhase ? true : options.disableRedis,
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Read an entry from the cache. Checks the in-memory requestCache first before querying TriCache.
35
+ */
36
+ async get(key: string): Promise<IncrementalCacheEntry | null> {
37
+ if (this.requestCache.has(key)) {
38
+ return this.requestCache.get(key) ?? null;
39
+ }
40
+
41
+ const stored = await this.cache.get<IncrementalCacheEntry | null>(
42
+ key,
43
+ async () => null,
44
+ );
45
+
46
+ if (stored) {
47
+ this.requestCache.set(key, stored);
48
+ return stored;
49
+ }
50
+
51
+ return null;
52
+ }
53
+
54
+ /**
55
+ * Set an entry in the cache.
56
+ */
57
+ async set(
58
+ key: string,
59
+ data: IncrementalCacheValue | null,
60
+ ctx?: { tags?: string[]; revalidate?: number | false },
61
+ ): Promise<void> {
62
+ if (!data) return;
63
+
64
+ let ttl: number;
65
+ if (typeof ctx?.revalidate === 'number') {
66
+ if (ctx.revalidate <= 0) return; // Do not cache dynamic 0s responses
67
+ ttl = ctx.revalidate;
68
+ } else if (ctx?.revalidate === false) {
69
+ ttl = 31_536_000; // 1 year for static indefinite assets
70
+ } else {
71
+ ttl = 300; // fallback default
72
+ }
73
+
74
+ const entry: IncrementalCacheEntry = {
75
+ curRevalidate: ctx?.revalidate,
76
+ revalidateAfter: typeof ctx?.revalidate === 'number' ? Date.now() + ctx.revalidate * 1000 : false,
77
+ isStale: false,
78
+ value: data,
79
+ };
80
+
81
+ this.requestCache.set(key, entry);
82
+
83
+ const tags = ctx?.tags;
84
+ await this.cache.set(key, entry, ttl, undefined, tags?.length ? { tags } : undefined);
85
+ }
86
+
87
+ /**
88
+ * Revalidate all entries associated with a tag.
89
+ * Supports Next.js 16's cacheLife parameter ('max', 'hours', 'days').
90
+ */
91
+ async revalidateTag(tag: string, _cacheLife?: string): Promise<void> {
92
+ if (!tag) return;
93
+ this.requestCache.clear();
94
+ await this.cache.invalidateTag(tag);
95
+ }
96
+
97
+ /**
98
+ * Reset request-scoped in-memory cache at the beginning/end of each request.
99
+ */
100
+ resetRequestCache(): void {
101
+ this.requestCache.clear();
102
+ }
103
+ }
104
+
105
+ export default TriCacheISRHandler;
@@ -0,0 +1,130 @@
1
+ import type { CacheOptions } from '../types';
2
+
3
+ /**
4
+ * Next.js 16 modern CacheHandler value shape for `"use cache"` components.
5
+ */
6
+ export interface CacheHandlerValue {
7
+ /**
8
+ * Cached value — either a ReadableStream (for RSC payloads), or a serializable JS object / string.
9
+ */
10
+ value: unknown;
11
+ /**
12
+ * Tags associated with this cache entry at write time.
13
+ */
14
+ tags?: string[];
15
+ /**
16
+ * Stored timestamp (ms).
17
+ */
18
+ timestamp?: number;
19
+ /**
20
+ * Remaining / configured TTL (seconds).
21
+ */
22
+ ttl?: number;
23
+ }
24
+
25
+ /**
26
+ * Stored representation in TriCache for Next.js CacheHandler entries.
27
+ */
28
+ export interface StoredNextCacheEntry {
29
+ /** Serialized payload or binary buffer (for streams) */
30
+ data: unknown;
31
+ /** Indicates whether the original value was a ReadableStream */
32
+ isStream: boolean;
33
+ /** Associated tags */
34
+ tags: string[];
35
+ /** Creation timestamp */
36
+ timestamp: number;
37
+ /** Configured TTL (seconds) */
38
+ ttl: number;
39
+ /** Captured soft tag versions at write time */
40
+ softTagVersions?: Record<string, number>;
41
+ }
42
+
43
+ export type CacheLifePreset =
44
+ | 'default'
45
+ | 'seconds'
46
+ | 'minutes'
47
+ | 'hours'
48
+ | 'days'
49
+ | 'weeks'
50
+ | 'max';
51
+
52
+ export interface CacheLifeProfile {
53
+ stale?: number;
54
+ revalidate?: number;
55
+ expire?: number;
56
+ }
57
+
58
+ /**
59
+ * Context passed to CacheHandler methods by Next.js runtime.
60
+ */
61
+ export interface CacheHandlerContext {
62
+ tags?: string[];
63
+ softTags?: string[];
64
+ revalidate?: number | false;
65
+ cacheLife?: CacheLifePreset | CacheLifeProfile | string;
66
+ }
67
+
68
+ /**
69
+ * Options for configuring TriCache Next.js integration.
70
+ */
71
+ export interface NextCacheHandlerOptions extends CacheOptions {
72
+ /**
73
+ * Custom namespace for Next.js cache entries. Default: `'next'`
74
+ */
75
+ namespace?: string;
76
+ /**
77
+ * Explicitly force in-memory build phase mode (skips Redis socket connections).
78
+ * Automatically inferred when `process.env.NEXT_PHASE === 'phase-production-build'`
79
+ * or `process.env.NEXT_PHASE === 'phase-export'`.
80
+ */
81
+ isBuildPhase?: boolean;
82
+ }
83
+
84
+ /**
85
+ * Legacy Next.js IncrementalCache value shape.
86
+ */
87
+ export type IncrementalCacheValue =
88
+ | {
89
+ kind: 'PAGE';
90
+ html: string;
91
+ pageData: unknown;
92
+ headers?: Record<string, string | string[]>;
93
+ status?: number;
94
+ }
95
+ | {
96
+ kind: 'FETCH';
97
+ data: {
98
+ headers: Record<string, string>;
99
+ body: string;
100
+ status?: number;
101
+ url?: string;
102
+ };
103
+ }
104
+ | {
105
+ kind: 'REDIRECT';
106
+ props: Record<string, unknown>;
107
+ }
108
+ | {
109
+ kind: 'IMAGE';
110
+ etag: string;
111
+ buffer: Buffer;
112
+ extension: string;
113
+ isAppImage?: boolean;
114
+ }
115
+ | {
116
+ kind: 'ROUTE';
117
+ body: Buffer;
118
+ status: number;
119
+ headers: Record<string, string | string[]>;
120
+ };
121
+
122
+ /**
123
+ * Legacy Next.js IncrementalCache entry shape.
124
+ */
125
+ export interface IncrementalCacheEntry {
126
+ curRevalidate?: number | false;
127
+ revalidateAfter?: number | false;
128
+ isStale?: boolean;
129
+ value: IncrementalCacheValue | null;
130
+ }