MCPcopy
hub / github.com/virattt/dexter / isValidCacheEntry

Function isValidCacheEntry

src/utils/cache.ts:97–107  ·  view source on GitHub ↗

* Validate that a parsed object has the shape of a CacheEntry. * Guards against truncated writes, schema changes, or manual edits.

(value: unknown)

Source from the content-addressed store, hash-verified

95 * Guards against truncated writes, schema changes, or manual edits.
96 */
97function isValidCacheEntry(value: unknown): value is CacheEntry {
98 if (typeof value !== 'object' || value === null) return false;
99 const obj = value as Record<string, unknown>;
100 return (
101 typeof obj.endpoint === 'string' &&
102 typeof obj.url === 'string' &&
103 typeof obj.cachedAt === 'string' &&
104 typeof obj.data === 'object' &&
105 obj.data !== null
106 );
107}
108
109/**
110 * Safely remove a cache file (e.g. when it's corrupted).

Callers 1

readCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected