Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/types/src/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,25 @@ export type LeaveResponse = {
taskId?: string
timestamp?: string
}

/**
* UsageStats
*/

export const usageStatsSchema = z.object({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding nonnegative validations for numeric fields (tasks, tokens, costs, and totals) to ensure usage stats cannot be negative.

success: z.boolean(),
data: z.object({
dates: z.array(z.string()), // Array of date strings
tasks: z.array(z.number()), // Array of task counts
tokens: z.array(z.number()), // Array of token counts
costs: z.array(z.number()), // Array of costs in USD
totals: z.object({
tasks: z.number(),
tokens: z.number(),
cost: z.number(), // Total cost in USD
}),
}),
period: z.number(), // Period in days (e.g., 30)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider validating 'period' as a positive integer (e.g. use z.number().int().positive()) to prevent invalid period values.

Suggested change
period: z.number(), // Period in days (e.g., 30)
period: z.number().int().positive(), // Period in days (e.g., 30)

})

export type UsageStats = z.infer<typeof usageStatsSchema>