Release: CI/CD Pipeline & Architecture Updates #177

Merged
jason.woltje merged 173 commits from develop into main 2026-02-01 19:18:48 +00:00
Showing only changes of commit ba9c272c20 - Show all commits

View File

@@ -5,9 +5,9 @@
* Interacts with Mosaic Stack's Events API for calendar management
*/
const https = require('https');
const http = require('http');
const { URL } = require('url');
import https from 'https';
import http from 'http';
import { URL } from 'url';
// Configuration
const API_URL = process.env.MOSAIC_API_URL || 'http://localhost:3001';
@@ -44,7 +44,20 @@ function apiRequest(method, path, body = null) {
if (res.statusCode >= 200 && res.statusCode < 300) {
resolve(parsed);
} else {
reject(new Error(`HTTP ${res.statusCode}: ${parsed.message || data}`));
// Provide helpful error messages based on status code
let errorMsg = `HTTP ${res.statusCode}: ${parsed.message || data}`;
if (res.statusCode === 401) {
errorMsg += '\n → Check MOSAIC_API_TOKEN is valid';
} else if (res.statusCode === 403) {
errorMsg += '\n → Verify workspace permissions and MOSAIC_WORKSPACE_ID';
} else if (res.statusCode === 404) {
errorMsg += '\n → Resource not found. Check the event ID';
} else if (res.statusCode === 400) {
errorMsg += '\n → Invalid request. Check date formats and required fields';
}
reject(new Error(errorMsg));
}
} catch (err) {
reject(new Error(`Failed to parse response: ${data}`));
@@ -105,7 +118,7 @@ async function createEvent(args) {
if (args['project-id']) body.projectId = args['project-id'];
if (args.metadata) body.metadata = JSON.parse(args.metadata);
const result = await apiRequest('POST', '/api/events', body);
const result = await apiRequest('POST', '/events', body);
return result;
}
@@ -123,7 +136,7 @@ async function listEvents(args) {
if (args.limit) params.append('limit', args.limit);
const query = params.toString();
const path = `/api/events${query ? '?' + query : ''}`;
const path = `/events${query ? '?' + query : ''}`;
const result = await apiRequest('GET', path);
return result;
@@ -137,7 +150,7 @@ async function getEvent(eventId) {
throw new Error('Event ID required');
}
const result = await apiRequest('GET', `/api/events/${eventId}`);
const result = await apiRequest('GET', `/events/${eventId}`);
return result;
}
@@ -160,7 +173,7 @@ async function updateEvent(eventId, args) {
if (args['project-id']) body.projectId = args['project-id'];
if (args.metadata) body.metadata = JSON.parse(args.metadata);
const result = await apiRequest('PATCH', `/api/events/${eventId}`, body);
const result = await apiRequest('PATCH', `/events/${eventId}`, body);
return result;
}
@@ -172,7 +185,7 @@ async function deleteEvent(eventId) {
throw new Error('Event ID required');
}
const result = await apiRequest('DELETE', `/api/events/${eventId}`);
const result = await apiRequest('DELETE', `/events/${eventId}`);
return result;
}
@@ -280,11 +293,9 @@ Environment:
}
// Run if called directly
if (require.main === module) {
main();
}
main();
module.exports = {
export {
createEvent,
listEvents,
getEvent,