/** * @adonisjs/session * * (c) AdonisJS * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import type { SessionData, TaggedSession, ResolvedSessionConfig } from './types.ts'; /** * SessionCollection provides APIs for programmatic session * management. It allows reading, destroying, and tagging * sessions without an HTTP context. * * @example * ```ts * import app from '@adonisjs/core/services/app' * import { SessionCollection } from '@adonisjs/session' * * const sessionCollection = await app.container.make(SessionCollection) * * // List all sessions for a user * const sessions = await sessionCollection.tagged(String(user.id)) * * // Destroy a specific session * await sessionCollection.destroy(sessionId) * ``` */ export declare class SessionCollection { #private; /** * Creates a new SessionCollection instance * * @param config - Resolved session configuration */ constructor(config: ResolvedSessionConfig); /** * Checks if the current store supports session tagging. * Only Memory, Redis, and Database stores support tagging. * * @example * const collection = await app.container.make(SessionCollection) * if (collection.supportsTagging()) { * await collection.tag(sessionId, userId) * } */ supportsTagging(): boolean; /** * Returns the session data for the given session ID, * or null if the session does not exist * * @param sessionId - Session identifier * * @example * const data = await sessionCollection.get('sess_abc123') */ get(sessionId: string): Promise; /** * Destroys a session by its ID * * @param sessionId - Session identifier * * @example * await sessionCollection.destroy('sess_abc123') */ destroy(sessionId: string): Promise; /** * Tag a session with a user ID. * Only supported by Memory, Redis and Database stores. * * @param sessionId - Session identifier * @param userId - User identifier to tag the session with * * @example * await sessionCollection.tag('sess_abc123', 'user_456') */ tag(sessionId: string, userId: string): Promise; /** * Get all sessions for a given user ID (tag). * Only supported by Memory, Redis and Database stores. * * @param userId - User identifier to get sessions for * * @example * const sessions = await sessionCollection.tagged('user_456') */ tagged(userId: string): Promise; }