Extracted a shared mapSessionRow(session, userOrgMapping, configData) helper into apps/apollo/src/lib/toolRouterV2/features/session/dbUtils/mapSessionRow.ts. This removes the duplicated ToolRouterSession assembly block that previously lived inline in both:
DB_TOOL_ROUTER_SESSION_CREATE.new (createToolRouterSession.ts)DB_TOOL_ROUTER_SESSION_GET.byNanoId (getToolRouterSession.ts)Both call sites built the exact same Ok({ id, configVersion, config: {...16 fields...}, projectId, orgMemberId, userId, project, user, org }) object, differing only in the local variable name for the validated config (config in create, data in get). The helper takes the already-validated ToolRouterConfigDB so callers remain responsible for ToolRouterConfigDBSchema.safeParse() before mapping (create validates data.config; get validates session.config).
A SessionRowInput type models the minimal Prisma row shape both call sites provide (the include/select on project { id, nanoId, autoId, orgId, org { nanoId } } and orgMember { id, email }). The redundant per-file imports (ConnectedAccountNanoId, ProjectAutoId, ToolRouterSessionNanoId in create, and normalizeConnectedAccountOverrides) were removed from the two call sites and now live only in the helper. Behaviour is byte-for-byte equivalent: every field mapping, default (?? true / ?? false), and the normalizeConnectedAccountOverrides call are preserved unchanged.
Note: dbConfigToResponseConfig/toSessionResponse in util/sessionResponse.ts are intentionally NOT folded in — they produce the camelCase API-response DTO (a different shape), not the internal ToolRouterSession.
node_modules is not installed in the review worktree, so local typecheck/tests were not run; relying on CI check-types and run-vitest-tests.config/data -> configData rename (zero behavioural difference).SessionRowInput matches the Prisma payload field-by-field (Project.autoId: Int, id/orgId/nanoId: String, Users.id/email: String), and that the UserOrgMappingItem param matches the UserOrgMapping.DB.get.mapping() return type.OrgNanoId, ProjectNanoId, UUID, ToolRouterSessionNanoId, ToolRouterSession) are still referenced.mapSessionRow.test.ts (Vitest, colocated): 19 cases covering id/project/user/org mapping, manageConnections defaults, workbench/preload/search/execute/multiAccount/experimental, and normalizeConnectedAccountOverrides (single-string -> array, undefined -> undefined). Each assertion was simulated against the implementation.🤖 Generated with Claude Code