@codeguide/core 0.0.33 → 0.0.36
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/usage/usage-service.test.ts +53 -29
- package/codeguide.ts +9 -0
- package/dist/codeguide.d.ts +4 -1
- package/dist/codeguide.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/services/chat/chat-service.d.ts +44 -0
- package/dist/services/chat/chat-service.js +85 -0
- package/dist/services/chat/chat-types.d.ts +88 -0
- package/dist/services/chat/chat-types.js +5 -0
- package/dist/services/chat/index.d.ts +2 -0
- package/dist/services/chat/index.js +20 -0
- package/dist/services/data-management/data-management-service.d.ts +53 -0
- package/dist/services/data-management/data-management-service.js +66 -0
- package/dist/services/data-management/data-management-types.d.ts +149 -0
- package/dist/services/data-management/data-management-types.js +7 -0
- package/dist/services/data-management/index.d.ts +2 -0
- package/dist/services/data-management/index.js +20 -0
- package/dist/services/generation/generation-service.d.ts +7 -1
- package/dist/services/generation/generation-service.js +18 -0
- package/dist/services/generation/generation-types.d.ts +123 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.js +13 -1
- package/dist/services/projects/project-service.d.ts +3 -1
- package/dist/services/projects/project-service.js +13 -1
- package/dist/services/projects/project-types.d.ts +85 -8
- package/dist/services/prompt-generations/index.d.ts +2 -0
- package/dist/services/prompt-generations/index.js +20 -0
- package/dist/services/prompt-generations/prompt-generations-service.d.ts +47 -0
- package/dist/services/prompt-generations/prompt-generations-service.js +58 -0
- package/dist/services/prompt-generations/prompt-generations-types.d.ts +94 -0
- package/dist/services/prompt-generations/prompt-generations-types.js +2 -0
- package/dist/services/streaming/index.d.ts +2 -0
- package/dist/services/streaming/index.js +20 -0
- package/dist/services/streaming/streaming-service.d.ts +30 -0
- package/dist/services/streaming/streaming-service.js +107 -0
- package/dist/services/streaming/streaming-types.d.ts +14 -0
- package/dist/services/streaming/streaming-types.js +2 -0
- package/dist/services/tasks/task-service.d.ts +3 -1
- package/dist/services/tasks/task-service.js +8 -0
- package/dist/services/tasks/task-types.d.ts +15 -0
- package/dist/services/usage/usage-service.d.ts +35 -1
- package/dist/services/usage/usage-service.js +68 -0
- package/dist/services/usage/usage-types.d.ts +109 -33
- package/dist/services/users/user-service.d.ts +9 -1
- package/dist/services/users/user-service.js +10 -0
- package/dist/services/users/user-types.d.ts +14 -0
- package/index.ts +10 -0
- package/package.json +1 -1
- package/services/chat/chat-service.ts +110 -0
- package/services/chat/chat-types.ts +145 -0
- package/services/chat/index.ts +2 -0
- package/services/data-management/data-management-service.ts +74 -0
- package/services/data-management/data-management-types.ts +163 -0
- package/services/data-management/index.ts +2 -0
- package/services/generation/generation-service.ts +40 -0
- package/services/generation/generation-types.ts +140 -0
- package/services/index.ts +8 -0
- package/services/projects/README.md +54 -0
- package/services/projects/project-service.ts +20 -1
- package/services/projects/project-types.ts +88 -8
- package/services/prompt-generations/index.ts +2 -0
- package/services/prompt-generations/prompt-generations-service.ts +75 -0
- package/services/prompt-generations/prompt-generations-types.ts +101 -0
- package/services/streaming/index.ts +2 -0
- package/services/streaming/streaming-service.ts +123 -0
- package/services/streaming/streaming-types.ts +15 -0
- package/services/tasks/task-service.ts +30 -2
- package/services/tasks/task-types.ts +19 -1
- package/services/usage/usage-service.ts +81 -0
- package/services/usage/usage-types.ts +117 -36
- package/services/users/user-service.ts +15 -1
- package/services/users/user-types.ts +16 -0
|
@@ -45,8 +45,8 @@ export interface CreditBalance {
|
|
|
45
45
|
remaining_credits: number;
|
|
46
46
|
is_over_limit: boolean;
|
|
47
47
|
utilization_percentage: number;
|
|
48
|
-
billing_cycle_start
|
|
49
|
-
billing_cycle_end
|
|
48
|
+
billing_cycle_start?: string;
|
|
49
|
+
billing_cycle_end?: string;
|
|
50
50
|
}
|
|
51
51
|
export interface LimitInfo {
|
|
52
52
|
allowed?: boolean;
|
|
@@ -69,17 +69,18 @@ export interface PlanLimits {
|
|
|
69
69
|
storage_gb: LimitInfo;
|
|
70
70
|
projects: LimitInfo;
|
|
71
71
|
collaborators: LimitInfo;
|
|
72
|
+
softwarev2_access?: LimitInfo;
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
export interface AuthorizationSubscription {
|
|
75
|
-
id
|
|
76
|
-
status
|
|
77
|
-
interval
|
|
78
|
-
current_period_start
|
|
79
|
-
current_period_end
|
|
80
|
-
price_id
|
|
81
|
-
product_name
|
|
82
|
-
plan_name
|
|
76
|
+
id?: string;
|
|
77
|
+
status?: string;
|
|
78
|
+
interval?: string;
|
|
79
|
+
current_period_start?: string;
|
|
80
|
+
current_period_end?: string;
|
|
81
|
+
price_id?: string;
|
|
82
|
+
product_name?: string | null;
|
|
83
|
+
plan_name?: string;
|
|
83
84
|
}
|
|
84
85
|
export interface AuthorizationData {
|
|
85
86
|
user_id: string;
|
|
@@ -93,7 +94,7 @@ export interface AuthorizationData {
|
|
|
93
94
|
can_create_tasks: boolean;
|
|
94
95
|
can_analyze_repos: boolean;
|
|
95
96
|
can_access_previous_projects: boolean;
|
|
96
|
-
plan_limits
|
|
97
|
+
plan_limits?: PlanLimits | null;
|
|
97
98
|
codespace_task_limit: LimitInfo | null;
|
|
98
99
|
}
|
|
99
100
|
export interface AuthorizationResponse {
|
|
@@ -253,31 +254,23 @@ export interface UsageSummaryRequest {
|
|
|
253
254
|
start_date?: string;
|
|
254
255
|
end_date?: string;
|
|
255
256
|
}
|
|
256
|
-
export interface CurrentPeriodUsage {
|
|
257
|
-
credits_consumed: number;
|
|
258
|
-
cost_usd: number;
|
|
259
|
-
requests_count: number;
|
|
260
|
-
}
|
|
261
|
-
export interface PreviousPeriodUsage {
|
|
262
|
-
credits_consumed: number;
|
|
263
|
-
cost_usd: number;
|
|
264
|
-
requests_count: number;
|
|
265
|
-
}
|
|
266
|
-
export interface BillingCycleInfo {
|
|
267
|
-
total_allotted: number;
|
|
268
|
-
total_consumed: number;
|
|
269
|
-
remaining_credits: number;
|
|
270
|
-
}
|
|
271
257
|
export interface UsageSummaryResponse {
|
|
272
258
|
status: string;
|
|
273
259
|
data: {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
260
|
+
period: {
|
|
261
|
+
start?: string;
|
|
262
|
+
end?: string;
|
|
263
|
+
};
|
|
264
|
+
usage: {
|
|
265
|
+
[key: string]: number;
|
|
266
|
+
};
|
|
267
|
+
breakdown: {
|
|
268
|
+
[key: string]: number;
|
|
269
|
+
};
|
|
270
|
+
service_breakdown: Array<{
|
|
271
|
+
service_type: string;
|
|
272
|
+
[key: string]: any;
|
|
273
|
+
}>;
|
|
281
274
|
};
|
|
282
275
|
}
|
|
283
276
|
export interface ServiceBreakdownRequest {
|
|
@@ -303,3 +296,86 @@ export interface ServiceBreakdownResponse {
|
|
|
303
296
|
status: string;
|
|
304
297
|
data: ServiceBreakdownData;
|
|
305
298
|
}
|
|
299
|
+
export type HeatmapPeriodType = '3m' | '6m' | '1y';
|
|
300
|
+
export type ActivityLevel = 0 | 1 | 2 | 3 | 4;
|
|
301
|
+
export interface ActivityHeatmapRequest {
|
|
302
|
+
period?: HeatmapPeriodType;
|
|
303
|
+
start_date?: string;
|
|
304
|
+
end_date?: string;
|
|
305
|
+
}
|
|
306
|
+
export interface HeatmapDayData {
|
|
307
|
+
date: string;
|
|
308
|
+
count: number;
|
|
309
|
+
level: ActivityLevel;
|
|
310
|
+
}
|
|
311
|
+
export interface ActivityHeatmapData {
|
|
312
|
+
period: PeriodInfo;
|
|
313
|
+
days: HeatmapDayData[];
|
|
314
|
+
total_tasks: number;
|
|
315
|
+
most_active_day: string | null;
|
|
316
|
+
max_daily_count: number;
|
|
317
|
+
average_daily: number;
|
|
318
|
+
active_days: number;
|
|
319
|
+
}
|
|
320
|
+
export interface ActivityHeatmapResponse {
|
|
321
|
+
status: string;
|
|
322
|
+
data: ActivityHeatmapData;
|
|
323
|
+
}
|
|
324
|
+
export type RepoAnalysisPeriodType = '7d' | '1w' | '1m' | '3m' | '6m' | '1y';
|
|
325
|
+
export interface RepositoryAnalysisSummaryRequest {
|
|
326
|
+
period?: RepoAnalysisPeriodType;
|
|
327
|
+
start_date?: string;
|
|
328
|
+
end_date?: string;
|
|
329
|
+
}
|
|
330
|
+
export interface RepositoryAnalysisSummaryData {
|
|
331
|
+
total_repositories: number;
|
|
332
|
+
total_lines: number;
|
|
333
|
+
total_files_processed: number;
|
|
334
|
+
total_files_found: number;
|
|
335
|
+
total_directories: number;
|
|
336
|
+
total_characters: number;
|
|
337
|
+
estimated_tokens_total: number;
|
|
338
|
+
total_size_bytes: number;
|
|
339
|
+
binary_files_skipped: number;
|
|
340
|
+
large_files_skipped: number;
|
|
341
|
+
encoding_errors: number;
|
|
342
|
+
average_lines_per_repo: number;
|
|
343
|
+
average_files_per_repo: number;
|
|
344
|
+
period: PeriodInfo | null;
|
|
345
|
+
}
|
|
346
|
+
export interface RepositoryAnalysisSummaryResponse {
|
|
347
|
+
status: string;
|
|
348
|
+
data: RepositoryAnalysisSummaryData;
|
|
349
|
+
}
|
|
350
|
+
export type TimelineGranularity = 'daily' | 'weekly' | 'monthly';
|
|
351
|
+
export interface RepositoryAnalysisTimelineRequest {
|
|
352
|
+
period?: RepoAnalysisPeriodType;
|
|
353
|
+
start_date?: string;
|
|
354
|
+
end_date?: string;
|
|
355
|
+
granularity?: TimelineGranularity;
|
|
356
|
+
}
|
|
357
|
+
export interface RepositoryAnalysisTimelineItem {
|
|
358
|
+
date: string;
|
|
359
|
+
repos_analyzed: number;
|
|
360
|
+
total_lines: number;
|
|
361
|
+
total_files: number;
|
|
362
|
+
total_characters: number;
|
|
363
|
+
estimated_tokens: number;
|
|
364
|
+
}
|
|
365
|
+
export interface RepositoryAnalysisTimelineTotals {
|
|
366
|
+
repos_analyzed: number;
|
|
367
|
+
total_lines: number;
|
|
368
|
+
total_files: number;
|
|
369
|
+
total_characters: number;
|
|
370
|
+
estimated_tokens: number;
|
|
371
|
+
}
|
|
372
|
+
export interface RepositoryAnalysisTimelineData {
|
|
373
|
+
period: PeriodInfo;
|
|
374
|
+
granularity: TimelineGranularity;
|
|
375
|
+
timeline: RepositoryAnalysisTimelineItem[];
|
|
376
|
+
totals: RepositoryAnalysisTimelineTotals;
|
|
377
|
+
}
|
|
378
|
+
export interface RepositoryAnalysisTimelineResponse {
|
|
379
|
+
status: string;
|
|
380
|
+
data: RepositoryAnalysisTimelineData;
|
|
381
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseService } from '../base/base-service';
|
|
2
|
-
import { GetCurrentClerkUserResponse } from './user-types';
|
|
2
|
+
import { GetCurrentClerkUserResponse, CheckAdminStatusResponse } from './user-types';
|
|
3
3
|
export declare class UserService extends BaseService {
|
|
4
4
|
/**
|
|
5
5
|
* Get the current Clerk user information
|
|
@@ -9,4 +9,12 @@ export declare class UserService extends BaseService {
|
|
|
9
9
|
* @returns Promise resolving to the current Clerk user data
|
|
10
10
|
*/
|
|
11
11
|
getCurrentClerkUser(): Promise<GetCurrentClerkUserResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if the current authenticated user has admin role
|
|
14
|
+
*
|
|
15
|
+
* GET /users/me/admin
|
|
16
|
+
*
|
|
17
|
+
* @returns Promise resolving to admin status data
|
|
18
|
+
*/
|
|
19
|
+
checkAdminStatus(): Promise<CheckAdminStatusResponse>;
|
|
12
20
|
}
|
|
@@ -13,5 +13,15 @@ class UserService extends base_service_1.BaseService {
|
|
|
13
13
|
async getCurrentClerkUser() {
|
|
14
14
|
return this.get('/users/me/clerk');
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if the current authenticated user has admin role
|
|
18
|
+
*
|
|
19
|
+
* GET /users/me/admin
|
|
20
|
+
*
|
|
21
|
+
* @returns Promise resolving to admin status data
|
|
22
|
+
*/
|
|
23
|
+
async checkAdminStatus() {
|
|
24
|
+
return this.get('/users/me/admin');
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
exports.UserService = UserService;
|
|
@@ -53,3 +53,17 @@ export interface GetCurrentClerkUserResponse {
|
|
|
53
53
|
status: 'success' | 'error';
|
|
54
54
|
data: ClerkUserData;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Admin status check data
|
|
58
|
+
*/
|
|
59
|
+
export interface AdminStatusData {
|
|
60
|
+
is_admin: boolean;
|
|
61
|
+
user_id: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Response for checking if current user is admin
|
|
65
|
+
*/
|
|
66
|
+
export interface CheckAdminStatusResponse {
|
|
67
|
+
status: 'success' | 'error';
|
|
68
|
+
data: AdminStatusData;
|
|
69
|
+
}
|
package/index.ts
CHANGED
|
@@ -19,6 +19,9 @@ export type {
|
|
|
19
19
|
GetProjectsRequest,
|
|
20
20
|
PaginatedProjectsRequest,
|
|
21
21
|
PaginatedProjectsResponse,
|
|
22
|
+
AITool,
|
|
23
|
+
GetAiToolsRequest,
|
|
24
|
+
GetAiToolsResponse,
|
|
22
25
|
} from './services/projects/project-types'
|
|
23
26
|
export type {
|
|
24
27
|
CreateCodespaceTaskRequestV2 as CreateCodespaceTaskRequest,
|
|
@@ -54,3 +57,10 @@ export type {
|
|
|
54
57
|
GetStarterKitsRequest,
|
|
55
58
|
GetStarterKitsResponse,
|
|
56
59
|
} from './services/starter-kits/starter-kits-types'
|
|
60
|
+
|
|
61
|
+
// Export data management types for convenience
|
|
62
|
+
export type {
|
|
63
|
+
DataStatsResponse,
|
|
64
|
+
DeleteAllDataRequest,
|
|
65
|
+
DeleteAllDataResponse,
|
|
66
|
+
} from './services/data-management/data-management-types'
|
package/package.json
CHANGED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service'
|
|
2
|
+
import {
|
|
3
|
+
GetDocumentTypesRequest,
|
|
4
|
+
GetDocumentTypesResponse,
|
|
5
|
+
GetChatsByDocumentTypeRequest,
|
|
6
|
+
GetChatsByDocumentTypeResponse,
|
|
7
|
+
GetChatHistoryRequest,
|
|
8
|
+
GetChatHistoryResponse,
|
|
9
|
+
ListDocumentChatsRequest,
|
|
10
|
+
ListDocumentChatsResponse,
|
|
11
|
+
GetChatByDocumentIdRequest,
|
|
12
|
+
GetChatByDocumentIdResponse,
|
|
13
|
+
} from './chat-types'
|
|
14
|
+
|
|
15
|
+
export class ChatService extends BaseService {
|
|
16
|
+
/**
|
|
17
|
+
* 1. GET /chat/document/types/{project_id}
|
|
18
|
+
* Get document types for UI grouping
|
|
19
|
+
*
|
|
20
|
+
* @param request - Project ID to get document types for
|
|
21
|
+
* @returns Document types available for the project
|
|
22
|
+
*/
|
|
23
|
+
async getDocumentTypes(request: GetDocumentTypesRequest): Promise<GetDocumentTypesResponse> {
|
|
24
|
+
return this.get<GetDocumentTypesResponse>(`/chat/document/types/${request.project_id}`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 2. GET /chat/document/by-type/{project_id}/{document_type}
|
|
29
|
+
* List all chats for a specific document type (PRIMARY endpoint for UI)
|
|
30
|
+
*
|
|
31
|
+
* @param request - Filter parameters for document type chats
|
|
32
|
+
* @returns Paginated list of document chats for the specified type
|
|
33
|
+
*/
|
|
34
|
+
async getChatsByDocumentType(
|
|
35
|
+
request: GetChatsByDocumentTypeRequest
|
|
36
|
+
): Promise<GetChatsByDocumentTypeResponse> {
|
|
37
|
+
const { project_id, document_type, chat_status = 'active', limit = 50, offset = 0 } = request
|
|
38
|
+
|
|
39
|
+
// Build query parameters
|
|
40
|
+
const params = new URLSearchParams()
|
|
41
|
+
if (chat_status) params.append('chat_status', chat_status)
|
|
42
|
+
if (limit !== undefined) params.append('limit', limit.toString())
|
|
43
|
+
if (offset !== undefined) params.append('offset', offset.toString())
|
|
44
|
+
|
|
45
|
+
const queryString = params.toString()
|
|
46
|
+
const url = `/chat/document/by-type/${project_id}/${document_type}${queryString ? `?${queryString}` : ''}`
|
|
47
|
+
|
|
48
|
+
return this.get<GetChatsByDocumentTypeResponse>(url)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 3. GET /chat/document/history/{conversation_id}
|
|
53
|
+
* Get full chat history with messages
|
|
54
|
+
*
|
|
55
|
+
* @param request - Conversation ID to get history for
|
|
56
|
+
* @returns Conversation details with all messages
|
|
57
|
+
*/
|
|
58
|
+
async getChatHistory(request: GetChatHistoryRequest): Promise<GetChatHistoryResponse> {
|
|
59
|
+
return this.get<GetChatHistoryResponse>(`/chat/document/history/${request.conversation_id}`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 4. GET /chat/document/list
|
|
64
|
+
* List all chats for current user (with optional filters)
|
|
65
|
+
*
|
|
66
|
+
* @param request - Filter parameters for listing chats
|
|
67
|
+
* @returns Paginated list of all document chats for the user
|
|
68
|
+
*/
|
|
69
|
+
async listDocumentChats(
|
|
70
|
+
request: ListDocumentChatsRequest = {}
|
|
71
|
+
): Promise<ListDocumentChatsResponse> {
|
|
72
|
+
const {
|
|
73
|
+
project_id,
|
|
74
|
+
document_type,
|
|
75
|
+
template,
|
|
76
|
+
chat_status = 'active',
|
|
77
|
+
limit = 50,
|
|
78
|
+
offset = 0,
|
|
79
|
+
} = request
|
|
80
|
+
|
|
81
|
+
// Build query parameters
|
|
82
|
+
const params = new URLSearchParams()
|
|
83
|
+
if (project_id) params.append('project_id', project_id)
|
|
84
|
+
if (document_type) params.append('document_type', document_type)
|
|
85
|
+
if (template) params.append('template', template)
|
|
86
|
+
if (chat_status) params.append('chat_status', chat_status)
|
|
87
|
+
if (limit !== undefined) params.append('limit', limit.toString())
|
|
88
|
+
if (offset !== undefined) params.append('offset', offset.toString())
|
|
89
|
+
|
|
90
|
+
const queryString = params.toString()
|
|
91
|
+
const url = `/chat/document/list${queryString ? `?${queryString}` : ''}`
|
|
92
|
+
|
|
93
|
+
return this.get<ListDocumentChatsResponse>(url)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 5. GET /chat/document/by-document/{document_id}
|
|
98
|
+
* Get chat by specific document version ID (Legacy)
|
|
99
|
+
*
|
|
100
|
+
* @param request - Document ID to get chat for
|
|
101
|
+
* @returns Conversation and messages for the specific document
|
|
102
|
+
*/
|
|
103
|
+
async getChatByDocumentId(
|
|
104
|
+
request: GetChatByDocumentIdRequest
|
|
105
|
+
): Promise<GetChatByDocumentIdResponse> {
|
|
106
|
+
return this.get<GetChatByDocumentIdResponse>(
|
|
107
|
+
`/chat/document/by-document/${request.document_id}`
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Document Chat GET Endpoint Types
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// 1. GET /chat/document/types/{project_id}
|
|
7
|
+
// Get document types for UI grouping
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
export interface GetDocumentTypesRequest {
|
|
11
|
+
project_id: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface GetDocumentTypesResponse {
|
|
15
|
+
project_id: string
|
|
16
|
+
project_name: string
|
|
17
|
+
document_types: DocumentType[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type DocumentType =
|
|
21
|
+
| 'project_requirements_document'
|
|
22
|
+
| 'app_flow_document'
|
|
23
|
+
| 'tech_stack_document'
|
|
24
|
+
| 'frontend_guidelines_document'
|
|
25
|
+
| 'database_schema_document'
|
|
26
|
+
| 'api_documentation_document'
|
|
27
|
+
| 'deployment_document'
|
|
28
|
+
| 'testing_document'
|
|
29
|
+
| 'custom_document'
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// 2. GET /chat/document/by-type/{project_id}/{document_type}
|
|
33
|
+
// List all chats for a specific document type (PRIMARY endpoint for UI)
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
export interface GetChatsByDocumentTypeRequest {
|
|
37
|
+
project_id: string
|
|
38
|
+
document_type: DocumentType
|
|
39
|
+
chat_status?: ChatStatus
|
|
40
|
+
limit?: number
|
|
41
|
+
offset?: number
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface GetChatsByDocumentTypeResponse {
|
|
45
|
+
chats: DocumentChatSummary[]
|
|
46
|
+
count: number
|
|
47
|
+
project_id: string
|
|
48
|
+
document_type: DocumentType
|
|
49
|
+
limit: number
|
|
50
|
+
offset: number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// 3. GET /chat/document/history/{conversation_id}
|
|
55
|
+
// Get full chat history with messages
|
|
56
|
+
// ============================================================================
|
|
57
|
+
|
|
58
|
+
export interface GetChatHistoryRequest {
|
|
59
|
+
conversation_id: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface GetChatHistoryResponse {
|
|
63
|
+
conversation: DocumentConversation
|
|
64
|
+
messages: ChatMessage[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// 4. GET /chat/document/list
|
|
69
|
+
// List all chats for current user (with optional filters)
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
export interface ListDocumentChatsRequest {
|
|
73
|
+
project_id?: string
|
|
74
|
+
document_type?: DocumentType
|
|
75
|
+
template?: 'blueprint' | 'wireframe'
|
|
76
|
+
chat_status?: ChatStatus
|
|
77
|
+
limit?: number
|
|
78
|
+
offset?: number
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ListDocumentChatsResponse {
|
|
82
|
+
chats: DocumentChatSummary[]
|
|
83
|
+
count: number
|
|
84
|
+
limit: number
|
|
85
|
+
offset: number
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// 5. GET /chat/document/by-document/{document_id}
|
|
90
|
+
// Get chat by specific document version ID (Legacy)
|
|
91
|
+
// ============================================================================
|
|
92
|
+
|
|
93
|
+
export interface GetChatByDocumentIdRequest {
|
|
94
|
+
document_id: string
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface GetChatByDocumentIdResponse {
|
|
98
|
+
conversation: DocumentConversation
|
|
99
|
+
messages: ChatMessage[]
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Common Types
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export type ChatStatus = 'active' | 'archived' | 'deleted'
|
|
107
|
+
|
|
108
|
+
export interface DocumentChatSummary {
|
|
109
|
+
id: string
|
|
110
|
+
project_id: string
|
|
111
|
+
document_type: DocumentType
|
|
112
|
+
title: string
|
|
113
|
+
template: 'blueprint' | 'wireframe'
|
|
114
|
+
status: ChatStatus
|
|
115
|
+
last_message_at: string
|
|
116
|
+
metadata?: Record<string, any>
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface DocumentConversation {
|
|
120
|
+
id: string
|
|
121
|
+
project_id: string
|
|
122
|
+
document_type: DocumentType
|
|
123
|
+
title: string
|
|
124
|
+
template: 'blueprint' | 'wireframe'
|
|
125
|
+
status: ChatStatus
|
|
126
|
+
created_at: string
|
|
127
|
+
last_message_at: string
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface ChatMessage {
|
|
131
|
+
id: string
|
|
132
|
+
role: 'user' | 'assistant' | 'system'
|
|
133
|
+
content: string
|
|
134
|
+
tool_calls?: ChatToolCall[]
|
|
135
|
+
created_at: string
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ChatToolCall {
|
|
139
|
+
id: string
|
|
140
|
+
type: string
|
|
141
|
+
function?: {
|
|
142
|
+
name: string
|
|
143
|
+
arguments: string
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service'
|
|
2
|
+
import {
|
|
3
|
+
DataStatsResponse,
|
|
4
|
+
DeleteAllDataRequest,
|
|
5
|
+
DeleteAllDataResponse,
|
|
6
|
+
DataExportResponse,
|
|
7
|
+
} from './data-management-types'
|
|
8
|
+
|
|
9
|
+
export class DataManagementService extends BaseService {
|
|
10
|
+
/**
|
|
11
|
+
* Get comprehensive statistics of all user data
|
|
12
|
+
*
|
|
13
|
+
* Calls GET /data/stats to retrieve aggregate counts of:
|
|
14
|
+
* - Projects
|
|
15
|
+
* - Project documents
|
|
16
|
+
* - Project repositories
|
|
17
|
+
* - Project tasks
|
|
18
|
+
* - Task groups
|
|
19
|
+
* - Chat conversations
|
|
20
|
+
* - Chat messages
|
|
21
|
+
* - Codespace tasks
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise resolving to DataStatsResponse with counts for each entity type
|
|
24
|
+
*/
|
|
25
|
+
async getDataStats(): Promise<DataStatsResponse> {
|
|
26
|
+
return this.get<DataStatsResponse>('/data/stats')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Export all user data
|
|
31
|
+
*
|
|
32
|
+
* Calls GET /data/export to retrieve complete export of all user data.
|
|
33
|
+
* This includes all projects, documents, repositories, tasks, conversations,
|
|
34
|
+
* messages, and codespace tasks with their full details.
|
|
35
|
+
*
|
|
36
|
+
* Use this for:
|
|
37
|
+
* - Creating backups
|
|
38
|
+
* - Migrating data to another system
|
|
39
|
+
* - Data analysis
|
|
40
|
+
* - Compliance and auditing
|
|
41
|
+
*
|
|
42
|
+
* @returns Promise resolving to DataExportResponse with complete user data
|
|
43
|
+
*/
|
|
44
|
+
async exportData(): Promise<DataExportResponse> {
|
|
45
|
+
return this.get<DataExportResponse>('/data/export')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Delete all user data with explicit confirmation
|
|
50
|
+
*
|
|
51
|
+
* Calls DELETE /data/all to perform bulk deletion of all user data.
|
|
52
|
+
* This operation requires confirmation to prevent accidental data loss.
|
|
53
|
+
*
|
|
54
|
+
* The deletion will affect:
|
|
55
|
+
* - All projects (including documents and repositories)
|
|
56
|
+
* - All task groups and project tasks
|
|
57
|
+
* - All chat conversations and messages
|
|
58
|
+
* - All codespace tasks
|
|
59
|
+
*
|
|
60
|
+
* @param request - DeleteAllDataRequest with confirm flag set to true
|
|
61
|
+
* @returns Promise resolving to DeleteAllDataResponse with deletion summary
|
|
62
|
+
* @throws Error if confirmation is not true
|
|
63
|
+
*/
|
|
64
|
+
async deleteAllData(request: DeleteAllDataRequest): Promise<DeleteAllDataResponse> {
|
|
65
|
+
// Validate confirmation flag to prevent accidental deletion
|
|
66
|
+
if (!request.confirm) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
'Confirmation required. Set confirm: true to delete all data. This action cannot be undone.'
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.delete<DeleteAllDataResponse>('/data/all')
|
|
73
|
+
}
|
|
74
|
+
}
|