Skip to content

Commit 6f37b02

Browse files
committed
Moves types to shared library
1 parent 0d1cd24 commit 6f37b02

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

packages/cloud/src/CloudAPI.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
import { z } from "zod"
22

3-
import { type AuthService, type ShareVisibility, type ShareResponse, shareResponseSchema } from "@roo-code/types"
3+
import {
4+
type AuthService,
5+
type ShareVisibility,
6+
type ShareResponse,
7+
shareResponseSchema,
8+
type UsageStats,
9+
usageStatsSchema,
10+
} from "@roo-code/types"
411

512
import { getRooCodeApiUrl } from "./config.js"
613
import { getUserAgent } from "./utils.js"
714
import { AuthenticationError, CloudAPIError, NetworkError, TaskNotFoundError } from "./errors.js"
815

9-
// Usage stats schemas
10-
const usageStatsSchema = z.object({
11-
success: z.boolean(),
12-
data: z.object({
13-
dates: z.array(z.string()), // Array of date strings
14-
tasks: z.array(z.number()), // Array of task counts
15-
tokens: z.array(z.number()), // Array of token counts
16-
costs: z.array(z.number()), // Array of costs in USD
17-
totals: z.object({
18-
tasks: z.number(),
19-
tokens: z.number(),
20-
cost: z.number(), // Total cost in USD
21-
}),
22-
}),
23-
period: z.number(), // Period in days (e.g., 30)
24-
})
25-
26-
export type UsageStats = z.infer<typeof usageStatsSchema>
27-
2816
interface CloudAPIRequestOptions extends Omit<RequestInit, "headers"> {
2917
timeout?: number
3018
headers?: Record<string, string>

packages/types/src/cloud.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,28 @@ export const shareResponseSchema = z.object({
227227

228228
export type ShareResponse = z.infer<typeof shareResponseSchema>
229229

230+
/**
231+
* UsageStats
232+
*/
233+
234+
export const usageStatsSchema = z.object({
235+
success: z.boolean(),
236+
data: z.object({
237+
dates: z.array(z.string()), // Array of date strings
238+
tasks: z.array(z.number()), // Array of task counts
239+
tokens: z.array(z.number()), // Array of token counts
240+
costs: z.array(z.number()), // Array of costs in USD
241+
totals: z.object({
242+
tasks: z.number(),
243+
tokens: z.number(),
244+
cost: z.number(), // Total cost in USD
245+
}),
246+
}),
247+
period: z.number(), // Period in days (e.g., 30)
248+
})
249+
250+
export type UsageStats = z.infer<typeof usageStatsSchema>
251+
230252
/**
231253
* AuthService
232254
*/

0 commit comments

Comments
 (0)