@codeguide/core 0.0.4 → 0.0.6
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/codeguide.ts +3 -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 +52 -0
- package/dist/services/api-key-enhanced/api-key-enhanced-service.js +66 -0
- package/dist/services/api-key-enhanced/index.d.ts +1 -0
- package/dist/services/api-key-enhanced/index.js +5 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +4 -1
- package/dist/types.d.ts +30 -0
- package/package.json +1 -1
- package/services/api-key-enhanced/api-key-enhanced-service.ts +87 -0
- package/services/api-key-enhanced/index.ts +1 -0
- package/services/index.ts +2 -0
- package/types.ts +57 -0
package/codeguide.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
UsageService,
|
|
13
13
|
RepositoryAnalysisService,
|
|
14
14
|
TaskService,
|
|
15
|
+
ApiKeyEnhancedService,
|
|
15
16
|
} from './services'
|
|
16
17
|
import { APIServiceConfig, CodeGuideOptions } from './types'
|
|
17
18
|
|
|
@@ -21,6 +22,7 @@ export class CodeGuide {
|
|
|
21
22
|
public usage: UsageService
|
|
22
23
|
public repositoryAnalysis: RepositoryAnalysisService
|
|
23
24
|
public tasks: TaskService
|
|
25
|
+
public apiKeyEnhanced: ApiKeyEnhancedService
|
|
24
26
|
private options: CodeGuideOptions
|
|
25
27
|
|
|
26
28
|
constructor(config: APIServiceConfig, options: CodeGuideOptions = {}) {
|
|
@@ -32,6 +34,7 @@ export class CodeGuide {
|
|
|
32
34
|
this.usage = new UsageService(config)
|
|
33
35
|
this.repositoryAnalysis = new RepositoryAnalysisService(config)
|
|
34
36
|
this.tasks = new TaskService(config)
|
|
37
|
+
this.apiKeyEnhanced = new ApiKeyEnhancedService(config)
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
// Convenience method for backward compatibility
|
package/dist/codeguide.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenerationService, ProjectService, UsageService, RepositoryAnalysisService, TaskService } from './services';
|
|
1
|
+
import { GenerationService, ProjectService, UsageService, RepositoryAnalysisService, TaskService, ApiKeyEnhancedService } from './services';
|
|
2
2
|
import { APIServiceConfig, CodeGuideOptions } from './types';
|
|
3
3
|
export declare class CodeGuide {
|
|
4
4
|
generation: GenerationService;
|
|
@@ -6,6 +6,7 @@ export declare class CodeGuide {
|
|
|
6
6
|
usage: UsageService;
|
|
7
7
|
repositoryAnalysis: RepositoryAnalysisService;
|
|
8
8
|
tasks: TaskService;
|
|
9
|
+
apiKeyEnhanced: ApiKeyEnhancedService;
|
|
9
10
|
private options;
|
|
10
11
|
constructor(config: APIServiceConfig, options?: CodeGuideOptions);
|
|
11
12
|
getGuidance(prompt: string): Promise<any>;
|
package/dist/codeguide.js
CHANGED
|
@@ -21,6 +21,7 @@ class CodeGuide {
|
|
|
21
21
|
this.usage = new services_1.UsageService(config);
|
|
22
22
|
this.repositoryAnalysis = new services_1.RepositoryAnalysisService(config);
|
|
23
23
|
this.tasks = new services_1.TaskService(config);
|
|
24
|
+
this.apiKeyEnhanced = new services_1.ApiKeyEnhancedService(config);
|
|
24
25
|
}
|
|
25
26
|
// Convenience method for backward compatibility
|
|
26
27
|
async getGuidance(prompt) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service';
|
|
2
|
+
import { ApiKey, CreateApiKeyRequest, CreateApiKeyResponse, ApiKeyPermission, RevokeApiKeyResponse } from '../../types';
|
|
3
|
+
export declare class ApiKeyEnhancedService extends BaseService {
|
|
4
|
+
constructor(config: any);
|
|
5
|
+
/**
|
|
6
|
+
* Get all API keys for the authenticated user
|
|
7
|
+
* GET /api-key-enhanced/
|
|
8
|
+
*/
|
|
9
|
+
getAllApiKeys(): Promise<ApiKey[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new API key
|
|
12
|
+
* POST /api-key-enhanced/
|
|
13
|
+
*/
|
|
14
|
+
createApiKey(request: CreateApiKeyRequest): Promise<CreateApiKeyResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Revoke an API key by ID
|
|
17
|
+
* DELETE /api-key-enhanced/{api_key_id}
|
|
18
|
+
*/
|
|
19
|
+
revokeApiKey(apiKeyId: string): Promise<RevokeApiKeyResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if user can create API keys
|
|
22
|
+
* GET /api-key-enhanced/check-permission
|
|
23
|
+
*/
|
|
24
|
+
checkApiKeyPermission(): Promise<ApiKeyPermission>;
|
|
25
|
+
/**
|
|
26
|
+
* Get API key details by ID
|
|
27
|
+
* GET /api-key-enhanced/{api_key_id}
|
|
28
|
+
*/
|
|
29
|
+
getApiKeyById(apiKeyId: string): Promise<ApiKey>;
|
|
30
|
+
/**
|
|
31
|
+
* Update API key name (if supported by API)
|
|
32
|
+
* PUT /api-key-enhanced/{api_key_id}
|
|
33
|
+
*/
|
|
34
|
+
updateApiKeyName(apiKeyId: string, name: string): Promise<ApiKey>;
|
|
35
|
+
/**
|
|
36
|
+
* Toggle API key active status (if supported by API)
|
|
37
|
+
* PATCH /api-key-enhanced/{api_key_id}/toggle
|
|
38
|
+
*/
|
|
39
|
+
toggleApiKeyStatus(apiKeyId: string): Promise<ApiKey>;
|
|
40
|
+
/**
|
|
41
|
+
* Get API key usage statistics (if supported by API)
|
|
42
|
+
* GET /api-key-enhanced/{api_key_id}/usage
|
|
43
|
+
*/
|
|
44
|
+
getApiKeyUsage(apiKeyId: string): Promise<{
|
|
45
|
+
usage_count: number;
|
|
46
|
+
last_used?: string;
|
|
47
|
+
daily_usage?: Array<{
|
|
48
|
+
date: string;
|
|
49
|
+
count: number;
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiKeyEnhancedService = void 0;
|
|
4
|
+
const base_service_1 = require("../base/base-service");
|
|
5
|
+
class ApiKeyEnhancedService extends base_service_1.BaseService {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super(config);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get all API keys for the authenticated user
|
|
11
|
+
* GET /api-key-enhanced/
|
|
12
|
+
*/
|
|
13
|
+
async getAllApiKeys() {
|
|
14
|
+
return this.get('/api-key-enhanced/');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a new API key
|
|
18
|
+
* POST /api-key-enhanced/
|
|
19
|
+
*/
|
|
20
|
+
async createApiKey(request) {
|
|
21
|
+
return this.post('/api-key-enhanced/', request);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Revoke an API key by ID
|
|
25
|
+
* DELETE /api-key-enhanced/{api_key_id}
|
|
26
|
+
*/
|
|
27
|
+
async revokeApiKey(apiKeyId) {
|
|
28
|
+
return this.delete(`/api-key-enhanced/${apiKeyId}`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if user can create API keys
|
|
32
|
+
* GET /api-key-enhanced/check-permission
|
|
33
|
+
*/
|
|
34
|
+
async checkApiKeyPermission() {
|
|
35
|
+
return this.get('/api-key-enhanced/check-permission');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get API key details by ID
|
|
39
|
+
* GET /api-key-enhanced/{api_key_id}
|
|
40
|
+
*/
|
|
41
|
+
async getApiKeyById(apiKeyId) {
|
|
42
|
+
return this.get(`/api-key-enhanced/${apiKeyId}`);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Update API key name (if supported by API)
|
|
46
|
+
* PUT /api-key-enhanced/{api_key_id}
|
|
47
|
+
*/
|
|
48
|
+
async updateApiKeyName(apiKeyId, name) {
|
|
49
|
+
return this.put(`/api-key-enhanced/${apiKeyId}`, { name });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Toggle API key active status (if supported by API)
|
|
53
|
+
* PATCH /api-key-enhanced/{api_key_id}/toggle
|
|
54
|
+
*/
|
|
55
|
+
async toggleApiKeyStatus(apiKeyId) {
|
|
56
|
+
return this.post(`/api-key-enhanced/${apiKeyId}/toggle`, {});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get API key usage statistics (if supported by API)
|
|
60
|
+
* GET /api-key-enhanced/{api_key_id}/usage
|
|
61
|
+
*/
|
|
62
|
+
async getApiKeyUsage(apiKeyId) {
|
|
63
|
+
return this.get(`/api-key-enhanced/${apiKeyId}/usage`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ApiKeyEnhancedService = ApiKeyEnhancedService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApiKeyEnhancedService } from './api-key-enhanced-service';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiKeyEnhancedService = void 0;
|
|
4
|
+
var api_key_enhanced_service_1 = require("./api-key-enhanced-service");
|
|
5
|
+
Object.defineProperty(exports, "ApiKeyEnhancedService", { enumerable: true, get: function () { return api_key_enhanced_service_1.ApiKeyEnhancedService; } });
|
package/dist/services/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ export { ProjectService } from './projects';
|
|
|
4
4
|
export { UsageService } from './usage';
|
|
5
5
|
export { RepositoryAnalysisService } from './repository-analysis';
|
|
6
6
|
export { TaskService } from './tasks';
|
|
7
|
+
export { ApiKeyEnhancedService } from './api-key-enhanced';
|
|
7
8
|
export * from './generation';
|
|
8
9
|
export * from './projects';
|
|
9
10
|
export * from './usage';
|
|
10
11
|
export * from './repository-analysis';
|
|
11
12
|
export * from './tasks';
|
|
13
|
+
export * from './api-key-enhanced';
|
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.TaskService = exports.RepositoryAnalysisService = exports.UsageService = exports.ProjectService = exports.GenerationService = exports.BaseService = void 0;
|
|
20
|
+
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
|
|
@@ -37,9 +37,12 @@ var repository_analysis_1 = require("./repository-analysis");
|
|
|
37
37
|
Object.defineProperty(exports, "RepositoryAnalysisService", { enumerable: true, get: function () { return repository_analysis_1.RepositoryAnalysisService; } });
|
|
38
38
|
var tasks_1 = require("./tasks");
|
|
39
39
|
Object.defineProperty(exports, "TaskService", { enumerable: true, get: function () { return tasks_1.TaskService; } });
|
|
40
|
+
var api_key_enhanced_1 = require("./api-key-enhanced");
|
|
41
|
+
Object.defineProperty(exports, "ApiKeyEnhancedService", { enumerable: true, get: function () { return api_key_enhanced_1.ApiKeyEnhancedService; } });
|
|
40
42
|
// Re-export all types for convenience
|
|
41
43
|
__exportStar(require("./generation"), exports);
|
|
42
44
|
__exportStar(require("./projects"), exports);
|
|
43
45
|
__exportStar(require("./usage"), exports);
|
|
44
46
|
__exportStar(require("./repository-analysis"), exports);
|
|
45
47
|
__exportStar(require("./tasks"), exports);
|
|
48
|
+
__exportStar(require("./api-key-enhanced"), exports);
|
package/dist/types.d.ts
CHANGED
|
@@ -40,3 +40,33 @@ export interface CodeGuideOptions {
|
|
|
40
40
|
context?: string;
|
|
41
41
|
verbose?: boolean;
|
|
42
42
|
}
|
|
43
|
+
export interface ApiKey {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
prefix: string;
|
|
47
|
+
created_at: string;
|
|
48
|
+
last_used?: string;
|
|
49
|
+
is_active: boolean;
|
|
50
|
+
usage_count?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface CreateApiKeyRequest {
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
55
|
+
export interface CreateApiKeyResponse {
|
|
56
|
+
api_key: string;
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
prefix: string;
|
|
60
|
+
created_at: string;
|
|
61
|
+
message: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ApiKeyPermission {
|
|
64
|
+
can_create: boolean;
|
|
65
|
+
reason?: string;
|
|
66
|
+
current_keys_count?: number;
|
|
67
|
+
max_keys_allowed?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface RevokeApiKeyResponse {
|
|
70
|
+
message: string;
|
|
71
|
+
revoked_key_id: string;
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service'
|
|
2
|
+
import {
|
|
3
|
+
ApiKey,
|
|
4
|
+
CreateApiKeyRequest,
|
|
5
|
+
CreateApiKeyResponse,
|
|
6
|
+
ApiKeyPermissionResponse,
|
|
7
|
+
RevokeApiKeyResponse,
|
|
8
|
+
ApiKeyListResponse,
|
|
9
|
+
ApiKeyResponse,
|
|
10
|
+
} from '../../types'
|
|
11
|
+
|
|
12
|
+
export class ApiKeyEnhancedService extends BaseService {
|
|
13
|
+
constructor(config: any) {
|
|
14
|
+
super(config)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get all API keys for the authenticated user
|
|
19
|
+
* GET /api-key-enhanced/
|
|
20
|
+
*/
|
|
21
|
+
async getAllApiKeys(): Promise<ApiKeyListResponse> {
|
|
22
|
+
return this.get<ApiKeyListResponse>('/api-key-enhanced/')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a new API key
|
|
27
|
+
* POST /api-key-enhanced/
|
|
28
|
+
*/
|
|
29
|
+
async createApiKey(request: CreateApiKeyRequest): Promise<CreateApiKeyResponse> {
|
|
30
|
+
return this.post<CreateApiKeyResponse>('/api-key-enhanced/', request)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Revoke an API key by ID
|
|
35
|
+
* DELETE /api-key-enhanced/{api_key_id}
|
|
36
|
+
*/
|
|
37
|
+
async revokeApiKey(apiKeyId: string): Promise<RevokeApiKeyResponse> {
|
|
38
|
+
return this.delete<RevokeApiKeyResponse>(`/api-key-enhanced/${apiKeyId}`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Check if user can create API keys
|
|
43
|
+
* GET /api-key-enhanced/check-permission
|
|
44
|
+
*/
|
|
45
|
+
async checkApiKeyPermission(): Promise<ApiKeyPermissionResponse> {
|
|
46
|
+
return this.get<ApiKeyPermissionResponse>('/api-key-enhanced/check-permission')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get API key details by ID
|
|
51
|
+
* GET /api-key-enhanced/{api_key_id}
|
|
52
|
+
*/
|
|
53
|
+
async getApiKeyById(apiKeyId: string): Promise<ApiKeyResponse> {
|
|
54
|
+
return this.get<ApiKeyResponse>(`/api-key-enhanced/${apiKeyId}`)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Update API key name (if supported by API)
|
|
59
|
+
* PUT /api-key-enhanced/{api_key_id}
|
|
60
|
+
*/
|
|
61
|
+
async updateApiKeyName(apiKeyId: string, name: string): Promise<ApiKeyResponse> {
|
|
62
|
+
return this.put<ApiKeyResponse>(`/api-key-enhanced/${apiKeyId}`, { name })
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Toggle API key active status (if supported by API)
|
|
67
|
+
* PATCH /api-key-enhanced/{api_key_id}/toggle
|
|
68
|
+
*/
|
|
69
|
+
async toggleApiKeyStatus(apiKeyId: string): Promise<ApiKeyResponse> {
|
|
70
|
+
return this.post<ApiKeyResponse>(`/api-key-enhanced/${apiKeyId}/toggle`, {})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get API key usage statistics (if supported by API)
|
|
75
|
+
* GET /api-key-enhanced/{api_key_id}/usage
|
|
76
|
+
*/
|
|
77
|
+
async getApiKeyUsage(apiKeyId: string): Promise<{
|
|
78
|
+
status: string
|
|
79
|
+
data: {
|
|
80
|
+
usage_count: number
|
|
81
|
+
last_used?: string
|
|
82
|
+
daily_usage?: Array<{ date: string; count: number }>
|
|
83
|
+
}
|
|
84
|
+
}> {
|
|
85
|
+
return this.get(`/api-key-enhanced/${apiKeyId}/usage`)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApiKeyEnhancedService } from './api-key-enhanced-service'
|
package/services/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { ProjectService } from './projects'
|
|
|
13
13
|
export { UsageService } from './usage'
|
|
14
14
|
export { RepositoryAnalysisService } from './repository-analysis'
|
|
15
15
|
export { TaskService } from './tasks'
|
|
16
|
+
export { ApiKeyEnhancedService } from './api-key-enhanced'
|
|
16
17
|
|
|
17
18
|
// Re-export all types for convenience
|
|
18
19
|
export * from './generation'
|
|
@@ -20,3 +21,4 @@ export * from './projects'
|
|
|
20
21
|
export * from './usage'
|
|
21
22
|
export * from './repository-analysis'
|
|
22
23
|
export * from './tasks'
|
|
24
|
+
export * from './api-key-enhanced'
|
package/types.ts
CHANGED
|
@@ -49,3 +49,60 @@ export interface CodeGuideOptions {
|
|
|
49
49
|
context?: string
|
|
50
50
|
verbose?: boolean
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
// API Key Enhanced Types
|
|
54
|
+
export interface ApiKey {
|
|
55
|
+
id: string
|
|
56
|
+
key: string
|
|
57
|
+
user_id: string
|
|
58
|
+
name: string
|
|
59
|
+
created_at: string
|
|
60
|
+
expires_at?: string
|
|
61
|
+
is_active: boolean
|
|
62
|
+
metadata?: Record<string, any>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// API Response wrapper
|
|
66
|
+
export interface ApiKeyListResponse {
|
|
67
|
+
status: string
|
|
68
|
+
data: ApiKey[]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface CreateApiKeyRequest {
|
|
72
|
+
name: string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface CreateApiKeyResponse {
|
|
76
|
+
status: string
|
|
77
|
+
data: {
|
|
78
|
+
api_key: string
|
|
79
|
+
id: string
|
|
80
|
+
name: string
|
|
81
|
+
created_at: string
|
|
82
|
+
expires_at?: string
|
|
83
|
+
is_active: boolean
|
|
84
|
+
metadata?: Record<string, any>
|
|
85
|
+
}
|
|
86
|
+
message?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ApiKeyPermissionResponse {
|
|
90
|
+
status: string
|
|
91
|
+
data: {
|
|
92
|
+
can_create: boolean
|
|
93
|
+
reason?: string
|
|
94
|
+
current_keys_count?: number
|
|
95
|
+
max_keys_allowed?: number
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ApiKeyResponse {
|
|
100
|
+
status: string
|
|
101
|
+
data: ApiKey
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface RevokeApiKeyResponse {
|
|
105
|
+
status: string
|
|
106
|
+
message: string
|
|
107
|
+
revoked_key_id?: string
|
|
108
|
+
}
|