buddy-workbench 0.1.16 → 0.1.17
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/package.json
CHANGED
|
@@ -158,4 +158,47 @@ router.get('/:id/issues', async (req, res) => {
|
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
+
// Clone an issue
|
|
162
|
+
router.post('/issues/clone', async (req, res) => {
|
|
163
|
+
const { issueKey, summary } = req.body || {};
|
|
164
|
+
if (!summary || typeof summary !== 'string' || !summary.trim()) {
|
|
165
|
+
return res.status(400).json({ error: 'Summary is required for clone.' });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const jiraHost = getJiraHost();
|
|
169
|
+
if (!jiraHost) {
|
|
170
|
+
return res.status(400).json({ error: 'Jira domain is not configured. Please set Domain in Settings.' });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const settings = readSettings();
|
|
174
|
+
const token = settings.jiraAccessToken;
|
|
175
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
176
|
+
if (token) {
|
|
177
|
+
headers.Authorization = token.startsWith('Bearer ') ? token : `Bearer ${token}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const projectKey = issueKey ? issueKey.split('-')[0] : '';
|
|
182
|
+
const url = `https://${jiraHost}/rest/api/2/issue`;
|
|
183
|
+
const payload = {
|
|
184
|
+
fields: {
|
|
185
|
+
summary: summary.trim(),
|
|
186
|
+
...(projectKey ? { project: { key: projectKey } } : {}),
|
|
187
|
+
issuetype: { name: 'Task' }
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const response = await httpClient.post(url, payload, { headers });
|
|
192
|
+
if (response.status !== 201 && response.status !== 200) {
|
|
193
|
+
const errMsg = response.data?.errorMessages?.[0] || response.data?.message || `Jira API returned status ${response.status}`;
|
|
194
|
+
return res.status(response.status).json({ error: errMsg });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const created = response.data || {};
|
|
198
|
+
res.status(201).json({ success: true, issue: { key: created.key || issueKey, id: created.id } });
|
|
199
|
+
} catch (error) {
|
|
200
|
+
res.status(500).json({ error: error.message || 'Failed to clone Jira issue.' });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
161
204
|
export default router;
|