@codeguide/core 0.0.27 → 0.0.29
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/README.md +50 -41
- package/__tests__/services/codespace/codespace-v2.test.ts +29 -18
- package/__tests__/services/usage/usage-service.test.ts +597 -85
- package/codeguide.ts +6 -0
- package/dist/codeguide.d.ts +3 -1
- package/dist/codeguide.js +2 -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 +55 -1
- package/dist/services/codespace/codespace-service.js +260 -5
- package/dist/services/codespace/codespace-types.d.ts +193 -13
- package/dist/services/codespace/index.d.ts +1 -1
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +7 -1
- package/dist/services/projects/project-types.d.ts +66 -32
- package/dist/services/repository-analysis/repository-types.d.ts +1 -0
- 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/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 +207 -34
- package/dist/services/users/index.d.ts +2 -0
- package/dist/services/users/index.js +20 -0
- package/dist/services/users/user-service.d.ts +12 -0
- package/dist/services/users/user-service.js +17 -0
- package/dist/services/users/user-types.d.ts +55 -0
- package/dist/services/users/user-types.js +2 -0
- 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 +558 -81
- 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 +616 -0
- package/index.ts +11 -3
- package/package.json +16 -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 +347 -8
- package/services/codespace/codespace-types.ts +263 -14
- package/services/codespace/index.ts +16 -1
- package/services/index.ts +4 -0
- package/services/projects/README.md +107 -34
- package/services/projects/project-types.ts +69 -32
- package/services/repository-analysis/repository-types.ts +1 -0
- 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/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 +239 -34
- package/services/users/index.ts +2 -0
- package/services/users/user-service.ts +15 -0
- package/services/users/user-types.ts +59 -0
|
@@ -9,6 +9,7 @@ export interface AnalyzeRepositoryRequest {
|
|
|
9
9
|
codespace_task_description?: string
|
|
10
10
|
codespace_branch?: string
|
|
11
11
|
codespace_base_branch?: string
|
|
12
|
+
execution_mode?: 'implementation' | 'docs-only' | 'direct'
|
|
12
13
|
model_api_keys?: {
|
|
13
14
|
model_name: string
|
|
14
15
|
api_key: string
|
|
@@ -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
|
+
|
|
@@ -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,45 +45,73 @@ export interface CreditCheckResponse {
|
|
|
41
45
|
model_key: string
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
|
|
49
|
+
export interface CreditBalance {
|
|
50
|
+
total_allotted: number
|
|
51
|
+
total_consumed: number
|
|
52
|
+
remaining_credits: number
|
|
53
|
+
is_over_limit: boolean
|
|
54
|
+
utilization_percentage: number
|
|
55
|
+
billing_cycle_start: string
|
|
56
|
+
billing_cycle_end: string
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
export interface
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
export interface LimitInfo {
|
|
60
|
+
allowed?: boolean
|
|
61
|
+
current_usage?: number
|
|
62
|
+
limit: number
|
|
63
|
+
remaining?: number
|
|
64
|
+
period_type?: string
|
|
65
|
+
period_start?: string | null
|
|
66
|
+
period_end?: string | null
|
|
67
|
+
message?: string
|
|
68
|
+
is_unlimited: boolean
|
|
69
|
+
period?: string
|
|
70
|
+
description?: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface PlanLimits {
|
|
74
|
+
plan_type: string
|
|
75
|
+
limits: {
|
|
76
|
+
codespace_tasks: LimitInfo
|
|
77
|
+
api_calls: LimitInfo
|
|
78
|
+
storage_gb: LimitInfo
|
|
79
|
+
projects: LimitInfo
|
|
80
|
+
collaborators: LimitInfo
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
83
|
|
|
71
|
-
export interface
|
|
84
|
+
export interface AuthorizationSubscription {
|
|
85
|
+
id: string
|
|
86
|
+
status: string
|
|
87
|
+
interval: string
|
|
88
|
+
current_period_start: string
|
|
89
|
+
current_period_end: string
|
|
90
|
+
price_id: string
|
|
91
|
+
product_name: string | null
|
|
92
|
+
plan_name: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface AuthorizationData {
|
|
72
96
|
user_id: string
|
|
73
|
-
subscription:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
subscription: AuthorizationSubscription | null
|
|
98
|
+
credit_balance: CreditBalance
|
|
99
|
+
has_active_subscription: boolean
|
|
100
|
+
has_previous_subscriptions: boolean
|
|
101
|
+
is_within_credit_limit: boolean
|
|
102
|
+
authorization_level: string
|
|
103
|
+
restrictions: string[]
|
|
104
|
+
can_create_tasks: boolean
|
|
105
|
+
can_analyze_repos: boolean
|
|
106
|
+
can_access_previous_projects: boolean
|
|
107
|
+
plan_limits: PlanLimits
|
|
108
|
+
codespace_task_limit: LimitInfo | null
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface AuthorizationResponse {
|
|
112
|
+
success: boolean
|
|
113
|
+
data: AuthorizationData
|
|
114
|
+
message: string
|
|
83
115
|
}
|
|
84
116
|
|
|
85
117
|
export interface FreeUserStatusResponse {
|
|
@@ -145,3 +177,176 @@ export interface HealthResponse {
|
|
|
145
177
|
timestamp: string
|
|
146
178
|
version: string
|
|
147
179
|
}
|
|
180
|
+
|
|
181
|
+
// Dashboard Analytics Types
|
|
182
|
+
export type PeriodType = "7d" | "1w" | "1m" | "3m"
|
|
183
|
+
export type ServiceType = "docs" | "chat" | "codespace_task" | "api"
|
|
184
|
+
export type SortOrder = "asc" | "desc"
|
|
185
|
+
export type SortByField = "created_at" | "credits_consumed" | "cost_amount"
|
|
186
|
+
|
|
187
|
+
export interface DashboardAnalyticsRequest {
|
|
188
|
+
period?: PeriodType
|
|
189
|
+
start_date?: string
|
|
190
|
+
end_date?: string
|
|
191
|
+
service_type?: ServiceType
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface DailyUsage {
|
|
195
|
+
date: string
|
|
196
|
+
credits_consumed: number
|
|
197
|
+
cost_usd: number
|
|
198
|
+
requests_count: number
|
|
199
|
+
average_credits_per_request: number
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface ServiceUsage {
|
|
203
|
+
service_type: ServiceType
|
|
204
|
+
credits_consumed: number
|
|
205
|
+
requests_count: number
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface AnalyticsTotals {
|
|
209
|
+
credits_consumed: number
|
|
210
|
+
cost_usd: number
|
|
211
|
+
requests_count: number
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface AnalyticsAverages {
|
|
215
|
+
daily_credits: number
|
|
216
|
+
daily_requests: number
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface AnalyticsTrends {
|
|
220
|
+
credits_consumed: number
|
|
221
|
+
requests_count: number
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface PeriodInfo {
|
|
225
|
+
start: string
|
|
226
|
+
end: string
|
|
227
|
+
label: string
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface DashboardAnalyticsResponse {
|
|
231
|
+
status: string
|
|
232
|
+
data: {
|
|
233
|
+
period: PeriodInfo
|
|
234
|
+
daily_usage: DailyUsage[]
|
|
235
|
+
totals: AnalyticsTotals
|
|
236
|
+
averages: AnalyticsAverages
|
|
237
|
+
trends: AnalyticsTrends
|
|
238
|
+
top_services: ServiceUsage[]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Usage Details Types
|
|
243
|
+
export interface UsageDetailsRequest {
|
|
244
|
+
period?: PeriodType
|
|
245
|
+
start_date?: string
|
|
246
|
+
end_date?: string
|
|
247
|
+
service_type?: ServiceType
|
|
248
|
+
page?: number
|
|
249
|
+
page_size?: number
|
|
250
|
+
sort_by?: SortByField
|
|
251
|
+
sort_order?: SortOrder
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface UsageDetailRecord {
|
|
255
|
+
id: string
|
|
256
|
+
created_at: string
|
|
257
|
+
service_type: ServiceType
|
|
258
|
+
model_name: string
|
|
259
|
+
usage_type: string
|
|
260
|
+
units_consumed: number
|
|
261
|
+
credits_consumed: number
|
|
262
|
+
cost_amount: number | null
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface UsageDetailsPagination {
|
|
266
|
+
page: number
|
|
267
|
+
page_size: number
|
|
268
|
+
total_count: number
|
|
269
|
+
total_pages: number
|
|
270
|
+
has_next: boolean
|
|
271
|
+
has_prev: boolean
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface UsageDetailsFilters {
|
|
275
|
+
period: string | null
|
|
276
|
+
start_date: string | null
|
|
277
|
+
end_date: string | null
|
|
278
|
+
service_type: string | null
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface UsageDetailsResponse {
|
|
282
|
+
status: string
|
|
283
|
+
data: UsageDetailRecord[]
|
|
284
|
+
pagination: UsageDetailsPagination
|
|
285
|
+
filters: UsageDetailsFilters
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Usage Summary Types
|
|
289
|
+
export interface UsageSummaryRequest {
|
|
290
|
+
period?: PeriodType
|
|
291
|
+
start_date?: string
|
|
292
|
+
end_date?: string
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface CurrentPeriodUsage {
|
|
296
|
+
credits_consumed: number
|
|
297
|
+
cost_usd: number
|
|
298
|
+
requests_count: number
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface PreviousPeriodUsage {
|
|
302
|
+
credits_consumed: number
|
|
303
|
+
cost_usd: number
|
|
304
|
+
requests_count: number
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface BillingCycleInfo {
|
|
308
|
+
total_allotted: number
|
|
309
|
+
total_consumed: number
|
|
310
|
+
remaining_credits: number
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface UsageSummaryResponse {
|
|
314
|
+
status: string
|
|
315
|
+
data: {
|
|
316
|
+
current_period: CurrentPeriodUsage
|
|
317
|
+
previous_period: PreviousPeriodUsage
|
|
318
|
+
billing_cycle: BillingCycleInfo
|
|
319
|
+
utilization_percentage: number
|
|
320
|
+
remaining_credits: number
|
|
321
|
+
daily_average: number
|
|
322
|
+
projected_monthly: number
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Service Breakdown Types
|
|
327
|
+
export interface ServiceBreakdownRequest {
|
|
328
|
+
period?: PeriodType
|
|
329
|
+
start_date?: string
|
|
330
|
+
end_date?: string
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface ServiceBreakdown {
|
|
334
|
+
service_type: ServiceType
|
|
335
|
+
credits_consumed: number
|
|
336
|
+
percentage: number
|
|
337
|
+
cost_usd: number
|
|
338
|
+
requests_count: number
|
|
339
|
+
trend: number
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface ServiceBreakdownData {
|
|
343
|
+
period: PeriodInfo
|
|
344
|
+
services: ServiceBreakdown[]
|
|
345
|
+
total_credits: number
|
|
346
|
+
total_cost: number
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface ServiceBreakdownResponse {
|
|
350
|
+
status: string
|
|
351
|
+
data: ServiceBreakdownData
|
|
352
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service'
|
|
2
|
+
import { GetCurrentClerkUserResponse } from './user-types'
|
|
3
|
+
|
|
4
|
+
export class UserService extends BaseService {
|
|
5
|
+
/**
|
|
6
|
+
* Get the current Clerk user information
|
|
7
|
+
*
|
|
8
|
+
* GET /users/me/clerk
|
|
9
|
+
*
|
|
10
|
+
* @returns Promise resolving to the current Clerk user data
|
|
11
|
+
*/
|
|
12
|
+
async getCurrentClerkUser(): Promise<GetCurrentClerkUserResponse> {
|
|
13
|
+
return this.get<GetCurrentClerkUserResponse>('/users/me/clerk')
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email address verification information
|
|
3
|
+
*/
|
|
4
|
+
export interface EmailVerification {
|
|
5
|
+
status: 'verified' | 'unverified'
|
|
6
|
+
strategy: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Email address information
|
|
11
|
+
*/
|
|
12
|
+
export interface EmailAddress {
|
|
13
|
+
id: string
|
|
14
|
+
email_address: string
|
|
15
|
+
verification: EmailVerification
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Clerk user metadata
|
|
20
|
+
*/
|
|
21
|
+
export interface ClerkUserMetadata {
|
|
22
|
+
[key: string]: any
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Clerk user data structure
|
|
27
|
+
*/
|
|
28
|
+
export interface ClerkUserData {
|
|
29
|
+
user_id: string
|
|
30
|
+
first_name: string | null
|
|
31
|
+
last_name: string | null
|
|
32
|
+
username: string | null
|
|
33
|
+
email_addresses: EmailAddress[]
|
|
34
|
+
phone_numbers: Array<{
|
|
35
|
+
id: string
|
|
36
|
+
phone_number: string
|
|
37
|
+
verification: {
|
|
38
|
+
status: 'verified' | 'unverified'
|
|
39
|
+
strategy: string
|
|
40
|
+
}
|
|
41
|
+
}>
|
|
42
|
+
primary_email_address: string | null
|
|
43
|
+
primary_phone_number: string | null
|
|
44
|
+
image_url: string | null
|
|
45
|
+
created_at: number
|
|
46
|
+
updated_at: number
|
|
47
|
+
last_sign_in_at: number | null
|
|
48
|
+
public_metadata: ClerkUserMetadata
|
|
49
|
+
private_metadata: ClerkUserMetadata
|
|
50
|
+
unsafe_metadata: ClerkUserMetadata
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Response for getting current Clerk user
|
|
55
|
+
*/
|
|
56
|
+
export interface GetCurrentClerkUserResponse {
|
|
57
|
+
status: 'success' | 'error'
|
|
58
|
+
data: ClerkUserData
|
|
59
|
+
}
|