Service Layer high complexity backend
4
Dependencies
1
Dependents
2
Entities
0
Integrations

Description

Processes bulk user operations - deactivation, role change, and invitation resend - as a single batched API call executed within a database transaction. Returns a per-record result array to the caller. For selections exceeding 100 users, dispatches the operation as a background job and streams incremental progress to the client via Server-Sent Events. Enforces the same authorization rules as individual actions, preventing bulk targeting of users with a higher privilege level than the requesting admin.

Feature: Bulk Actions

bulk-user-service

Sources & reasoning

All business logic for the feature lives here. The implementation notes specify a single batched API call with server-side transaction, per-record result array, background job dispatch for >100 users with SSE, and identical authorization checks as individual actions - a cohesive service boundary that owns the entire execution path from API handler to database.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • Execute bulk deactivation, role change, and invitation resend within a single database transaction
  • Return per-record result array indicating success or failure reason for each user
  • Dispatch operations exceeding 100 users to background job queue
  • Stream background job progress via SSE to connected admin clients
  • Enforce authorization constraints - requesting admin cannot bulk-act on higher-privilege users

Interfaces

bulkDeactivate(userIds: string[], requesterId: string): Promise<BulkOperationResult[]>
bulkChangeRole(userIds: string[], newRoleId: string, requesterId: string): Promise<BulkOperationResult[]>
bulkResendInvitation(userIds: string[], requesterId: string): Promise<BulkOperationResult[]>
dispatchBackgroundJob(action: BulkActionType, userIds: string[], requesterId: string): Promise<string>
getJobStatus(jobId: string): Promise<BulkJobStatus>
streamJobProgress(jobId: string, res: Response): void
validatePrivilegeConstraints(requesterId: string, targetUserIds: string[]): Promise<void>

Relationships

Dependencies (4)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component