Skip to content

Commit 57a8429

Browse files
committed
chore: update dependencies and fix Next.js 16 compatibility
- Update all npm dependencies - Add turbopack config for Next.js 16 (replaces deprecated eslint config) - Remove unused React imports from TSX files (React 19 JSX transform) - Fix React.Fragment and React.useCallback references - Update Vitest 4.x mock syntax for better-sqlite3 - Add NEXTAUTH_SECRET to test setup for auth validation - Disable new React 19 ESLint rules that catch pre-existing patterns Build: ✓ Unit Tests: 96/96 passing
1 parent 57aed21 commit 57a8429

File tree

164 files changed

+31570
-1388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+31570
-1388
lines changed

.open-next/.build/cache.cjs

Lines changed: 532 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
globalThis.disableIncrementalCache = false;globalThis.disableDynamoDBCache = false;globalThis.isNextAfter15 = true;globalThis.openNextDebug = false;globalThis.openNextVersion = "3.8.5";
2+
var __defProp = Object.defineProperty;
3+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4+
var __getOwnPropNames = Object.getOwnPropertyNames;
5+
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
var __export = (target, all) => {
7+
for (var name in all)
8+
__defProp(target, name, { get: all[name], enumerable: true });
9+
};
10+
var __copyProps = (to, from, except, desc) => {
11+
if (from && typeof from === "object" || typeof from === "function") {
12+
for (let key of __getOwnPropNames(from))
13+
if (!__hasOwnProp.call(to, key) && key !== except)
14+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15+
}
16+
return to;
17+
};
18+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19+
20+
// node_modules/@opennextjs/aws/dist/adapters/composable-cache.js
21+
var composable_cache_exports = {};
22+
__export(composable_cache_exports, {
23+
default: () => composable_cache_default
24+
});
25+
module.exports = __toCommonJS(composable_cache_exports);
26+
27+
// node_modules/@opennextjs/aws/dist/adapters/logger.js
28+
function debug(...args) {
29+
if (globalThis.openNextDebug) {
30+
console.log(...args);
31+
}
32+
}
33+
34+
// node_modules/@opennextjs/aws/dist/utils/cache.js
35+
function getTagKey(tag) {
36+
if (typeof tag === "string") {
37+
return tag;
38+
}
39+
return JSON.stringify({
40+
tag: tag.tag,
41+
path: tag.path
42+
});
43+
}
44+
async function writeTags(tags) {
45+
const store = globalThis.__openNextAls.getStore();
46+
debug("Writing tags", tags, store);
47+
if (!store || globalThis.openNextConfig.dangerous?.disableTagCache) {
48+
return;
49+
}
50+
const tagsToWrite = tags.filter((t) => {
51+
const tagKey = getTagKey(t);
52+
const shouldWrite = !store.writtenTags.has(tagKey);
53+
if (shouldWrite) {
54+
store.writtenTags.add(tagKey);
55+
}
56+
return shouldWrite;
57+
});
58+
if (tagsToWrite.length === 0) {
59+
return;
60+
}
61+
await globalThis.tagCache.writeTags(tagsToWrite);
62+
}
63+
64+
// node_modules/@opennextjs/aws/dist/utils/stream.js
65+
var import_web = require("node:stream/web");
66+
async function fromReadableStream(stream, base64) {
67+
const chunks = [];
68+
let totalLength = 0;
69+
for await (const chunk of stream) {
70+
chunks.push(chunk);
71+
totalLength += chunk.length;
72+
}
73+
if (chunks.length === 0) {
74+
return "";
75+
}
76+
if (chunks.length === 1) {
77+
return Buffer.from(chunks[0]).toString(base64 ? "base64" : "utf8");
78+
}
79+
const buffer = Buffer.alloc(totalLength);
80+
let offset = 0;
81+
for (const chunk of chunks) {
82+
buffer.set(chunk, offset);
83+
offset += chunk.length;
84+
}
85+
return buffer.toString(base64 ? "base64" : "utf8");
86+
}
87+
function toReadableStream(value, isBase64) {
88+
return new import_web.ReadableStream({
89+
pull(controller) {
90+
controller.enqueue(Buffer.from(value, isBase64 ? "base64" : "utf8"));
91+
controller.close();
92+
}
93+
}, { highWaterMark: 0 });
94+
}
95+
96+
// node_modules/@opennextjs/aws/dist/adapters/composable-cache.js
97+
var pendingWritePromiseMap = /* @__PURE__ */ new Map();
98+
var composable_cache_default = {
99+
async get(cacheKey) {
100+
try {
101+
if (pendingWritePromiseMap.has(cacheKey)) {
102+
const stored = pendingWritePromiseMap.get(cacheKey);
103+
if (stored) {
104+
return stored.then((entry) => ({
105+
...entry,
106+
value: toReadableStream(entry.value)
107+
}));
108+
}
109+
}
110+
const result = await globalThis.incrementalCache.get(cacheKey, "composable");
111+
if (!result?.value?.value) {
112+
return void 0;
113+
}
114+
debug("composable cache result", result);
115+
if (globalThis.tagCache.mode === "nextMode" && result.value.tags.length > 0) {
116+
const hasBeenRevalidated = result.shouldBypassTagCache ? false : await globalThis.tagCache.hasBeenRevalidated(result.value.tags, result.lastModified);
117+
if (hasBeenRevalidated)
118+
return void 0;
119+
} else if (globalThis.tagCache.mode === "original" || globalThis.tagCache.mode === void 0) {
120+
const hasBeenRevalidated = result.shouldBypassTagCache ? false : await globalThis.tagCache.getLastModified(cacheKey, result.lastModified) === -1;
121+
if (hasBeenRevalidated)
122+
return void 0;
123+
}
124+
return {
125+
...result.value,
126+
value: toReadableStream(result.value.value)
127+
};
128+
} catch (e) {
129+
debug("Cannot read composable cache entry");
130+
return void 0;
131+
}
132+
},
133+
async set(cacheKey, pendingEntry) {
134+
const promiseEntry = pendingEntry.then(async (entry2) => ({
135+
...entry2,
136+
value: await fromReadableStream(entry2.value)
137+
}));
138+
pendingWritePromiseMap.set(cacheKey, promiseEntry);
139+
const entry = await promiseEntry.finally(() => {
140+
pendingWritePromiseMap.delete(cacheKey);
141+
});
142+
await globalThis.incrementalCache.set(cacheKey, {
143+
...entry,
144+
value: entry.value
145+
}, "composable");
146+
if (globalThis.tagCache.mode === "original") {
147+
const storedTags = await globalThis.tagCache.getByPath(cacheKey);
148+
const tagsToWrite = entry.tags.filter((tag) => !storedTags.includes(tag));
149+
if (tagsToWrite.length > 0) {
150+
await writeTags(tagsToWrite.map((tag) => ({ tag, path: cacheKey })));
151+
}
152+
}
153+
},
154+
async refreshTags() {
155+
return;
156+
},
157+
async getExpiration(...tags) {
158+
if (globalThis.tagCache.mode === "nextMode") {
159+
return globalThis.tagCache.getLastRevalidated(tags);
160+
}
161+
return 0;
162+
},
163+
async expireTags(...tags) {
164+
if (globalThis.tagCache.mode === "nextMode") {
165+
return writeTags(tags);
166+
}
167+
const tagCache = globalThis.tagCache;
168+
const revalidatedAt = Date.now();
169+
const pathsToUpdate = await Promise.all(tags.map(async (tag) => {
170+
const paths = await tagCache.getByTag(tag);
171+
return paths.map((path) => ({
172+
path,
173+
tag,
174+
revalidatedAt
175+
}));
176+
}));
177+
const setToWrite = /* @__PURE__ */ new Set();
178+
for (const entry of pathsToUpdate.flat()) {
179+
setToWrite.add(entry);
180+
}
181+
await writeTags(Array.from(setToWrite));
182+
},
183+
// This one is necessary for older versions of next
184+
async receiveExpiredTags(...tags) {
185+
return;
186+
}
187+
};
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
globalThis.openNextDebug = false;globalThis.openNextVersion = "3.8.5";
2+
3+
// node_modules/@opennextjs/cloudflare/dist/api/durable-objects/bucket-cache-purge.js
4+
import { DurableObject } from "cloudflare:workers";
5+
6+
// node_modules/@opennextjs/aws/dist/utils/error.js
7+
function isOpenNextError(e) {
8+
try {
9+
return "__openNextInternal" in e;
10+
} catch {
11+
return false;
12+
}
13+
}
14+
15+
// node_modules/@opennextjs/aws/dist/adapters/logger.js
16+
function debug(...args) {
17+
if (globalThis.openNextDebug) {
18+
console.log(...args);
19+
}
20+
}
21+
function warn(...args) {
22+
console.warn(...args);
23+
}
24+
var DOWNPLAYED_ERROR_LOGS = [
25+
{
26+
clientName: "S3Client",
27+
commandName: "GetObjectCommand",
28+
errorName: "NoSuchKey"
29+
}
30+
];
31+
var isDownplayedErrorLog = (errorLog) => DOWNPLAYED_ERROR_LOGS.some((downplayedInput) => downplayedInput.clientName === errorLog?.clientName && downplayedInput.commandName === errorLog?.commandName && (downplayedInput.errorName === errorLog?.error?.name || downplayedInput.errorName === errorLog?.error?.Code));
32+
function error(...args) {
33+
if (args.some((arg) => isDownplayedErrorLog(arg))) {
34+
return debug(...args);
35+
}
36+
if (args.some((arg) => isOpenNextError(arg))) {
37+
const error2 = args.find((arg) => isOpenNextError(arg));
38+
if (error2.logLevel < getOpenNextErrorLogLevel()) {
39+
return;
40+
}
41+
if (error2.logLevel === 0) {
42+
return console.log(...args.map((arg) => isOpenNextError(arg) ? `${arg.name}: ${arg.message}` : arg));
43+
}
44+
if (error2.logLevel === 1) {
45+
return warn(...args.map((arg) => isOpenNextError(arg) ? `${arg.name}: ${arg.message}` : arg));
46+
}
47+
return console.error(...args);
48+
}
49+
console.error(...args);
50+
}
51+
function getOpenNextErrorLogLevel() {
52+
const strLevel = process.env.OPEN_NEXT_ERROR_LOG_LEVEL ?? "1";
53+
switch (strLevel.toLowerCase()) {
54+
case "debug":
55+
case "0":
56+
return 0;
57+
case "error":
58+
case "2":
59+
return 2;
60+
default:
61+
return 1;
62+
}
63+
}
64+
65+
// node_modules/@opennextjs/cloudflare/dist/api/cloudflare-context.js
66+
var cloudflareContextSymbol = Symbol.for("__cloudflare-context__");
67+
68+
// node_modules/@opennextjs/cloudflare/dist/api/overrides/internal.js
69+
var debugCache = (name, ...args) => {
70+
if (process.env.NEXT_PRIVATE_DEBUG_CACHE) {
71+
console.log(`[${name}] `, ...args);
72+
}
73+
};
74+
async function internalPurgeCacheByTags(env, tags) {
75+
if (!env.CACHE_PURGE_ZONE_ID || !env.CACHE_PURGE_API_TOKEN) {
76+
error("No cache zone ID or API token provided. Skipping cache purge.");
77+
return "missing-credentials";
78+
}
79+
let response;
80+
try {
81+
response = await fetch(`https://api.cloudflare.com/client/v4/zones/${env.CACHE_PURGE_ZONE_ID}/purge_cache`, {
82+
headers: {
83+
Authorization: `Bearer ${env.CACHE_PURGE_API_TOKEN}`,
84+
"Content-Type": "application/json"
85+
},
86+
method: "POST",
87+
body: JSON.stringify({
88+
tags
89+
})
90+
});
91+
if (response.status === 429) {
92+
error("purgeCacheByTags: Rate limit exceeded. Skipping cache purge.");
93+
return "rate-limit-exceeded";
94+
}
95+
const bodyResponse = await response.json();
96+
if (!bodyResponse.success) {
97+
error("purgeCacheByTags: Cache purge failed. Errors:", bodyResponse.errors.map((error2) => `${error2.code}: ${error2.message}`));
98+
return "purge-failed";
99+
}
100+
debugCache("purgeCacheByTags", "Cache purged successfully for tags:", tags);
101+
return "purge-success";
102+
} catch (error2) {
103+
console.error("Error purging cache by tags:", error2);
104+
return "purge-failed";
105+
} finally {
106+
try {
107+
await response?.body?.cancel();
108+
} catch {
109+
}
110+
}
111+
}
112+
113+
// node_modules/@opennextjs/cloudflare/dist/api/durable-objects/bucket-cache-purge.js
114+
var DEFAULT_BUFFER_TIME_IN_SECONDS = 5;
115+
var MAX_NUMBER_OF_TAGS_PER_PURGE = 100;
116+
var BucketCachePurge = class extends DurableObject {
117+
bufferTimeInSeconds;
118+
constructor(state, env) {
119+
super(state, env);
120+
this.bufferTimeInSeconds = env.NEXT_CACHE_DO_PURGE_BUFFER_TIME_IN_SECONDS ? parseInt(env.NEXT_CACHE_DO_PURGE_BUFFER_TIME_IN_SECONDS) : DEFAULT_BUFFER_TIME_IN_SECONDS;
121+
state.blockConcurrencyWhile(async () => {
122+
state.storage.sql.exec(`
123+
CREATE TABLE IF NOT EXISTS cache_purge (
124+
tag TEXT NOT NULL
125+
);
126+
CREATE UNIQUE INDEX IF NOT EXISTS tag_index ON cache_purge (tag);
127+
`);
128+
});
129+
}
130+
async purgeCacheByTags(tags) {
131+
for (const tag of tags) {
132+
this.ctx.storage.sql.exec(`
133+
INSERT OR REPLACE INTO cache_purge (tag)
134+
VALUES (?)`, [tag]);
135+
}
136+
const nextAlarm = await this.ctx.storage.getAlarm();
137+
if (!nextAlarm) {
138+
this.ctx.storage.setAlarm(Date.now() + this.bufferTimeInSeconds * 1e3);
139+
}
140+
}
141+
async alarm() {
142+
let tags = this.ctx.storage.sql.exec(`
143+
SELECT * FROM cache_purge LIMIT ${MAX_NUMBER_OF_TAGS_PER_PURGE}
144+
`).toArray();
145+
do {
146+
if (tags.length === 0) {
147+
return;
148+
}
149+
const result = await internalPurgeCacheByTags(this.env, tags.map((row) => row.tag));
150+
if (result === "rate-limit-exceeded") {
151+
throw new Error("Rate limit exceeded");
152+
}
153+
this.ctx.storage.sql.exec(`
154+
DELETE FROM cache_purge
155+
WHERE tag IN (${tags.map(() => "?").join(",")})
156+
`, tags.map((row) => row.tag));
157+
if (tags.length < MAX_NUMBER_OF_TAGS_PER_PURGE) {
158+
tags = [];
159+
} else {
160+
tags = this.ctx.storage.sql.exec(`
161+
SELECT * FROM cache_purge LIMIT ${MAX_NUMBER_OF_TAGS_PER_PURGE}
162+
`).toArray();
163+
}
164+
} while (tags.length >= 0);
165+
}
166+
};
167+
export {
168+
BucketCachePurge
169+
};

0 commit comments

Comments
 (0)