npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@iworldafric/timelog

v0.1.5

Published

Advanced Time Log system for iWorldAfric developer platform

Readme

@iworldafric/timelog

npm version License: MIT TypeScript Next.js React

A production-grade, advanced Time Log system for Next.js applications. Built with TypeScript, React 19, Prisma, and Chakra UI.

Features

  • 🎯 Complete Time Tracking: Track time entries with start/end times, duration, and billable status
  • 🔄 Approval Workflows: Multi-stage approval system (DRAFT → SUBMITTED → APPROVED → LOCKED → BILLED)
  • 🔒 Time Locks: Period-based locking to prevent edits in closed periods
  • 💰 Finance Integration: Automatic cost calculations with flexible rate cards
  • 📊 Rich Analytics: Project, developer, and daily aggregations with visual charts
  • 🏗️ Hexagonal Architecture: Clean separation of domain, persistence, and presentation layers
  • 🔐 Role-Based Access: Developer, Client, Finance, and Admin roles with proper authorization
  • 📝 Audit Trail: Complete audit logging for all state transitions
  • High Performance: Optimized queries with proper indexing
  • 🎨 Beautiful UI: Pre-built Chakra UI components ready to use

Installation

npm install @iworldafric/timelog
# or
yarn add @iworldafric/timelog
# or
pnpm add @iworldafric/timelog

The package will automatically run post-install migrations to set up your database schema.

Quick Start

1. Configure Your Database

The post-install script will automatically create the necessary Prisma migrations. If you need to run them manually:

npx prisma migrate dev

2. Set Up API Routes (Next.js App Router)

Create /app/api/time-entries/route.ts:

import { createTimeEntryRoutes } from '@iworldafric/timelog/server/next';
import prisma from '@/lib/prisma';
import { authOptions } from '@/lib/auth';

export const { GET, POST, PUT, DELETE } = createTimeEntryRoutes({ 
  prisma, 
  authOptions 
});

3. Use React Components

import { 
  TimeEntryForm, 
  Timer, 
  WeeklyTimesheetGrid,
  ApprovalQueue,
  ProjectTimeChart 
} from '@iworldafric/timelog/react';
import { TimelogProvider } from '@iworldafric/timelog/react';

function MyApp() {
  return (
    <TimelogProvider>
      <Timer />
      <TimeEntryForm onSubmit={handleSubmit} />
      <WeeklyTimesheetGrid 
        weekStart={new Date()} 
        entries={entries}
      />
    </TimelogProvider>
  );
}

Architecture

The package follows Hexagonal Architecture with clear separation of concerns:

@iworldafric/timelog
├── /core           # Domain logic, types, validation, policies
├── /adapters       # Prisma repositories
├── /server/next    # Next.js route factories
└── /react          # React components and hooks

Import Paths

// Core domain logic
import { TimeEntry, RateCard, submitTimeEntries } from '@iworldafric/timelog/core';

// Prisma adapters
import { TimeEntryRepository } from '@iworldafric/timelog/adapters/prisma';

// Next.js server
import { createTimeEntryRoutes } from '@iworldafric/timelog/server/next';

// React components
import { Timer, ApprovalQueue } from '@iworldafric/timelog/react';

Core Features

Time Entry Management

import { submitTimeEntries, approveTimeEntries } from '@iworldafric/timelog/core';

// Submit entries for approval
const result = submitTimeEntries({
  entries: [entry1, entry2],
  context: { userId, userRole, timestamp }
});

// Approve submitted entries
const approved = approveTimeEntries({
  entries: submittedEntries,
  context: { userId, userRole, timestamp }
});

Finance Calculations

import { calculateEntryCosts, generateFinanceExport } from '@iworldafric/timelog/core';

// Calculate costs with rate cards
const costs = calculateEntryCosts({
  entries,
  rateCards,
  roundingInterval: RoundingInterval.FIFTEEN_MINUTES
});

// Generate finance export
const export = generateFinanceExport({
  entries,
  rateCards,
  groupBy: 'project'
});

Time Locks

import { createTimeLock, checkEntryLockConflict } from '@iworldafric/timelog/core';

// Create a time lock
const lock = createTimeLock({
  projectId: 'project-1',
  periodStart: new Date('2024-03-01'),
  periodEnd: new Date('2024-03-31'),
  reason: 'Monthly closing',
  lockedBy: userId
});

// Check for conflicts
const conflict = checkEntryLockConflict(entry, locks);

Components

Timer Component

Track time with start/stop functionality:

<Timer 
  onStart={handleStart}
  onStop={handleStop}
  initialMinutes={0}
/>

Weekly Timesheet Grid

Editable grid for weekly time entries:

<WeeklyTimesheetGrid
  weekStart={monday}
  entries={entries}
  onCellEdit={handleEdit}
  onAddEntry={handleAdd}
/>

Approval Queue

Bulk approval interface:

<ApprovalQueue
  items={submittedEntries}
  type="entries"
  onApprove={handleApprove}
  onReject={handleReject}
  showStats={true}
/>

Charts

Visual analytics with Recharts:

<ProjectTimeChart data={projectData} height={300} />
<DeveloperHoursChart data={developerData} showLegend />

Configuration

Rate Card Precedence

The system applies rates in the following order:

  1. Project-specific rate
  2. Client-specific rate
  3. Developer default rate

Rounding Intervals

  • NONE: No rounding
  • ONE_MINUTE: Round to nearest minute
  • FIVE_MINUTES: Round to nearest 5 minutes
  • SIX_MINUTES: Round to nearest 6 minutes (1/10 hour)
  • FIFTEEN_MINUTES: Round to nearest 15 minutes (1/4 hour)

Status Workflow

DRAFT → SUBMITTED → APPROVED → LOCKED → BILLED
              ↓
           REJECTED → DRAFT

Database Schema

The package creates the following tables:

  • TimeEntry - Individual time records
  • Timesheet - Weekly/daily rollups
  • RateCard - Hourly rates configuration
  • TimeCategory - Categorization of time
  • TimeLock - Period locking mechanism
  • AuditLog - Complete audit trail

All tables include proper indexes for optimal query performance.

Requirements

  • Node.js 18+
  • Next.js 15+
  • React 19+
  • Prisma 5+
  • PostgreSQL/MySQL/SQLite database

Testing

The package includes comprehensive test coverage:

npm test                 # Run all tests
npm run test:coverage    # With coverage report
npm run test:ui          # Interactive UI

Development

# Clone the repository
git clone https://github.com/Mrrobotke/iworldafric-timelog.git
cd iworldafric-timelog

# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build

Support

Author

Antony Ngigge

License

MIT © 2024 iWorld Afric


Built with ❤️ by iWorld Afric