@codeguide/core 0.0.28 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/services/codespace/codespace-v2.test.ts +53 -0
- package/__tests__/services/usage/usage-service.test.ts +458 -104
- package/codeguide.ts +3 -0
- package/dist/codeguide.d.ts +2 -1
- package/dist/codeguide.js +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/services/base/base-service.d.ts +21 -0
- package/dist/services/base/base-service.js +114 -0
- package/dist/services/codespace/codespace-service.d.ts +64 -1
- package/dist/services/codespace/codespace-service.js +272 -0
- package/dist/services/codespace/codespace-types.d.ts +213 -12
- package/dist/services/codespace/index.d.ts +1 -1
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +4 -1
- package/dist/services/projects/project-types.d.ts +66 -32
- package/dist/services/starter-kits/index.d.ts +2 -0
- package/dist/services/starter-kits/index.js +20 -0
- package/dist/services/starter-kits/starter-kits-service.d.ts +13 -0
- package/dist/services/starter-kits/starter-kits-service.js +27 -0
- package/dist/services/starter-kits/starter-kits-types.d.ts +34 -0
- package/dist/services/starter-kits/starter-kits-types.js +2 -0
- package/dist/services/subscriptions/subscription-service.d.ts +11 -1
- package/dist/services/subscriptions/subscription-service.js +14 -0
- package/dist/services/tasks/task-service.d.ts +2 -1
- package/dist/services/tasks/task-service.js +8 -0
- package/dist/services/tasks/task-types.d.ts +26 -7
- package/dist/services/usage/usage-service.d.ts +5 -2
- package/dist/services/usage/usage-service.js +58 -9
- package/dist/services/usage/usage-types.d.ts +157 -34
- package/dist/types.d.ts +18 -2
- package/docs/.vitepress/README.md +51 -0
- package/docs/.vitepress/config.ts +139 -0
- package/docs/.vitepress/theme/custom.css +80 -0
- package/docs/.vitepress/theme/index.ts +13 -0
- package/docs/.vitepress/tsconfig.json +19 -0
- package/docs/QUICKSTART.md +77 -0
- package/docs/README.md +134 -0
- package/docs/README_SETUP.md +46 -0
- package/docs/authentication.md +351 -0
- package/docs/codeguide-client.md +350 -0
- package/docs/codespace-models.md +1004 -0
- package/docs/codespace-service.md +444 -0
- package/docs/index.md +135 -0
- package/docs/package.json +14 -0
- package/docs/projects-service.md +688 -0
- package/docs/security-keys-service.md +773 -0
- package/docs/starter-kits-service.md +249 -0
- package/docs/task-service.md +955 -0
- package/docs/testsprite_tests/TC001_Homepage_Load_and_Hero_Section_Display.py +70 -0
- package/docs/testsprite_tests/TC002_Sidebar_Navigation_ExpandCollapse_Functionality.py +73 -0
- package/docs/testsprite_tests/TC003_Full_Text_Local_Search_with_Keyboard_Shortcut.py +90 -0
- package/docs/testsprite_tests/TC004_Dark_Mode_Toggle_and_Persistence.py +73 -0
- package/docs/testsprite_tests/TC005_Mobile_Responsiveness_and_Touch_Navigation.py +113 -0
- package/docs/testsprite_tests/TC006_GitHub_Integration_Edit_this_page_Links.py +73 -0
- package/docs/testsprite_tests/TC007_Syntax_Highlighting_and_Code_Copy_Functionality.py +73 -0
- package/docs/testsprite_tests/TC008_Auto_Generated_Table_of_Contents_Accuracy.py +73 -0
- package/docs/testsprite_tests/TC009_SEO_and_Content_Discoverability_Verification.py +73 -0
- package/docs/testsprite_tests/TC010_Accessibility_Compliance_WCAG_AA.py +73 -0
- package/docs/testsprite_tests/TC011_Local_Development_Workflow_Build_and_Hot_Reload.py +74 -0
- package/docs/testsprite_tests/TC012_Performance_Metrics_Compliance.py +73 -0
- package/docs/testsprite_tests/standard_prd.json +122 -0
- package/docs/testsprite_tests/testsprite-mcp-test-report.html +2508 -0
- package/docs/testsprite_tests/testsprite-mcp-test-report.md +273 -0
- package/docs/testsprite_tests/testsprite_frontend_test_plan.json +390 -0
- package/docs/usage-service.md +291 -1
- package/index.ts +11 -3
- package/package.json +17 -2
- package/plans/CODESPACE_LOGS_STREAMING_GUIDE.md +320 -0
- package/plans/CODESPACE_TASK_LOGS_API_COMPLETE_GUIDE.md +821 -0
- package/services/base/base-service.ts +130 -0
- package/services/codespace/codespace-service.ts +359 -0
- package/services/codespace/codespace-types.ts +295 -13
- package/services/codespace/index.ts +21 -1
- package/services/index.ts +2 -0
- package/services/projects/README.md +107 -34
- package/services/projects/project-types.ts +69 -32
- package/services/starter-kits/index.ts +2 -0
- package/services/starter-kits/starter-kits-service.ts +33 -0
- package/services/starter-kits/starter-kits-types.ts +38 -0
- package/services/subscriptions/subscription-service.ts +23 -5
- package/services/tasks/task-service.ts +10 -0
- package/services/tasks/task-types.ts +29 -7
- package/services/usage/usage-service.ts +59 -10
- package/services/usage/usage-types.ts +186 -36
- package/types.ts +22 -2
|
@@ -1,31 +1,50 @@
|
|
|
1
|
+
|
|
1
2
|
export interface ProjectRepository {
|
|
2
3
|
id: string
|
|
3
|
-
|
|
4
|
+
name: string
|
|
4
5
|
repo_url: string
|
|
5
6
|
branch: string
|
|
7
|
+
project_id: string
|
|
8
|
+
user_id: string
|
|
9
|
+
files_processed: number
|
|
10
|
+
total_characters: number
|
|
11
|
+
total_lines: number
|
|
12
|
+
total_files_found: number
|
|
13
|
+
total_directories: number
|
|
6
14
|
author: string
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
estimated_tokens: number
|
|
16
|
+
estimated_size_bytes: number
|
|
17
|
+
tree_structure?: string
|
|
9
18
|
created_at: string
|
|
10
|
-
updated_at: string
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export interface Project {
|
|
14
22
|
id: string
|
|
15
23
|
title: string
|
|
16
24
|
description: string
|
|
17
|
-
|
|
25
|
+
status: string
|
|
26
|
+
category_id: string
|
|
27
|
+
starter_kit_id?: string
|
|
28
|
+
ai_questionaire?: {
|
|
29
|
+
experience_level?: string
|
|
30
|
+
timeline?: string
|
|
31
|
+
team_size?: number
|
|
32
|
+
}
|
|
33
|
+
tools_selected?: string[]
|
|
34
|
+
project_outline?: {
|
|
35
|
+
features?: string[]
|
|
36
|
+
architecture?: string
|
|
37
|
+
}
|
|
38
|
+
codie_tool_id?: string
|
|
39
|
+
existing_project_repo_url?: string | null
|
|
18
40
|
created_at: string
|
|
19
41
|
updated_at: string
|
|
42
|
+
user_id: string
|
|
20
43
|
project_documents: ProjectDocument[]
|
|
21
|
-
project_repositories: ProjectRepository[]
|
|
22
44
|
category?: Category
|
|
45
|
+
starter_kit?: StarterKitReference
|
|
23
46
|
codie_tool?: CodieTool
|
|
24
|
-
|
|
25
|
-
status?: string
|
|
26
|
-
tools_selected?: string[]
|
|
27
|
-
ai_questionaire?: Record<string, any>
|
|
28
|
-
project_outline?: Record<string, any>
|
|
47
|
+
project_repositories: ProjectRepository[]
|
|
29
48
|
}
|
|
30
49
|
|
|
31
50
|
export interface ProjectDocument {
|
|
@@ -56,37 +75,62 @@ export interface GetProjectDocumentsResponse {
|
|
|
56
75
|
export interface Category {
|
|
57
76
|
id: string
|
|
58
77
|
name: string
|
|
59
|
-
description
|
|
78
|
+
description: string
|
|
60
79
|
}
|
|
61
80
|
|
|
62
81
|
export interface CodieTool {
|
|
63
82
|
id: string
|
|
64
83
|
name: string
|
|
65
|
-
description
|
|
66
|
-
|
|
84
|
+
description: string
|
|
85
|
+
type: string
|
|
86
|
+
api_endpoint?: string
|
|
87
|
+
created_at?: string
|
|
88
|
+
updated_at?: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface StarterKitReference {
|
|
92
|
+
id: string
|
|
93
|
+
name: string
|
|
94
|
+
description: string
|
|
67
95
|
}
|
|
68
96
|
|
|
69
97
|
export interface CreateProjectRequest {
|
|
70
98
|
title: string
|
|
71
99
|
description: string
|
|
72
100
|
category_id?: string
|
|
73
|
-
|
|
101
|
+
starter_kit_id?: string
|
|
102
|
+
ai_questionaire?: {
|
|
103
|
+
experience_level?: string
|
|
104
|
+
timeline?: string
|
|
105
|
+
team_size?: number
|
|
106
|
+
}
|
|
74
107
|
tools_selected?: string[]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
project_outline?: {
|
|
109
|
+
features?: string[]
|
|
110
|
+
architecture?: string
|
|
111
|
+
}
|
|
112
|
+
codie_tool_id?: string
|
|
113
|
+
existing_project_repo_url?: string
|
|
78
114
|
}
|
|
79
115
|
|
|
80
116
|
export interface UpdateProjectRequest {
|
|
81
117
|
title?: string
|
|
82
118
|
description?: string
|
|
119
|
+
status?: string
|
|
83
120
|
category_id?: string
|
|
84
|
-
|
|
121
|
+
starter_kit_id?: string
|
|
122
|
+
ai_questionaire?: {
|
|
123
|
+
experience_level?: string
|
|
124
|
+
timeline?: string
|
|
125
|
+
team_size?: number
|
|
126
|
+
}
|
|
85
127
|
tools_selected?: string[]
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
128
|
+
project_outline?: {
|
|
129
|
+
features?: string[]
|
|
130
|
+
architecture?: string
|
|
131
|
+
}
|
|
132
|
+
codie_tool_id?: string
|
|
133
|
+
existing_project_repo_url?: string
|
|
90
134
|
}
|
|
91
135
|
|
|
92
136
|
export interface ProjectListResponse {
|
|
@@ -131,13 +175,6 @@ export interface ConnectRepositoryRequest {
|
|
|
131
175
|
|
|
132
176
|
export interface ConnectRepositoryResponse {
|
|
133
177
|
status: string
|
|
134
|
-
data:
|
|
135
|
-
id: string
|
|
136
|
-
project_id: string
|
|
137
|
-
repo_url: string
|
|
138
|
-
branch: string
|
|
139
|
-
connection_status: 'pending' | 'connected' | 'failed'
|
|
140
|
-
created_at: string
|
|
141
|
-
updated_at: string
|
|
142
|
-
}
|
|
178
|
+
data: ProjectRepository
|
|
143
179
|
}
|
|
180
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service'
|
|
2
|
+
import {
|
|
3
|
+
StarterKit,
|
|
4
|
+
GetStarterKitsRequest,
|
|
5
|
+
GetStarterKitsResponse,
|
|
6
|
+
} from './starter-kits-types'
|
|
7
|
+
|
|
8
|
+
export class StarterKitsService extends BaseService {
|
|
9
|
+
/**
|
|
10
|
+
* Get starter kits with optional filtering
|
|
11
|
+
*
|
|
12
|
+
* GET /starter-kits/
|
|
13
|
+
*
|
|
14
|
+
* @param params Optional query parameters for filtering
|
|
15
|
+
* @returns Promise resolving to an array of starter kits
|
|
16
|
+
*/
|
|
17
|
+
async getStarterKits(params?: GetStarterKitsRequest): Promise<StarterKit[]> {
|
|
18
|
+
const queryParams = new URLSearchParams()
|
|
19
|
+
|
|
20
|
+
if (params?.name) {
|
|
21
|
+
queryParams.append('name', params.name)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (params?.repo_name) {
|
|
25
|
+
queryParams.append('repo_name', params.repo_name)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const url = `/starter-kits${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
|
|
29
|
+
const response = await this.get<GetStarterKitsResponse>(url)
|
|
30
|
+
return response.data
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starter Kit metadata
|
|
3
|
+
*/
|
|
4
|
+
export interface StarterKitMetadata {
|
|
5
|
+
[key: string]: any
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Starter Kit data structure
|
|
10
|
+
*/
|
|
11
|
+
export interface StarterKit {
|
|
12
|
+
id: string
|
|
13
|
+
created_at: string
|
|
14
|
+
updated_at: string
|
|
15
|
+
name: string
|
|
16
|
+
repo_name: string | null
|
|
17
|
+
kit_name: string | null
|
|
18
|
+
metadata: StarterKitMetadata | null
|
|
19
|
+
project_structure: string | null
|
|
20
|
+
ordinal: number | null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Request parameters for getting starter kits
|
|
25
|
+
*/
|
|
26
|
+
export interface GetStarterKitsRequest {
|
|
27
|
+
name?: string
|
|
28
|
+
repo_name?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Response for getting starter kits
|
|
33
|
+
*/
|
|
34
|
+
export interface GetStarterKitsResponse {
|
|
35
|
+
status: 'success' | 'error'
|
|
36
|
+
data: StarterKit[]
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
UserSubscriptionsResponse,
|
|
5
5
|
CancelSubscriptionRequest,
|
|
6
6
|
CancelSubscriptionResponse,
|
|
7
|
+
SubscriptionProductsResponse,
|
|
8
|
+
CreateCheckoutSessionRequest,
|
|
9
|
+
CreateCheckoutSessionResponse,
|
|
7
10
|
} from '../../types'
|
|
8
11
|
|
|
9
12
|
export class SubscriptionService extends BaseService {
|
|
@@ -11,6 +14,16 @@ export class SubscriptionService extends BaseService {
|
|
|
11
14
|
super(config)
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Create a Stripe checkout session for subscription purchase
|
|
19
|
+
* POST /subscriptions/create-checkout-session
|
|
20
|
+
*/
|
|
21
|
+
async createCheckoutSession(
|
|
22
|
+
request: CreateCheckoutSessionRequest
|
|
23
|
+
): Promise<CreateCheckoutSessionResponse> {
|
|
24
|
+
return this.post<CreateCheckoutSessionResponse>('/subscriptions/create-checkout-session', request)
|
|
25
|
+
}
|
|
26
|
+
|
|
14
27
|
/**
|
|
15
28
|
* Get the currently active subscription for the authenticated user
|
|
16
29
|
* GET /subscriptions/current
|
|
@@ -27,6 +40,14 @@ export class SubscriptionService extends BaseService {
|
|
|
27
40
|
return this.get<UserSubscriptionsResponse>('/subscriptions/')
|
|
28
41
|
}
|
|
29
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Get all available subscription products and their prices
|
|
45
|
+
* GET /subscriptions/products
|
|
46
|
+
*/
|
|
47
|
+
async getSubscriptionProducts(): Promise<SubscriptionProductsResponse> {
|
|
48
|
+
return this.get<SubscriptionProductsResponse>('/subscriptions/products')
|
|
49
|
+
}
|
|
50
|
+
|
|
30
51
|
/**
|
|
31
52
|
* Cancel subscription but keep it active until the end of the current billing period
|
|
32
53
|
* POST /subscriptions/{subscription_id}/cancel
|
|
@@ -35,10 +56,7 @@ export class SubscriptionService extends BaseService {
|
|
|
35
56
|
subscriptionId: string,
|
|
36
57
|
request: CancelSubscriptionRequest
|
|
37
58
|
): Promise<CancelSubscriptionResponse> {
|
|
38
|
-
return this.post<CancelSubscriptionResponse>(
|
|
39
|
-
`/subscriptions/${subscriptionId}/cancel`,
|
|
40
|
-
request
|
|
41
|
-
)
|
|
59
|
+
return this.post<CancelSubscriptionResponse>(`/subscriptions/${subscriptionId}/cancel`, request)
|
|
42
60
|
}
|
|
43
61
|
|
|
44
62
|
/**
|
|
@@ -144,4 +162,4 @@ export class SubscriptionService extends BaseService {
|
|
|
144
162
|
}> {
|
|
145
163
|
return this.get(`/subscriptions/${subscriptionId}/history`)
|
|
146
164
|
}
|
|
147
|
-
}
|
|
165
|
+
}
|
|
@@ -173,4 +173,14 @@ export class TaskService extends BaseService {
|
|
|
173
173
|
async updateTask(taskId: string, request: UpdateTaskRequest): Promise<UpdateTaskResponse> {
|
|
174
174
|
return this.put<UpdateTaskResponse>(`/project-tasks/${taskId}`, request)
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
// Get Project Tasks by Codespace
|
|
178
|
+
async getProjectTasksbyCodespace(codespaceTaskId: string): Promise<ProjectTaskListResponse> {
|
|
179
|
+
if (!codespaceTaskId) {
|
|
180
|
+
throw new Error('Codespace task ID is required')
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const url = `/project-tasks/by-codespace/${codespaceTaskId}`
|
|
184
|
+
return this.get<ProjectTaskListResponse>(url)
|
|
185
|
+
}
|
|
176
186
|
}
|
|
@@ -23,19 +23,41 @@ export interface RawTask {
|
|
|
23
23
|
status?: string
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export interface
|
|
26
|
+
export interface ProjectTaskSubtask {
|
|
27
27
|
id: string
|
|
28
28
|
title: string
|
|
29
|
-
description
|
|
29
|
+
description: string
|
|
30
|
+
details: string
|
|
30
31
|
status: string
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
test_strategy: string
|
|
33
|
+
priority: string
|
|
34
|
+
ordinal: number
|
|
33
35
|
task_group_id: string
|
|
34
|
-
parent_task_id
|
|
36
|
+
parent_task_id: string
|
|
37
|
+
ai_result: string
|
|
38
|
+
created_at: string
|
|
39
|
+
user_id: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ProjectTask {
|
|
43
|
+
id: string
|
|
44
|
+
title: string
|
|
45
|
+
description: string
|
|
46
|
+
details: string
|
|
47
|
+
status: string
|
|
48
|
+
test_strategy: string
|
|
49
|
+
priority: string
|
|
35
50
|
ordinal: number
|
|
51
|
+
task_group_id: string
|
|
52
|
+
parent_task_id: string
|
|
53
|
+
ai_result: string
|
|
36
54
|
created_at: string
|
|
37
|
-
|
|
38
|
-
subtasks?:
|
|
55
|
+
user_id: string
|
|
56
|
+
subtasks?: ProjectTaskSubtask[]
|
|
57
|
+
// Optional fields for backward compatibility
|
|
58
|
+
updated_at?: string
|
|
59
|
+
// Legacy support for simpler subtask structure
|
|
60
|
+
subtasks_legacy?: ProjectTask[]
|
|
39
61
|
}
|
|
40
62
|
|
|
41
63
|
export interface CreateTaskGroupRequest {
|
|
@@ -15,6 +15,12 @@ import {
|
|
|
15
15
|
TrackCodespaceUsageResponse,
|
|
16
16
|
CodespaceTaskUsageResponse,
|
|
17
17
|
HealthResponse,
|
|
18
|
+
DashboardAnalyticsRequest,
|
|
19
|
+
DashboardAnalyticsResponse,
|
|
20
|
+
UsageDetailsRequest,
|
|
21
|
+
UsageDetailsResponse,
|
|
22
|
+
ServiceBreakdownRequest,
|
|
23
|
+
ServiceBreakdownResponse,
|
|
18
24
|
} from './usage-types'
|
|
19
25
|
|
|
20
26
|
export class UsageService extends BaseService {
|
|
@@ -29,6 +35,7 @@ export class UsageService extends BaseService {
|
|
|
29
35
|
async checkCredits(params: CreditCheckRequest): Promise<CreditCheckResponse> {
|
|
30
36
|
const queryParams = new URLSearchParams()
|
|
31
37
|
|
|
38
|
+
queryParams.append('model_key', params.model_key)
|
|
32
39
|
if (params.input_tokens !== undefined)
|
|
33
40
|
queryParams.append('input_tokens', params.input_tokens.toString())
|
|
34
41
|
if (params.output_tokens !== undefined)
|
|
@@ -40,16 +47,7 @@ export class UsageService extends BaseService {
|
|
|
40
47
|
return this.get<CreditCheckResponse>(url)
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
const queryParams = new URLSearchParams()
|
|
45
|
-
|
|
46
|
-
if (params?.start_date) queryParams.append('start_date', params.start_date)
|
|
47
|
-
if (params?.end_date) queryParams.append('end_date', params.end_date)
|
|
48
|
-
|
|
49
|
-
const url = `/usage/summary${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
|
|
50
|
-
return this.get<UsageSummaryResponse>(url)
|
|
51
|
-
}
|
|
52
|
-
|
|
50
|
+
|
|
53
51
|
async getAuthorization(): Promise<AuthorizationResponse> {
|
|
54
52
|
return this.get<AuthorizationResponse>('/usage/authorization')
|
|
55
53
|
}
|
|
@@ -93,4 +91,55 @@ export class UsageService extends BaseService {
|
|
|
93
91
|
return false
|
|
94
92
|
}
|
|
95
93
|
}
|
|
94
|
+
|
|
95
|
+
// Dashboard Analytics Methods
|
|
96
|
+
async getDashboardAnalytics(params?: DashboardAnalyticsRequest): Promise<DashboardAnalyticsResponse> {
|
|
97
|
+
const queryParams = new URLSearchParams()
|
|
98
|
+
|
|
99
|
+
if (params?.period) queryParams.append('period', params.period)
|
|
100
|
+
if (params?.start_date) queryParams.append('start_date', params.start_date)
|
|
101
|
+
if (params?.end_date) queryParams.append('end_date', params.end_date)
|
|
102
|
+
if (params?.service_type) queryParams.append('service_type', params.service_type)
|
|
103
|
+
|
|
104
|
+
const url = `/usage/dashboard/analytics${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
|
|
105
|
+
return this.get<DashboardAnalyticsResponse>(url)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async getUsageDetails(params?: UsageDetailsRequest): Promise<UsageDetailsResponse> {
|
|
109
|
+
const queryParams = new URLSearchParams()
|
|
110
|
+
|
|
111
|
+
if (params?.period) queryParams.append('period', params.period)
|
|
112
|
+
if (params?.start_date) queryParams.append('start_date', params.start_date)
|
|
113
|
+
if (params?.end_date) queryParams.append('end_date', params.end_date)
|
|
114
|
+
if (params?.service_type) queryParams.append('service_type', params.service_type)
|
|
115
|
+
if (params?.page !== undefined) queryParams.append('page', params.page.toString())
|
|
116
|
+
if (params?.page_size !== undefined) queryParams.append('page_size', params.page_size.toString())
|
|
117
|
+
if (params?.sort_by) queryParams.append('sort_by', params.sort_by)
|
|
118
|
+
if (params?.sort_order) queryParams.append('sort_order', params.sort_order)
|
|
119
|
+
|
|
120
|
+
const url = `/usage/dashboard/details${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
|
|
121
|
+
return this.get<UsageDetailsResponse>(url)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async getUsageSummary(params?: UsageSummaryRequest): Promise<UsageSummaryResponse> {
|
|
125
|
+
const queryParams = new URLSearchParams()
|
|
126
|
+
|
|
127
|
+
if (params?.period) queryParams.append('period', params.period)
|
|
128
|
+
if (params?.start_date) queryParams.append('start_date', params.start_date)
|
|
129
|
+
if (params?.end_date) queryParams.append('end_date', params.end_date)
|
|
130
|
+
|
|
131
|
+
const url = `/usage/dashboard/summary${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
|
|
132
|
+
return this.get<UsageSummaryResponse>(url)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async getServiceBreakdown(params?: ServiceBreakdownRequest): Promise<ServiceBreakdownResponse> {
|
|
136
|
+
const queryParams = new URLSearchParams()
|
|
137
|
+
|
|
138
|
+
if (params?.period) queryParams.append('period', params.period)
|
|
139
|
+
if (params?.start_date) queryParams.append('start_date', params.start_date)
|
|
140
|
+
if (params?.end_date) queryParams.append('end_date', params.end_date)
|
|
141
|
+
|
|
142
|
+
const url = `/usage/dashboard/services${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
|
|
143
|
+
return this.get<ServiceBreakdownResponse>(url)
|
|
144
|
+
}
|
|
96
145
|
}
|
|
@@ -13,7 +13,7 @@ export interface TrackUsageResponse {
|
|
|
13
13
|
message: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface CreditBalanceData {
|
|
17
17
|
user_id: string
|
|
18
18
|
total_consumed: number
|
|
19
19
|
total_allotted: number
|
|
@@ -27,6 +27,10 @@ export interface CreditBalanceResponse {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export interface CreditBalanceResponse {
|
|
31
|
+
data: CreditBalanceData
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
export interface CreditCheckRequest {
|
|
31
35
|
model_key: string
|
|
32
36
|
input_tokens?: number
|
|
@@ -41,33 +45,6 @@ export interface CreditCheckResponse {
|
|
|
41
45
|
model_key: string
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
export interface UsageSummaryRequest {
|
|
45
|
-
start_date?: string
|
|
46
|
-
end_date?: string
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface UsageSummaryResponse {
|
|
50
|
-
user_id: string
|
|
51
|
-
period: {
|
|
52
|
-
start_date: string
|
|
53
|
-
end_date: string
|
|
54
|
-
}
|
|
55
|
-
usage_summary: {
|
|
56
|
-
total_credits_used: number
|
|
57
|
-
total_calls: number
|
|
58
|
-
model_breakdown: Record<string, any>
|
|
59
|
-
daily_usage: Array<{
|
|
60
|
-
date: string
|
|
61
|
-
credits_used: number
|
|
62
|
-
calls: number
|
|
63
|
-
}>
|
|
64
|
-
}
|
|
65
|
-
subscription: {
|
|
66
|
-
plan: string
|
|
67
|
-
status: string
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
48
|
export interface CreditBalance {
|
|
72
49
|
total_allotted: number
|
|
73
50
|
total_consumed: number
|
|
@@ -183,15 +160,15 @@ export interface TrackCodespaceUsageResponse {
|
|
|
183
160
|
created_at: string
|
|
184
161
|
}
|
|
185
162
|
|
|
163
|
+
export interface CodespaceTaskUsageData {
|
|
164
|
+
total_records: number
|
|
165
|
+
total_credits_consumed: number
|
|
166
|
+
latest_usage: string
|
|
167
|
+
}
|
|
168
|
+
|
|
186
169
|
export interface CodespaceTaskUsageResponse {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
total_input_tokens: number
|
|
190
|
-
total_output_tokens: number
|
|
191
|
-
total_call_seconds: number
|
|
192
|
-
total_cost: number
|
|
193
|
-
}
|
|
194
|
-
usage_records: TrackCodespaceUsageResponse[]
|
|
170
|
+
status: string
|
|
171
|
+
data: CodespaceTaskUsageData
|
|
195
172
|
}
|
|
196
173
|
|
|
197
174
|
export interface HealthResponse {
|
|
@@ -199,3 +176,176 @@ export interface HealthResponse {
|
|
|
199
176
|
timestamp: string
|
|
200
177
|
version: string
|
|
201
178
|
}
|
|
179
|
+
|
|
180
|
+
// Dashboard Analytics Types
|
|
181
|
+
export type PeriodType = '7d' | '1w' | '1m' | '3m'
|
|
182
|
+
export type ServiceType = 'docs' | 'chat' | 'codespace_task' | 'api'
|
|
183
|
+
export type SortOrder = 'asc' | 'desc'
|
|
184
|
+
export type SortByField = 'created_at' | 'credits_consumed' | 'cost_amount'
|
|
185
|
+
|
|
186
|
+
export interface DashboardAnalyticsRequest {
|
|
187
|
+
period?: PeriodType
|
|
188
|
+
start_date?: string
|
|
189
|
+
end_date?: string
|
|
190
|
+
service_type?: ServiceType
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface DailyUsage {
|
|
194
|
+
date: string
|
|
195
|
+
credits_consumed: number
|
|
196
|
+
cost_usd: number
|
|
197
|
+
requests_count: number
|
|
198
|
+
average_credits_per_request: number
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface ServiceUsage {
|
|
202
|
+
service_type: ServiceType
|
|
203
|
+
credits_consumed: number
|
|
204
|
+
requests_count: number
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface AnalyticsTotals {
|
|
208
|
+
credits_consumed: number
|
|
209
|
+
cost_usd: number
|
|
210
|
+
requests_count: number
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface AnalyticsAverages {
|
|
214
|
+
daily_credits: number
|
|
215
|
+
daily_requests: number
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface AnalyticsTrends {
|
|
219
|
+
credits_consumed: number
|
|
220
|
+
requests_count: number
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface PeriodInfo {
|
|
224
|
+
start: string
|
|
225
|
+
end: string
|
|
226
|
+
label: string
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface DashboardAnalyticsResponse {
|
|
230
|
+
status: string
|
|
231
|
+
data: {
|
|
232
|
+
period: PeriodInfo
|
|
233
|
+
daily_usage: DailyUsage[]
|
|
234
|
+
totals: AnalyticsTotals
|
|
235
|
+
averages: AnalyticsAverages
|
|
236
|
+
trends: AnalyticsTrends
|
|
237
|
+
top_services: ServiceUsage[]
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Usage Details Types
|
|
242
|
+
export interface UsageDetailsRequest {
|
|
243
|
+
period?: PeriodType
|
|
244
|
+
start_date?: string
|
|
245
|
+
end_date?: string
|
|
246
|
+
service_type?: ServiceType
|
|
247
|
+
page?: number
|
|
248
|
+
page_size?: number
|
|
249
|
+
sort_by?: SortByField
|
|
250
|
+
sort_order?: SortOrder
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface UsageDetailRecord {
|
|
254
|
+
id: string
|
|
255
|
+
created_at: string
|
|
256
|
+
service_type: ServiceType
|
|
257
|
+
model_name: string
|
|
258
|
+
usage_type: string
|
|
259
|
+
units_consumed: number
|
|
260
|
+
credits_consumed: number
|
|
261
|
+
cost_amount: number | null
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface UsageDetailsPagination {
|
|
265
|
+
page: number
|
|
266
|
+
page_size: number
|
|
267
|
+
total_count: number
|
|
268
|
+
total_pages: number
|
|
269
|
+
has_next: boolean
|
|
270
|
+
has_prev: boolean
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface UsageDetailsFilters {
|
|
274
|
+
period: string | null
|
|
275
|
+
start_date: string | null
|
|
276
|
+
end_date: string | null
|
|
277
|
+
service_type: string | null
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface UsageDetailsResponse {
|
|
281
|
+
status: string
|
|
282
|
+
data: UsageDetailRecord[]
|
|
283
|
+
pagination: UsageDetailsPagination
|
|
284
|
+
filters: UsageDetailsFilters
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Usage Summary Types
|
|
288
|
+
export interface UsageSummaryRequest {
|
|
289
|
+
period?: PeriodType
|
|
290
|
+
start_date?: string
|
|
291
|
+
end_date?: string
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface CurrentPeriodUsage {
|
|
295
|
+
credits_consumed: number
|
|
296
|
+
cost_usd: number
|
|
297
|
+
requests_count: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface PreviousPeriodUsage {
|
|
301
|
+
credits_consumed: number
|
|
302
|
+
cost_usd: number
|
|
303
|
+
requests_count: number
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface BillingCycleInfo {
|
|
307
|
+
total_allotted: number
|
|
308
|
+
total_consumed: number
|
|
309
|
+
remaining_credits: number
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface UsageSummaryResponse {
|
|
313
|
+
status: string
|
|
314
|
+
data: {
|
|
315
|
+
current_period: CurrentPeriodUsage
|
|
316
|
+
previous_period: PreviousPeriodUsage
|
|
317
|
+
billing_cycle: BillingCycleInfo
|
|
318
|
+
utilization_percentage: number
|
|
319
|
+
remaining_credits: number
|
|
320
|
+
daily_average: number
|
|
321
|
+
projected_monthly: number
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Service Breakdown Types
|
|
326
|
+
export interface ServiceBreakdownRequest {
|
|
327
|
+
period?: PeriodType
|
|
328
|
+
start_date?: string
|
|
329
|
+
end_date?: string
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface ServiceBreakdown {
|
|
333
|
+
service_type: ServiceType
|
|
334
|
+
credits_consumed: number
|
|
335
|
+
percentage: number
|
|
336
|
+
cost_usd: number
|
|
337
|
+
requests_count: number
|
|
338
|
+
trend: number
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface ServiceBreakdownData {
|
|
342
|
+
period: PeriodInfo
|
|
343
|
+
services: ServiceBreakdown[]
|
|
344
|
+
total_credits: number
|
|
345
|
+
total_cost: number
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export interface ServiceBreakdownResponse {
|
|
349
|
+
status: string
|
|
350
|
+
data: ServiceBreakdownData
|
|
351
|
+
}
|