UNPKG

ccusage-live

Version:

Enhanced Claude Code usage analysis tool with live team monitoring and collaboration features

45 lines (44 loc) 2.48 kB
import { z } from "zod"; /** * Branded Zod schemas for type safety using Zod's built-in brand functionality */ const modelNameSchema = z.string().min(1, "Model name cannot be empty").brand(); const sessionIdSchema = z.string().min(1, "Session ID cannot be empty").brand(); const requestIdSchema = z.string().min(1, "Request ID cannot be empty").brand(); const messageIdSchema = z.string().min(1, "Message ID cannot be empty").brand(); const isoTimestampSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/, "Invalid ISO timestamp").brand(); const dailyDateSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format").brand(); const activityDateSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format").brand(); const monthlyDateSchema = z.string().regex(/^\d{4}-\d{2}$/, "Date must be in YYYY-MM format").brand(); const filterDateSchema = z.string().regex(/^\d{8}$/, "Date must be in YYYYMMDD format").brand(); const projectPathSchema = z.string().min(1, "Project path cannot be empty").brand(); const versionSchema = z.string().regex(/^\d+\.\d+\.\d+/, "Invalid version format").brand(); const createSessionId = (value) => sessionIdSchema.parse(value); const createDailyDate = (value) => dailyDateSchema.parse(value); const createMonthlyDate = (value) => monthlyDateSchema.parse(value); const createProjectPath = (value) => projectPathSchema.parse(value); /** * Available cost calculation modes * - auto: Use pre-calculated costs when available, otherwise calculate from tokens * - calculate: Always calculate costs from token counts using model pricing * - display: Always use pre-calculated costs, show 0 for missing costs */ const CostModes = [ "auto", "calculate", "display" ]; /** * Available sort orders for data presentation */ const SortOrders = ["desc", "asc"]; /** * Zod schema for model pricing information from LiteLLM */ const modelPricingSchema = z.object({ input_cost_per_token: z.number().optional(), output_cost_per_token: z.number().optional(), cache_creation_input_token_cost: z.number().optional(), cache_read_input_token_cost: z.number().optional() }); export { CostModes, SortOrders, activityDateSchema, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, dailyDateSchema, filterDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, modelPricingSchema, monthlyDateSchema, projectPathSchema, requestIdSchema, sessionIdSchema, versionSchema };