@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
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
ApiKey,
|
|
4
4
|
CreateApiKeyRequest,
|
|
5
5
|
CreateApiKeyResponse,
|
|
6
|
-
|
|
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<
|
|
20
|
-
return this.get<
|
|
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<
|
|
44
|
-
return this.get<
|
|
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<
|
|
52
|
-
return this.get<
|
|
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<
|
|
60
|
-
return this.put<
|
|
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<
|
|
68
|
-
return this.post<
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
60
|
+
expires_at?: string
|
|
60
61
|
is_active: boolean
|
|
61
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
107
|
+
revoked_key_id?: string
|
|
87
108
|
}
|