@codeguide/core 0.0.4 → 0.0.5

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 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
@@ -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; } });
@@ -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';
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeguide/core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Core package for code guidance with programmatic API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,82 @@
1
+ import { BaseService } from '../base/base-service'
2
+ import {
3
+ ApiKey,
4
+ CreateApiKeyRequest,
5
+ CreateApiKeyResponse,
6
+ ApiKeyPermission,
7
+ RevokeApiKeyResponse,
8
+ } from '../../types'
9
+
10
+ export class ApiKeyEnhancedService extends BaseService {
11
+ constructor(config: any) {
12
+ super(config)
13
+ }
14
+
15
+ /**
16
+ * Get all API keys for the authenticated user
17
+ * GET /api-key-enhanced/
18
+ */
19
+ async getAllApiKeys(): Promise<ApiKey[]> {
20
+ return this.get<ApiKey[]>('/api-key-enhanced/')
21
+ }
22
+
23
+ /**
24
+ * Create a new API key
25
+ * POST /api-key-enhanced/
26
+ */
27
+ async createApiKey(request: CreateApiKeyRequest): Promise<CreateApiKeyResponse> {
28
+ return this.post<CreateApiKeyResponse>('/api-key-enhanced/', request)
29
+ }
30
+
31
+ /**
32
+ * Revoke an API key by ID
33
+ * DELETE /api-key-enhanced/{api_key_id}
34
+ */
35
+ async revokeApiKey(apiKeyId: string): Promise<RevokeApiKeyResponse> {
36
+ return this.delete<RevokeApiKeyResponse>(`/api-key-enhanced/${apiKeyId}`)
37
+ }
38
+
39
+ /**
40
+ * Check if user can create API keys
41
+ * GET /api-key-enhanced/check-permission
42
+ */
43
+ async checkApiKeyPermission(): Promise<ApiKeyPermission> {
44
+ return this.get<ApiKeyPermission>('/api-key-enhanced/check-permission')
45
+ }
46
+
47
+ /**
48
+ * Get API key details by ID
49
+ * GET /api-key-enhanced/{api_key_id}
50
+ */
51
+ async getApiKeyById(apiKeyId: string): Promise<ApiKey> {
52
+ return this.get<ApiKey>(`/api-key-enhanced/${apiKeyId}`)
53
+ }
54
+
55
+ /**
56
+ * Update API key name (if supported by API)
57
+ * PUT /api-key-enhanced/{api_key_id}
58
+ */
59
+ async updateApiKeyName(apiKeyId: string, name: string): Promise<ApiKey> {
60
+ return this.put<ApiKey>(`/api-key-enhanced/${apiKeyId}`, { name })
61
+ }
62
+
63
+ /**
64
+ * Toggle API key active status (if supported by API)
65
+ * PATCH /api-key-enhanced/{api_key_id}/toggle
66
+ */
67
+ async toggleApiKeyStatus(apiKeyId: string): Promise<ApiKey> {
68
+ return this.post<ApiKey>(`/api-key-enhanced/${apiKeyId}/toggle`, {})
69
+ }
70
+
71
+ /**
72
+ * Get API key usage statistics (if supported by API)
73
+ * GET /api-key-enhanced/{api_key_id}/usage
74
+ */
75
+ async getApiKeyUsage(apiKeyId: string): Promise<{
76
+ usage_count: number
77
+ last_used?: string
78
+ daily_usage?: Array<{ date: string; count: number }>
79
+ }> {
80
+ return this.get(`/api-key-enhanced/${apiKeyId}/usage`)
81
+ }
82
+ }
@@ -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,39 @@ 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
+ name: string
57
+ prefix: string
58
+ created_at: string
59
+ last_used?: string
60
+ is_active: boolean
61
+ usage_count?: number
62
+ }
63
+
64
+ export interface CreateApiKeyRequest {
65
+ name: string
66
+ }
67
+
68
+ export interface CreateApiKeyResponse {
69
+ api_key: string
70
+ id: string
71
+ name: string
72
+ prefix: string
73
+ created_at: string
74
+ message: string
75
+ }
76
+
77
+ export interface ApiKeyPermission {
78
+ can_create: boolean
79
+ reason?: string
80
+ current_keys_count?: number
81
+ max_keys_allowed?: number
82
+ }
83
+
84
+ export interface RevokeApiKeyResponse {
85
+ message: string
86
+ revoked_key_id: string
87
+ }