@codeguide/core 0.0.5 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeguide/core",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Core package for code guidance with programmatic API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,8 +3,10 @@ import {
3
3
  ApiKey,
4
4
  CreateApiKeyRequest,
5
5
  CreateApiKeyResponse,
6
- ApiKeyPermission,
6
+ ApiKeyPermissionResponse,
7
7
  RevokeApiKeyResponse,
8
+ ApiKeyListResponse,
9
+ ApiKeyResponse,
8
10
  } from '../../types'
9
11
 
10
12
  export class ApiKeyEnhancedService extends BaseService {
@@ -16,8 +18,8 @@ export class ApiKeyEnhancedService extends BaseService {
16
18
  * Get all API keys for the authenticated user
17
19
  * GET /api-key-enhanced/
18
20
  */
19
- async getAllApiKeys(): Promise<ApiKey[]> {
20
- return this.get<ApiKey[]>('/api-key-enhanced/')
21
+ async getAllApiKeys(): Promise<ApiKeyListResponse> {
22
+ return this.get<ApiKeyListResponse>('/api-key-enhanced/')
21
23
  }
22
24
 
23
25
  /**
@@ -40,32 +42,32 @@ export class ApiKeyEnhancedService extends BaseService {
40
42
  * Check if user can create API keys
41
43
  * GET /api-key-enhanced/check-permission
42
44
  */
43
- async checkApiKeyPermission(): Promise<ApiKeyPermission> {
44
- return this.get<ApiKeyPermission>('/api-key-enhanced/check-permission')
45
+ async checkApiKeyPermission(): Promise<ApiKeyPermissionResponse> {
46
+ return this.get<ApiKeyPermissionResponse>('/api-key-enhanced/check-permission')
45
47
  }
46
48
 
47
49
  /**
48
50
  * Get API key details by ID
49
51
  * GET /api-key-enhanced/{api_key_id}
50
52
  */
51
- async getApiKeyById(apiKeyId: string): Promise<ApiKey> {
52
- return this.get<ApiKey>(`/api-key-enhanced/${apiKeyId}`)
53
+ async getApiKeyById(apiKeyId: string): Promise<ApiKeyResponse> {
54
+ return this.get<ApiKeyResponse>(`/api-key-enhanced/${apiKeyId}`)
53
55
  }
54
56
 
55
57
  /**
56
58
  * Update API key name (if supported by API)
57
59
  * PUT /api-key-enhanced/{api_key_id}
58
60
  */
59
- async updateApiKeyName(apiKeyId: string, name: string): Promise<ApiKey> {
60
- return this.put<ApiKey>(`/api-key-enhanced/${apiKeyId}`, { name })
61
+ async updateApiKeyName(apiKeyId: string, name: string): Promise<ApiKeyResponse> {
62
+ return this.put<ApiKeyResponse>(`/api-key-enhanced/${apiKeyId}`, { name })
61
63
  }
62
64
 
63
65
  /**
64
66
  * Toggle API key active status (if supported by API)
65
67
  * PATCH /api-key-enhanced/{api_key_id}/toggle
66
68
  */
67
- async toggleApiKeyStatus(apiKeyId: string): Promise<ApiKey> {
68
- return this.post<ApiKey>(`/api-key-enhanced/${apiKeyId}/toggle`, {})
69
+ async toggleApiKeyStatus(apiKeyId: string): Promise<ApiKeyResponse> {
70
+ return this.post<ApiKeyResponse>(`/api-key-enhanced/${apiKeyId}/toggle`, {})
69
71
  }
70
72
 
71
73
  /**
@@ -73,9 +75,12 @@ export class ApiKeyEnhancedService extends BaseService {
73
75
  * GET /api-key-enhanced/{api_key_id}/usage
74
76
  */
75
77
  async getApiKeyUsage(apiKeyId: string): Promise<{
76
- usage_count: number
77
- last_used?: string
78
- daily_usage?: Array<{ date: string; count: number }>
78
+ status: string
79
+ data: {
80
+ usage_count: number
81
+ last_used?: string
82
+ daily_usage?: Array<{ date: string; count: number }>
83
+ }
79
84
  }> {
80
85
  return this.get(`/api-key-enhanced/${apiKeyId}/usage`)
81
86
  }
package/types.ts CHANGED
@@ -53,12 +53,19 @@ export interface CodeGuideOptions {
53
53
  // API Key Enhanced Types
54
54
  export interface ApiKey {
55
55
  id: string
56
+ key: string
57
+ user_id: string
56
58
  name: string
57
- prefix: string
58
59
  created_at: string
59
- last_used?: string
60
+ expires_at?: string
60
61
  is_active: boolean
61
- usage_count?: number
62
+ metadata?: Record<string, any>
63
+ }
64
+
65
+ // API Response wrapper
66
+ export interface ApiKeyListResponse {
67
+ status: string
68
+ data: ApiKey[]
62
69
  }
63
70
 
64
71
  export interface CreateApiKeyRequest {
@@ -66,22 +73,36 @@ export interface CreateApiKeyRequest {
66
73
  }
67
74
 
68
75
  export interface CreateApiKeyResponse {
69
- api_key: string
70
- id: string
71
- name: string
72
- prefix: string
73
- created_at: string
74
- message: string
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
+ }
75
97
  }
76
98
 
77
- export interface ApiKeyPermission {
78
- can_create: boolean
79
- reason?: string
80
- current_keys_count?: number
81
- max_keys_allowed?: number
99
+ export interface ApiKeyResponse {
100
+ status: string
101
+ data: ApiKey
82
102
  }
83
103
 
84
104
  export interface RevokeApiKeyResponse {
105
+ status: string
85
106
  message: string
86
- revoked_key_id: string
107
+ revoked_key_id?: string
87
108
  }