Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 27x 27x 36x 36x 40x 40x 31x 31x | /**
* Router Helpers
*
* Shared require*() helpers that validate context dependencies
* and throw TRPCError when a required dependency is missing.
*/
import { TRPCError } from '@trpc/server';
import type { TRPCContext } from '../context.js';
import type { TaskRepository } from '../../db/repositories/task-repository.js';
import type { MessageRepository } from '../../db/repositories/message-repository.js';
import type { InitiativeRepository } from '../../db/repositories/initiative-repository.js';
import type { PhaseRepository } from '../../db/repositories/phase-repository.js';
import type { PageRepository } from '../../db/repositories/page-repository.js';
import type { ProjectRepository } from '../../db/repositories/project-repository.js';
import type { AccountRepository } from '../../db/repositories/account-repository.js';
import type { ChangeSetRepository } from '../../db/repositories/change-set-repository.js';
import type { LogChunkRepository } from '../../db/repositories/log-chunk-repository.js';
import type { ConversationRepository } from '../../db/repositories/conversation-repository.js';
import type { DispatchManager, PhaseDispatchManager } from '../../dispatch/types.js';
import type { CoordinationManager } from '../../coordination/types.js';
import type { BranchManager } from '../../git/branch-manager.js';
import type { ExecutionOrchestrator } from '../../execution/orchestrator.js';
import type { PreviewManager } from '../../preview/index.js';
export function requireAgentManager(ctx: TRPCContext) {
Iif (!ctx.agentManager) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Agent manager not available',
});
}
return ctx.agentManager;
}
export function requireTaskRepository(ctx: TRPCContext): TaskRepository {
Iif (!ctx.taskRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Task repository not available',
});
}
return ctx.taskRepository;
}
export function requireMessageRepository(ctx: TRPCContext): MessageRepository {
if (!ctx.messageRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Message repository not available',
});
}
return ctx.messageRepository;
}
export function requireDispatchManager(ctx: TRPCContext): DispatchManager {
if (!ctx.dispatchManager) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Dispatch manager not available',
});
}
return ctx.dispatchManager;
}
export function requireCoordinationManager(ctx: TRPCContext): CoordinationManager {
if (!ctx.coordinationManager) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Coordination manager not available',
});
}
return ctx.coordinationManager;
}
export function requireInitiativeRepository(ctx: TRPCContext): InitiativeRepository {
Iif (!ctx.initiativeRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Initiative repository not available',
});
}
return ctx.initiativeRepository;
}
export function requirePhaseRepository(ctx: TRPCContext): PhaseRepository {
Iif (!ctx.phaseRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Phase repository not available',
});
}
return ctx.phaseRepository;
}
export function requirePhaseDispatchManager(ctx: TRPCContext): PhaseDispatchManager {
if (!ctx.phaseDispatchManager) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Phase dispatch manager not available',
});
}
return ctx.phaseDispatchManager;
}
export function requirePageRepository(ctx: TRPCContext): PageRepository {
if (!ctx.pageRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Page repository not available',
});
}
return ctx.pageRepository;
}
export function requireProjectRepository(ctx: TRPCContext): ProjectRepository {
if (!ctx.projectRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Project repository not available',
});
}
return ctx.projectRepository;
}
export function requireAccountRepository(ctx: TRPCContext): AccountRepository {
if (!ctx.accountRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Account repository not available',
});
}
return ctx.accountRepository;
}
export function requireChangeSetRepository(ctx: TRPCContext): ChangeSetRepository {
if (!ctx.changeSetRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Change set repository not available',
});
}
return ctx.changeSetRepository;
}
export function requireLogChunkRepository(ctx: TRPCContext): LogChunkRepository {
if (!ctx.logChunkRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Log chunk repository not available',
});
}
return ctx.logChunkRepository;
}
export function requireBranchManager(ctx: TRPCContext): BranchManager {
if (!ctx.branchManager) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Branch manager not available',
});
}
return ctx.branchManager;
}
export function requireExecutionOrchestrator(ctx: TRPCContext): ExecutionOrchestrator {
if (!ctx.executionOrchestrator) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Execution orchestrator not available',
});
}
return ctx.executionOrchestrator;
}
export function requirePreviewManager(ctx: TRPCContext): PreviewManager {
if (!ctx.previewManager) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Preview manager not available',
});
}
return ctx.previewManager;
}
export function requireConversationRepository(ctx: TRPCContext): ConversationRepository {
if (!ctx.conversationRepository) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Conversation repository not available',
});
}
return ctx.conversationRepository;
}
|