data-mapping

Transform raw API payloads into strongly-typed internal models with validation and type mapping.

6|Updated Feb 20, 2025
One-click install
npx skills add https://github.com/zerobias-org/module --skill data-mapping
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-mapping
Source: https://github.com/zerobias-org/module/tree/main/.claude/skills/data-mapping
Command: npx skills add https://github.com/zerobias-org/module --skill data-mapping

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Data mapping patterns enable transforming raw API responses into strongly-typed internal models, enforcing contracts and reducing runtime errors during data ingestion.

Core Features & Use Cases

  • Ensure required fields with consistent validation using ensureProperties()
  • Normalize optional fields with optional() to preserve legitimate falsy values
  • Convert and map primitive types with map() for DateTime, UUID, URL, and Email
  • Handle nested objects with mapWith() and dedicated helper mappers
  • Convert snake_case in API payloads to camelCase in code
  • Map enums with toEnum() for robust type safety in API integration
  • Support arrays by mapping items individually and applying appropriate type transforms

Quick Start

Provide a raw API response and request a strongly-typed model using to<Model> mappers to generate the internal representation.

Frequently Asked Questions about data-mapping

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

FAQPage Schema
How do I convert API responses to strongly-typed TypeScript models?

You can transform raw API payloads into strongly-typed internal models using a standardized mapper framework. This enforces required-field validation, type-specific mappings, and consistent type safety during data ingestion.

What's the best way to convert snake_case API payloads to camelCase in TypeScript?

Converting snake_case API payloads to camelCase is handled automatically during the model mapping process. This normalization ensures your internal codebase consistently uses camelCase while consuming snake_case data from external APIs.

How do I validate required fields and handle optional properties in API data mapping?

API data mapping validates required fields using ensureProperties() and normalizes optional fields with optional(). This preserves legitimate falsy values instead of treating them as missing, ensuring robust runtime validation.

Can I map nested objects and arrays from API responses to internal TypeScript models?

Yes, nested objects are handled with mapWith() and dedicated helper mappers, while arrays are supported by mapping items individually. This applies appropriate type transforms to deeply nested API structures.

How do I safely convert API string values to enums in TypeScript?

API string values are safely converted to enums using the toEnum() mapper. This provides robust type safety during API integration by ensuring only valid enum values are accepted into your internal models.

Do I need external dependencies to map primitive types like UUID and DateTime from API responses?

No external dependencies are required to map primitive types. The mapper framework includes built-in map() functions for converting DateTime, UUID, URL, and Email primitives directly from API payloads.