Core capabilities: - Jira ticket lifecycle: status, update, comment, transitions, close - JSM Store Support request creation with Assets object resolution - Assets AQL diagnostic probe endpoint with schema/type introspection - Webex transcript ingestion (audio + JSON + human-readable) with restricted-visibility summary comments - Grok-powered single-ticket and open-tickets-by-reporter summaries Repo hygiene: - .gitignore covering .env, node_modules, logs, IDE dirs - .env.example documenting every env var - discover-ss-*.js scripts refactored to read credentials from .env - README covering setup, endpoints, and the Assets scope-vs-role gotcha Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
// discover-ss-fields.js
|
|
// One-off helper to dump JSM request-type field definitions for the Store
|
|
// Support service desk. Output files (ss-fields-<id>.json) are used to keep
|
|
// REQUEST_TYPE_MAP in src/services/jiraService.js in sync with what JSM
|
|
// actually accepts.
|
|
//
|
|
// Usage: node discover-ss-fields.js
|
|
// Reads credentials from .env — never commit real tokens into this file.
|
|
|
|
import 'dotenv/config';
|
|
import fetch from 'node-fetch';
|
|
import fs from 'fs/promises';
|
|
|
|
const BASE_URL = (process.env.JIRA_BASE_URL || 'https://your-site.atlassian.net').replace(/\/$/, '');
|
|
const SERVICE_DESK_ID = process.env.JIRA_SERVICE_DESK_ID || '170';
|
|
const EMAIL = process.env.JIRA_EMAIL;
|
|
const TOKEN = process.env.JIRA_API_TOKEN;
|
|
|
|
if (!EMAIL || !TOKEN) {
|
|
console.error('JIRA_EMAIL and JIRA_API_TOKEN must be set in .env');
|
|
process.exit(1);
|
|
}
|
|
|
|
const headers = {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Basic ' + Buffer.from(`${EMAIL}:${TOKEN}`).toString('base64')
|
|
};
|
|
|
|
// Request-type ids that we care about (matches REQUEST_TYPE_MAP in jiraService.js).
|
|
const importantTypes = [269, 266, 273, 274, 267, 275, 272, 268, 271, 270, 426, 493];
|
|
|
|
async function getFields(requestTypeId) {
|
|
console.log(`Fetching fields for request type ${requestTypeId}...`);
|
|
const res = await fetch(`${BASE_URL}/rest/servicedeskapi/servicedesk/${SERVICE_DESK_ID}/requesttype/${requestTypeId}/field`, { headers });
|
|
const data = await res.json();
|
|
|
|
if (res.ok) {
|
|
await fs.writeFile(`ss-fields-${requestTypeId}.json`, JSON.stringify(data, null, 2));
|
|
console.log(` saved ss-fields-${requestTypeId}.json`);
|
|
} else {
|
|
console.error(' error:', data);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
for (const id of importantTypes) {
|
|
await getFields(id);
|
|
}
|
|
|
|
console.log('\nDone. Check the generated ss-fields-*.json files.');
|