@stats-organization/github-readme-stats-core 2.1.5 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/build/api/gist.d.ts +2 -7
  2. package/build/api/gist.d.ts.map +1 -1
  3. package/build/api/gist.js +9 -41
  4. package/build/api/index.d.ts +3 -8
  5. package/build/api/index.d.ts.map +1 -1
  6. package/build/api/index.js +23 -45
  7. package/build/api/pin.d.ts +2 -7
  8. package/build/api/pin.d.ts.map +1 -1
  9. package/build/api/pin.js +9 -41
  10. package/build/api/top-langs.d.ts +2 -7
  11. package/build/api/top-langs.d.ts.map +1 -1
  12. package/build/api/top-langs.js +11 -55
  13. package/build/api/wakatime.d.ts +2 -7
  14. package/build/api/wakatime.d.ts.map +1 -1
  15. package/build/api/wakatime.js +9 -41
  16. package/build/cards/common-options.d.ts +13 -0
  17. package/build/cards/common-options.d.ts.map +1 -0
  18. package/build/cards/common-options.js +1 -0
  19. package/build/cards/gist.d.ts +11 -16
  20. package/build/cards/gist.d.ts.map +1 -1
  21. package/build/cards/gist.js +26 -31
  22. package/build/cards/repo.d.ts +19 -16
  23. package/build/cards/repo.d.ts.map +1 -1
  24. package/build/cards/repo.js +58 -60
  25. package/build/cards/stats.d.ts +29 -46
  26. package/build/cards/stats.d.ts.map +1 -1
  27. package/build/cards/stats.js +113 -181
  28. package/build/cards/top-languages.d.ts +81 -77
  29. package/build/cards/top-languages.d.ts.map +1 -1
  30. package/build/cards/top-languages.js +174 -200
  31. package/build/cards/wakatime.d.ts +21 -11
  32. package/build/cards/wakatime.d.ts.map +1 -1
  33. package/build/cards/wakatime.js +73 -111
  34. package/build/common/Card.d.ts +34 -13
  35. package/build/common/Card.d.ts.map +1 -1
  36. package/build/common/Card.js +73 -40
  37. package/build/common/I18n.d.ts +4 -2
  38. package/build/common/I18n.d.ts.map +1 -1
  39. package/build/common/color.d.ts +60 -18
  40. package/build/common/color.d.ts.map +1 -1
  41. package/build/common/color.js +102 -5
  42. package/build/common/config.d.ts +2 -1
  43. package/build/common/config.d.ts.map +1 -1
  44. package/build/common/config.js +16 -26
  45. package/build/common/constants.d.ts +2 -1
  46. package/build/common/constants.d.ts.map +1 -1
  47. package/build/common/date.d.ts +37 -0
  48. package/build/common/date.d.ts.map +1 -0
  49. package/build/common/date.js +31 -0
  50. package/build/common/http.d.ts +25 -2
  51. package/build/common/http.d.ts.map +1 -1
  52. package/build/common/http.js +26 -3
  53. package/build/common/icons.d.ts +1 -0
  54. package/build/common/icons.d.ts.map +1 -1
  55. package/build/common/icons.js +1 -0
  56. package/build/common/languageColors.d.ts +11 -0
  57. package/build/common/languageColors.d.ts.map +1 -0
  58. package/build/common/languageColors.js +15 -0
  59. package/build/common/languageColors.json +1 -0
  60. package/build/common/ops.d.ts +3 -10
  61. package/build/common/ops.d.ts.map +1 -1
  62. package/build/common/ops.js +3 -15
  63. package/build/common/render.d.ts +43 -6
  64. package/build/common/render.d.ts.map +1 -1
  65. package/build/common/render.js +77 -11
  66. package/build/common/retryer.d.ts +3 -2
  67. package/build/common/retryer.d.ts.map +1 -1
  68. package/build/common/retryer.js +1 -0
  69. package/build/fetchers/gist.d.ts.map +1 -1
  70. package/build/fetchers/gist.js +8 -39
  71. package/build/fetchers/repo.d.ts +12 -11
  72. package/build/fetchers/repo.d.ts.map +1 -1
  73. package/build/fetchers/repo.js +26 -67
  74. package/build/fetchers/stats.d.ts +24 -17
  75. package/build/fetchers/stats.d.ts.map +1 -1
  76. package/build/fetchers/stats.js +302 -183
  77. package/build/fetchers/top-languages.d.ts +10 -15
  78. package/build/fetchers/top-languages.d.ts.map +1 -1
  79. package/build/fetchers/top-languages.js +52 -103
  80. package/build/fetchers/types.d.ts +24 -20
  81. package/build/fetchers/types.d.ts.map +1 -1
  82. package/build/fetchers/wakatime.d.ts +9 -5
  83. package/build/fetchers/wakatime.d.ts.map +1 -1
  84. package/build/fetchers/wakatime.js +8 -4
  85. package/build/graphql/contributionsDocument.d.ts +18 -0
  86. package/build/graphql/contributionsDocument.d.ts.map +1 -0
  87. package/build/graphql/contributionsDocument.js +30 -0
  88. package/build/graphql/generated/common.d.ts +42 -0
  89. package/build/graphql/generated/common.d.ts.map +1 -0
  90. package/build/graphql/generated/common.js +2 -0
  91. package/build/graphql/generated/gist.d.ts +44 -0
  92. package/build/graphql/generated/gist.d.ts.map +1 -0
  93. package/build/graphql/generated/gist.js +27 -0
  94. package/build/graphql/generated/repo.d.ts +67 -0
  95. package/build/graphql/generated/repo.d.ts.map +1 -0
  96. package/build/graphql/generated/repo.js +30 -0
  97. package/build/graphql/generated/stats.d.ts +150 -0
  98. package/build/graphql/generated/stats.d.ts.map +1 -0
  99. package/build/graphql/generated/stats.js +95 -0
  100. package/build/graphql/generated/top-languages.d.ts +54 -0
  101. package/build/graphql/generated/top-languages.d.ts.map +1 -0
  102. package/build/graphql/generated/top-languages.js +27 -0
  103. package/build/graphql/graphqlDocument.d.ts +22 -0
  104. package/build/graphql/graphqlDocument.d.ts.map +1 -0
  105. package/build/graphql/graphqlDocument.js +8 -0
  106. package/build/graphql/reposContributedToDocument.d.ts +27 -0
  107. package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
  108. package/build/graphql/reposContributedToDocument.js +59 -0
  109. package/build/index.d.ts +3 -1
  110. package/build/index.d.ts.map +1 -1
  111. package/build/index.js +2 -1
  112. package/build/themes/index.d.ts +32 -0
  113. package/build/themes/index.d.ts.map +1 -1
  114. package/build/themes/index.js +28 -0
  115. package/build/translations.d.ts +17 -0
  116. package/build/translations.d.ts.map +1 -1
  117. package/build/translations.js +17 -0
  118. package/package.json +13 -7
  119. package/src/_github-username-regex.d.ts +4 -0
  120. package/src/api/gist.js +10 -46
  121. package/src/api/index.js +30 -51
  122. package/src/api/pin.js +10 -46
  123. package/src/api/top-langs.js +13 -60
  124. package/src/api/wakatime.js +10 -46
  125. package/src/cards/common-options.ts +13 -0
  126. package/src/cards/{gist.js → gist.ts} +37 -37
  127. package/src/cards/{repo.js → repo.ts} +86 -68
  128. package/src/cards/{stats.js → stats.ts} +168 -219
  129. package/src/cards/{top-languages.js → top-languages.ts} +309 -265
  130. package/src/cards/{wakatime.js → wakatime.ts} +136 -130
  131. package/src/common/Card.ts +94 -49
  132. package/src/common/I18n.ts +6 -2
  133. package/src/common/color.ts +163 -14
  134. package/src/common/config.ts +22 -29
  135. package/src/common/constants.ts +3 -1
  136. package/src/common/date.ts +45 -0
  137. package/src/common/http.ts +43 -3
  138. package/src/common/icons.ts +1 -0
  139. package/src/common/languageColors.json +1 -0
  140. package/src/common/languageColors.ts +19 -0
  141. package/src/common/ops.ts +8 -18
  142. package/src/common/render.ts +114 -14
  143. package/src/common/retryer.ts +6 -5
  144. package/src/fetchers/gist.ts +15 -72
  145. package/src/fetchers/repo.ts +114 -0
  146. package/src/fetchers/stats.ts +743 -0
  147. package/src/fetchers/top-languages.ts +135 -0
  148. package/src/fetchers/types.ts +28 -20
  149. package/src/fetchers/{wakatime.js → wakatime.ts} +19 -5
  150. package/src/graphql/contributionsDocument.ts +44 -0
  151. package/src/graphql/generated/common.ts +26 -0
  152. package/src/graphql/generated/gist.ts +59 -0
  153. package/src/graphql/generated/repo.ts +90 -0
  154. package/src/graphql/generated/stats.ts +194 -0
  155. package/src/graphql/generated/top-languages.ts +75 -0
  156. package/src/graphql/graphqlDocument.ts +25 -0
  157. package/src/graphql/queries/gist.graphql +25 -0
  158. package/src/graphql/queries/repo.graphql +28 -0
  159. package/src/graphql/queries/stats.graphql +120 -0
  160. package/src/graphql/queries/top-languages.graphql +34 -0
  161. package/src/graphql/reposContributedToDocument.ts +86 -0
  162. package/src/index.ts +3 -1
  163. package/src/themes/index.ts +33 -0
  164. package/src/translations.ts +17 -0
  165. package/src/cards/types.d.ts +0 -78
  166. package/src/fetchers/repo.js +0 -161
  167. package/src/fetchers/stats.js +0 -473
  168. package/src/fetchers/top-languages.js +0 -175
  169. package/src/themes/README.md +0 -229
@@ -0,0 +1,135 @@
1
+ import { getConfig } from "../common/config.js";
2
+ import { CustomError, MissingParamError } from "../common/error.js";
3
+ import { wrapTextMultiline } from "../common/fmt.js";
4
+ import { createGraphQLFetcher } from "../common/http.js";
5
+ import { logger } from "../common/log.js";
6
+ import { parseOwnerAffiliations } from "../common/ops.js";
7
+ import { retryer } from "../common/retryer.js";
8
+ import { TopLanguagesDocument } from "../graphql/generated/top-languages.js";
9
+ import type {
10
+ TopLanguageFragment,
11
+ TopLanguagesRepositoryFragment,
12
+ } from "../graphql/generated/top-languages.js";
13
+
14
+ import type { Lang, TopLangData } from "./types.js";
15
+
16
+ const fetcher = createGraphQLFetcher(TopLanguagesDocument, "token");
17
+
18
+ /**
19
+ * Fetch top languages for a given username.
20
+ *
21
+ * @param username GitHub username.
22
+ * @param exclude_repo List of repositories to exclude. Default: [].
23
+ * @param size_weight Weightage to be given to size.
24
+ * @param count_weight Weightage to be given to count.
25
+ * @param ownerAffiliations The owner affiliations to filter by. Default: OWNER.
26
+ * @param pat Optional PAT override.
27
+ * @returns Top languages data.
28
+ */
29
+ const fetchTopLanguages = async (
30
+ username: string,
31
+ exclude_repo: Array<string> = [],
32
+ size_weight = 1,
33
+ count_weight = 0,
34
+ ownerAffiliations: Array<string> = [],
35
+ pat: string | null = null,
36
+ ): Promise<TopLangData> => {
37
+ if (!username) {
38
+ throw new MissingParamError(["username"]);
39
+ }
40
+ const affiliations = parseOwnerAffiliations(ownerAffiliations);
41
+
42
+ const res = await retryer(
43
+ fetcher,
44
+ {
45
+ login: username,
46
+ ownerAffiliations: affiliations,
47
+ },
48
+ pat,
49
+ );
50
+
51
+ if (res.data.errors) {
52
+ logger.error(res.data.errors);
53
+ const firstError = res.data.errors[0];
54
+ if (firstError?.type === "NOT_FOUND") {
55
+ throw new CustomError(
56
+ firstError.message || "Could not fetch user.",
57
+ CustomError.USER_NOT_FOUND,
58
+ );
59
+ }
60
+ if (firstError?.message) {
61
+ throw new CustomError(
62
+ wrapTextMultiline(firstError.message, 525, 12)[0] ?? "",
63
+ res.statusText,
64
+ );
65
+ }
66
+ throw new CustomError(
67
+ "Something went wrong while trying to retrieve the language data using the GraphQL API.",
68
+ CustomError.GRAPHQL_ERROR,
69
+ );
70
+ }
71
+
72
+ const repoToHide: Record<string, boolean> = {};
73
+ const allExcludedRepos = [
74
+ ...exclude_repo,
75
+ ...getConfig().excludeRepositories,
76
+ ];
77
+
78
+ // populate repoToHide map for quick lookup while filtering out
79
+ allExcludedRepos.forEach((repoName) => {
80
+ repoToHide[repoName] = true;
81
+ });
82
+
83
+ // filter out repositories to be hidden
84
+ const repoNodes = (res.data.data.user?.repositories.nodes ?? []).filter(
85
+ (node): node is TopLanguagesRepositoryFragment =>
86
+ !!node && !repoToHide[node.name],
87
+ );
88
+
89
+ // flatten edges across repos. Order matters: `concat(acc)` prepends, and the
90
+ // shared repoCount below depends on visitation order.
91
+ const languageEdges = repoNodes.reduce<Array<TopLanguageFragment>>(
92
+ (acc, repo) => {
93
+ const edges = (repo.languages?.edges ?? []).filter(
94
+ (edge): edge is TopLanguageFragment => !!edge,
95
+ );
96
+ return edges.length > 0 ? edges.concat(acc) : acc;
97
+ },
98
+ [],
99
+ );
100
+
101
+ // accumulate size and repo count per language
102
+ const languageMap: Record<string, Lang> = {};
103
+ let repoCount: number;
104
+ for (const edge of languageEdges) {
105
+ const existing = languageMap[edge.node.name];
106
+
107
+ // same language seen again: add to its size and bump count; else reset to 1
108
+ let langSize = edge.size;
109
+ if (existing && edge.node.name === existing.name) {
110
+ langSize = edge.size + existing.size;
111
+ repoCount = existing.count + 1;
112
+ } else {
113
+ repoCount = 1;
114
+ }
115
+ languageMap[edge.node.name] = {
116
+ name: edge.node.name,
117
+ color: edge.node.color,
118
+ size: langSize,
119
+ count: repoCount,
120
+ };
121
+ }
122
+
123
+ // comparison index calculation
124
+ for (const lang of Object.values(languageMap)) {
125
+ lang.size =
126
+ Math.pow(lang.size, size_weight) * Math.pow(lang.count, count_weight);
127
+ }
128
+
129
+ // return languages sorted by (weighted) size, descending
130
+ return Object.fromEntries(
131
+ Object.entries(languageMap).sort(([, a], [, b]) => b.size - a.size),
132
+ );
133
+ };
134
+
135
+ export { fetchTopLanguages };
@@ -1,3 +1,5 @@
1
+ import type { RepoInfoFragment } from "../graphql/generated/repo.js";
2
+
1
3
  export interface GistData {
2
4
  name: string;
3
5
  nameWithOwner: string;
@@ -7,28 +9,29 @@ export interface GistData {
7
9
  forksCount: number;
8
10
  }
9
11
 
10
- export interface RepositoryData {
11
- name: string;
12
- nameWithOwner: string;
13
- isPrivate: boolean;
14
- isArchived: boolean;
15
- isTemplate: boolean;
16
- stargazerCount: number;
17
- description: string;
12
+ /**
13
+ * What the repo query returns, with `primaryLanguage` loosened:
14
+ * the schema says `name` is non-null, but the card falls back to defaults for callers passing untyped data.
15
+ */
16
+ type RepoInfo = Omit<RepoInfoFragment, "primaryLanguage"> & {
18
17
  primaryLanguage: {
19
- color: string;
20
- id: string;
21
- name: string;
22
- };
23
- forkCount: number;
24
- starCount: number;
25
- totalPRsAuthored: number;
26
- totalPRsCommented: number;
27
- totalPRsReviewed: number;
28
- totalIssuesAuthored: number;
29
- totalIssuesCommented: number;
18
+ color: string | null;
19
+ id?: string;
20
+ name: string | null;
21
+ } | null;
22
+ };
23
+
24
+ export interface RepoUserStats {
25
+ // only present when the matching include_* flag is set (see fetchRepoUserStats)
26
+ totalPRsAuthored?: number;
27
+ totalPRsCommented?: number;
28
+ totalPRsReviewed?: number;
29
+ totalIssuesAuthored?: number;
30
+ totalIssuesCommented?: number;
30
31
  }
31
32
 
33
+ export type RepositoryData = RepoInfo & RepoUserStats;
34
+
32
35
  export interface StatsData {
33
36
  name: string;
34
37
  totalPRs: number;
@@ -41,18 +44,23 @@ export interface StatsData {
41
44
  totalDiscussionsStarted: number;
42
45
  totalDiscussionsAnswered: number;
43
46
  contributedTo: number;
47
+ allTimeContributedTo: number;
44
48
  totalPRsAuthored: number;
45
49
  totalPRsCommented: number;
46
50
  totalPRsReviewed: number;
47
51
  totalIssuesAuthored: number;
48
52
  totalIssuesCommented: number;
53
+ totalContributions: number;
49
54
  rank: { level: string; percentile: number };
50
55
  }
51
56
 
52
57
  export interface Lang {
53
58
  name: string;
54
- color: string;
59
+ // GitHub's GraphQL `Language.color` is nullable — the card falls back to a default.
60
+ color: string | null;
55
61
  size: number;
62
+ /** Number of repositories the language appears in. */
63
+ count: number;
56
64
  }
57
65
 
58
66
  export type TopLangData = Record<string, Lang>;
@@ -2,19 +2,29 @@ import axios from "axios";
2
2
 
3
3
  import { CustomError, MissingParamError } from "../common/error.js";
4
4
 
5
+ import type { WakaTimeData } from "./types.js";
6
+
5
7
  /**
6
8
  * WakaTime data fetcher.
7
9
  *
8
- * @param {{username: string, api_domain: string }} props Fetcher props.
9
- * @returns {Promise<import("./types").WakaTimeData>} WakaTime data response.
10
+ * @param props Fetcher props.
11
+ * @param props.username WakaTime username.
12
+ * @param props.api_domain Optional WakaTime API domain (defaults to `wakatime.com`).
13
+ * @returns WakaTime data response.
10
14
  */
11
- const fetchWakatimeStats = async ({ username, api_domain }) => {
15
+ const fetchWakatimeStats = async ({
16
+ username,
17
+ api_domain,
18
+ }: {
19
+ username: string;
20
+ api_domain?: string;
21
+ }): Promise<WakaTimeData> => {
12
22
  if (!username) {
13
23
  throw new MissingParamError(["username"]);
14
24
  }
15
25
 
16
26
  try {
17
- const { data } = await axios.get(
27
+ const { data } = await axios.get<{ data: WakaTimeData }>(
18
28
  `https://${
19
29
  api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com"
20
30
  }/api/v1/users/${username}/stats?is_including_today=true`,
@@ -22,7 +32,11 @@ const fetchWakatimeStats = async ({ username, api_domain }) => {
22
32
 
23
33
  return data.data;
24
34
  } catch (err) {
25
- if (err.response.status < 200 || err.response.status > 299) {
35
+ if (
36
+ axios.isAxiosError(err) &&
37
+ err.response &&
38
+ (err.response.status < 200 || err.response.status > 299)
39
+ ) {
26
40
  throw new CustomError(
27
41
  `Could not resolve to a User with the login of '${username}'`,
28
42
  "WAKATIME_USER_NOT_FOUND",
@@ -0,0 +1,44 @@
1
+ import { getGitHubYearRange, toGitHubDateTime } from "../common/date.js";
2
+
3
+ import type { YearContributionsFragment } from "./generated/stats.js";
4
+ import { graphqlDocument } from "./graphqlDocument.js";
5
+
6
+ interface ContributionsQueryVariables {
7
+ login: string;
8
+ }
9
+
10
+ interface ContributionsQuery {
11
+ user: Record<`year_${number}`, YearContributionsFragment> | null;
12
+ }
13
+
14
+ /**
15
+ * Build the all-time contributions query, one aliased `contributionsCollection` field per year.
16
+ * The shape is only known at runtime.
17
+ *
18
+ * @param years Contribution years, one `year_<year>` alias each.
19
+ * @returns Document for `createGraphQLFetcher`.
20
+ */
21
+ const buildContributionsDocument = (years: Array<number>) => {
22
+ const yearFields = years
23
+ .map((year) => {
24
+ const { from, to } = getGitHubYearRange(year);
25
+ return `year_${year}: contributionsCollection(from: "${toGitHubDateTime(from)}", to: "${toGitHubDateTime(to)}") { ...YearContributions }`;
26
+ })
27
+ .join("\n");
28
+
29
+ // fragment must match queries/stats.graphql, which generates its type
30
+ return graphqlDocument<ContributionsQuery, ContributionsQueryVariables>(`
31
+ query userContributions($login: String!) {
32
+ user(login: $login) {
33
+ ${yearFields}
34
+ }
35
+ }
36
+ fragment YearContributions on ContributionsCollection {
37
+ contributionCalendar {
38
+ totalContributions
39
+ }
40
+ }`);
41
+ };
42
+
43
+ export { buildContributionsDocument };
44
+ export type { ContributionsQuery };
@@ -0,0 +1,26 @@
1
+ // Generated file — see .github/CONTRIBUTING.md
2
+
3
+ export type Maybe<T> = T | null;
4
+ export type InputMaybe<T> = Maybe<T>;
5
+ /** All built-in and custom scalars, mapped to their actual values */
6
+ export type Scalars = {
7
+ ID: { input: string; output: string };
8
+ String: { input: string; output: string };
9
+ Boolean: { input: boolean; output: boolean };
10
+ Int: { input: number; output: number };
11
+ Float: { input: number; output: number };
12
+ /** An ISO-8601 encoded UTC date string. */
13
+ DateTime: { input: string; output: string };
14
+ };
15
+
16
+ /** The affiliation of a user to a repository */
17
+ export type RepositoryAffiliation =
18
+ /** Repositories that the user has been added to as a collaborator. */
19
+ | "COLLABORATOR"
20
+ /**
21
+ * Repositories that the user has access to through being a member of an
22
+ * organization. This includes every repository on every team that the user is on.
23
+ */
24
+ | "ORGANIZATION_MEMBER"
25
+ /** Repositories that are owned by the authenticated user. */
26
+ | "OWNER";
@@ -0,0 +1,59 @@
1
+ // Generated file — see .github/CONTRIBUTING.md
2
+
3
+ /** Internal type. DO NOT USE DIRECTLY. */
4
+ type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
5
+ import { graphqlDocument } from "../graphqlDocument.js";
6
+ export type GistFileInfoFragment = {
7
+ name: string | null;
8
+ size: number | null;
9
+ language: { name: string } | null;
10
+ };
11
+
12
+ export type GistInfoQueryVariables = Exact<{
13
+ gistName: string;
14
+ }>;
15
+
16
+ export type GistInfoQuery = {
17
+ viewer: {
18
+ gist: {
19
+ description: string | null;
20
+ stargazerCount: number;
21
+ owner: { login: string } | { login: string } | null;
22
+ forks: { totalCount: number };
23
+ files: Array<{
24
+ name: string | null;
25
+ size: number | null;
26
+ language: { name: string } | null;
27
+ } | null> | null;
28
+ } | null;
29
+ };
30
+ };
31
+
32
+ export const GistInfoDocument = graphqlDocument<
33
+ GistInfoQuery,
34
+ GistInfoQueryVariables
35
+ >(`
36
+ query gistInfo($gistName: String!) {
37
+ viewer {
38
+ gist(name: $gistName) {
39
+ description
40
+ owner {
41
+ login
42
+ }
43
+ stargazerCount
44
+ forks {
45
+ totalCount
46
+ }
47
+ files {
48
+ ...GistFileInfo
49
+ }
50
+ }
51
+ }
52
+ }
53
+ fragment GistFileInfo on GistFile {
54
+ name
55
+ language {
56
+ name
57
+ }
58
+ size
59
+ }`);
@@ -0,0 +1,90 @@
1
+ // Generated file — see .github/CONTRIBUTING.md
2
+
3
+ /** Internal type. DO NOT USE DIRECTLY. */
4
+ type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
5
+ import { graphqlDocument } from "../graphqlDocument.js";
6
+ export type RepoInfoFragment = {
7
+ name: string;
8
+ nameWithOwner: string;
9
+ isPrivate: boolean;
10
+ isArchived: boolean;
11
+ isTemplate: boolean;
12
+ stargazerCount: number;
13
+ description: string | null;
14
+ forkCount: number;
15
+ primaryLanguage: { color: string | null; id: string; name: string } | null;
16
+ };
17
+
18
+ export type GetRepoQueryVariables = Exact<{
19
+ login: string;
20
+ repo: string;
21
+ }>;
22
+
23
+ export type GetRepoQuery = {
24
+ user: {
25
+ repository: {
26
+ name: string;
27
+ nameWithOwner: string;
28
+ isPrivate: boolean;
29
+ isArchived: boolean;
30
+ isTemplate: boolean;
31
+ stargazerCount: number;
32
+ description: string | null;
33
+ forkCount: number;
34
+ primaryLanguage: {
35
+ color: string | null;
36
+ id: string;
37
+ name: string;
38
+ } | null;
39
+ } | null;
40
+ } | null;
41
+ organization: {
42
+ repository: {
43
+ name: string;
44
+ nameWithOwner: string;
45
+ isPrivate: boolean;
46
+ isArchived: boolean;
47
+ isTemplate: boolean;
48
+ stargazerCount: number;
49
+ description: string | null;
50
+ forkCount: number;
51
+ primaryLanguage: {
52
+ color: string | null;
53
+ id: string;
54
+ name: string;
55
+ } | null;
56
+ } | null;
57
+ } | null;
58
+ };
59
+
60
+ export const GetRepoDocument = graphqlDocument<
61
+ GetRepoQuery,
62
+ GetRepoQueryVariables
63
+ >(`
64
+ query getRepo($login: String!, $repo: String!) {
65
+ user(login: $login) {
66
+ repository(name: $repo) {
67
+ ...RepoInfo
68
+ }
69
+ }
70
+ organization(login: $login) {
71
+ repository(name: $repo) {
72
+ ...RepoInfo
73
+ }
74
+ }
75
+ }
76
+ fragment RepoInfo on Repository {
77
+ name
78
+ nameWithOwner
79
+ isPrivate
80
+ isArchived
81
+ isTemplate
82
+ stargazerCount
83
+ description
84
+ primaryLanguage {
85
+ color
86
+ id
87
+ name
88
+ }
89
+ forkCount
90
+ }`);
@@ -0,0 +1,194 @@
1
+ // Generated file — see .github/CONTRIBUTING.md
2
+
3
+ /** Internal type. DO NOT USE DIRECTLY. */
4
+ type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
5
+ import type * as Types from "./common.js";
6
+
7
+ import { graphqlDocument } from "../graphqlDocument.js";
8
+ export type RepoNodeFragment = { name: string; stargazerCount: number };
9
+
10
+ export type RepoStarsFragment = {
11
+ repositories: {
12
+ totalCount: number;
13
+ nodes: Array<{ name: string; stargazerCount: number } | null> | null;
14
+ pageInfo: { hasNextPage: boolean; endCursor: string | null };
15
+ };
16
+ };
17
+
18
+ export type UserReposQueryVariables = Exact<{
19
+ login: string;
20
+ after?: string | null | undefined;
21
+ ownerAffiliations?:
22
+ | Array<Types.RepositoryAffiliation | null | undefined>
23
+ | Types.RepositoryAffiliation
24
+ | null
25
+ | undefined;
26
+ }>;
27
+
28
+ export type UserReposQuery = {
29
+ user: {
30
+ repositories: {
31
+ totalCount: number;
32
+ nodes: Array<{ name: string; stargazerCount: number } | null> | null;
33
+ pageInfo: { hasNextPage: boolean; endCursor: string | null };
34
+ };
35
+ } | null;
36
+ };
37
+
38
+ export type UserInfoQueryVariables = Exact<{
39
+ login: string;
40
+ after?: string | null | undefined;
41
+ includeMergedPullRequests: boolean;
42
+ includeDiscussions: boolean;
43
+ includeDiscussionsAnswers: boolean;
44
+ startTime?: string | null | undefined;
45
+ ownerAffiliations?:
46
+ | Array<Types.RepositoryAffiliation | null | undefined>
47
+ | Types.RepositoryAffiliation
48
+ | null
49
+ | undefined;
50
+ includeUserRepositories: boolean;
51
+ }>;
52
+
53
+ export type UserInfoQuery = {
54
+ user: {
55
+ name: string | null;
56
+ login: string;
57
+ commits: { totalCommitContributions: number };
58
+ reviews: { totalPullRequestReviewContributions: number };
59
+ repositoriesContributedTo: { totalCount: number };
60
+ pullRequests: { totalCount: number };
61
+ mergedPullRequests?: { totalCount: number };
62
+ openIssues: { totalCount: number };
63
+ closedIssues: { totalCount: number };
64
+ followers: { totalCount: number };
65
+ repositoryDiscussions?: { totalCount: number };
66
+ repositoryDiscussionComments?: { totalCount: number };
67
+ contributionsCollection: { contributionYears: Array<number> };
68
+ repositories: {
69
+ totalCount: number;
70
+ nodes: Array<{ name: string; stargazerCount: number } | null> | null;
71
+ pageInfo: { hasNextPage: boolean; endCursor: string | null };
72
+ };
73
+ } | null;
74
+ };
75
+
76
+ export type YearContributionsFragment = {
77
+ contributionCalendar: { totalContributions: number };
78
+ };
79
+
80
+ export type RangeContributionsByRepoFragment = {
81
+ commitContributionsByRepository: Array<{
82
+ repository: { nameWithOwner: string };
83
+ }>;
84
+ issueContributionsByRepository: Array<{
85
+ repository: { nameWithOwner: string };
86
+ }>;
87
+ pullRequestContributionsByRepository: Array<{
88
+ repository: { nameWithOwner: string };
89
+ }>;
90
+ repositoryContributions?: {
91
+ nodes: Array<{ repository: { nameWithOwner: string } } | null> | null;
92
+ };
93
+ };
94
+
95
+ export const UserReposDocument = graphqlDocument<
96
+ UserReposQuery,
97
+ UserReposQueryVariables
98
+ >(`
99
+ query userRepos($login: String!, $after: String, $ownerAffiliations: [RepositoryAffiliation]) {
100
+ user(login: $login) {
101
+ ...RepoStars
102
+ }
103
+ }
104
+ fragment RepoStars on User {
105
+ repositories(
106
+ first: 100
107
+ after: $after
108
+ ownerAffiliations: $ownerAffiliations
109
+ orderBy: {direction: DESC, field: STARGAZERS}
110
+ ) {
111
+ totalCount
112
+ nodes {
113
+ ...RepoNode
114
+ }
115
+ pageInfo {
116
+ hasNextPage
117
+ endCursor
118
+ }
119
+ }
120
+ }
121
+ fragment RepoNode on Repository {
122
+ name
123
+ stargazerCount
124
+ }`);
125
+
126
+ export const UserInfoDocument = graphqlDocument<
127
+ UserInfoQuery,
128
+ UserInfoQueryVariables
129
+ >(`
130
+ query userInfo($login: String!, $after: String, $includeMergedPullRequests: Boolean!, $includeDiscussions: Boolean!, $includeDiscussionsAnswers: Boolean!, $startTime: DateTime = null, $ownerAffiliations: [RepositoryAffiliation], $includeUserRepositories: Boolean!) {
131
+ user(login: $login) {
132
+ name
133
+ login
134
+ commits: contributionsCollection(from: $startTime) {
135
+ totalCommitContributions
136
+ }
137
+ reviews: contributionsCollection {
138
+ totalPullRequestReviewContributions
139
+ }
140
+ repositoriesContributedTo(
141
+ first: 1
142
+ contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]
143
+ includeUserRepositories: $includeUserRepositories
144
+ ) {
145
+ totalCount
146
+ }
147
+ pullRequests(first: 1) {
148
+ totalCount
149
+ }
150
+ mergedPullRequests: pullRequests(states: MERGED) @include(if: $includeMergedPullRequests) {
151
+ totalCount
152
+ }
153
+ openIssues: issues(states: OPEN) {
154
+ totalCount
155
+ }
156
+ closedIssues: issues(states: CLOSED) {
157
+ totalCount
158
+ }
159
+ followers {
160
+ totalCount
161
+ }
162
+ repositoryDiscussions @include(if: $includeDiscussions) {
163
+ totalCount
164
+ }
165
+ repositoryDiscussionComments(onlyAnswers: true) @include(if: $includeDiscussionsAnswers) {
166
+ totalCount
167
+ }
168
+ contributionsCollection {
169
+ contributionYears
170
+ }
171
+ ...RepoStars
172
+ }
173
+ }
174
+ fragment RepoStars on User {
175
+ repositories(
176
+ first: 100
177
+ after: $after
178
+ ownerAffiliations: $ownerAffiliations
179
+ orderBy: {direction: DESC, field: STARGAZERS}
180
+ ) {
181
+ totalCount
182
+ nodes {
183
+ ...RepoNode
184
+ }
185
+ pageInfo {
186
+ hasNextPage
187
+ endCursor
188
+ }
189
+ }
190
+ }
191
+ fragment RepoNode on Repository {
192
+ name
193
+ stargazerCount
194
+ }`);