@codeguide/core 0.0.29 → 0.0.35
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 +138 -119
- package/codeguide.ts +3 -0
- package/dist/codeguide.d.ts +2 -1
- package/dist/codeguide.js +1 -0
- package/dist/index.d.ts +1 -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/codespace/codespace-service.d.ts +11 -2
- package/dist/services/codespace/codespace-service.js +18 -3
- package/dist/services/codespace/codespace-types.d.ts +21 -0
- package/dist/services/codespace/index.d.ts +1 -1
- 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 +95 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +7 -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 +24 -1
- 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/subscriptions/subscription-service.d.ts +11 -1
- package/dist/services/subscriptions/subscription-service.js +14 -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 +119 -45
- package/dist/types.d.ts +18 -2
- package/index.ts +3 -0
- package/package.json +2 -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/codespace/codespace-service.ts +25 -3
- package/services/codespace/codespace-types.ts +33 -0
- package/services/codespace/index.ts +6 -1
- package/services/generation/generation-service.ts +40 -0
- package/services/generation/generation-types.ts +110 -0
- package/services/index.ts +4 -0
- package/services/projects/README.md +54 -0
- package/services/projects/project-service.ts +20 -1
- package/services/projects/project-types.ts +27 -1
- 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/subscriptions/subscription-service.ts +23 -5
- 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 +128 -49
- package/types.ts +22 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.StreamingService = void 0;
|
|
18
|
+
var streaming_service_1 = require("./streaming-service");
|
|
19
|
+
Object.defineProperty(exports, "StreamingService", { enumerable: true, get: function () { return streaming_service_1.StreamingService; } });
|
|
20
|
+
__exportStar(require("./streaming-types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service';
|
|
2
|
+
import { StreamTechSpecRequest } from './streaming-types';
|
|
3
|
+
export declare class StreamingService extends BaseService {
|
|
4
|
+
/**
|
|
5
|
+
* Stream a tech-spec document for the given project.
|
|
6
|
+
*
|
|
7
|
+
* This method connects to the `/chat/tech-spec` endpoint and streams the response
|
|
8
|
+
* using Server-Sent Events (SSE) format. Each chunk is passed to the `onChunk`
|
|
9
|
+
* callback as it arrives, allowing for incremental UI updates.
|
|
10
|
+
*
|
|
11
|
+
* @param request - The request containing the project_id
|
|
12
|
+
* @param onChunk - Callback function invoked with each content chunk as it arrives
|
|
13
|
+
* @param onError - Optional callback function for handling errors
|
|
14
|
+
* @returns Promise that resolves to the full accumulated content when streaming completes
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const streamingService = new StreamingService(config);
|
|
19
|
+
* let fullContent = '';
|
|
20
|
+
*
|
|
21
|
+
* fullContent = await streamingService.streamTechSpec(
|
|
22
|
+
* { project_id: 'project-123' },
|
|
23
|
+
* (chunk) => {
|
|
24
|
+
* setContent(prev => prev + chunk); // Update UI incrementally
|
|
25
|
+
* }
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
streamTechSpec(request: StreamTechSpecRequest, onChunk: (content: string) => void, onError?: (error: Error) => void): Promise<string>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamingService = void 0;
|
|
4
|
+
const base_service_1 = require("../base/base-service");
|
|
5
|
+
class StreamingService extends base_service_1.BaseService {
|
|
6
|
+
/**
|
|
7
|
+
* Stream a tech-spec document for the given project.
|
|
8
|
+
*
|
|
9
|
+
* This method connects to the `/chat/tech-spec` endpoint and streams the response
|
|
10
|
+
* using Server-Sent Events (SSE) format. Each chunk is passed to the `onChunk`
|
|
11
|
+
* callback as it arrives, allowing for incremental UI updates.
|
|
12
|
+
*
|
|
13
|
+
* @param request - The request containing the project_id
|
|
14
|
+
* @param onChunk - Callback function invoked with each content chunk as it arrives
|
|
15
|
+
* @param onError - Optional callback function for handling errors
|
|
16
|
+
* @returns Promise that resolves to the full accumulated content when streaming completes
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const streamingService = new StreamingService(config);
|
|
21
|
+
* let fullContent = '';
|
|
22
|
+
*
|
|
23
|
+
* fullContent = await streamingService.streamTechSpec(
|
|
24
|
+
* { project_id: 'project-123' },
|
|
25
|
+
* (chunk) => {
|
|
26
|
+
* setContent(prev => prev + chunk); // Update UI incrementally
|
|
27
|
+
* }
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
async streamTechSpec(request, onChunk, onError) {
|
|
32
|
+
return new Promise(async (resolve, reject) => {
|
|
33
|
+
let fullContent = '';
|
|
34
|
+
const fullUrl = `${this.client.defaults.baseURL}/chat/tech-spec`;
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetch(fullUrl, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
...Object.fromEntries(Object.entries(this.client.defaults.headers).filter(([_, v]) => typeof v === 'string')),
|
|
40
|
+
Accept: 'text/event-stream',
|
|
41
|
+
'Cache-Control': 'no-cache',
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify(request),
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
const errorText = await response.text();
|
|
47
|
+
const error = new Error(`HTTP ${response.status}: ${errorText || response.statusText}`);
|
|
48
|
+
onError?.(error);
|
|
49
|
+
reject(error);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const reader = response.body?.getReader();
|
|
53
|
+
if (!reader) {
|
|
54
|
+
const error = new Error('Response body is not readable');
|
|
55
|
+
onError?.(error);
|
|
56
|
+
reject(error);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const decoder = new TextDecoder();
|
|
60
|
+
let buffer = '';
|
|
61
|
+
while (true) {
|
|
62
|
+
const { done, value } = await reader.read();
|
|
63
|
+
if (done) {
|
|
64
|
+
resolve(fullContent);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
buffer += decoder.decode(value, { stream: true });
|
|
68
|
+
const lines = buffer.split('\n');
|
|
69
|
+
buffer = lines.pop() || ''; // Keep incomplete line in buffer
|
|
70
|
+
for (const line of lines) {
|
|
71
|
+
if (line.startsWith('data: ')) {
|
|
72
|
+
const jsonStr = line.slice(6); // Remove 'data: ' prefix
|
|
73
|
+
if (jsonStr.trim()) {
|
|
74
|
+
try {
|
|
75
|
+
const chunk = JSON.parse(jsonStr);
|
|
76
|
+
if (chunk.error) {
|
|
77
|
+
const error = new Error(chunk.error);
|
|
78
|
+
onError?.(error);
|
|
79
|
+
reject(error);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (chunk.done) {
|
|
83
|
+
resolve(fullContent);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (chunk.content) {
|
|
87
|
+
fullContent += chunk.content;
|
|
88
|
+
onChunk(chunk.content);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (parseError) {
|
|
92
|
+
console.warn('Failed to parse SSE data:', jsonStr, parseError);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
101
|
+
onError?.(err);
|
|
102
|
+
reject(err);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.StreamingService = StreamingService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request type for streaming a tech-spec
|
|
3
|
+
*/
|
|
4
|
+
export interface StreamTechSpecRequest {
|
|
5
|
+
project_id: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A single chunk from the SSE stream
|
|
9
|
+
*/
|
|
10
|
+
export interface StreamChunk {
|
|
11
|
+
content: string;
|
|
12
|
+
done: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { BaseService } from '../base/base-service';
|
|
2
|
-
import { CurrentSubscriptionResponse, UserSubscriptionsResponse, CancelSubscriptionRequest, CancelSubscriptionResponse } from '../../types';
|
|
2
|
+
import { CurrentSubscriptionResponse, UserSubscriptionsResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, SubscriptionProductsResponse, CreateCheckoutSessionRequest, CreateCheckoutSessionResponse } from '../../types';
|
|
3
3
|
export declare class SubscriptionService extends BaseService {
|
|
4
4
|
constructor(config: any);
|
|
5
|
+
/**
|
|
6
|
+
* Create a Stripe checkout session for subscription purchase
|
|
7
|
+
* POST /subscriptions/create-checkout-session
|
|
8
|
+
*/
|
|
9
|
+
createCheckoutSession(request: CreateCheckoutSessionRequest): Promise<CreateCheckoutSessionResponse>;
|
|
5
10
|
/**
|
|
6
11
|
* Get the currently active subscription for the authenticated user
|
|
7
12
|
* GET /subscriptions/current
|
|
@@ -12,6 +17,11 @@ export declare class SubscriptionService extends BaseService {
|
|
|
12
17
|
* GET /subscriptions/
|
|
13
18
|
*/
|
|
14
19
|
getAllSubscriptions(): Promise<UserSubscriptionsResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Get all available subscription products and their prices
|
|
22
|
+
* GET /subscriptions/products
|
|
23
|
+
*/
|
|
24
|
+
getSubscriptionProducts(): Promise<SubscriptionProductsResponse>;
|
|
15
25
|
/**
|
|
16
26
|
* Cancel subscription but keep it active until the end of the current billing period
|
|
17
27
|
* POST /subscriptions/{subscription_id}/cancel
|
|
@@ -6,6 +6,13 @@ class SubscriptionService extends base_service_1.BaseService {
|
|
|
6
6
|
constructor(config) {
|
|
7
7
|
super(config);
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a Stripe checkout session for subscription purchase
|
|
11
|
+
* POST /subscriptions/create-checkout-session
|
|
12
|
+
*/
|
|
13
|
+
async createCheckoutSession(request) {
|
|
14
|
+
return this.post('/subscriptions/create-checkout-session', request);
|
|
15
|
+
}
|
|
9
16
|
/**
|
|
10
17
|
* Get the currently active subscription for the authenticated user
|
|
11
18
|
* GET /subscriptions/current
|
|
@@ -20,6 +27,13 @@ class SubscriptionService extends base_service_1.BaseService {
|
|
|
20
27
|
async getAllSubscriptions() {
|
|
21
28
|
return this.get('/subscriptions/');
|
|
22
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all available subscription products and their prices
|
|
32
|
+
* GET /subscriptions/products
|
|
33
|
+
*/
|
|
34
|
+
async getSubscriptionProducts() {
|
|
35
|
+
return this.get('/subscriptions/products');
|
|
36
|
+
}
|
|
23
37
|
/**
|
|
24
38
|
* Cancel subscription but keep it active until the end of the current billing period
|
|
25
39
|
* POST /subscriptions/{subscription_id}/cancel
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseService } from '../base/base-service';
|
|
2
|
-
import { TaskGroup, ProjectTask, CreateTaskGroupRequest, UpdateTaskGroupRequest, CreateProjectTaskRequest, UpdateProjectTaskRequest, ProjectTaskListResponse, PaginatedTaskGroupsRequest, PaginatedTaskGroupsResponse, PaginatedProjectTasksRequest, PaginatedProjectTasksResponse, GenerateTasksRequest, GenerateTasksResponse, GetTasksByProjectRequest, GetTasksByProjectResponse, UpdateTaskRequest, UpdateTaskResponse } from './task-types';
|
|
2
|
+
import { TaskGroup, ProjectTask, CreateTaskGroupRequest, UpdateTaskGroupRequest, CreateProjectTaskRequest, UpdateProjectTaskRequest, ProjectTaskListResponse, PaginatedTaskGroupsRequest, PaginatedTaskGroupsResponse, PaginatedProjectTasksRequest, PaginatedProjectTasksResponse, GenerateTasksRequest, GenerateTasksResponse, GetTasksByProjectRequest, GetTasksByProjectResponse, UpdateTaskRequest, UpdateTaskResponse, GenerateTasksCustomBackgroundRequest, GenerateTasksCustomBackgroundResponse, GeneratePromptRequest, GeneratePromptResponse } from './task-types';
|
|
3
3
|
export declare class TaskService extends BaseService {
|
|
4
4
|
getAllTaskGroups(): Promise<TaskGroup[]>;
|
|
5
5
|
getPaginatedTaskGroups(params: PaginatedTaskGroupsRequest): Promise<PaginatedTaskGroupsResponse>;
|
|
@@ -25,7 +25,9 @@ export declare class TaskService extends BaseService {
|
|
|
25
25
|
message: string;
|
|
26
26
|
}>;
|
|
27
27
|
generateTasks(request: GenerateTasksRequest): Promise<GenerateTasksResponse>;
|
|
28
|
+
generateTasksCustomBackground(request: GenerateTasksCustomBackgroundRequest): Promise<GenerateTasksCustomBackgroundResponse>;
|
|
28
29
|
getTasksByProject(request: GetTasksByProjectRequest): Promise<GetTasksByProjectResponse>;
|
|
29
30
|
updateTask(taskId: string, request: UpdateTaskRequest): Promise<UpdateTaskResponse>;
|
|
30
31
|
getProjectTasksbyCodespace(codespaceTaskId: string): Promise<ProjectTaskListResponse>;
|
|
32
|
+
generatePrompt(taskId: string, request?: GeneratePromptRequest): Promise<GeneratePromptResponse>;
|
|
31
33
|
}
|
|
@@ -116,6 +116,10 @@ class TaskService extends base_service_1.BaseService {
|
|
|
116
116
|
async generateTasks(request) {
|
|
117
117
|
return this.post('/project-tasks/generate-tasks', request);
|
|
118
118
|
}
|
|
119
|
+
// Generate Tasks Custom (Background)
|
|
120
|
+
async generateTasksCustomBackground(request) {
|
|
121
|
+
return this.post('/project-tasks/generate-tasks-custom/background', request);
|
|
122
|
+
}
|
|
119
123
|
// Get Tasks by Project
|
|
120
124
|
async getTasksByProject(request) {
|
|
121
125
|
const queryParams = new URLSearchParams();
|
|
@@ -138,5 +142,9 @@ class TaskService extends base_service_1.BaseService {
|
|
|
138
142
|
const url = `/project-tasks/by-codespace/${codespaceTaskId}`;
|
|
139
143
|
return this.get(url);
|
|
140
144
|
}
|
|
145
|
+
// Generate Prompt for a Project Task
|
|
146
|
+
async generatePrompt(taskId, request = {}) {
|
|
147
|
+
return this.post(`/project-tasks/${taskId}/generate-prompt`, request);
|
|
148
|
+
}
|
|
141
149
|
}
|
|
142
150
|
exports.TaskService = TaskService;
|
|
@@ -170,3 +170,18 @@ export interface UpdateTaskResponse {
|
|
|
170
170
|
task: ProjectTask;
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
+
export interface GenerateTasksCustomBackgroundRequest {
|
|
174
|
+
project_id: string;
|
|
175
|
+
}
|
|
176
|
+
export interface GenerateTasksCustomBackgroundResponse {
|
|
177
|
+
status: string;
|
|
178
|
+
job_id: string;
|
|
179
|
+
message: string;
|
|
180
|
+
}
|
|
181
|
+
export interface GeneratePromptRequest {
|
|
182
|
+
additional_context?: string;
|
|
183
|
+
}
|
|
184
|
+
export interface GeneratePromptResponse {
|
|
185
|
+
status: string;
|
|
186
|
+
prompt: string;
|
|
187
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseService } from '../base/base-service';
|
|
2
|
-
import { TrackUsageRequest, TrackUsageResponse, CreditBalanceResponse, CreditCheckRequest, CreditCheckResponse, UsageSummaryRequest, UsageSummaryResponse, AuthorizationResponse, FreeUserStatusResponse, CalculateUsageRequest, CalculateUsageResponse, TrackCodespaceUsageRequest, TrackCodespaceUsageResponse, CodespaceTaskUsageResponse, DashboardAnalyticsRequest, DashboardAnalyticsResponse, UsageDetailsRequest, UsageDetailsResponse, ServiceBreakdownRequest, ServiceBreakdownResponse } from './usage-types';
|
|
2
|
+
import { TrackUsageRequest, TrackUsageResponse, CreditBalanceResponse, CreditCheckRequest, CreditCheckResponse, UsageSummaryRequest, UsageSummaryResponse, AuthorizationResponse, FreeUserStatusResponse, CalculateUsageRequest, CalculateUsageResponse, TrackCodespaceUsageRequest, TrackCodespaceUsageResponse, CodespaceTaskUsageResponse, DashboardAnalyticsRequest, DashboardAnalyticsResponse, UsageDetailsRequest, UsageDetailsResponse, ServiceBreakdownRequest, ServiceBreakdownResponse, ActivityHeatmapRequest, ActivityHeatmapResponse, RepositoryAnalysisSummaryRequest, RepositoryAnalysisSummaryResponse, RepositoryAnalysisTimelineRequest, RepositoryAnalysisTimelineResponse } from './usage-types';
|
|
3
3
|
export declare class UsageService extends BaseService {
|
|
4
4
|
trackUsage(request: TrackUsageRequest): Promise<TrackUsageResponse>;
|
|
5
5
|
getCreditBalance(): Promise<CreditBalanceResponse>;
|
|
@@ -14,4 +14,38 @@ export declare class UsageService extends BaseService {
|
|
|
14
14
|
getUsageDetails(params?: UsageDetailsRequest): Promise<UsageDetailsResponse>;
|
|
15
15
|
getUsageSummary(params?: UsageSummaryRequest): Promise<UsageSummaryResponse>;
|
|
16
16
|
getServiceBreakdown(params?: ServiceBreakdownRequest): Promise<ServiceBreakdownResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Get activity heatmap data based on codespace tasks created.
|
|
19
|
+
* Similar to GitHub's contribution graph.
|
|
20
|
+
*
|
|
21
|
+
* @param params - Optional request parameters
|
|
22
|
+
* @param params.period - Time period: '3m', '6m', '1y' (default: '3m')
|
|
23
|
+
* @param params.start_date - Custom start date in YYYY-MM-DD format
|
|
24
|
+
* @param params.end_date - Custom end date in YYYY-MM-DD format
|
|
25
|
+
* @returns Activity heatmap data with daily counts and levels
|
|
26
|
+
*/
|
|
27
|
+
getActivityHeatmap(params?: ActivityHeatmapRequest): Promise<ActivityHeatmapResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Get summary statistics for repository analysis.
|
|
30
|
+
* Provides aggregated metrics across all analyzed repositories.
|
|
31
|
+
*
|
|
32
|
+
* @param params - Optional request parameters
|
|
33
|
+
* @param params.period - Time period: '7d', '1w', '1m', '3m', '6m', '1y' (optional - defaults to all-time)
|
|
34
|
+
* @param params.start_date - Custom start date in YYYY-MM-DD format
|
|
35
|
+
* @param params.end_date - Custom end date in YYYY-MM-DD format
|
|
36
|
+
* @returns Summary statistics including total repos, lines, files, etc.
|
|
37
|
+
*/
|
|
38
|
+
getRepositoryAnalysisSummary(params?: RepositoryAnalysisSummaryRequest): Promise<RepositoryAnalysisSummaryResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Get timeline data for repository analysis suitable for line graphs.
|
|
41
|
+
* Provides time-series data for visualization.
|
|
42
|
+
*
|
|
43
|
+
* @param params - Optional request parameters
|
|
44
|
+
* @param params.period - Time period: '7d', '1w', '1m', '3m', '6m', '1y' (default: '1m')
|
|
45
|
+
* @param params.start_date - Custom start date in YYYY-MM-DD format
|
|
46
|
+
* @param params.end_date - Custom end date in YYYY-MM-DD format
|
|
47
|
+
* @param params.granularity - Data granularity: 'daily', 'weekly', 'monthly' (default: 'daily')
|
|
48
|
+
* @returns Timeline data with repos analyzed, lines, files per period
|
|
49
|
+
*/
|
|
50
|
+
getRepositoryAnalysisTimeline(params?: RepositoryAnalysisTimelineRequest): Promise<RepositoryAnalysisTimelineResponse>;
|
|
17
51
|
}
|
|
@@ -113,5 +113,73 @@ class UsageService extends base_service_1.BaseService {
|
|
|
113
113
|
const url = `/usage/dashboard/services${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
114
114
|
return this.get(url);
|
|
115
115
|
}
|
|
116
|
+
// Activity Heatmap Methods
|
|
117
|
+
/**
|
|
118
|
+
* Get activity heatmap data based on codespace tasks created.
|
|
119
|
+
* Similar to GitHub's contribution graph.
|
|
120
|
+
*
|
|
121
|
+
* @param params - Optional request parameters
|
|
122
|
+
* @param params.period - Time period: '3m', '6m', '1y' (default: '3m')
|
|
123
|
+
* @param params.start_date - Custom start date in YYYY-MM-DD format
|
|
124
|
+
* @param params.end_date - Custom end date in YYYY-MM-DD format
|
|
125
|
+
* @returns Activity heatmap data with daily counts and levels
|
|
126
|
+
*/
|
|
127
|
+
async getActivityHeatmap(params) {
|
|
128
|
+
const queryParams = new URLSearchParams();
|
|
129
|
+
if (params?.period)
|
|
130
|
+
queryParams.append('period', params.period);
|
|
131
|
+
if (params?.start_date)
|
|
132
|
+
queryParams.append('start_date', params.start_date);
|
|
133
|
+
if (params?.end_date)
|
|
134
|
+
queryParams.append('end_date', params.end_date);
|
|
135
|
+
const url = `/usage/dashboard/activity-heatmap${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
136
|
+
return this.get(url);
|
|
137
|
+
}
|
|
138
|
+
// Repository Analysis Stats Methods
|
|
139
|
+
/**
|
|
140
|
+
* Get summary statistics for repository analysis.
|
|
141
|
+
* Provides aggregated metrics across all analyzed repositories.
|
|
142
|
+
*
|
|
143
|
+
* @param params - Optional request parameters
|
|
144
|
+
* @param params.period - Time period: '7d', '1w', '1m', '3m', '6m', '1y' (optional - defaults to all-time)
|
|
145
|
+
* @param params.start_date - Custom start date in YYYY-MM-DD format
|
|
146
|
+
* @param params.end_date - Custom end date in YYYY-MM-DD format
|
|
147
|
+
* @returns Summary statistics including total repos, lines, files, etc.
|
|
148
|
+
*/
|
|
149
|
+
async getRepositoryAnalysisSummary(params) {
|
|
150
|
+
const queryParams = new URLSearchParams();
|
|
151
|
+
if (params?.period)
|
|
152
|
+
queryParams.append('period', params.period);
|
|
153
|
+
if (params?.start_date)
|
|
154
|
+
queryParams.append('start_date', params.start_date);
|
|
155
|
+
if (params?.end_date)
|
|
156
|
+
queryParams.append('end_date', params.end_date);
|
|
157
|
+
const url = `/usage/dashboard/repo-analysis/summary${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
158
|
+
return this.get(url);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get timeline data for repository analysis suitable for line graphs.
|
|
162
|
+
* Provides time-series data for visualization.
|
|
163
|
+
*
|
|
164
|
+
* @param params - Optional request parameters
|
|
165
|
+
* @param params.period - Time period: '7d', '1w', '1m', '3m', '6m', '1y' (default: '1m')
|
|
166
|
+
* @param params.start_date - Custom start date in YYYY-MM-DD format
|
|
167
|
+
* @param params.end_date - Custom end date in YYYY-MM-DD format
|
|
168
|
+
* @param params.granularity - Data granularity: 'daily', 'weekly', 'monthly' (default: 'daily')
|
|
169
|
+
* @returns Timeline data with repos analyzed, lines, files per period
|
|
170
|
+
*/
|
|
171
|
+
async getRepositoryAnalysisTimeline(params) {
|
|
172
|
+
const queryParams = new URLSearchParams();
|
|
173
|
+
if (params?.period)
|
|
174
|
+
queryParams.append('period', params.period);
|
|
175
|
+
if (params?.start_date)
|
|
176
|
+
queryParams.append('start_date', params.start_date);
|
|
177
|
+
if (params?.end_date)
|
|
178
|
+
queryParams.append('end_date', params.end_date);
|
|
179
|
+
if (params?.granularity)
|
|
180
|
+
queryParams.append('granularity', params.granularity);
|
|
181
|
+
const url = `/usage/dashboard/repo-analysis/timeline${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
182
|
+
return this.get(url);
|
|
183
|
+
}
|
|
116
184
|
}
|
|
117
185
|
exports.UsageService = UsageService;
|
|
@@ -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;
|
|
@@ -72,14 +72,14 @@ export interface PlanLimits {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
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
|
|
75
|
+
id?: string;
|
|
76
|
+
status?: string;
|
|
77
|
+
interval?: string;
|
|
78
|
+
current_period_start?: string;
|
|
79
|
+
current_period_end?: string;
|
|
80
|
+
price_id?: string;
|
|
81
|
+
product_name?: string | null;
|
|
82
|
+
plan_name?: string;
|
|
83
83
|
}
|
|
84
84
|
export interface AuthorizationData {
|
|
85
85
|
user_id: string;
|
|
@@ -93,7 +93,7 @@ export interface AuthorizationData {
|
|
|
93
93
|
can_create_tasks: boolean;
|
|
94
94
|
can_analyze_repos: boolean;
|
|
95
95
|
can_access_previous_projects: boolean;
|
|
96
|
-
plan_limits
|
|
96
|
+
plan_limits?: PlanLimits | null;
|
|
97
97
|
codespace_task_limit: LimitInfo | null;
|
|
98
98
|
}
|
|
99
99
|
export interface AuthorizationResponse {
|
|
@@ -143,25 +143,24 @@ export interface TrackCodespaceUsageResponse {
|
|
|
143
143
|
cost_amount: number;
|
|
144
144
|
created_at: string;
|
|
145
145
|
}
|
|
146
|
+
export interface CodespaceTaskUsageData {
|
|
147
|
+
total_records: number;
|
|
148
|
+
total_credits_consumed: number;
|
|
149
|
+
latest_usage: string;
|
|
150
|
+
}
|
|
146
151
|
export interface CodespaceTaskUsageResponse {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
total_input_tokens: number;
|
|
150
|
-
total_output_tokens: number;
|
|
151
|
-
total_call_seconds: number;
|
|
152
|
-
total_cost: number;
|
|
153
|
-
};
|
|
154
|
-
usage_records: TrackCodespaceUsageResponse[];
|
|
152
|
+
status: string;
|
|
153
|
+
data: CodespaceTaskUsageData;
|
|
155
154
|
}
|
|
156
155
|
export interface HealthResponse {
|
|
157
156
|
status: string;
|
|
158
157
|
timestamp: string;
|
|
159
158
|
version: string;
|
|
160
159
|
}
|
|
161
|
-
export type PeriodType =
|
|
162
|
-
export type ServiceType =
|
|
163
|
-
export type SortOrder =
|
|
164
|
-
export type SortByField =
|
|
160
|
+
export type PeriodType = '7d' | '1w' | '1m' | '3m';
|
|
161
|
+
export type ServiceType = 'docs' | 'chat' | 'codespace_task' | 'api';
|
|
162
|
+
export type SortOrder = 'asc' | 'desc';
|
|
163
|
+
export type SortByField = 'created_at' | 'credits_consumed' | 'cost_amount';
|
|
165
164
|
export interface DashboardAnalyticsRequest {
|
|
166
165
|
period?: PeriodType;
|
|
167
166
|
start_date?: string;
|
|
@@ -254,31 +253,23 @@ export interface UsageSummaryRequest {
|
|
|
254
253
|
start_date?: string;
|
|
255
254
|
end_date?: string;
|
|
256
255
|
}
|
|
257
|
-
export interface CurrentPeriodUsage {
|
|
258
|
-
credits_consumed: number;
|
|
259
|
-
cost_usd: number;
|
|
260
|
-
requests_count: number;
|
|
261
|
-
}
|
|
262
|
-
export interface PreviousPeriodUsage {
|
|
263
|
-
credits_consumed: number;
|
|
264
|
-
cost_usd: number;
|
|
265
|
-
requests_count: number;
|
|
266
|
-
}
|
|
267
|
-
export interface BillingCycleInfo {
|
|
268
|
-
total_allotted: number;
|
|
269
|
-
total_consumed: number;
|
|
270
|
-
remaining_credits: number;
|
|
271
|
-
}
|
|
272
256
|
export interface UsageSummaryResponse {
|
|
273
257
|
status: string;
|
|
274
258
|
data: {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
259
|
+
period: {
|
|
260
|
+
start?: string;
|
|
261
|
+
end?: string;
|
|
262
|
+
};
|
|
263
|
+
usage: {
|
|
264
|
+
[key: string]: number;
|
|
265
|
+
};
|
|
266
|
+
breakdown: {
|
|
267
|
+
[key: string]: number;
|
|
268
|
+
};
|
|
269
|
+
service_breakdown: Array<{
|
|
270
|
+
service_type: string;
|
|
271
|
+
[key: string]: any;
|
|
272
|
+
}>;
|
|
282
273
|
};
|
|
283
274
|
}
|
|
284
275
|
export interface ServiceBreakdownRequest {
|
|
@@ -304,3 +295,86 @@ export interface ServiceBreakdownResponse {
|
|
|
304
295
|
status: string;
|
|
305
296
|
data: ServiceBreakdownData;
|
|
306
297
|
}
|
|
298
|
+
export type HeatmapPeriodType = '3m' | '6m' | '1y';
|
|
299
|
+
export type ActivityLevel = 0 | 1 | 2 | 3 | 4;
|
|
300
|
+
export interface ActivityHeatmapRequest {
|
|
301
|
+
period?: HeatmapPeriodType;
|
|
302
|
+
start_date?: string;
|
|
303
|
+
end_date?: string;
|
|
304
|
+
}
|
|
305
|
+
export interface HeatmapDayData {
|
|
306
|
+
date: string;
|
|
307
|
+
count: number;
|
|
308
|
+
level: ActivityLevel;
|
|
309
|
+
}
|
|
310
|
+
export interface ActivityHeatmapData {
|
|
311
|
+
period: PeriodInfo;
|
|
312
|
+
days: HeatmapDayData[];
|
|
313
|
+
total_tasks: number;
|
|
314
|
+
most_active_day: string | null;
|
|
315
|
+
max_daily_count: number;
|
|
316
|
+
average_daily: number;
|
|
317
|
+
active_days: number;
|
|
318
|
+
}
|
|
319
|
+
export interface ActivityHeatmapResponse {
|
|
320
|
+
status: string;
|
|
321
|
+
data: ActivityHeatmapData;
|
|
322
|
+
}
|
|
323
|
+
export type RepoAnalysisPeriodType = '7d' | '1w' | '1m' | '3m' | '6m' | '1y';
|
|
324
|
+
export interface RepositoryAnalysisSummaryRequest {
|
|
325
|
+
period?: RepoAnalysisPeriodType;
|
|
326
|
+
start_date?: string;
|
|
327
|
+
end_date?: string;
|
|
328
|
+
}
|
|
329
|
+
export interface RepositoryAnalysisSummaryData {
|
|
330
|
+
total_repositories: number;
|
|
331
|
+
total_lines: number;
|
|
332
|
+
total_files_processed: number;
|
|
333
|
+
total_files_found: number;
|
|
334
|
+
total_directories: number;
|
|
335
|
+
total_characters: number;
|
|
336
|
+
estimated_tokens_total: number;
|
|
337
|
+
total_size_bytes: number;
|
|
338
|
+
binary_files_skipped: number;
|
|
339
|
+
large_files_skipped: number;
|
|
340
|
+
encoding_errors: number;
|
|
341
|
+
average_lines_per_repo: number;
|
|
342
|
+
average_files_per_repo: number;
|
|
343
|
+
period: PeriodInfo | null;
|
|
344
|
+
}
|
|
345
|
+
export interface RepositoryAnalysisSummaryResponse {
|
|
346
|
+
status: string;
|
|
347
|
+
data: RepositoryAnalysisSummaryData;
|
|
348
|
+
}
|
|
349
|
+
export type TimelineGranularity = 'daily' | 'weekly' | 'monthly';
|
|
350
|
+
export interface RepositoryAnalysisTimelineRequest {
|
|
351
|
+
period?: RepoAnalysisPeriodType;
|
|
352
|
+
start_date?: string;
|
|
353
|
+
end_date?: string;
|
|
354
|
+
granularity?: TimelineGranularity;
|
|
355
|
+
}
|
|
356
|
+
export interface RepositoryAnalysisTimelineItem {
|
|
357
|
+
date: string;
|
|
358
|
+
repos_analyzed: number;
|
|
359
|
+
total_lines: number;
|
|
360
|
+
total_files: number;
|
|
361
|
+
total_characters: number;
|
|
362
|
+
estimated_tokens: number;
|
|
363
|
+
}
|
|
364
|
+
export interface RepositoryAnalysisTimelineTotals {
|
|
365
|
+
repos_analyzed: number;
|
|
366
|
+
total_lines: number;
|
|
367
|
+
total_files: number;
|
|
368
|
+
total_characters: number;
|
|
369
|
+
estimated_tokens: number;
|
|
370
|
+
}
|
|
371
|
+
export interface RepositoryAnalysisTimelineData {
|
|
372
|
+
period: PeriodInfo;
|
|
373
|
+
granularity: TimelineGranularity;
|
|
374
|
+
timeline: RepositoryAnalysisTimelineItem[];
|
|
375
|
+
totals: RepositoryAnalysisTimelineTotals;
|
|
376
|
+
}
|
|
377
|
+
export interface RepositoryAnalysisTimelineResponse {
|
|
378
|
+
status: string;
|
|
379
|
+
data: RepositoryAnalysisTimelineData;
|
|
380
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -108,8 +108,8 @@ export interface Product {
|
|
|
108
108
|
id: string;
|
|
109
109
|
active: boolean;
|
|
110
110
|
name: string;
|
|
111
|
-
description: string;
|
|
112
|
-
image: string;
|
|
111
|
+
description: string | null;
|
|
112
|
+
image: string | null;
|
|
113
113
|
metadata: Record<string, any>;
|
|
114
114
|
marketing_features: string[];
|
|
115
115
|
live_mode: boolean;
|
|
@@ -140,6 +140,13 @@ export interface UserSubscriptionsResponse {
|
|
|
140
140
|
status: string;
|
|
141
141
|
data: Subscription[];
|
|
142
142
|
}
|
|
143
|
+
export interface SubscriptionProductsResponse {
|
|
144
|
+
status: string;
|
|
145
|
+
data: Array<{
|
|
146
|
+
product: Product;
|
|
147
|
+
prices: Price[];
|
|
148
|
+
}>;
|
|
149
|
+
}
|
|
143
150
|
export interface CancelSubscriptionRequest {
|
|
144
151
|
cancel_at_period_end: boolean;
|
|
145
152
|
}
|
|
@@ -148,6 +155,15 @@ export interface CancelSubscriptionResponse {
|
|
|
148
155
|
message: string;
|
|
149
156
|
data: Subscription;
|
|
150
157
|
}
|
|
158
|
+
export interface CreateCheckoutSessionRequest {
|
|
159
|
+
price_id: string;
|
|
160
|
+
success_url: string;
|
|
161
|
+
cancel_url: string;
|
|
162
|
+
}
|
|
163
|
+
export interface CreateCheckoutSessionResponse {
|
|
164
|
+
status: string;
|
|
165
|
+
checkout_url: string;
|
|
166
|
+
}
|
|
151
167
|
export interface CancellationFunnelInitiateRequest {
|
|
152
168
|
subscription_id: string;
|
|
153
169
|
}
|