feat(api): limits read unifiedWindows, unknown seven-day windows labelled by model
This commit is contained in:
@@ -215,6 +215,8 @@ export interface LimitWindow extends LimitRecord {
|
||||
gateway: UsageTotals & { since: string };
|
||||
// The last figure reported inside this window, if any: a lower bound.
|
||||
last_known: LimitRecord | null;
|
||||
// When the figure came from another event's unified report.
|
||||
reported_at?: string | null;
|
||||
}
|
||||
|
||||
export interface LimitsResponse {
|
||||
|
||||
+11
-1
@@ -6,8 +6,18 @@ export const LIMIT_LABELS: Record<string, string> = {
|
||||
seven_day_sonnet: "7-day · Sonnet",
|
||||
};
|
||||
|
||||
const SEVEN_DAY = "seven_day_";
|
||||
|
||||
export function limitLabel(window: string): string {
|
||||
return LIMIT_LABELS[window] ?? window;
|
||||
const known = LIMIT_LABELS[window];
|
||||
if (known) {
|
||||
return known;
|
||||
}
|
||||
if (window.startsWith(SEVEN_DAY)) {
|
||||
const model = window.slice(SEVEN_DAY.length);
|
||||
return `7-day · ${model.charAt(0).toUpperCase()}${model.slice(1)}`;
|
||||
}
|
||||
return window.replaceAll("_", " ");
|
||||
}
|
||||
|
||||
// The status as a word, for the windows the API never puts a figure on.
|
||||
|
||||
Reference in New Issue
Block a user