import { Global, Module } from '@nestjs/common';
import { UserDirectoryService } from './user-directory.service';

/**
 * `UsersModule` — owns the persistent user directory per ADR-0020
 * §"v1 scope — User list".
 *
 * v1 ships `UserDirectoryService` only (the write path: upsert at
 * every sign-in via `SessionEstablisher`). The future
 * `GET /api/admin/users` read endpoint lands in a sibling PR
 * alongside the SPA viewer screen — those add a controller and
 * possibly a read-side service, but the storage layer is here.
 *
 * Declared `@Global()` so `SessionEstablisher` (which lives in the
 * auth module) can inject `UserDirectoryService` without re-routing
 * the module graph through an import. The directory is a true
 * cross-cutting concern: it has one writer (the auth callback) and
 * one reader (admin), neither of which "owns" identity in a
 * domain-module sense.
 */
@Global()
@Module({
  providers: [UserDirectoryService],
  exports: [UserDirectoryService],
})
export class UsersModule {}
