forked from microsoft/vscode-copilot-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeimaQuotaService.ts
More file actions
65 lines (56 loc) · 1.99 KB
/
feimaQuotaService.ts
File metadata and controls
65 lines (56 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*---------------------------------------------------------------------------------------------
* Licensed under the MIT License. See License.txt in the project root for license information.
6B54
div>
*--------------------------------------------------------------------------------------------*/
import { Event } from '../../../util/vs/base/common/event';
import { createDecorator } from '../../../util/vs/platform/instantiation/common/instantiation';
/**
* Quota information from feima-api
* T094: Define IFeimaQuota data model
*/
export interface IFeimaQuota {
/** Maximum requests allowed in current period */
readonly limit: number;
/** Remaining requests available */
readonly remaining: number;
/** Total requests used in current period */
readonly used: number;
/** Date when quota resets (ISO 8601 string) */
readonly resetDate: string;
/** Whether user has unlimited quota (pro tier) */
readonly unlimited: boolean;
/** Percentage of quota used (0-100) */
readonly usagePercent: number;
/** Timestamp when quota was last updated */
readonly lastUpdated: number;
}
/**
* Service for tracking API quota usage
* T093: Create IFeimaQuotaService interface
*/
export interface IFeimaQuotaService {
readonly _serviceBrand: undefined;
/**
* Get current quota information
*/
getQuota(): IFeimaQuota | undefined;
/**
* Update quota from API response headers
* T096-T098: Parse X-Quota-* headers
*/
updateQuotaFromHeaders(headers: Record<string, string | string[] | undefined>): void;
/**
* Event fired when quota changes
* T100: Emit onDidChangeQuota event
*/
readonly onDidChangeQuota: Event<IFeimaQuota | undefined>;
/**
* Get quota from workspace state (persisted across restarts)
* T101: Store last known quota in workspace state
*/
restoreQuotaFromState(): Promise<IFeimaQuota | undefined>;
/**
* Save quota to workspace state
*/
saveQuotaToState(quota: IFeimaQuota): Promise<void>;
}
export const IFeimaQuotaService = createDecorator<IFeimaQuotaService>('feimaQuotaService');