@wellpipe/core
The core package contains shared interfaces, types, and utilities used across all Wellpipe packages. It defines the contracts that providers must implement and the normalized data structures they return.
Installation
npm install @wellpipe/core
Package Philosophy
Minimal Dependencies
@wellpipe/core has exactly one runtime dependency: Zod. This is intentional:
- Zod provides runtime validation for API responses
- No other dependencies means smaller bundle sizes
- Reduces version conflicts across the ecosystem
Provider Independence
The core package defines interfaces that any health data provider can implement. This enables:
- Consistent data structures across WHOOP, Oura, Garmin, etc.
- Swappable providers without changing consumer code
- Type-safe development with full IntelliSense
What's Included
Interfaces
| Interface | Purpose |
|---|---|
TokenProvider | OAuth token management contract |
HealthProvider | Health data access contract |
Types
| Type | Purpose |
|---|---|
SleepData | Normalized sleep session data |
RecoveryData | Normalized recovery/readiness data |
WorkoutData | Normalized workout/activity data |
SleepStages | Sleep stage breakdown |
Zod Schemas
Each type has a corresponding Zod schema for runtime validation:
import { SleepDataSchema, RecoveryDataSchema } from '@wellpipe/core';
// Validate API response
const validated = SleepDataSchema.parse(apiResponse);
Usage Example
import type { HealthProvider, SleepData } from '@wellpipe/core';
class MyProvider implements HealthProvider {
readonly name = 'my-provider';
async getSleep(startDate: string, endDate: string): Promise<SleepData[]> {
const response = await this.fetchFromApi('/sleep', { startDate, endDate });
return this.normalizeSleepData(response);
}
async getRecovery(startDate: string, endDate: string): Promise<RecoveryData[]> {
// Implementation
}
async getWorkouts(startDate: string, endDate: string): Promise<WorkoutData[]> {
// Implementation
}
}
Source Code
The package source is available on GitHub: