mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 04:03:29 +00:00
* [PM-14416] Add initial SecurityTask models and enums * [PM-14416] Add support for PATCH request method and 204 No Content response * [PM-14416] Add initial task service abstraction * [PM-14416] Add SecurityTask state/key definitions * [PM-14416] Add DefaultTaskService implementation * [PM-14416] Add DefaultTaskService tests * [PM-14416] Add better null checking to new models * [PM-14416] Improve null value filtering for task service
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Observable } from "rxjs";
|
|
|
|
import { SecurityTaskId, UserId } from "@bitwarden/common/types/guid";
|
|
import { SecurityTask } from "@bitwarden/vault";
|
|
|
|
export abstract class TaskService {
|
|
/**
|
|
* Observable indicating if tasks are enabled for a given user.
|
|
*
|
|
* @remarks Internally, this checks the user's organization details to determine if tasks are enabled.
|
|
* @param userId
|
|
*/
|
|
abstract tasksEnabled$(userId: UserId): Observable<boolean>;
|
|
|
|
/**
|
|
* Observable of all tasks for a given user.
|
|
* @param userId
|
|
*/
|
|
abstract tasks$(userId: UserId): Observable<SecurityTask[]>;
|
|
|
|
/**
|
|
* Observable of pending tasks for a given user.
|
|
* @param userId
|
|
*/
|
|
abstract pendingTasks$(userId: UserId): Observable<SecurityTask[]>;
|
|
|
|
/**
|
|
* Retrieves tasks from the API for a given user and updates the local state.
|
|
* @param userId
|
|
*/
|
|
abstract refreshTasks(userId: UserId): Promise<void>;
|
|
|
|
/**
|
|
* Clears all the tasks from state for the given user.
|
|
* @param userId
|
|
*/
|
|
abstract clear(userId: UserId): Promise<void>;
|
|
|
|
/**
|
|
* Marks a task as complete in local state and updates the server.
|
|
* @param taskId - The ID of the task to mark as complete.
|
|
* @param userId - The user who is completing the task.
|
|
*/
|
|
abstract markAsComplete(taskId: SecurityTaskId, userId: UserId): Promise<void>;
|
|
}
|