Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm
Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)
Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability
Migration completed: $(date)
🤖 Clean migration with full functionality preserved
102 lines
3.1 KiB
JavaScript
102 lines
3.1 KiB
JavaScript
/**
|
|
* url-builder.js
|
|
* Utility for building URLs based on admin settings and project context
|
|
* Handles dynamic Storybook URL generation with hostname, port, skin
|
|
*/
|
|
|
|
import { useAdminStore } from '../stores/admin-store.js';
|
|
import { useProjectStore } from '../stores/project-store.js';
|
|
|
|
class URLBuilder {
|
|
/**
|
|
* Get Storybook URL for current context
|
|
* @param {Object} options - Options for URL generation
|
|
* @param {string} options.skin - Skin/theme name (optional, uses project default)
|
|
* @param {string} options.projectId - Project ID (optional, uses current project)
|
|
* @returns {string} Full Storybook URL
|
|
*/
|
|
static getStorybookUrl(options = {}) {
|
|
const adminStore = useAdminStore();
|
|
const projectStore = useProjectStore();
|
|
|
|
const skin = options.skin || projectStore.getCurrentProject()?.skinSelected || 'default';
|
|
const projectId = options.projectId || projectStore.currentProjectId;
|
|
|
|
const protocol = adminStore.state.isRemote ? 'https' : 'http';
|
|
const hostname = adminStore.state.hostname;
|
|
const port = adminStore.state.port;
|
|
|
|
const baseUrl = `${protocol}://${hostname}:${port}/storybook/`;
|
|
const params = new URLSearchParams();
|
|
|
|
if (skin) params.append('skin', skin);
|
|
if (projectId) params.append('project', projectId);
|
|
|
|
const queryString = params.toString();
|
|
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
}
|
|
|
|
/**
|
|
* Get API base URL for backend
|
|
* @returns {string} API base URL
|
|
*/
|
|
static getAPIBaseUrl() {
|
|
const adminStore = useAdminStore();
|
|
const protocol = adminStore.state.isRemote ? 'https' : 'http';
|
|
const hostname = adminStore.state.hostname;
|
|
|
|
return `${protocol}://${hostname}:3456/api`;
|
|
}
|
|
|
|
/**
|
|
* Get Jira API URL (depends on backend for authentication)
|
|
* @returns {string} Jira API endpoint URL
|
|
*/
|
|
static getJiraApiUrl() {
|
|
const baseUrl = this.getAPIBaseUrl();
|
|
return `${baseUrl}/integrations/jira`;
|
|
}
|
|
|
|
/**
|
|
* Get Figma API URL (depends on backend for authentication)
|
|
* @returns {string} Figma API endpoint URL
|
|
*/
|
|
static getFigmaApiUrl() {
|
|
const baseUrl = this.getAPIBaseUrl();
|
|
return `${baseUrl}/integrations/figma`;
|
|
}
|
|
|
|
/**
|
|
* Get MCP bridge URL for tool execution
|
|
* @returns {string} MCP bridge endpoint URL
|
|
*/
|
|
static getMCPBridgeUrl() {
|
|
const baseUrl = this.getAPIBaseUrl();
|
|
return `${baseUrl}/mcp-bridge`;
|
|
}
|
|
|
|
/**
|
|
* Build a link to a component in Storybook
|
|
* @param {Object} component - Component info
|
|
* @param {string} component.id - Component ID
|
|
* @param {string} component.name - Component name
|
|
* @returns {string} Link to Storybook component
|
|
*/
|
|
static getComponentUrl(component) {
|
|
const baseUrl = this.getStorybookUrl();
|
|
const componentPath = `${component.id}--${component.name}`.toLowerCase().replace(/\s+/g, '-');
|
|
return `${baseUrl}?path=/story/${componentPath}`;
|
|
}
|
|
|
|
/**
|
|
* Build a link to theme/skin preview
|
|
* @param {string} skin - Skin name
|
|
* @returns {string} Link to Storybook with selected skin
|
|
*/
|
|
static getSkinPreviewUrl(skin) {
|
|
return this.getStorybookUrl({ skin });
|
|
}
|
|
}
|
|
|
|
export default URLBuilder;
|