@giantswarm-io/pro 1.3.1
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.
- package/LICENSE +201 -0
- package/README.md +317 -0
- package/bin/index.js +65 -0
- package/package.json +40 -0
- package/src/index.js +49 -0
- package/src/lib/api.js +87 -0
- package/src/lib/auth/provider.js +395 -0
- package/src/lib/fields.js +111 -0
- package/src/lib/items.js +426 -0
- package/src/lib/logger.js +40 -0
- package/src/lib/mcp/http.js +233 -0
- package/src/lib/mcp/resources.js +304 -0
- package/src/lib/mcp/server.js +156 -0
- package/src/lib/mcp/sub-issues.js +580 -0
- package/src/lib/mcp/tools.js +601 -0
- package/src/lib/project.js +406 -0
- package/src/lib/rest-api.js +141 -0
- package/src/lib/selfupdate.js +107 -0
- package/src/lib/sub-issues.js +100 -0
- package/src/lib/utils.js +23 -0
- package/src/lib/version.js +19 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-Issues Core Module
|
|
3
|
+
*
|
|
4
|
+
* Plain functions for the GitHub sub-issues REST API (parent/child issue
|
|
5
|
+
* relationships). Used by the MCP tool handlers and importable as part of
|
|
6
|
+
* the @giantswarm-io/pro package (e.g. by the Backstage roadmap backend).
|
|
7
|
+
*
|
|
8
|
+
* All functions take an explicit { owner, repo, issue_number } target plus
|
|
9
|
+
* an optional per-request token (falls back to GITHUB_API_TOKEN).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { getOctokit } from './rest-api.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* List the sub-issues of a parent issue.
|
|
16
|
+
* @param {{ owner: string, repo: string, issue_number: number, per_page?: number, page?: number }} target
|
|
17
|
+
* @param {string} [token] - Optional per-request GitHub token
|
|
18
|
+
* @returns {Promise<Array>} - Array of sub-issue objects (REST issue shape)
|
|
19
|
+
*/
|
|
20
|
+
export async function listSubIssues({ owner, repo, issue_number, per_page = 30, page = 1 }, token) {
|
|
21
|
+
const client = getOctokit(token);
|
|
22
|
+
const { data } = await client.request(
|
|
23
|
+
'GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues',
|
|
24
|
+
{ owner, repo, issue_number, per_page, page }
|
|
25
|
+
);
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Add a sub-issue to a parent issue.
|
|
31
|
+
* @param {{ owner: string, repo: string, issue_number: number, subIssueId: number, replaceParent?: boolean }} target
|
|
32
|
+
* - subIssueId is the child issue's integer ID (not its number)
|
|
33
|
+
* @param {string} [token] - Optional per-request GitHub token
|
|
34
|
+
* @returns {Promise<Object>} - The updated parent issue (REST issue shape)
|
|
35
|
+
*/
|
|
36
|
+
export async function addSubIssue({ owner, repo, issue_number, subIssueId, replaceParent = false }, token) {
|
|
37
|
+
const client = getOctokit(token);
|
|
38
|
+
const { data } = await client.request(
|
|
39
|
+
'POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues',
|
|
40
|
+
{ owner, repo, issue_number, sub_issue_id: subIssueId, replace_parent: replaceParent }
|
|
41
|
+
);
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Remove a sub-issue from a parent issue.
|
|
47
|
+
* @param {{ owner: string, repo: string, issue_number: number, subIssueId: number }} target
|
|
48
|
+
* @param {string} [token] - Optional per-request GitHub token
|
|
49
|
+
* @returns {Promise<void>}
|
|
50
|
+
*/
|
|
51
|
+
export async function removeSubIssue({ owner, repo, issue_number, subIssueId }, token) {
|
|
52
|
+
const client = getOctokit(token);
|
|
53
|
+
await client.request(
|
|
54
|
+
'DELETE /repos/{owner}/{repo}/issues/{issue_number}/sub_issue',
|
|
55
|
+
{ owner, repo, issue_number, sub_issue_id: subIssueId }
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the parent issue of a given issue.
|
|
61
|
+
* @param {{ owner: string, repo: string, issue_number: number }} target
|
|
62
|
+
* @param {string} [token] - Optional per-request GitHub token
|
|
63
|
+
* @returns {Promise<Object|null>} - The parent issue, or null if the issue has no parent
|
|
64
|
+
*/
|
|
65
|
+
export async function getParentIssue({ owner, repo, issue_number }, token) {
|
|
66
|
+
const client = getOctokit(token);
|
|
67
|
+
try {
|
|
68
|
+
const { data } = await client.request(
|
|
69
|
+
'GET /repos/{owner}/{repo}/issues/{issue_number}/parent',
|
|
70
|
+
{ owner, repo, issue_number }
|
|
71
|
+
);
|
|
72
|
+
return data;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (error.status === 404) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Reorder a sub-issue within its parent's sub-issue list.
|
|
83
|
+
* Exactly one of afterId or beforeId must be provided.
|
|
84
|
+
* @param {{ owner: string, repo: string, issue_number: number, subIssueId: number, afterId?: number, beforeId?: number }} target
|
|
85
|
+
* @param {string} [token] - Optional per-request GitHub token
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
export async function reprioritizeSubIssue({ owner, repo, issue_number, subIssueId, afterId, beforeId }, token) {
|
|
89
|
+
if (!afterId && !beforeId) {
|
|
90
|
+
throw new Error('Provide either afterId or beforeId to specify the new position.');
|
|
91
|
+
}
|
|
92
|
+
const client = getOctokit(token);
|
|
93
|
+
const body = { sub_issue_id: subIssueId };
|
|
94
|
+
if (afterId) body.after_id = afterId;
|
|
95
|
+
if (beforeId) body.before_id = beforeId;
|
|
96
|
+
await client.request(
|
|
97
|
+
'PATCH /repos/{owner}/{repo}/issues/{issue_number}/sub_issues/priority',
|
|
98
|
+
{ owner, repo, issue_number, ...body }
|
|
99
|
+
);
|
|
100
|
+
}
|
package/src/lib/utils.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility Functions Module
|
|
3
|
+
*
|
|
4
|
+
* Common utility functions used across the application.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Normalize a field value for consistent comparison.
|
|
9
|
+
* Converts to lowercase, removes emojis and special characters, trims whitespace.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} value - Field value to normalize
|
|
12
|
+
* @returns {string} - Normalized field value for comparison
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeFieldValue(value) {
|
|
15
|
+
if (!value) return '';
|
|
16
|
+
return value.toLowerCase()
|
|
17
|
+
// Remove emojis and special unicode characters
|
|
18
|
+
.replace(/[\u{1F600}-\u{1F64F}|\u{1F300}-\u{1F5FF}|\u{1F680}-\u{1F6FF}|\u{2600}-\u{26FF}|\u{2700}-\u{27BF}|\u{1F900}-\u{1F9FF}|\u{1F1E0}-\u{1F1FF}|\u{1F100}-\u{1F1FF}|\u{E000}-\u{F8FF}]/gu, '')
|
|
19
|
+
// Remove other special characters but keep alphanumeric and spaces
|
|
20
|
+
.replace(/[^\w\s]/g, '')
|
|
21
|
+
// Trim extra whitespace
|
|
22
|
+
.trim();
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version utility
|
|
3
|
+
*
|
|
4
|
+
* Reads the version from package.json so it stays in sync
|
|
5
|
+
* with the npm package version and autorelease workflow.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
const pkgPath = join(__dirname, '..', '..', 'package.json');
|
|
16
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
17
|
+
|
|
18
|
+
export const version = pkg.version;
|
|
19
|
+
export const name = pkg.name;
|