@stoked-ui/github 0.0.0-a.0 → 0.1.0-alpha.11.2

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 (87) hide show
  1. package/GithubBranch/GithubBranch.d.ts +12 -0
  2. package/GithubBranch/GithubBranch.js +177 -0
  3. package/GithubBranch/index.d.ts +2 -0
  4. package/GithubBranch/index.js +2 -0
  5. package/GithubBranch/package.json +6 -0
  6. package/GithubCalendar/GithubCalendar.d.ts +6 -2
  7. package/GithubCalendar/GithubCalendar.js +70 -28
  8. package/GithubCommit/GithubCommit.d.ts +11 -0
  9. package/GithubCommit/GithubCommit.js +170 -0
  10. package/GithubCommit/index.d.ts +2 -0
  11. package/GithubCommit/index.js +2 -0
  12. package/GithubCommit/package.json +6 -0
  13. package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +1 -1
  14. package/GithubEvents/GithubEvents.d.ts +4 -24
  15. package/GithubEvents/GithubEvents.js +141 -220
  16. package/apiHandlers/createGithubBranchHandler.d.ts +12 -0
  17. package/apiHandlers/createGithubBranchHandler.js +41 -0
  18. package/apiHandlers/createGithubCommitHandler.d.ts +12 -0
  19. package/apiHandlers/createGithubCommitHandler.js +39 -0
  20. package/apiHandlers/createGithubContributionsHandler.d.ts +15 -0
  21. package/apiHandlers/createGithubContributionsHandler.js +41 -0
  22. package/apiHandlers/createGithubEventsHandler.d.ts +15 -0
  23. package/apiHandlers/createGithubEventsHandler.js +50 -0
  24. package/apiHandlers/getBranchCompareDetails.d.ts +9 -0
  25. package/apiHandlers/getBranchCompareDetails.js +29 -0
  26. package/apiHandlers/getCommitDetails.d.ts +8 -0
  27. package/apiHandlers/getCommitDetails.js +34 -0
  28. package/apiHandlers/getGithubContributions.d.ts +8 -0
  29. package/apiHandlers/getGithubContributions.js +126 -0
  30. package/apiHandlers/getGithubEvents.d.ts +25 -0
  31. package/apiHandlers/getGithubEvents.js +142 -0
  32. package/apiHandlers/getPullRequestDetails.js +2 -2
  33. package/apiHandlers/githubApi.d.ts +17 -0
  34. package/apiHandlers/githubApi.js +155 -0
  35. package/apiHandlers/index.d.ts +9 -0
  36. package/apiHandlers/index.js +9 -1
  37. package/components/GithubContributorsList.d.ts +8 -0
  38. package/components/GithubContributorsList.js +72 -0
  39. package/components/fetchGithubViewData.d.ts +1 -0
  40. package/components/fetchGithubViewData.js +10 -0
  41. package/index.d.ts +7 -3
  42. package/index.js +6 -4
  43. package/modern/GithubBranch/GithubBranch.js +177 -0
  44. package/modern/GithubBranch/index.js +2 -0
  45. package/modern/GithubCalendar/GithubCalendar.js +70 -28
  46. package/modern/GithubCommit/GithubCommit.js +170 -0
  47. package/modern/GithubCommit/index.js +2 -0
  48. package/modern/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +1 -1
  49. package/modern/GithubEvents/GithubEvents.js +141 -220
  50. package/modern/apiHandlers/createGithubBranchHandler.js +41 -0
  51. package/modern/apiHandlers/createGithubCommitHandler.js +39 -0
  52. package/modern/apiHandlers/createGithubContributionsHandler.js +41 -0
  53. package/modern/apiHandlers/createGithubEventsHandler.js +50 -0
  54. package/modern/apiHandlers/getBranchCompareDetails.js +29 -0
  55. package/modern/apiHandlers/getCommitDetails.js +34 -0
  56. package/modern/apiHandlers/getGithubContributions.js +126 -0
  57. package/modern/apiHandlers/getGithubEvents.js +142 -0
  58. package/modern/apiHandlers/getPullRequestDetails.js +2 -2
  59. package/modern/apiHandlers/githubApi.js +155 -0
  60. package/modern/apiHandlers/index.js +9 -1
  61. package/modern/components/GithubContributorsList.js +72 -0
  62. package/modern/components/fetchGithubViewData.js +10 -0
  63. package/modern/index.js +6 -4
  64. package/node/GithubBranch/GithubBranch.js +185 -0
  65. package/node/GithubBranch/index.js +9 -0
  66. package/node/GithubCalendar/GithubCalendar.js +70 -28
  67. package/node/GithubCommit/GithubCommit.js +178 -0
  68. package/node/GithubCommit/index.js +9 -0
  69. package/node/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +1 -1
  70. package/node/GithubEvents/GithubEvents.js +148 -223
  71. package/node/apiHandlers/createGithubBranchHandler.js +48 -0
  72. package/node/apiHandlers/createGithubCommitHandler.js +46 -0
  73. package/node/apiHandlers/createGithubContributionsHandler.js +48 -0
  74. package/node/apiHandlers/createGithubEventsHandler.js +57 -0
  75. package/node/apiHandlers/getBranchCompareDetails.js +35 -0
  76. package/node/apiHandlers/getCommitDetails.js +40 -0
  77. package/node/apiHandlers/getGithubContributions.js +132 -0
  78. package/node/apiHandlers/getGithubEvents.js +149 -0
  79. package/node/apiHandlers/getPullRequestDetails.js +2 -2
  80. package/node/apiHandlers/githubApi.js +168 -0
  81. package/node/apiHandlers/index.js +64 -1
  82. package/node/components/GithubContributorsList.js +80 -0
  83. package/node/components/fetchGithubViewData.js +16 -0
  84. package/node/index.js +77 -2
  85. package/package.json +2 -5
  86. package/stoked-ui-github-0.1.0-alpha.11.2.tgz +0 -0
  87. package/types/github.d.ts +75 -11
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = GithubContributorsList;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
10
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
11
+ var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
12
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
+ var _styles = require("@mui/material/styles");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
+ const ContributorCard = (0, _styles.styled)(_Box.default)(({
17
+ theme
18
+ }) => ({
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ gap: theme.spacing(1.5),
22
+ padding: theme.spacing(1.5),
23
+ border: `1px solid ${theme.palette.divider}`,
24
+ borderRadius: theme.shape.borderRadius,
25
+ backgroundColor: theme.palette.background.paper
26
+ }));
27
+ function GithubContributorsList({
28
+ contributors,
29
+ title
30
+ }) {
31
+ if (!contributors.length) {
32
+ return null;
33
+ }
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
35
+ sx: {
36
+ mb: 3
37
+ },
38
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
39
+ variant: "subtitle2",
40
+ color: "text.secondary",
41
+ sx: {
42
+ mb: 1.5
43
+ },
44
+ children: title
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
46
+ sx: {
47
+ display: 'flex',
48
+ flexWrap: 'wrap',
49
+ gap: 1.5
50
+ },
51
+ children: contributors.map(contributor => /*#__PURE__*/(0, _jsxRuntime.jsxs)(ContributorCard, {
52
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
53
+ src: contributor.avatarUrl,
54
+ alt: contributor.login,
55
+ sx: {
56
+ width: 40,
57
+ height: 40
58
+ }
59
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
60
+ sx: {
61
+ minWidth: 0
62
+ },
63
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
64
+ variant: "body2",
65
+ fontWeight: 600,
66
+ children: contributor.login
67
+ }), contributor.name && contributor.name !== contributor.login ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
68
+ variant: "caption",
69
+ color: "text.secondary",
70
+ children: contributor.name
71
+ }) : null]
72
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
73
+ label: `${contributor.contributions} commit${contributor.contributions === 1 ? '' : 's'}`,
74
+ size: "small",
75
+ variant: "outlined"
76
+ })]
77
+ }, `${contributor.login}-${contributor.name}`))
78
+ })]
79
+ });
80
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = fetchGithubViewData;
7
+ async function fetchGithubViewData(apiUrl, params) {
8
+ const query = new URLSearchParams(params);
9
+ const separator = apiUrl.includes('?') ? '&' : '?';
10
+ const response = await fetch(`${apiUrl}${separator}${query.toString()}`);
11
+ if (!response.ok) {
12
+ const errorBody = await response.json().catch(() => null);
13
+ throw new Error((errorBody == null ? void 0 : errorBody.message) || 'Failed to fetch GitHub data');
14
+ }
15
+ return response.json();
16
+ }
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @stoked-ui/github v0.0.0-a.0
2
+ * @stoked-ui/github v0.1.0-alpha.11.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,17 +11,92 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
11
11
  Object.defineProperty(exports, "__esModule", {
12
12
  value: true
13
13
  });
14
+ Object.defineProperty(exports, "GithubBranch", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _GithubBranch.default;
18
+ }
19
+ });
14
20
  Object.defineProperty(exports, "GithubCalendar", {
15
21
  enumerable: true,
16
22
  get: function () {
17
23
  return _GithubCalendar.default;
18
24
  }
19
25
  });
26
+ Object.defineProperty(exports, "GithubCommit", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _GithubCommit.default;
30
+ }
31
+ });
20
32
  Object.defineProperty(exports, "GithubEvents", {
21
33
  enumerable: true,
22
34
  get: function () {
23
35
  return _GithubEvents.default;
24
36
  }
25
37
  });
38
+ Object.defineProperty(exports, "createGithubBranchHandler", {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _apiHandlers.createGithubBranchHandler;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "createGithubCommitHandler", {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _apiHandlers.createGithubCommitHandler;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "createGithubContributionsHandler", {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _apiHandlers.createGithubContributionsHandler;
54
+ }
55
+ });
56
+ Object.defineProperty(exports, "createGithubEventsHandler", {
57
+ enumerable: true,
58
+ get: function () {
59
+ return _apiHandlers.createGithubEventsHandler;
60
+ }
61
+ });
62
+ Object.defineProperty(exports, "getBranchCompareDetails", {
63
+ enumerable: true,
64
+ get: function () {
65
+ return _apiHandlers.getBranchCompareDetails;
66
+ }
67
+ });
68
+ Object.defineProperty(exports, "getCommitDetails", {
69
+ enumerable: true,
70
+ get: function () {
71
+ return _apiHandlers.getCommitDetails;
72
+ }
73
+ });
74
+ Object.defineProperty(exports, "getGithubContributions", {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _apiHandlers.getGithubContributions;
78
+ }
79
+ });
80
+ Object.defineProperty(exports, "getGithubEvents", {
81
+ enumerable: true,
82
+ get: function () {
83
+ return _apiHandlers.getGithubEvents;
84
+ }
85
+ });
86
+ Object.defineProperty(exports, "getPullRequestDetails", {
87
+ enumerable: true,
88
+ get: function () {
89
+ return _apiHandlers.getPullRequestDetails;
90
+ }
91
+ });
92
+ Object.defineProperty(exports, "githubEventsQuery", {
93
+ enumerable: true,
94
+ get: function () {
95
+ return _apiHandlers.githubEventsQuery;
96
+ }
97
+ });
98
+ var _GithubBranch = _interopRequireDefault(require("./GithubBranch"));
26
99
  var _GithubCalendar = _interopRequireDefault(require("./GithubCalendar"));
27
- var _GithubEvents = _interopRequireDefault(require("./GithubEvents"));
100
+ var _GithubCommit = _interopRequireDefault(require("./GithubCommit"));
101
+ var _GithubEvents = _interopRequireDefault(require("./GithubEvents"));
102
+ var _apiHandlers = require("./apiHandlers");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoked-ui/github",
3
- "version": "0.0.0-a.0",
3
+ "version": "0.1.0-alpha.11.2",
4
4
  "description": "Github components for Stoked UI",
5
5
  "author": "Brian Stoker",
6
6
  "main": "./node/index.js",
@@ -40,6 +40,7 @@
40
40
  "@mui/utils": "^5.15.20",
41
41
  "@octokit/request-error": "^6.1.8",
42
42
  "@octokit/types": "^14.0.0",
43
+ "@stoked-ui/common": "0.1.3-a.0",
43
44
  "date-fns": "^3.0.0",
44
45
  "date-fns-tz": "^3.2.0",
45
46
  "lodash": "^4.17.23",
@@ -55,10 +56,6 @@
55
56
  "@emotion/styled": "^11.8.1",
56
57
  "@mui/icons-material": "^5.15.21",
57
58
  "@mui/material": "^5.15.21",
58
- "@stoked-ui/common": "workspace:^",
59
- "@stoked-ui/file-explorer": "workspace:^",
60
- "@stoked-ui/media": "workspace:^",
61
- "@stoked-ui/timeline": "workspace:^",
62
59
  "react": "18.3.1",
63
60
  "react-dom": "^17.0.0 || ^18.0.0"
64
61
  },
package/types/github.d.ts CHANGED
@@ -31,6 +31,80 @@ export interface CachedData {
31
31
  lastFetched: number;
32
32
  totalCount: number;
33
33
  }
34
+ export type GithubDiffLineType = 'addition' | 'deletion' | 'context';
35
+ export interface GithubDiffLine {
36
+ type: GithubDiffLineType;
37
+ content: string;
38
+ lineNumber: number;
39
+ }
40
+ export type GithubFileChangeType = 'added' | 'modified' | 'deleted';
41
+ export interface GithubChangedFile {
42
+ path: string;
43
+ type: GithubFileChangeType;
44
+ additions: number;
45
+ deletions: number;
46
+ diff: GithubDiffLine[];
47
+ }
48
+ export interface GithubContributor {
49
+ login: string;
50
+ name: string;
51
+ avatarUrl: string;
52
+ contributions: number;
53
+ }
54
+ export interface GithubCommitListItem {
55
+ id: string;
56
+ message: string;
57
+ author: {
58
+ name: string;
59
+ login: string;
60
+ avatar: string;
61
+ };
62
+ date: string;
63
+ hash: string;
64
+ url: string;
65
+ }
66
+ export interface GithubCommitStats {
67
+ additions: number;
68
+ deletions: number;
69
+ changedFiles: number;
70
+ }
71
+ export interface GithubContributionDay {
72
+ date: string;
73
+ count: number;
74
+ level: number;
75
+ }
76
+ export interface GithubContributionsResponse {
77
+ total: Record<string, number>;
78
+ contributions: GithubContributionDay[];
79
+ countLabel?: string;
80
+ }
81
+ export interface GithubCommitData {
82
+ repo: string;
83
+ ref: string;
84
+ shortRef: string;
85
+ url: string;
86
+ summary: string;
87
+ message: string;
88
+ committedAt: string;
89
+ contributor: GithubContributor;
90
+ commits: GithubCommitListItem[];
91
+ files: GithubChangedFile[];
92
+ stats: GithubCommitStats;
93
+ }
94
+ export interface GithubBranchData {
95
+ repo: string;
96
+ baseRef: string;
97
+ headRef: string;
98
+ status: string;
99
+ aheadBy: number;
100
+ behindBy: number;
101
+ totalCommits: number;
102
+ url: string;
103
+ contributors: GithubContributor[];
104
+ commits: GithubCommitListItem[];
105
+ files: GithubChangedFile[];
106
+ stats: GithubCommitStats;
107
+ }
34
108
  export interface PullRequestDetails {
35
109
  title: string;
36
110
  number: number;
@@ -93,15 +167,5 @@ export interface PullRequestDetails {
93
167
  avatar_url: string;
94
168
  };
95
169
  }>;
96
- files?: Array<{
97
- path: string;
98
- type: 'added' | 'modified' | 'deleted';
99
- additions: number;
100
- deletions: number;
101
- diff: Array<{
102
- type: 'addition' | 'deletion' | 'context';
103
- content: string;
104
- lineNumber: number;
105
- }>;
106
- }>;
170
+ files?: GithubChangedFile[];
107
171
  }