tessl install tessl/npm-walletconnect--types@2.21.0TypeScript type definitions and interfaces for the WalletConnect Protocol v2, enabling type-safe development across the WalletConnect ecosystem
Agent Success
Agent success rate when using this tile
70%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.19x
Baseline
Agent success rate without this tile
59%
Build a session cache manager that stores and retrieves user session data with filtering capabilities.
Your task is to implement a session cache manager with the following features:
The session data should have the following structure:
id: unique session identifier (string)userId: user identifier (string)active: whether the session is currently active (boolean)expiresAt: expiration timestamp (number)Create a SessionCacheManager class that manages session storage. The implementation should:
Create a test file named session-cache.test.ts with the following test cases:
// Store a session and retrieve it
const manager = new SessionCacheManager();
const session = {
id: 'session-1',
userId: 'user-123',
active: true,
expiresAt: Date.now() + 3600000
};
await manager.store(session);
const retrieved = await manager.get('session-1');
// Should return the stored session// Store multiple sessions and filter by criteria
const manager = new SessionCacheManager();
await manager.store({
id: 'session-1',
userId: 'user-123',
active: true,
expiresAt: Date.now() + 3600000
});
await manager.store({
id: 'session-2',
userId: 'user-456',
active: false,
expiresAt: Date.now() + 7200000
});
await manager.store({
id: 'session-3',
userId: 'user-123',
active: true,
expiresAt: Date.now() + 1800000
});
const userSessions = await manager.filter({ userId: 'user-123' });
// Should return 2 sessions (session-1 and session-3)
const activeSessions = await manager.filter({ active: true });
// Should return 2 sessions (session-1 and session-3)// Update a session and then delete it
const manager = new SessionCacheManager();
const session = {
id: 'session-1',
userId: 'user-123',
active: true,
expiresAt: Date.now() + 3600000
};
await manager.store(session);
// Update the session
await manager.update('session-1', { active: false });
const updated = await manager.get('session-1');
// Should have active: false
// Delete the session
await manager.delete('session-1', 'User logged out');
const deleted = await manager.get('session-1');
// Should be undefinedProvides TypeScript type definitions for WalletConnect Protocol v2, including storage interface types.