/**
 * Shared core types used across modules and adapters.
 *
 * UserContext: Result of JWT validation. Every authenticated API route receives
 * one of these and uses it to scope DB queries to the user's workspaces.
 * Built by `src/proxy.ts` (formerly `middleware.ts`) and the `withAuth` HOF.
 */

export interface UserContext {
  userId: string;
  workspaceIds: string[];
  permissions: string[];
  email?: string;
  displayName?: string;
}

/**
 * WorkspaceContext: a single workspace within the user's allowed set.
 * Used when a request explicitly operates on one workspace (campaign-edit,
 * recipient-import etc.). API routes pass it to repos for query-scoping.
 */
export interface WorkspaceContext {
  workspaceId: string;
  user: UserContext;
}
