Skip to content

Commit

Permalink
add CachedFetchValue overrides type
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Feb 6, 2025
1 parent f9b9ae9 commit 0078428
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/open-next/src/types/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,29 @@ export type CachedFile =
meta?: Meta;
};

export type FetchCache = Object;
// type taken from: https://github.com/vercel/next.js/blob/9a1cd356/packages/next/src/server/response-cache/types.ts#L26-L38
export type CachedFetchValue = {
kind: "FETCH";
data: {
headers: { [k: string]: string };
body: string;
url: string;
status?: number;
// field used by older versions of Next.js (see: https://github.com/vercel/next.js/blob/fda1ecc/packages/next/src/server/response-cache/types.ts#L23)
tags?: string[];
};
// tags are only present with file-system-cache
// fetch cache stores tags outside of cache entry
tags?: string[];
};

export type WithLastModified<T> = {
lastModified?: number;
value?: T;
};

export type CacheValue<IsFetch extends boolean> = (IsFetch extends true
? FetchCache
? Partial<CachedFetchValue>
: CachedFile) & { revalidate?: number | false };

export type IncrementalCache = {
Expand Down

0 comments on commit 0078428

Please sign in to comment.