cd78f72f33
Complete rename of all technical identifiers across the codebase: Package names (11 packages): - @planarchy/* → @capakraken/* in all package.json, tsconfig, imports Import statements: 277 files, 548 occurrences replaced Database & Docker: - PostgreSQL user/db: planarchy → capakraken - Docker volumes: planarchy_pgdata → capakraken_pgdata - Connection strings updated in docker-compose, .env, CI CI/CD: - GitHub Actions workflow: all filter commands updated - Test database credentials updated Infrastructure: - Redis channel: planarchy:sse → capakraken:sse - Logger service name: planarchy-api → capakraken-api - Anonymization seed updated - Start/stop/restart scripts updated Test data: - Seed emails: @planarchy.dev → @capakraken.dev - E2E test credentials: all 11 spec files updated - Email defaults: @planarchy.app → @capakraken.app - localStorage keys: planarchy_* → capakraken_* Documentation: 30+ .md files updated Verification: - pnpm install: workspace resolution works - TypeScript: only pre-existing TS2589 (no new errors) - Engine: 310/310 tests pass - Staffing: 37/37 tests pass Co-Authored-By: claude-flow <ruv@ruv.net>
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import type { PrismaClient } from "@capakraken/db";
|
|
import {
|
|
AllocationStatus,
|
|
type FillDemandRequirementInput,
|
|
} from "@capakraken/shared";
|
|
import {
|
|
createAssignment,
|
|
type AssignmentWithRelations,
|
|
} from "./create-assignment.js";
|
|
import { applyDemandRequirementFillProgress } from "./apply-demand-requirement-fill-progress.js";
|
|
|
|
export interface DemandRequirementFillTarget {
|
|
id: string;
|
|
projectId: string;
|
|
startDate: Date;
|
|
endDate: Date;
|
|
hoursPerDay: number;
|
|
role: string | null;
|
|
roleId: string | null;
|
|
headcount: number;
|
|
metadata: unknown;
|
|
}
|
|
|
|
export interface FillDemandRequirementWithLegacySyncResult {
|
|
assignment: AssignmentWithRelations;
|
|
updatedDemandRequirement: Awaited<
|
|
ReturnType<typeof applyDemandRequirementFillProgress>
|
|
>;
|
|
}
|
|
|
|
export async function fillDemandRequirementWithLegacySync(
|
|
db: PrismaClient,
|
|
demandRequirement: DemandRequirementFillTarget,
|
|
input: FillDemandRequirementInput,
|
|
): Promise<FillDemandRequirementWithLegacySyncResult> {
|
|
const hoursPerDay = input.hoursPerDay ?? demandRequirement.hoursPerDay;
|
|
const percentage = Math.max(1, Math.min(100, Math.round((hoursPerDay / 8) * 100)));
|
|
|
|
return db.$transaction(async (tx) => {
|
|
const createdAssignment = await createAssignment(tx, {
|
|
demandRequirementId: demandRequirement.id,
|
|
resourceId: input.resourceId,
|
|
projectId: demandRequirement.projectId,
|
|
startDate: demandRequirement.startDate,
|
|
endDate: demandRequirement.endDate,
|
|
hoursPerDay,
|
|
percentage,
|
|
role: demandRequirement.role ?? undefined,
|
|
roleId: demandRequirement.roleId ?? undefined,
|
|
status: input.status ?? AllocationStatus.PROPOSED,
|
|
metadata: (demandRequirement.metadata as Record<string, unknown> | null) ?? {},
|
|
});
|
|
|
|
const updatedDemandRequirement = await applyDemandRequirementFillProgress(tx, {
|
|
demandRequirementId: demandRequirement.id,
|
|
headcount: demandRequirement.headcount,
|
|
});
|
|
|
|
return {
|
|
assignment: createdAssignment,
|
|
updatedDemandRequirement,
|
|
};
|
|
});
|
|
}
|