@codeguide/core 0.0.6 → 0.0.8
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 +503 -0
- package/codeguide.ts +6 -0
- package/dist/codeguide.d.ts +2 -1
- package/dist/codeguide.js +1 -0
- package/dist/services/api-key-enhanced/api-key-enhanced-service.d.ts +15 -12
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +4 -1
- package/dist/services/subscriptions/index.d.ts +1 -0
- package/dist/services/subscriptions/index.js +5 -0
- package/dist/services/subscriptions/subscription-service.d.ts +103 -0
- package/dist/services/subscriptions/subscription-service.js +73 -0
- package/dist/types.d.ts +94 -14
- package/package.json +1 -1
- package/services/cancellation-funnel/cancellation-funnel-service.ts +239 -0
- package/services/cancellation-funnel/index.ts +1 -0
- package/services/index.ts +4 -0
- package/services/subscriptions/index.ts +1 -0
- package/services/subscriptions/subscription-service.ts +147 -0
- package/types.ts +132 -0
package/README.md
ADDED
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
# @codeguide/core
|
|
2
|
+
|
|
3
|
+
The core package for CodeGuide with programmatic API access. This package provides TypeScript interfaces and services for integrating CodeGuide functionality into your applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔑 **API Key Management**: Full CRUD operations for API keys
|
|
8
|
+
- 📝 **Project Management**: Create and manage projects programmatically
|
|
9
|
+
- 🎯 **Task Management**: Organize and track development tasks
|
|
10
|
+
- 📊 **Usage Analytics**: Monitor API usage and credits
|
|
11
|
+
- 🔍 **Repository Analysis**: Analyze code repositories
|
|
12
|
+
- 🎨 **Code Generation**: Generate code with AI assistance
|
|
13
|
+
- 🔐 **Multiple Authentication**: Support for various auth methods
|
|
14
|
+
- 🛡️ **TypeScript Support**: Full type safety and IntelliSense
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @codeguide/core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Basic Usage
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { CodeGuide } from '@codeguide/core'
|
|
28
|
+
|
|
29
|
+
const codeguide = new CodeGuide({
|
|
30
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
31
|
+
databaseApiKey: 'sk_your_database_api_key'
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Get all API keys
|
|
35
|
+
const keysResponse = await codeguide.apiKeyEnhanced.getAllApiKeys()
|
|
36
|
+
console.log(`Found ${keysResponse.data.length} API keys`)
|
|
37
|
+
|
|
38
|
+
// Create a new API key
|
|
39
|
+
const newKey = await codeguide.apiKeyEnhanced.createApiKey({
|
|
40
|
+
name: 'My Application'
|
|
41
|
+
})
|
|
42
|
+
console.log(`Created key: ${newKey.data.api_key}`)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### API Key Management
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import {
|
|
49
|
+
CodeGuide,
|
|
50
|
+
ApiKeyListResponse,
|
|
51
|
+
CreateApiKeyRequest
|
|
52
|
+
} from '@codeguide/core'
|
|
53
|
+
|
|
54
|
+
const codeguide = new CodeGuide({
|
|
55
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
56
|
+
databaseApiKey: 'sk_your_database_api_key'
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// List all API keys
|
|
60
|
+
const keysResponse: ApiKeyListResponse = await codeguide.apiKeyEnhanced.getAllApiKeys()
|
|
61
|
+
|
|
62
|
+
// Check if you can create new keys
|
|
63
|
+
const permission = await codeguide.apiKeyEnhanced.checkApiKeyPermission()
|
|
64
|
+
if (permission.data.can_create) {
|
|
65
|
+
console.log('You can create new API keys')
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Create a new key
|
|
69
|
+
const createRequest: CreateApiKeyRequest = {
|
|
70
|
+
name: 'Production Application'
|
|
71
|
+
}
|
|
72
|
+
const newKey = await codeguide.apiKeyEnhanced.createApiKey(createRequest)
|
|
73
|
+
|
|
74
|
+
// Revoke a key
|
|
75
|
+
await codeguide.apiKeyEnhanced.revokeApiKey('key-id-123')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Project Management
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { CodeGuide } from '@codeguide/core'
|
|
82
|
+
|
|
83
|
+
const codeguide = new CodeGuide({
|
|
84
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
85
|
+
databaseApiKey: 'sk_your_database_api_key'
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// Create a new project
|
|
89
|
+
const project = await codeguide.projects.createProject({
|
|
90
|
+
title: 'My Web Application',
|
|
91
|
+
description: 'A modern web app built with React'
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// Get project details
|
|
95
|
+
const projectDetails = await codeguide.projects.getProject(project.id)
|
|
96
|
+
|
|
97
|
+
// List all projects
|
|
98
|
+
const projects = await codeguide.projects.getAllProjects()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Task Management
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { CodeGuide } from '@codeguide/core'
|
|
105
|
+
|
|
106
|
+
const codeguide = new CodeGuide({
|
|
107
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
108
|
+
databaseApiKey: 'sk_your_database_api_key'
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
// Generate tasks for a project
|
|
112
|
+
const tasks = await codeguide.tasks.generateTasks({
|
|
113
|
+
project_id: 'project-id-123',
|
|
114
|
+
context: 'Building a React application with TypeScript'
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
// Get all tasks for a project
|
|
118
|
+
const projectTasks = await codeguide.tasks.getProjectTasks('project-id-123')
|
|
119
|
+
|
|
120
|
+
// Update task status
|
|
121
|
+
await codeguide.tasks.updateTask('task-id-123', {
|
|
122
|
+
status: 'in_progress',
|
|
123
|
+
notes: 'Started working on authentication module'
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Authentication
|
|
128
|
+
|
|
129
|
+
The CodeGuide client supports multiple authentication methods with automatic priority handling:
|
|
130
|
+
|
|
131
|
+
### 1. Database API Key (Highest Priority)
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const codeguide = new CodeGuide({
|
|
135
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
136
|
+
databaseApiKey: 'sk_your_database_api_key'
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. Legacy API Key + User ID
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const codeguide = new CodeGuide({
|
|
144
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
145
|
+
apiKey: 'your_api_key',
|
|
146
|
+
userId: 'your_user_id'
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### 3. Clerk JWT Token
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const codeguide = new CodeGuide({
|
|
154
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
155
|
+
jwtToken: 'your_jwt_token'
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Automatic Fallback
|
|
160
|
+
|
|
161
|
+
The client automatically falls back through authentication methods:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const codeguide = new CodeGuide({
|
|
165
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
166
|
+
databaseApiKey: 'sk_key', // Will try this first
|
|
167
|
+
apiKey: 'legacy_key', // Fallback if database key fails
|
|
168
|
+
userId: 'user_id', // Required for legacy auth
|
|
169
|
+
jwtToken: 'jwt_token' // Final fallback
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## API Reference
|
|
174
|
+
|
|
175
|
+
### ApiKeyEnhancedService
|
|
176
|
+
|
|
177
|
+
#### getAllApiKeys()
|
|
178
|
+
```typescript
|
|
179
|
+
async getAllApiKeys(): Promise<ApiKeyListResponse>
|
|
180
|
+
```
|
|
181
|
+
Get all API keys for the authenticated user.
|
|
182
|
+
|
|
183
|
+
**Returns:** `Promise<ApiKeyListResponse>`
|
|
184
|
+
|
|
185
|
+
**Example:**
|
|
186
|
+
```typescript
|
|
187
|
+
const response = await codeguide.apiKeyEnhanced.getAllApiKeys()
|
|
188
|
+
console.log(response.data) // Array of ApiKey objects
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### createApiKey(request)
|
|
192
|
+
```typescript
|
|
193
|
+
async createApiKey(request: CreateApiKeyRequest): Promise<CreateApiKeyResponse>
|
|
194
|
+
```
|
|
195
|
+
Create a new API key.
|
|
196
|
+
|
|
197
|
+
**Parameters:**
|
|
198
|
+
- `request.name` (string): Name for the new API key
|
|
199
|
+
|
|
200
|
+
**Returns:** `Promise<CreateApiKeyResponse>`
|
|
201
|
+
|
|
202
|
+
**Example:**
|
|
203
|
+
```typescript
|
|
204
|
+
const response = await codeguide.apiKeyEnhanced.createApiKey({
|
|
205
|
+
name: 'My Application'
|
|
206
|
+
})
|
|
207
|
+
console.log(response.data.api_key) // The new API key
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### revokeApiKey(apiKeyId)
|
|
211
|
+
```typescript
|
|
212
|
+
async revokeApiKey(apiKeyId: string): Promise<RevokeApiKeyResponse>
|
|
213
|
+
```
|
|
214
|
+
Revoke an API key by ID.
|
|
215
|
+
|
|
216
|
+
**Parameters:**
|
|
217
|
+
- `apiKeyId` (string): ID of the API key to revoke
|
|
218
|
+
|
|
219
|
+
**Returns:** `Promise<RevokeApiKeyResponse>`
|
|
220
|
+
|
|
221
|
+
#### checkApiKeyPermission()
|
|
222
|
+
```typescript
|
|
223
|
+
async checkApiKeyPermission(): Promise<ApiKeyPermissionResponse>
|
|
224
|
+
```
|
|
225
|
+
Check if the user can create new API keys.
|
|
226
|
+
|
|
227
|
+
**Returns:** `Promise<ApiKeyPermissionResponse>`
|
|
228
|
+
|
|
229
|
+
### ProjectService
|
|
230
|
+
|
|
231
|
+
#### createProject(request)
|
|
232
|
+
```typescript
|
|
233
|
+
async createProject(request: CreateProjectRequest): Promise<ProjectResponse>
|
|
234
|
+
```
|
|
235
|
+
Create a new project.
|
|
236
|
+
|
|
237
|
+
#### getProject(projectId)
|
|
238
|
+
```typescript
|
|
239
|
+
async getProject(projectId: string): Promise<ProjectResponse>
|
|
240
|
+
```
|
|
241
|
+
Get project details by ID.
|
|
242
|
+
|
|
243
|
+
#### getAllProjects()
|
|
244
|
+
```typescript
|
|
245
|
+
async getAllProjects(): Promise<ProjectsListResponse>
|
|
246
|
+
```
|
|
247
|
+
Get all projects for the authenticated user.
|
|
248
|
+
|
|
249
|
+
### TaskService
|
|
250
|
+
|
|
251
|
+
#### generateTasks(request)
|
|
252
|
+
```typescript
|
|
253
|
+
async generateTasks(request: GenerateTasksRequest): Promise<TasksResponse>
|
|
254
|
+
```
|
|
255
|
+
Generate tasks for a project.
|
|
256
|
+
|
|
257
|
+
#### getProjectTasks(projectId)
|
|
258
|
+
```typescript
|
|
259
|
+
async getProjectTasks(projectId: string): Promise<TasksResponse>
|
|
260
|
+
```
|
|
261
|
+
Get all tasks for a project.
|
|
262
|
+
|
|
263
|
+
#### updateTask(taskId, update)
|
|
264
|
+
```typescript
|
|
265
|
+
async updateTask(taskId: string, update: UpdateTaskRequest): Promise<TaskResponse>
|
|
266
|
+
```
|
|
267
|
+
Update task status and notes.
|
|
268
|
+
|
|
269
|
+
## Types
|
|
270
|
+
|
|
271
|
+
### ApiKey
|
|
272
|
+
```typescript
|
|
273
|
+
interface ApiKey {
|
|
274
|
+
id: string
|
|
275
|
+
key: string // Full API key string
|
|
276
|
+
user_id: string
|
|
277
|
+
name: string
|
|
278
|
+
created_at: string
|
|
279
|
+
expires_at?: string
|
|
280
|
+
is_active: boolean
|
|
281
|
+
metadata?: Record<string, any>
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### ApiKeyListResponse
|
|
286
|
+
```typescript
|
|
287
|
+
interface ApiKeyListResponse {
|
|
288
|
+
status: string
|
|
289
|
+
data: ApiKey[]
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### CreateApiKeyRequest
|
|
294
|
+
```typescript
|
|
295
|
+
interface CreateApiKeyRequest {
|
|
296
|
+
name: string
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### CreateApiKeyResponse
|
|
301
|
+
```typescript
|
|
302
|
+
interface CreateApiKeyResponse {
|
|
303
|
+
status: string
|
|
304
|
+
data: {
|
|
305
|
+
api_key: string
|
|
306
|
+
id: string
|
|
307
|
+
name: string
|
|
308
|
+
created_at: string
|
|
309
|
+
expires_at?: string
|
|
310
|
+
is_active: boolean
|
|
311
|
+
metadata?: Record<string, any>
|
|
312
|
+
}
|
|
313
|
+
message?: string
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### APIServiceConfig
|
|
318
|
+
```typescript
|
|
319
|
+
interface APIServiceConfig {
|
|
320
|
+
baseUrl: string
|
|
321
|
+
databaseApiKey?: string // Highest priority
|
|
322
|
+
apiKey?: string // Legacy API key
|
|
323
|
+
userId?: string // Required for legacy auth
|
|
324
|
+
jwtToken?: string // Clerk JWT token
|
|
325
|
+
timeout?: number // Default: 3600000 (1 hour)
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Error Handling
|
|
330
|
+
|
|
331
|
+
The client provides detailed error information:
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
try {
|
|
335
|
+
const keys = await codeguide.apiKeyEnhanced.getAllApiKeys()
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (error.message.includes('401')) {
|
|
338
|
+
console.error('Authentication failed:', error.message)
|
|
339
|
+
} else if (error.message.includes('403')) {
|
|
340
|
+
console.error('Permission denied:', error.message)
|
|
341
|
+
} else if (error.message.includes('429')) {
|
|
342
|
+
console.error('Rate limited:', error.message)
|
|
343
|
+
} else {
|
|
344
|
+
console.error('API error:', error.message)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Configuration
|
|
350
|
+
|
|
351
|
+
### Timeout Configuration
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
const codeguide = new CodeGuide({
|
|
355
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
356
|
+
databaseApiKey: 'sk_your_key',
|
|
357
|
+
timeout: 1800000 // 30 minutes
|
|
358
|
+
})
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Verbose Logging
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
const codeguide = new CodeGuide({
|
|
365
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
366
|
+
databaseApiKey: 'sk_your_key'
|
|
367
|
+
}, {
|
|
368
|
+
verbose: true // Enable detailed logging
|
|
369
|
+
})
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Advanced Usage
|
|
373
|
+
|
|
374
|
+
### Custom Headers
|
|
375
|
+
|
|
376
|
+
The BaseService allows you to intercept and modify requests:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// Access the underlying axios instance
|
|
380
|
+
const client = codeguide.apiKeyEnhanced.client
|
|
381
|
+
|
|
382
|
+
// Add custom headers
|
|
383
|
+
client.interceptors.request.use(config => {
|
|
384
|
+
config.headers['X-Custom-Header'] = 'value'
|
|
385
|
+
return config
|
|
386
|
+
})
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Response Interceptors
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
// Add custom response handling
|
|
393
|
+
client.interceptors.response.use(
|
|
394
|
+
response => response,
|
|
395
|
+
error => {
|
|
396
|
+
// Custom error handling
|
|
397
|
+
console.error('API Error:', error.response?.data)
|
|
398
|
+
return Promise.reject(error)
|
|
399
|
+
}
|
|
400
|
+
)
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## Examples
|
|
404
|
+
|
|
405
|
+
### Complete API Key Management Flow
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import { CodeGuide } from '@codeguide/core'
|
|
409
|
+
|
|
410
|
+
async function manageApiKeys() {
|
|
411
|
+
const codeguide = new CodeGuide({
|
|
412
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
413
|
+
databaseApiKey: 'sk_your_key'
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
try {
|
|
417
|
+
// Check permissions
|
|
418
|
+
const permission = await codeguide.apiKeyEnhanced.checkApiKeyPermission()
|
|
419
|
+
if (!permission.data.can_create) {
|
|
420
|
+
console.log('Cannot create new keys:', permission.data.reason)
|
|
421
|
+
return
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// List current keys
|
|
425
|
+
const currentKeys = await codeguide.apiKeyEnhanced.getAllApiKeys()
|
|
426
|
+
console.log(`Current keys: ${currentKeys.data.length}`)
|
|
427
|
+
|
|
428
|
+
// Create new key
|
|
429
|
+
const newKey = await codeguide.apiKeyEnhanced.createApiKey({
|
|
430
|
+
name: 'Production Application'
|
|
431
|
+
})
|
|
432
|
+
console.log('Created key:', newKey.data.api_key)
|
|
433
|
+
|
|
434
|
+
// Revoke old key if needed
|
|
435
|
+
if (currentKeys.data.length > 5) {
|
|
436
|
+
await codeguide.apiKeyEnhanced.revokeApiKey(currentKeys.data[0].id)
|
|
437
|
+
console.log('Revoked oldest key')
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.error('API key management failed:', error.message)
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Project Setup with Tasks
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { CodeGuide } from '@codeguide/core'
|
|
450
|
+
|
|
451
|
+
async function setupProject() {
|
|
452
|
+
const codeguide = new CodeGuide({
|
|
453
|
+
baseUrl: 'https://api.codeguide.ai',
|
|
454
|
+
databaseApiKey: 'sk_your_key'
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
try {
|
|
458
|
+
// Create project
|
|
459
|
+
const project = await codeguide.projects.createProject({
|
|
460
|
+
title: 'E-commerce Platform',
|
|
461
|
+
description: 'Modern e-commerce solution with React and Node.js'
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
// Generate tasks
|
|
465
|
+
const tasks = await codeguide.tasks.generateTasks({
|
|
466
|
+
project_id: project.id,
|
|
467
|
+
context: 'Building a full-stack e-commerce platform'
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
console.log(`Created project with ${tasks.data.length} tasks`)
|
|
471
|
+
|
|
472
|
+
// Start first task
|
|
473
|
+
if (tasks.data.length > 0) {
|
|
474
|
+
await codeguide.tasks.updateTask(tasks.data[0].id, {
|
|
475
|
+
status: 'in_progress',
|
|
476
|
+
notes: 'Starting project setup'
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
} catch (error) {
|
|
481
|
+
console.error('Project setup failed:', error.message)
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
## Contributing
|
|
487
|
+
|
|
488
|
+
1. Fork the repository
|
|
489
|
+
2. Create a feature branch
|
|
490
|
+
3. Make your changes
|
|
491
|
+
4. Add tests
|
|
492
|
+
5. Submit a pull request
|
|
493
|
+
|
|
494
|
+
## Support
|
|
495
|
+
|
|
496
|
+
- **Documentation**: [Main README](../../README.md)
|
|
497
|
+
- **CLI Package**: [@codeguide/cli](../cli/README.md)
|
|
498
|
+
- **Issues**: [GitHub Issues](https://github.com/CodeGuide-dev/codeguide/issues)
|
|
499
|
+
- **Discussions**: [GitHub Discussions](https://github.com/CodeGuide-dev/codeguide/discussions)
|
|
500
|
+
|
|
501
|
+
## License
|
|
502
|
+
|
|
503
|
+
MIT License - see [LICENSE](../../LICENSE) file for details.
|
package/codeguide.ts
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
RepositoryAnalysisService,
|
|
14
14
|
TaskService,
|
|
15
15
|
ApiKeyEnhancedService,
|
|
16
|
+
SubscriptionService,
|
|
17
|
+
CancellationFunnelService,
|
|
16
18
|
} from './services'
|
|
17
19
|
import { APIServiceConfig, CodeGuideOptions } from './types'
|
|
18
20
|
|
|
@@ -23,6 +25,8 @@ export class CodeGuide {
|
|
|
23
25
|
public repositoryAnalysis: RepositoryAnalysisService
|
|
24
26
|
public tasks: TaskService
|
|
25
27
|
public apiKeyEnhanced: ApiKeyEnhancedService
|
|
28
|
+
public subscription: SubscriptionService
|
|
29
|
+
public cancellationFunnel: CancellationFunnelService
|
|
26
30
|
private options: CodeGuideOptions
|
|
27
31
|
|
|
28
32
|
constructor(config: APIServiceConfig, options: CodeGuideOptions = {}) {
|
|
@@ -35,6 +39,8 @@ export class CodeGuide {
|
|
|
35
39
|
this.repositoryAnalysis = new RepositoryAnalysisService(config)
|
|
36
40
|
this.tasks = new TaskService(config)
|
|
37
41
|
this.apiKeyEnhanced = new ApiKeyEnhancedService(config)
|
|
42
|
+
this.subscription = new SubscriptionService(config)
|
|
43
|
+
this.cancellationFunnel = new CancellationFunnelService(config)
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
// Convenience method for backward compatibility
|
package/dist/codeguide.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenerationService, ProjectService, UsageService, RepositoryAnalysisService, TaskService, ApiKeyEnhancedService } from './services';
|
|
1
|
+
import { GenerationService, ProjectService, UsageService, RepositoryAnalysisService, TaskService, ApiKeyEnhancedService, SubscriptionService } from './services';
|
|
2
2
|
import { APIServiceConfig, CodeGuideOptions } from './types';
|
|
3
3
|
export declare class CodeGuide {
|
|
4
4
|
generation: GenerationService;
|
|
@@ -7,6 +7,7 @@ export declare class CodeGuide {
|
|
|
7
7
|
repositoryAnalysis: RepositoryAnalysisService;
|
|
8
8
|
tasks: TaskService;
|
|
9
9
|
apiKeyEnhanced: ApiKeyEnhancedService;
|
|
10
|
+
subscription: SubscriptionService;
|
|
10
11
|
private options;
|
|
11
12
|
constructor(config: APIServiceConfig, options?: CodeGuideOptions);
|
|
12
13
|
getGuidance(prompt: string): Promise<any>;
|
package/dist/codeguide.js
CHANGED
|
@@ -22,6 +22,7 @@ class CodeGuide {
|
|
|
22
22
|
this.repositoryAnalysis = new services_1.RepositoryAnalysisService(config);
|
|
23
23
|
this.tasks = new services_1.TaskService(config);
|
|
24
24
|
this.apiKeyEnhanced = new services_1.ApiKeyEnhancedService(config);
|
|
25
|
+
this.subscription = new services_1.SubscriptionService(config);
|
|
25
26
|
}
|
|
26
27
|
// Convenience method for backward compatibility
|
|
27
28
|
async getGuidance(prompt) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BaseService } from '../base/base-service';
|
|
2
|
-
import {
|
|
2
|
+
import { CreateApiKeyRequest, CreateApiKeyResponse, ApiKeyPermissionResponse, RevokeApiKeyResponse, ApiKeyListResponse, ApiKeyResponse } from '../../types';
|
|
3
3
|
export declare class ApiKeyEnhancedService extends BaseService {
|
|
4
4
|
constructor(config: any);
|
|
5
5
|
/**
|
|
6
6
|
* Get all API keys for the authenticated user
|
|
7
7
|
* GET /api-key-enhanced/
|
|
8
8
|
*/
|
|
9
|
-
getAllApiKeys(): Promise<
|
|
9
|
+
getAllApiKeys(): Promise<ApiKeyListResponse>;
|
|
10
10
|
/**
|
|
11
11
|
* Create a new API key
|
|
12
12
|
* POST /api-key-enhanced/
|
|
@@ -21,32 +21,35 @@ export declare class ApiKeyEnhancedService extends BaseService {
|
|
|
21
21
|
* Check if user can create API keys
|
|
22
22
|
* GET /api-key-enhanced/check-permission
|
|
23
23
|
*/
|
|
24
|
-
checkApiKeyPermission(): Promise<
|
|
24
|
+
checkApiKeyPermission(): Promise<ApiKeyPermissionResponse>;
|
|
25
25
|
/**
|
|
26
26
|
* Get API key details by ID
|
|
27
27
|
* GET /api-key-enhanced/{api_key_id}
|
|
28
28
|
*/
|
|
29
|
-
getApiKeyById(apiKeyId: string): Promise<
|
|
29
|
+
getApiKeyById(apiKeyId: string): Promise<ApiKeyResponse>;
|
|
30
30
|
/**
|
|
31
31
|
* Update API key name (if supported by API)
|
|
32
32
|
* PUT /api-key-enhanced/{api_key_id}
|
|
33
33
|
*/
|
|
34
|
-
updateApiKeyName(apiKeyId: string, name: string): Promise<
|
|
34
|
+
updateApiKeyName(apiKeyId: string, name: string): Promise<ApiKeyResponse>;
|
|
35
35
|
/**
|
|
36
36
|
* Toggle API key active status (if supported by API)
|
|
37
37
|
* PATCH /api-key-enhanced/{api_key_id}/toggle
|
|
38
38
|
*/
|
|
39
|
-
toggleApiKeyStatus(apiKeyId: string): Promise<
|
|
39
|
+
toggleApiKeyStatus(apiKeyId: string): Promise<ApiKeyResponse>;
|
|
40
40
|
/**
|
|
41
41
|
* Get API key usage statistics (if supported by API)
|
|
42
42
|
* GET /api-key-enhanced/{api_key_id}/usage
|
|
43
43
|
*/
|
|
44
44
|
getApiKeyUsage(apiKeyId: string): Promise<{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
status: string;
|
|
46
|
+
data: {
|
|
47
|
+
usage_count: number;
|
|
48
|
+
last_used?: string;
|
|
49
|
+
daily_usage?: Array<{
|
|
50
|
+
date: string;
|
|
51
|
+
count: number;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
51
54
|
}>;
|
|
52
55
|
}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -5,9 +5,11 @@ export { UsageService } from './usage';
|
|
|
5
5
|
export { RepositoryAnalysisService } from './repository-analysis';
|
|
6
6
|
export { TaskService } from './tasks';
|
|
7
7
|
export { ApiKeyEnhancedService } from './api-key-enhanced';
|
|
8
|
+
export { SubscriptionService } from './subscriptions';
|
|
8
9
|
export * from './generation';
|
|
9
10
|
export * from './projects';
|
|
10
11
|
export * from './usage';
|
|
11
12
|
export * from './repository-analysis';
|
|
12
13
|
export * from './tasks';
|
|
13
14
|
export * from './api-key-enhanced';
|
|
15
|
+
export * from './subscriptions';
|
package/dist/services/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.ApiKeyEnhancedService = exports.TaskService = exports.RepositoryAnalysisService = exports.UsageService = exports.ProjectService = exports.GenerationService = exports.BaseService = void 0;
|
|
20
|
+
exports.SubscriptionService = exports.ApiKeyEnhancedService = exports.TaskService = exports.RepositoryAnalysisService = exports.UsageService = exports.ProjectService = exports.GenerationService = exports.BaseService = void 0;
|
|
21
21
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
22
22
|
const path_1 = __importDefault(require("path"));
|
|
23
23
|
// Load environment variables from project root
|
|
@@ -39,6 +39,8 @@ var tasks_1 = require("./tasks");
|
|
|
39
39
|
Object.defineProperty(exports, "TaskService", { enumerable: true, get: function () { return tasks_1.TaskService; } });
|
|
40
40
|
var api_key_enhanced_1 = require("./api-key-enhanced");
|
|
41
41
|
Object.defineProperty(exports, "ApiKeyEnhancedService", { enumerable: true, get: function () { return api_key_enhanced_1.ApiKeyEnhancedService; } });
|
|
42
|
+
var subscriptions_1 = require("./subscriptions");
|
|
43
|
+
Object.defineProperty(exports, "SubscriptionService", { enumerable: true, get: function () { return subscriptions_1.SubscriptionService; } });
|
|
42
44
|
// Re-export all types for convenience
|
|
43
45
|
__exportStar(require("./generation"), exports);
|
|
44
46
|
__exportStar(require("./projects"), exports);
|
|
@@ -46,3 +48,4 @@ __exportStar(require("./usage"), exports);
|
|
|
46
48
|
__exportStar(require("./repository-analysis"), exports);
|
|
47
49
|
__exportStar(require("./tasks"), exports);
|
|
48
50
|
__exportStar(require("./api-key-enhanced"), exports);
|
|
51
|
+
__exportStar(require("./subscriptions"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SubscriptionService } from './subscription-service';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionService = void 0;
|
|
4
|
+
var subscription_service_1 = require("./subscription-service");
|
|
5
|
+
Object.defineProperty(exports, "SubscriptionService", { enumerable: true, get: function () { return subscription_service_1.SubscriptionService; } });
|