chore(server): remove the MCP config re-export and the dormant row-shape helper

Only their own tests imported them. The MCP knobs are parsed in
app-config/parsers.ts, which tests them directly, and toCamelCase was never
wired into a plugin RPC handler.
This commit is contained in:
Maurice
2026-10-10 11:48:59 +02:00
parent 2050e796eb
commit db8babffc7
5 changed files with 1 additions and 247 deletions
+1 -3
View File
@@ -1,7 +1,6 @@
/**
* Pure env-string coercion helpers shared by the whole config layer (derive.ts,
* env.schema.ts) and — until their call sites migrate — by legacy readers like
* src/mcp/config.ts. Kept free of imports so units can test them in isolation.
* env.schema.ts). Kept free of imports so units can test them in isolation.
*
* Each helper reproduces a coercion family that already exists in the codebase.
* Parity is law: do NOT "fix" a family's quirks here (e.g. `numberOr` treating
@@ -102,7 +101,6 @@ export function parseDurationMs(value: string): number | null {
/**
* Session idle TTL in SECONDS via MCP_SESSION_TTL, default 1 hour, clamped to
* 24h so a milliseconds-value typo can't produce a 1000-hour session.
* (Same contract as src/mcp/config.ts, which commit 7 retires in favor of this.)
*/
export function resolveSessionTtlMs(raw: string | undefined): number {
const parsed = Number.parseInt(raw ?? '');
-7
View File
@@ -1,7 +0,0 @@
/**
* MCP tuning knobs from the environment (#1414). The parsers moved into the
* app-config layer (src/app-config/parsers.ts) — this module re-exports them
* so existing import paths keep working. mcp/index.ts consumes the derived
* values via readEnv().mcp.
*/
export { resolveSessionTtlMs, resolveKeepaliveMs } from '../app-config/parsers';
@@ -1,79 +0,0 @@
/**
* `toCamelCase` — the R-facade utility from Plan 3j's Task 6 (design spec D8, program
* `docs/superpowers/plans/2026-09-25-orm-phase3j-plugins.md`). It is DORMANT: built,
* tested and exported, but wired into ZERO of the 23 `*.rpc.ts` plugin-host handlers.
* `plugin-sdk/src/index.ts`'s published row types (`User`, `Place`, `Day`, `Reservation`,
* `PackingItem`, `TripFile`, `BudgetItem`, …) are snake_case today, and neither the SDK
* nor its tests carry any camelCase precedent — so applying this additively to a
* handler's return value would grow the plugin contract's visible surface with fields no
* published type, plugin author or test fixture expects, for no proven benefit. Whether
* TREK should start publishing camelCase copies going forward is a real product decision
* (see the plan's "For the user" note), not one an ORM-migration task makes unilaterally.
* This function exists so that decision, if it is ever made, is a one-line change at
* `HostSurfaceRpc#getUser`'s single return statement rather than new plumbing to design
* and land. It is a pure function — no class, no DI, no constructor — matching the
* `num`/`str`/`asPayload` shape in the sibling `rpc-params.ts` every one of the 23
* `*.rpc.ts` files already imports the same way, specifically so it never ripples through
* `tests/helpers/plugin-host.ts`/`rpc-host-deps.ts`'s hand-construction of all 23 classes.
*
* Scope, operate ONLY on a DB-row-shaped object the HOST itself assembled (e.g.
* `SELECT id, username, display_name, avatar FROM users …`). NEVER apply it to an opaque
* JSON-text value a PLUGIN wrote and the host merely parsed (`MetaRpc#get`/`#list`'s
* values, a plugin's own `config`) — a generic key transform would silently rewrite keys
* inside that stored blob, which is exactly why a generic deep-key transform was rejected
* project-wide (design spec D1/D8).
*/
/**
* Returns a shallow, additive camelCase COPY of `value`'s keys: every key containing `_`
* gets a camelCase sibling holding the same value (`display_name` -> `displayName`,
* `content_base64` -> `contentBase64`); the original snake_case key is never removed or
* replaced. A key with no underscore is left exactly as it is — no identity-transform
* copy is ever added for it. The conversion is ONE level deep only: a nested object, a
* `Date`, a `Buffer` or any other VALUE under a key is passed through completely
* unchanged (never recursed into, never spread) — only the row's own TOP-LEVEL key names
* are touched. This is the scope choice inventory §13 flagged as an open ambiguity in the
* design spec's "shallow" wording; a future caller wiring this in should expect a
* `user_profile: { first_name: 'A' }` row to gain `userProfile` pointing at the SAME
* nested object, with `first_name` inside it untouched — never a recursively-mapped
* `userProfile: { firstName: 'A' }`.
*
* An array is mapped element-wise, each element run back through `toCamelCase`. `null`,
* `undefined`, a `Date`, a `Buffer` and any other non-plain-object value passed as the
* top-level argument pass through completely unchanged, defensively — a caller mistake
* here (this is never called with anything but a row object in the codebase today, since
* it is unwired) must not throw into an RPC dispatch.
*/
export function toCamelCase<T extends Record<string, unknown>>(value: readonly T[]): (T & Record<string, unknown>)[];
export function toCamelCase<T extends Record<string, unknown>>(value: T): T & Record<string, unknown>;
export function toCamelCase<V>(value: V): V;
export function toCamelCase(value: unknown): unknown {
if (Array.isArray(value)) return value.map((item) => toCamelCase(item));
if (
value === null ||
typeof value !== 'object' ||
value instanceof Date ||
Buffer.isBuffer(value)
) {
return value;
}
const row = value as Record<string, unknown>;
const camelCopies: Record<string, unknown> = {};
for (const key of Object.keys(row)) {
if (!key.includes('_')) continue;
const camelKey = snakeKeyToCamel(key);
if (camelKey !== key) camelCopies[camelKey] = row[key];
}
return { ...row, ...camelCopies };
}
/**
* `display_name` -> `displayName`; `content_base64` -> `contentBase64`. A digit right
* after an underscore follows the same rule and needs no special case — uppercasing a
* digit is a no-op, so `place_2_id` -> `place2Id`.
*/
function snakeKeyToCamel(key: string): string {
return key.replace(/_([a-zA-Z0-9])/g, (_match, char: string) => char.toUpperCase());
}