UNPKG

ccusage

Version:

Usage analysis tool for Claude Code

74 lines (71 loc) 2.39 kB
import { c as SessionUsage, n as DailyUsage, s as MonthlyUsage, u as WeeklyUsage } from "./data-loader-fDs6JbEv.js"; //#region src/_token-utils.d.ts /** * @fileoverview Token calculation utilities * * This module provides shared utilities for calculating token totals * across different token types. Used throughout the application to * ensure consistent token counting logic. */ /** * Token counts structure for raw usage data (uses InputTokens suffix) */ type TokenCounts = { inputTokens: number; outputTokens: number; cacheCreationInputTokens: number; cacheReadInputTokens: number; }; /** * Token counts structure for aggregated data (uses shorter names) */ type AggregatedTokenCounts = { inputTokens: number; outputTokens: number; cacheCreationTokens: number; cacheReadTokens: number; }; /** * Union type that supports both token count formats */ type AnyTokenCounts = TokenCounts | AggregatedTokenCounts; /** * Calculates the total number of tokens across all token types * Supports both raw usage data format and aggregated data format * @param tokenCounts - Object containing counts for each token type * @returns Total number of tokens */ declare function getTotalTokens(tokenCounts: AnyTokenCounts): number; //#endregion //#region src/calculate-cost.d.ts /** * Alias for AggregatedTokenCounts from shared utilities * @deprecated Use AggregatedTokenCounts from _token-utils.ts instead */ type TokenData = AggregatedTokenCounts; /** * Token totals including cost information */ type TokenTotals = TokenData & { totalCost: number; }; /** * Complete totals object with token counts, cost, and total token sum */ type TotalsObject = TokenTotals & { totalTokens: number; }; /** * Calculates total token usage and cost across multiple usage data entries * @param data - Array of daily, monthly, or session usage data * @returns Aggregated token totals and cost */ declare function calculateTotals(data: Array<DailyUsage | MonthlyUsage | WeeklyUsage | SessionUsage>): TokenTotals; /** * Creates a complete totals object by adding total token count to existing totals * @param totals - Token totals with cost information * @returns Complete totals object including total token sum */ declare function createTotalsObject(totals: TokenTotals): TotalsObject; //#endregion export { calculateTotals, createTotalsObject, getTotalTokens };