Skip to content

Commit 7ee2274

Browse files
docs(types): add JSDoc comments to all interfaces in types/index.ts (JhaSourav07#815)
## Description Fixes JhaSourav07#518 Adds JSDoc `/** */` comments to every field in all interfaces in `types/index.ts` — `StreakStats`, `BadgeTheme`, `ContributionDay`, `ContributionWeek`, `ContributionCalendar`, `MonthlyStats`, and `BadgeParams` — so IDE autocomplete and new contributors immediately understand each field's purpose without consulting the README. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A — documentation-only change, no SVG output affected. ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [ ] (Recommended) I joined the CommitPulse Discord server for faster collaboration, mentorship, and PR support.
1 parent 5be45a2 commit 7ee2274

1 file changed

Lines changed: 89 additions & 2 deletions

File tree

types/index.ts

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,145 @@
11
export type HexColor = string & { __brand: 'HexColor' };
22

3+
/**
4+
* Processed streak statistics calculated from the user's GitHub contribution data.
5+
*/
36
export interface StreakStats {
7+
/** The user's current active streak in days. Resets to 0 if no contributions today or yesterday. */
48
currentStreak: number;
9+
10+
/** The user's all-time longest streak in days. */
511
longestStreak: number;
12+
13+
/** Total number of contributions in the queried period. */
614
totalContributions: number;
7-
todayDate: string; // local calendar date used as "today" (YYYY-MM-DD)
15+
16+
/** Local calendar date used as "today" for streak calculation (format: YYYY-MM-DD). */
17+
todayDate: string;
818
}
919

20+
/**
21+
* Resolved color palette for a badge theme after URL parameter overrides have been applied.
22+
*/
1023
export interface BadgeTheme {
24+
/** Background fill color as a hex string WITHOUT the leading '#' (e.g. '0d1117'). */
1125
bg: HexColor;
26+
27+
/** Label and stat text color as a hex string WITHOUT the leading '#' (e.g. 'ffffff'). */
1228
text: HexColor;
29+
30+
/** Tower and glow accent color as a hex string WITHOUT the leading '#' (e.g. '58a6ff'). */
1331
accent: HexColor;
1432
}
1533

34+
/**
35+
* Represents a single day's contribution data returned from the GitHub GraphQL API.
36+
*/
1637
export interface ContributionDay {
38+
/** Number of contributions made on this day. */
1739
contributionCount: number;
40+
41+
/** Calendar date of this contribution entry (format: YYYY-MM-DD). */
1842
date: string;
1943
}
2044

45+
/**
46+
* Represents a single week's worth of contribution days.
47+
*/
2148
export interface ContributionWeek {
49+
/** Array of contribution day entries for this week, ordered Sunday to Saturday. */
2250
contributionDays: ContributionDay[];
2351
}
2452

53+
/**
54+
* Full contribution calendar returned from the GitHub GraphQL API.
55+
*/
2556
export interface ContributionCalendar {
57+
/** Total number of contributions across all weeks in this calendar. */
2658
totalContributions: number;
59+
60+
/** Array of weekly contribution data covering the queried date range. */
2761
weeks: ContributionWeek[];
2862
}
2963

64+
/**
65+
* Month-over-month contribution statistics used by the monthly view.
66+
*/
3067
export interface MonthlyStats {
68+
/** Total number of contributions in the current calendar month. */
3169
currentMonthTotal: number;
70+
71+
/** Total number of contributions in the previous calendar month. */
3272
previousMonthTotal: number;
73+
74+
/** Percentage change in contributions compared to the previous month (can be negative). */
3375
deltaPercentage: number;
76+
77+
/** Absolute change in contribution count compared to the previous month (can be negative). */
3478
deltaAbsolute: number;
79+
80+
/** Human-readable name of the current month (e.g. 'January', 'February'). */
3581
currentMonthName: string;
3682
}
3783

84+
/**
85+
* Parameters accepted by the /api/streak endpoint.
86+
* All fields except `user` are optional; URL parameters override theme defaults.
87+
*/
3888
export interface BadgeParams {
89+
/** GitHub username whose contribution data will be fetched and rendered. Required. */
3990
user: string;
91+
92+
/** Number of grace days before a streak resets (handles timezone edge cases). Defaults to 1. */
93+
grace?: number;
94+
95+
/** Background fill color as a hex string WITHOUT the leading '#'. Overrides theme default. */
4096
bg: HexColor;
97+
98+
/** Label and stat text color as a hex string WITHOUT the leading '#'. Overrides theme default. */
4199
text: HexColor;
100+
101+
/** Tower and glow accent color as a hex string WITHOUT the leading '#'. Overrides theme default. */
42102
accent: HexColor;
103+
104+
/** Duration of the radar scan line animation (e.g. '4s', '8s', '12s'). Defaults to '8s'. */
43105
speed: string;
106+
107+
/** Tower height scaling algorithm. 'linear' scales proportionally; 'log' uses logarithmic scale for high contributors. Defaults to 'linear'. */
44108
scale: 'linear' | 'log';
109+
110+
/** Font family override for badge typography (e.g. 'monospace'). Defaults to theme font. */
45111
font?: string;
112+
113+
/** Border corner radius in pixels. Defaults to 8. */
46114
radius?: number;
115+
116+
/** When true, automatically selects a theme based on the viewer's system color scheme. */
47117
autoTheme?: boolean;
118+
119+
/** When true, hides the username title from the badge. */
48120
hide_title?: boolean;
121+
122+
/** When true, renders the badge without a background card. */
49123
hideBackground?: boolean;
124+
125+
/** When true, hides the streak and contribution stat numbers from the badge. */
50126
hide_stats?: boolean;
127+
128+
/** Language/locale code for stat labels (e.g. 'en', 'fr', 'ja'). Defaults to 'en'. */
51129
lang?: string;
130+
131+
/** Badge layout variant. 'default' shows the isometric monolith; 'monthly' shows month-over-month stats. */
52132
view?: 'default' | 'monthly';
133+
134+
/** Format for the monthly delta indicator. 'percent' shows %, 'absolute' shows raw count, 'both' shows both. */
53135
delta_format?: 'percent' | 'absolute' | 'both';
136+
137+
/** Custom width of the badge in pixels. Defaults to theme preset. */
54138
width?: number;
139+
140+
/** Custom height of the badge in pixels. Defaults to theme preset. */
55141
height?: number;
142+
143+
/** Preset size of the badge. 'small', 'medium', or 'large'. Overrides width and height. */
56144
size?: 'small' | 'medium' | 'large';
57-
grace?: number;
58145
}

0 commit comments

Comments
 (0)