Socket
Book a DemoInstallSign in
Socket

@bernierllc/task-manager

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bernierllc/task-manager

Pure task business logic and management utilities for @bernierllc packages

0.1.1
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@bernierllc/task-manager

Pure task business logic and management utilities for @bernierllc packages.

Installation

npm install @bernierllc/task-manager

Usage

import { TaskManager, CreateTaskRequest } from '@bernierllc/task-manager';

const taskManager = new TaskManager();

// Create a new task
const createRequest: CreateTaskRequest = {
  userId: '123e4567-e89b-12d3-a456-426614174000',
  type: 'review',
  title: 'Review pull request',
  description: 'Review the new authentication feature PR',
  priority: 'high'
};

const result = taskManager.createTask(createRequest);
if (result.success) {
  console.log('Task created:', result.data);
} else {
  console.error('Error:', result.error);
}

// Get all tasks
const tasksResult = taskManager.getTasks();
if (tasksResult.success) {
  console.log('All tasks:', tasksResult.data);
}

// Filter tasks
const filteredResult = taskManager.getTasks({
  userId: '123e4567-e89b-12d3-a456-426614174000',
  status: 'pending',
  priority: 'urgent'
});

// Complete a task
const completionResult = taskManager.completeTask(result.data!.id, {
  completedBy: '123e4567-e89b-12d3-a456-426614174000',
  notes: 'Completed successfully'
});

// Get analytics
const analyticsResult = taskManager.getTaskAnalytics();
if (analyticsResult.success) {
  console.log('Completion rate:', analyticsResult.data!.completionRate);
}

API Reference

TaskManager

Core Methods

  • createTask(request: CreateTaskRequest): TaskOperationResult<Task>
  • getTasks(filters?: TaskFilters): TaskOperationResult<Task[]>
  • getTask(id: string): TaskOperationResult<Task | null>
  • updateTask(id: string, request: UpdateTaskRequest, userId: string): TaskOperationResult<Task>
  • completeTask(id: string, request: TaskCompletionRequest): TaskOperationResult<Task>
  • deleteTask(id: string, userId: string): TaskOperationResult<void>

Task Type Management

  • getTaskTypes(): TaskOperationResult<TaskType[]>
  • createTaskType(taskType: TaskType): TaskOperationResult<TaskType>
  • updateTaskType(id: string, updates: Partial<TaskType>): TaskOperationResult<TaskType>
  • deleteTaskType(id: string): TaskOperationResult<void>

Analytics & History

  • getTaskAnalytics(filters?: TaskFilters): TaskOperationResult<TaskAnalytics>
  • getTaskHistory(taskId?: string): TaskOperationResult<TaskHistoryItem[]>

Validation

  • validateTask(task: Partial<Task>): TaskValidationResult

Utilities

  • getTaskCount(): number
  • getTaskTypeCount(): number
  • clearTasks(): void (for testing)
  • clearTaskTypes(): void (for testing)

Types

Task

interface Task {
  readonly id: string;
  readonly userId: string;
  readonly groupId?: string;
  readonly type: TaskType;
  readonly title: string;
  readonly description: string;
  readonly priority: TaskPriority;
  readonly dueDate?: string;
  readonly status: TaskStatus;
  readonly relatedId?: string;
  readonly actionUrl?: string;
  readonly canCompleteDirectly: boolean;
  readonly createdAt: string;
  readonly updatedAt: string;
  readonly completedAt?: string;
  readonly completedBy?: string;
}

TaskType

interface TaskType {
  readonly id: string;
  readonly name: string;
  readonly description: string;
  readonly icon: string;
  readonly defaultPriority: TaskPriority;
}

TaskPriority

type TaskPriority = 'urgent' | 'high' | 'normal';

TaskStatus

type TaskStatus = 'pending' | 'in-progress' | 'completed';

Default Task Types

The TaskManager comes with 4 built-in task types:

  • review - Review Required (high priority)
  • approval - Approval Needed (urgent priority)
  • update - Update Required (normal priority)
  • notification - Notification (normal priority)

Configuration

All requests are validated using Zod schemas. Invalid data will result in operation failure with descriptive error messages.

Validation Rules

  • Task titles: Required, 1-255 characters
  • Task descriptions: Required, 1-1000 characters
  • User IDs: Must be valid UUIDs
  • Due dates: Must be valid ISO datetime strings
  • Action URLs: Must be valid URL format

Error Handling

All methods return TaskOperationResult<T> with consistent structure:

interface TaskOperationResult<T = void> {
  readonly success: boolean;
  readonly data?: T;
  readonly error?: string;
}

Always check the success property before accessing data.

Features

  • Pure Business Logic - No UI or external dependencies
  • Type Safety - Full TypeScript support with strict typing
  • Validation - Comprehensive input validation using Zod
  • Filtering & Sorting - Flexible task filtering and priority-based sorting
  • Analytics - Built-in analytics and completion metrics
  • Audit Trail - Complete history tracking for all operations
  • Task Types - Flexible task categorization system
  • Error Handling - Consistent error handling with descriptive messages

See Also

  • @bernierllc/task-service - Higher-level task orchestration
  • @bernierllc/task-ui - React components for task management

License

Copyright (c) 2025 Bernier LLC. All rights reserved.

Keywords

tasks

FAQs

Package last updated on 19 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.