PR #3 deduplicated VALID_RANGES in src/api/analytics.ts and src/api/bundles.ts to derive from the canonical TIMELINE_RANGES in src/api/schemas.ts. Two more copies remain on main:
src/api/schemas.ts:206 — TimelineDataSchema defines range: z.enum(["24h", "7d", "30d", "90d", "1y", "all"]) inline. Same data, different file. The OpenAPI shape would diverge from TIMELINE_RANGES if either is edited in isolation.
src/services/admin-management.ts:11 — const VALID_RANGES: TimelineRange[] = ["24h", "7d", "30d", "90d", "1y", "all"] hand-written, used by isValidRange() and the default_range setting validator.
Both should derive from TIMELINE_RANGES so adding/removing a range is a one-place change.
Out-of-scope notes (for context, not changes wanted here):
- Test files (
__tests__/page/settings-page.test.ts:34, __tests__/service/admin-service.test.ts:119, __tests__/unit/mcp-range-wrapper.test.ts:55, __tests__/unit/api-schemas.test.ts:50) also hard-code the array. Boundary tests are arguably better with literal values; leaving them out.
PR #3 deduplicated
VALID_RANGESinsrc/api/analytics.tsandsrc/api/bundles.tsto derive from the canonicalTIMELINE_RANGESinsrc/api/schemas.ts. Two more copies remain onmain:src/api/schemas.ts:206—TimelineDataSchemadefinesrange: z.enum(["24h", "7d", "30d", "90d", "1y", "all"])inline. Same data, different file. The OpenAPI shape would diverge fromTIMELINE_RANGESif either is edited in isolation.src/services/admin-management.ts:11—const VALID_RANGES: TimelineRange[] = ["24h", "7d", "30d", "90d", "1y", "all"]hand-written, used byisValidRange()and thedefault_rangesetting validator.Both should derive from
TIMELINE_RANGESso adding/removing a range is a one-place change.Out-of-scope notes (for context, not changes wanted here):
__tests__/page/settings-page.test.ts:34,__tests__/service/admin-service.test.ts:119,__tests__/unit/mcp-range-wrapper.test.ts:55,__tests__/unit/api-schemas.test.ts:50) also hard-code the array. Boundary tests are arguably better with literal values; leaving them out.