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>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { validateCustomFields } from "@capakraken/engine";
|
|
import { BlueprintTarget, type BlueprintFieldDefinition } from "@capakraken/shared";
|
|
import { TRPCError } from "@trpc/server";
|
|
import { findUniqueOrThrow } from "../db/helpers.js";
|
|
|
|
interface BlueprintLookup {
|
|
blueprint: {
|
|
findUnique: (args: {
|
|
where: { id: string };
|
|
select: { fieldDefs: true; target: true };
|
|
}) => Promise<{ fieldDefs: unknown; target: string } | null>;
|
|
};
|
|
}
|
|
|
|
interface AssertBlueprintDynamicFieldsInput {
|
|
db: BlueprintLookup;
|
|
blueprintId: string | undefined;
|
|
dynamicFields: Record<string, unknown>;
|
|
target: BlueprintTarget;
|
|
}
|
|
|
|
export async function assertBlueprintDynamicFields({
|
|
db,
|
|
blueprintId,
|
|
dynamicFields,
|
|
target,
|
|
}: AssertBlueprintDynamicFieldsInput): Promise<void> {
|
|
if (!blueprintId) return;
|
|
|
|
const blueprint = await findUniqueOrThrow(
|
|
db.blueprint.findUnique({
|
|
where: { id: blueprintId },
|
|
select: { fieldDefs: true, target: true },
|
|
}),
|
|
"Blueprint",
|
|
);
|
|
|
|
if (blueprint.target !== target) {
|
|
throw new TRPCError({
|
|
code: "BAD_REQUEST",
|
|
message: `${target} entities require a ${target.toLowerCase()} blueprint`,
|
|
});
|
|
}
|
|
|
|
const fieldDefs = blueprint.fieldDefs as BlueprintFieldDefinition[];
|
|
const errors = validateCustomFields(fieldDefs, dynamicFields);
|
|
|
|
if (errors.length > 0) {
|
|
throw new TRPCError({
|
|
code: "UNPROCESSABLE_CONTENT",
|
|
message: errors.map((error) => error.message).join("; "),
|
|
});
|
|
}
|
|
}
|