refactor: remove additional dead exports and unused actions
Remove buildFontUrl, measureText, uncached, invalidateCache, fetchJsonWithFlareSolver, upsertPermission, deletePermission, bulkImportPermissions, clearAllPermissions, bulkDeletePermissions, bulkDeletePhotos, userReplyTicket, closeTicketByUser. Update staff-smoke-contract test for bulkDeletePhotos removal.
This commit is contained in:
1 parent
24bf8eabb9
commit
6a67fb6e83
10 files changed
+3
-187
No files matched your search
@@ -47,15 +47,3 @@ export async function cached<T>(
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/** Invalidate a single cache key across Redis + memory (call after writes). */
|
||||
export async function uncached(key: string): Promise<void> {
|
||||
memory.delete(key);
|
||||
if (redis && redis.status !== "end") {
|
||||
try {
|
||||
await redis.del(key);
|
||||
} catch {
|
||||
/* non-critical */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,15 +44,6 @@ export async function cachedQuery<T>(
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Invalidate cache keys matching a glob pattern. */
|
||||
export async function invalidateCache(pattern: string): Promise<number> {
|
||||
if (!isRedisAvailable()) return 0;
|
||||
const r = redis;
|
||||
if (!r) return 0;
|
||||
const keys = await r.keys(pattern);
|
||||
return keys.length > 0 ? r.del(...keys) : 0;
|
||||
}
|
||||
|
||||
/** Invalidate a single cache key immediately. */
|
||||
export async function invalidateKey(key: string): Promise<number> {
|
||||
if (!isRedisAvailable()) return 0;
|
||||
|
||||
@@ -39,15 +39,3 @@ export async function fetchWithFlareSolver(
|
||||
|
||||
return data.solution.response;
|
||||
}
|
||||
|
||||
export async function fetchJsonWithFlareSolver<T = unknown>(
|
||||
url: string,
|
||||
timeout = 30000,
|
||||
): Promise<T> {
|
||||
const body = await fetchWithFlareSolver(url, timeout);
|
||||
try {
|
||||
return JSON.parse(body) as T;
|
||||
} catch {
|
||||
throw new Error(`flare-solver: could not parse JSON from ${url}`);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@ import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("staff smoke contract", () => {
|
||||
it("gates photos delete/bulk with PAGES_EDIT", () => {
|
||||
it("gates photos delete with PAGES_EDIT", () => {
|
||||
const src = readFileSync("src/actions/admin-photos.ts", "utf8");
|
||||
expect(src).toContain("PERMS.PAGES_EDIT");
|
||||
expect(src).toContain("deletePhoto");
|
||||
expect(src).toContain("bulkDeletePhotos");
|
||||
expect(src).toContain("logStaffActivity");
|
||||
expect(existsSync("src/app/admin/photos/page.tsx")).toBe(true);
|
||||
expect(readFileSync("src/app/admin/photos/page.tsx", "utf8")).toContain(
|
||||
|
||||
Reference in new issue
Block a user