UNPKG

mcp-casual-interview

Version:

MCP server for casual interview preparation workflow management

129 lines 5.93 kB
import { WorkflowValues, WorkflowPolicies } from '../../term/interview-workflow/index.js'; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Event Projections - Building Views from Events // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ /** * Project current workflow state from event stream */ const projectCurrentStateFromEvents = (events) => { let currentState = 'information_initially_registered'; for (const event of events) { switch (event.type) { case 'ProgressChecked': currentState = event.workflowState; break; case 'WorkflowStateUpdated': currentState = event.newState; break; default: // Exhaustive check const _exhaustive = event; throw new Error(`Unknown event type: ${_exhaustive}`); } } return currentState; }; /** * Build state history from events for analytics */ const buildStateHistoryFromEvents = (events) => { const history = []; for (const event of events) { switch (event.type) { case 'WorkflowStateUpdated': history.push({ state: event.newState, timestamp: event.timestamp, transitionType: 'manual' // Could be enhanced with more context }); break; } } return history; }; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // View Construction Functions // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ /** * Calculate progress statistics */ // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Query Functions - The Read Model Interface // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ /** * Create basic progress response from current state */ const createProgressResponseFromState = (currentState) => { const nextAction = WorkflowValues.NextActionPrompts[currentState]; const nextState = WorkflowPolicies.StateTransitions.getNextState(currentState); const canAdvance = nextState !== null; return { currentState, nextAction, canAdvance, lastUpdated: new Date() }; }; /** * Create progress response from event stream (event sourcing) */ const createProgressResponseFromEvents = (events) => { const currentState = projectCurrentStateFromEvents(events); return createProgressResponseFromState(currentState); }; /** * Create detailed progress view with analytics */ const createDetailedProgressView = (currentState, events = []) => { const baseResponse = createProgressResponseFromState(currentState); const stateHistory = buildStateHistoryFromEvents(events); return { ...baseResponse, stateHistory }; }; /** * Query for workflow completion status */ const queryCompletionStatus = (currentState) => { const isCompleted = currentState === 'completed'; const nextStep = WorkflowPolicies.StateTransitions.getNextState(currentState); return { isCompleted, hasNextStep: nextStep !== null, nextStep }; }; /** * Query for available actions based on current state */ const queryAvailableActions = (currentState) => { const nextState = WorkflowPolicies.StateTransitions.getNextState(currentState); const canAdvance = nextState !== null; const canGoBack = currentState !== 'information_initially_registered'; const availableTransitions = ['information_initially_registered', 'career_summary_created', 'match_position_determined', 'match_degree_prediagnosed', 'attract_plan_determined', 'completed'] .filter(state => WorkflowPolicies.StateTransitions.canTransition(currentState, state)) .map(state => state); return { canAdvance, canGoBack, nextState, availableTransitions, currentStateActions: WorkflowValues.NextActionPrompts[currentState] }; }; // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Public API - Progress View Queries // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ export const ProgressViewQueries = { fromState: createProgressResponseFromState, fromEvents: createProgressResponseFromEvents, detailed: createDetailedProgressView, completionStatus: queryCompletionStatus, availableActions: queryAvailableActions }; export const ProgressProjections = { projectCurrentStateFromEvents, buildStateHistoryFromEvents }; //# sourceMappingURL=index.js.map