Domain service classes for business logic orchestration. Services extend BaseService from @repo/base-service, so their perform() methods return Safe<T> results. The package currently includes services for chart review and other domain operations.
Use a service when logic should be decoupled from tRPC (or other transports): the same orchestration can be called from a router, a script, a job, or tests without importing @repo/trpc.
Services are a good fit when you want to:
@repo/db (or peers) and calling perform() or the functionify export, without spinning up tRPC.tRPC procedures should stay thin: validate input, call the service, map Safe errors to TRPCError (or similar), and return result.data.
graph TD
services["@repo/services"]
base_service["@repo/base-service"]
safe["@repo/safe"]
db["@repo/db"]
typescript_config["@repo/typescript-config"]
vitest_config["@repo/vitest-config"]
services --> base_service
services --> safe
services --> db
services -.-> typescript_config
services -.-> vitest_configimport { listRecentPatientReviewRunsService } from "@repo/services/chart-review/listRecentPatientReviewRuns.service";
import { runChartReviewService } from "@repo/services/chart-review/runChartReview.service";
const recent = await listRecentPatientReviewRunsService({ patientId: "123" });
if (recent.error) {
// handle error
}
const chartReview = await runChartReviewService({ patientId: "123", templateId: 1 });
if (chartReview.error) {
// handle error
}
| Script | Description |
|---|---|
test |
Run Vitest with coverage |
test:watch |
Run Vitest in watch mode |
check-types |
Typecheck with tsc --noEmit |