refactor(api): reorganise allocation router into allocation/ subdirectory
Moves read, assignment-procedures, assignment-mutations, and demand procedures into allocation/ so the domain boundary is discoverable without grep. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
import { allocationAssignmentProcedures } from "./allocation-assignment-procedures.js";
|
||||
import { allocationDemandProcedures } from "./allocation-demand-procedures.js";
|
||||
import { allocationReadProcedures } from "./allocation-read-procedures.js";
|
||||
import { createTRPCRouter } from "../trpc.js";
|
||||
|
||||
export const allocationRouter = createTRPCRouter({
|
||||
...allocationReadProcedures,
|
||||
...allocationDemandProcedures,
|
||||
...allocationAssignmentProcedures,
|
||||
});
|
||||
+2
-2
@@ -2,12 +2,12 @@ import {
|
||||
emitAllocationCreated,
|
||||
emitAllocationDeleted,
|
||||
emitAllocationUpdated,
|
||||
} from "../sse/event-bus.js";
|
||||
} from "../../sse/event-bus.js";
|
||||
import {
|
||||
checkBudgetThresholdsInBackground,
|
||||
dispatchAllocationWebhookInBackground,
|
||||
invalidateDashboardCacheInBackground,
|
||||
} from "./allocation-effects.js";
|
||||
} from "./effects.js";
|
||||
|
||||
type AllocationMutationDb = Parameters<typeof checkBudgetThresholdsInBackground>[0];
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@ import {
|
||||
} from "@capakraken/shared";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { z } from "zod";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { ASSIGNMENT_INCLUDE, toIsoDate } from "./allocation-shared.js";
|
||||
import { findUniqueOrThrow } from "../../db/helpers.js";
|
||||
import { ASSIGNMENT_INCLUDE, toIsoDate } from "./shared.js";
|
||||
import {
|
||||
findAllocationEntryOrNull,
|
||||
toAssignmentUpdateInput,
|
||||
toDemandRequirementUpdateInput,
|
||||
} from "./allocation-support.js";
|
||||
} from "./support.js";
|
||||
|
||||
type AllocationMutationDb = Pick<
|
||||
PrismaClient,
|
||||
+4
-4
@@ -11,14 +11,14 @@ import {
|
||||
UpdateAssignmentSchema,
|
||||
} from "@capakraken/shared";
|
||||
import { z } from "zod";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { findUniqueOrThrow } from "../../db/helpers.js";
|
||||
import {
|
||||
publishAllocationCreated,
|
||||
publishAllocationDeleted,
|
||||
publishAllocationUpdated,
|
||||
publishBatchAllocationDeletes,
|
||||
publishBatchAllocationStatusUpdates,
|
||||
} from "./allocation-assignment-effects.js";
|
||||
} from "./assignment-effects.js";
|
||||
import {
|
||||
batchDeleteAllocationsWithAudit,
|
||||
batchUpdateAllocationStatusWithAudit,
|
||||
@@ -27,11 +27,11 @@ import {
|
||||
deleteAssignmentWithAudit,
|
||||
ensureAssignmentRecord,
|
||||
updateAllocationWithAudit,
|
||||
} from "./allocation-assignment-mutations.js";
|
||||
} from "./assignment-mutations.js";
|
||||
import {
|
||||
managerProcedure,
|
||||
requirePermission,
|
||||
} from "../trpc.js";
|
||||
} from "../../trpc.js";
|
||||
|
||||
export const allocationAssignmentProcedures = {
|
||||
create: managerProcedure
|
||||
+2
-2
@@ -6,8 +6,8 @@ import {
|
||||
calculateEffectiveDayAvailability,
|
||||
countEffectiveWorkingDays,
|
||||
loadResourceDailyAvailabilityContexts,
|
||||
} from "../lib/resource-capacity.js";
|
||||
import { averagePerWorkingDay, round1, toIsoDate } from "./allocation-shared.js";
|
||||
} from "../../lib/resource-capacity.js";
|
||||
import { averagePerWorkingDay, round1, toIsoDate } from "./shared.js";
|
||||
|
||||
export async function buildResourceAvailabilityView(
|
||||
db: Pick<import("@capakraken/db").PrismaClient, "resource" | "assignment" | "vacation" | "holidayCalendar">,
|
||||
+6
-6
@@ -11,28 +11,28 @@ import {
|
||||
UpdateDemandRequirementSchema,
|
||||
} from "@capakraken/shared";
|
||||
import { z } from "zod";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { findUniqueOrThrow } from "../../db/helpers.js";
|
||||
import {
|
||||
emitAllocationCreated,
|
||||
emitAllocationDeleted,
|
||||
emitAllocationUpdated,
|
||||
} from "../sse/event-bus.js";
|
||||
} from "../../sse/event-bus.js";
|
||||
import {
|
||||
checkBudgetThresholdsInBackground,
|
||||
createDemandRequirementWithEffects,
|
||||
dispatchAllocationWebhookInBackground,
|
||||
fillDemandRequirementWithEffects,
|
||||
invalidateDashboardCacheInBackground,
|
||||
} from "./allocation-effects.js";
|
||||
import { DEMAND_INCLUDE } from "./allocation-shared.js";
|
||||
} from "./effects.js";
|
||||
import { DEMAND_INCLUDE } from "./shared.js";
|
||||
import {
|
||||
buildCreateDemandRequirementInput,
|
||||
getDemandRequirementByIdOrThrow,
|
||||
} from "./allocation-support.js";
|
||||
} from "./support.js";
|
||||
import {
|
||||
managerProcedure,
|
||||
requirePermission,
|
||||
} from "../trpc.js";
|
||||
} from "../../trpc.js";
|
||||
|
||||
export const allocationDemandProcedures = {
|
||||
createDemandRequirement: managerProcedure
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
import { createDemandRequirement, fillDemandRequirement } from "@capakraken/application";
|
||||
import { buildTaskAction, CreateDemandRequirementSchema, FillDemandRequirementSchema } from "@capakraken/shared";
|
||||
import { z } from "zod";
|
||||
import { checkBudgetThresholds } from "../lib/budget-alerts.js";
|
||||
import { generateAutoSuggestions } from "../lib/auto-staffing.js";
|
||||
import { invalidateDashboardCache } from "../lib/cache.js";
|
||||
import { logger } from "../lib/logger.js";
|
||||
import { dispatchWebhooks } from "../lib/webhook-dispatcher.js";
|
||||
import { emitAllocationCreated, emitAllocationUpdated, emitNotificationCreated } from "../sse/event-bus.js";
|
||||
import { checkBudgetThresholds } from "../../lib/budget-alerts.js";
|
||||
import { generateAutoSuggestions } from "../../lib/auto-staffing.js";
|
||||
import { invalidateDashboardCache } from "../../lib/cache.js";
|
||||
import { logger } from "../../lib/logger.js";
|
||||
import { dispatchWebhooks } from "../../lib/webhook-dispatcher.js";
|
||||
import { emitAllocationCreated, emitAllocationUpdated, emitNotificationCreated } from "../../sse/event-bus.js";
|
||||
|
||||
export function runAllocationBackgroundEffect(
|
||||
effectName: string,
|
||||
@@ -0,0 +1,10 @@
|
||||
import { allocationAssignmentProcedures } from "./assignment-procedures.js";
|
||||
import { allocationDemandProcedures } from "./demand.js";
|
||||
import { allocationReadProcedures } from "./read.js";
|
||||
import { createTRPCRouter } from "../../trpc.js";
|
||||
|
||||
export const allocationRouter = createTRPCRouter({
|
||||
...allocationReadProcedures,
|
||||
...allocationDemandProcedures,
|
||||
...allocationAssignmentProcedures,
|
||||
});
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
import { AllocationStatus } from "@capakraken/shared";
|
||||
import { z } from "zod";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { anonymizeResource, getAnonymizationDirectory } from "../lib/anonymization.js";
|
||||
import { planningReadProcedure } from "../trpc.js";
|
||||
import { buildResourceAvailabilitySummary, buildResourceAvailabilityView } from "./allocation-availability.js";
|
||||
import { ASSIGNMENT_INCLUDE, DEMAND_INCLUDE } from "./allocation-shared.js";
|
||||
import { getDemandRequirementByIdOrThrow, loadAllocationReadModel, resolveAssignmentBySelection } from "./allocation-support.js";
|
||||
import { findUniqueOrThrow } from "../../db/helpers.js";
|
||||
import { anonymizeResource, getAnonymizationDirectory } from "../../lib/anonymization.js";
|
||||
import { planningReadProcedure } from "../../trpc.js";
|
||||
import { buildResourceAvailabilitySummary, buildResourceAvailabilityView } from "./availability.js";
|
||||
import { ASSIGNMENT_INCLUDE, DEMAND_INCLUDE } from "./shared.js";
|
||||
import { getDemandRequirementByIdOrThrow, loadAllocationReadModel, resolveAssignmentBySelection } from "./support.js";
|
||||
|
||||
export const allocationReadProcedures = {
|
||||
list: planningReadProcedure
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { AllocationStatus, UpdateAllocationSchema } from "@capakraken/shared";
|
||||
import { z } from "zod";
|
||||
import { PROJECT_BRIEF_SELECT, RESOURCE_BRIEF_SELECT, ROLE_BRIEF_SELECT } from "../db/selects.js";
|
||||
import { PROJECT_BRIEF_SELECT, RESOURCE_BRIEF_SELECT, ROLE_BRIEF_SELECT } from "../../db/selects.js";
|
||||
|
||||
export const DEMAND_INCLUDE = {
|
||||
project: { select: PROJECT_BRIEF_SELECT },
|
||||
+3
-3
@@ -2,9 +2,9 @@ import { buildSplitAllocationReadModel, loadAllocationEntry } from "@capakraken/
|
||||
import { AllocationStatus, CreateDemandRequirementSchema } from "@capakraken/shared";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { z } from "zod";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { anonymizeResource, getAnonymizationDirectory } from "../lib/anonymization.js";
|
||||
import { ASSIGNMENT_INCLUDE, type AllocationEntryUpdateInput, type AllocationListFilters, type AssignmentResolutionInput, type CreateDemandDraftInput, DEMAND_INCLUDE, toIsoDate } from "./allocation-shared.js";
|
||||
import { findUniqueOrThrow } from "../../db/helpers.js";
|
||||
import { anonymizeResource, getAnonymizationDirectory } from "../../lib/anonymization.js";
|
||||
import { ASSIGNMENT_INCLUDE, type AllocationEntryUpdateInput, type AllocationListFilters, type AssignmentResolutionInput, type CreateDemandDraftInput, DEMAND_INCLUDE, toIsoDate } from "./shared.js";
|
||||
|
||||
export function toDemandRequirementUpdateInput(input: AllocationEntryUpdateInput) {
|
||||
return {
|
||||
@@ -49,7 +49,7 @@ import { experienceMultiplierRouter } from "./experience-multiplier.js";
|
||||
import { dashboardRouter } from "./dashboard.js";
|
||||
import { insightsRouter } from "./insights.js";
|
||||
import { scenarioRouter } from "./scenario.js";
|
||||
import { allocationRouter } from "./allocation.js";
|
||||
import { allocationRouter } from "./allocation/index.js";
|
||||
import { staffingRouter } from "./staffing.js";
|
||||
import { advancedTimelineToolDefinitions, createAdvancedTimelineExecutors } from "./assistant-tools/advanced-timeline.js";
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createTRPCRouter } from "../trpc.js";
|
||||
import { allocationRouter } from "./allocation.js";
|
||||
import { allocationRouter } from "./allocation/index.js";
|
||||
import { assistantRouter } from "./assistant.js";
|
||||
import { auditLogRouter } from "./audit-log.js";
|
||||
import { calculationRuleRouter } from "./calculation-rules.js";
|
||||
|
||||
Reference in New Issue
Block a user