@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
@@ -1,67 +1,29 @@
1
1
  import { MissingParamError } from "../common/error.js";
2
- import { request } from "../common/http.js";
2
+ import { createGraphQLFetcher } from "../common/http.js";
3
3
  import { retryer } from "../common/retryer.js";
4
+ import { GetRepoDocument } from "../graphql/generated/repo.js";
4
5
  import { fetchRepoUserStats } from "./stats.js";
5
- /**
6
- * Repo data fetcher.
7
- *
8
- * @param {object} variables Fetcher variables.
9
- * @param {string} token GitHub token.
10
- * @returns {Promise<import('axios').AxiosResponse>} The response.
11
- */
12
- const fetcher = (variables, token) => {
13
- return request({
14
- query: `
15
- fragment RepoInfo on Repository {
16
- name
17
- nameWithOwner
18
- isPrivate
19
- isArchived
20
- isTemplate
21
- stargazerCount
22
- description
23
- primaryLanguage {
24
- color
25
- id
26
- name
27
- }
28
- forkCount
29
- }
30
- query getRepo($login: String!, $repo: String!) {
31
- user(login: $login) {
32
- repository(name: $repo) {
33
- ...RepoInfo
34
- }
35
- }
36
- organization(login: $login) {
37
- repository(name: $repo) {
38
- ...RepoInfo
39
- }
40
- }
41
- }
42
- `,
43
- variables,
44
- }, {
45
- Authorization: `token ${token}`,
46
- });
47
- };
6
+ const fetcher = createGraphQLFetcher(GetRepoDocument, "token");
48
7
  const urlExample = "/api/pin?username=USERNAME&repo=REPO_NAME";
49
- /**
50
- * @typedef {import("./types").RepositoryData} RepositoryData Repository data.
51
- */
52
8
  /**
53
9
  * Fetch repository data.
54
10
  *
55
- * @param {string} username GitHub username.
56
- * @param {string} reponame GitHub repository name.
57
- * @returns {Promise<RepositoryData>} Repository data.
11
+ * @param username GitHub username.
12
+ * @param reponame GitHub repository name.
13
+ * @param include_prs_authored Include count of PRs authored.
14
+ * @param include_prs_commented Include count of PRs commented.
15
+ * @param include_prs_reviewed Include count of PRs reviewed.
16
+ * @param include_issues_authored Include count of issues authored.
17
+ * @param include_issues_commented Include count of issues commented.
18
+ * @param pat Optional PAT override.
19
+ * @returns Repository data.
58
20
  */
59
21
  const fetchRepo = async (username, reponame, include_prs_authored = false, include_prs_commented = false, include_prs_reviewed = false, include_issues_authored = false, include_issues_commented = false, pat = null) => {
60
22
  let owner = username;
61
23
  if (reponame && reponame.includes("/")) {
62
- const [parsed_owner, parsed_repo] = reponame.split("/");
63
- owner = parsed_owner;
64
- reponame = parsed_repo;
24
+ const [parsedOwner, parsedRepo] = reponame.split("/");
25
+ owner = parsedOwner ?? "";
26
+ reponame = parsedRepo ?? "";
65
27
  }
66
28
  if (owner && !username) {
67
29
  username = owner;
@@ -78,34 +40,31 @@ const fetchRepo = async (username, reponame, include_prs_authored = false, inclu
78
40
  if (!reponame) {
79
41
  throw new MissingParamError(["repo"], urlExample);
80
42
  }
81
- let res = await retryer(fetcher, { login: owner, repo: reponame }, pat);
43
+ const res = await retryer(fetcher, { login: owner, repo: reponame }, pat);
82
44
  const data = res.data.data;
83
45
  if (!data.user && !data.organization) {
84
46
  throw new Error("Not found");
85
47
  }
86
- const isUser = data.organization === null && data.user;
87
- const isOrg = data.user === null && data.organization;
88
- if (isUser) {
89
- if (!data.user.repository || data.user.repository.isPrivate) {
48
+ if (data.organization === null && data.user) {
49
+ const repository = data.user.repository;
50
+ if (!repository || repository.isPrivate) {
90
51
  throw new Error("User Repository Not found");
91
52
  }
92
- let repoUserStats = await fetchRepoUserStats(username, [owner + "/" + reponame], [], include_prs_authored, include_prs_commented, include_prs_reviewed, include_issues_authored, include_issues_commented, pat);
53
+ const repoUserStats = await fetchRepoUserStats(username, [owner + "/" + reponame], [], include_prs_authored, include_prs_commented, include_prs_reviewed, include_issues_authored, include_issues_commented, pat);
93
54
  return {
94
55
  ...repoUserStats,
95
- ...data.user.repository,
96
- starCount: data.user.repository.stargazerCount,
56
+ ...repository,
97
57
  };
98
58
  }
99
- if (isOrg) {
100
- if (!data.organization.repository ||
101
- data.organization.repository.isPrivate) {
59
+ if (data.user === null && data.organization) {
60
+ const repository = data.organization.repository;
61
+ if (!repository || repository.isPrivate) {
102
62
  throw new Error("Organization Repository Not found");
103
63
  }
104
- let repoUserStats = await fetchRepoUserStats(username, [owner + "/" + reponame], [], include_prs_authored, include_prs_commented, include_prs_reviewed, include_issues_authored, include_issues_commented, pat);
64
+ const repoUserStats = await fetchRepoUserStats(username, [owner + "/" + reponame], [], include_prs_authored, include_prs_commented, include_prs_reviewed, include_issues_authored, include_issues_commented, pat);
105
65
  return {
106
66
  ...repoUserStats,
107
- ...data.organization.repository,
108
- starCount: data.organization.repository.stargazerCount,
67
+ ...repository,
109
68
  };
110
69
  }
111
70
  throw new Error("Unexpected behavior");
@@ -1,22 +1,29 @@
1
+ import type { RepoUserStats, StatsData } from "./types.js";
2
+ declare const fetchRepoUserStats: (username: string, repo: Array<string>, owner: Array<string>, include_prs_authored: boolean, include_prs_commented: boolean, include_prs_reviewed: boolean, include_issues_authored: boolean, include_issues_commented: boolean, pat: string | null) => Promise<RepoUserStats>;
1
3
  /**
2
4
  * Fetch stats for a given username.
3
5
  *
4
- * @param {string} username GitHub username.
5
- * @param {boolean} include_all_commits Include all commits.
6
- * @param {string[]} exclude_repo Repositories to exclude.
7
- * @param {boolean} include_merged_pull_requests Include merged pull requests.
8
- * @param {boolean} include_discussions Include discussions.
9
- * @param {boolean} include_discussions_answers Include discussions answers.
10
- * @param {number|undefined} commits_year Year to count total commits
11
- * @param {string[]} ownerAffiliations Owner affiliations. Default: OWNER.
12
- * @returns {Promise<import("./types").StatsData>} Stats data.
6
+ * @param username GitHub username.
7
+ * @param include_all_commits Include all commits.
8
+ * @param exclude_repo Repositories to exclude.
9
+ * @param include_merged_pull_requests Include merged pull requests.
10
+ * @param include_discussions Include discussions.
11
+ * @param include_discussions_answers Include discussions answers.
12
+ * @param commits_year Year to count total commits.
13
+ * @param repo Repositories to scope the REST search to.
14
+ * @param owner Owners to scope the REST search to.
15
+ * @param include_prs_authored Include count of PRs authored.
16
+ * @param include_prs_commented Include count of PRs commented.
17
+ * @param include_prs_reviewed Include count of PRs reviewed.
18
+ * @param include_issues_authored Include count of issues authored.
19
+ * @param include_issues_commented Include count of issues commented.
20
+ * @param ownerAffiliations Owner affiliations. Default: OWNER.
21
+ * @param include_contributions Include all-time contributions.
22
+ * @param include_all_time_contribs Include all-time count of repos contributed to.
23
+ * @param contribs_include_own_repos Include user-owned repos in contributed-to counts.
24
+ * @param pat Optional PAT override.
25
+ * @returns Stats data.
13
26
  */
14
- export function fetchStats(username: string, include_all_commits: boolean | undefined, exclude_repo: string[] | undefined, include_merged_pull_requests: boolean | undefined, include_discussions: boolean | undefined, include_discussions_answers: boolean | undefined, commits_year: number | undefined, repo?: any[], owner?: any[], include_prs_authored?: boolean, include_prs_commented?: boolean, include_prs_reviewed?: boolean, include_issues_authored?: boolean, include_issues_commented?: boolean, ownerAffiliations?: string[], pat?: null): Promise<any>;
15
- export function fetchRepoUserStats(username: any, repo: any, owner: any, include_prs_authored: any, include_prs_commented: any, include_prs_reviewed: any, include_issues_authored: any, include_issues_commented: any, pat: any): Promise<{
16
- totalPRsAuthored: number;
17
- totalPRsCommented: number;
18
- totalPRsReviewed: number;
19
- totalIssuesAuthored: number;
20
- totalIssuesCommented: number;
21
- }>;
27
+ declare const fetchStats: (username: string, include_all_commits?: boolean, exclude_repo?: Array<string>, include_merged_pull_requests?: boolean, include_discussions?: boolean, include_discussions_answers?: boolean, commits_year?: number, repo?: Array<string>, owner?: Array<string>, include_prs_authored?: boolean, include_prs_commented?: boolean, include_prs_reviewed?: boolean, include_issues_authored?: boolean, include_issues_commented?: boolean, ownerAffiliations?: Array<string>, include_contributions?: boolean, include_all_time_contribs?: boolean, contribs_include_own_repos?: boolean, pat?: string | null) => Promise<StatsData>;
28
+ export { fetchStats, fetchRepoUserStats };
22
29
  //# sourceMappingURL=stats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/fetchers/stats.js"],"names":[],"mappings":"AAkTA;;;;;;;;;;;;GAYG;AACH,qCAVW,MAAM,uBACN,OAAO,4BACP,MAAM,EAAE,4CACR,OAAO,mCACP,OAAO,2CACP,OAAO,4BACP,MAAM,GAAC,SAAS,2NAChB,MAAM,EAAE,eACN,OAAO,CAAC,GAA2B,CAAC,CAyJhD;AArOD;;;;;;GA+DC"}
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/fetchers/stats.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAgM3D,QAAA,MAAM,kBAAkB,GACtB,UAAU,MAAM,EAChB,MAAM,KAAK,CAAC,MAAM,CAAC,EACnB,OAAO,KAAK,CAAC,MAAM,CAAC,EACpB,sBAAsB,OAAO,EAC7B,uBAAuB,OAAO,EAC9B,sBAAsB,OAAO,EAC7B,yBAAyB,OAAO,EAChC,0BAA0B,OAAO,EACjC,KAAK,MAAM,GAAG,IAAI,KACjB,OAAO,CAAC,aAAa,CAqDvB,CAAC;AAiQF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,UAAU,GACd,UAAU,MAAM,EAChB,6BAA2B,EAC3B,eAAc,KAAK,CAAC,MAAM,CAAM,EAChC,sCAAoC,EACpC,6BAA2B,EAC3B,qCAAmC,EACnC,eAAe,MAAM,EACrB,OAAM,KAAK,CAAC,MAAM,CAAM,EACxB,QAAO,KAAK,CAAC,MAAM,CAAM,EACzB,8BAA4B,EAC5B,+BAA6B,EAC7B,8BAA4B,EAC5B,iCAA+B,EAC/B,kCAAgC,EAChC,oBAAmB,KAAK,CAAC,MAAM,CAAM,EACrC,+BAA6B,EAC7B,mCAAiC,EACjC,oCAAkC,EAClC,MAAK,MAAM,GAAG,IAAW,KACxB,OAAO,CAAC,SAAS,CA2JnB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC"}