refactor(ai): deduplicated usage provider coercion helpers
- Deleted usage/shared.ts's duplicate toNumber; every consumer in the directory now resolves the single catalog implementation. - Promoted HOUR_MS, DAY_MS, WEEK_MS, parseIsoTimestamp, parsePositiveTimestamp and usageStatus into usage/shared.ts and dropped the local copies. - Left the epoch coercers, status thresholds and base-url normalizers alone: they disagree on the 1e12 boundary, non-positive values and warn levels, so merging them would change reported usage.
This commit is contained in:
@@ -18,6 +18,7 @@ import type {
|
||||
UsageWindow,
|
||||
} from "../usage";
|
||||
import { isRecord } from "../utils";
|
||||
import { parseIsoTimestamp } from "./shared";
|
||||
|
||||
type CopilotQuotaDetail = {
|
||||
entitlement: number;
|
||||
@@ -74,8 +75,8 @@ function resolveGitHubApiBaseUrl(params: UsageFetchParams): string {
|
||||
|
||||
function buildWindow(resetDate: string | undefined): UsageWindow | undefined {
|
||||
if (!resetDate) return undefined;
|
||||
const resetAt = Date.parse(resetDate);
|
||||
if (!Number.isFinite(resetAt)) return undefined;
|
||||
const resetAt = parseIsoTimestamp(resetDate);
|
||||
if (resetAt === undefined) return undefined;
|
||||
return {
|
||||
id: "monthly",
|
||||
label: "Monthly",
|
||||
|
||||
Reference in New Issue
Block a user