types

Generate TypeScript types and mapper functions for Prisma API responses.

Updated Apr 16, 2025
One-click install
npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill types-teexiii
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: types
Source: https://github.com/teexiii/boilerplate-rest-bun-for-noob/tree/main/.agent/skills/types
Command: npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill types-teexiii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Centralizes and standardizes TypeScript type definitions, input/update/query shapes, and mapper functions for Prisma-backed APIs to reduce duplication, runtime type errors, and inconsistent API contracts.

Core Features & Use Cases

  • Extended Prisma Types: Define model types with nested relations and omit sensitive fields for API exposure.
  • Input & Response Interfaces: Provide clear create/update input shapes and flattened, consumer-friendly response contracts.
  • Mapper Functions: Convert internal/database types into API responses, handle nested arrays, optional relations, and date serialization.
  • Use Case: Turn complex Prisma query results with nested relations into stable API response objects for frontend consumption.

Quick Start

Convert a Prisma user record with nested relations into a UserResponse using the toUserResponse mapper.

Frequently Asked Questions about types

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate TypeScript types and mappers for Prisma API responses?

Generate TypeScript types and mappers for Prisma API responses by defining extended model types, creating input/update shapes, and using mapping functions to flatten nested relations and serialize dates for frontend consumption.

What is the best way to flatten nested Prisma relations for API output?

Flatten nested Prisma relations for API output by applying mapper functions that transform internal database records into stable response interfaces, handling optional relations and nested arrays to ensure consistent API contracts.

How do I omit sensitive fields from Prisma models in TypeScript?

Omit sensitive fields from Prisma models in TypeScript by defining extended types that exclude specific fields, creating consumer-friendly response interfaces that prevent unauthorized data exposure in your API contracts.

Does this approach work with backend TypeScript projects using Prisma?

Yes, this approach works directly with backend TypeScript projects using Prisma, providing type definitions and mapping functions to standardize API contracts, reduce duplication, and prevent runtime type errors.

How do I handle ISO date formatting when mapping Prisma types to API responses?

Handle ISO date formatting when mapping Prisma types to API responses by using mapper functions that serialize date fields during the conversion from internal database types to flattened API response objects.