types-slot-cars
v0.0.13
Published
TypeScript definitions and Zod schemas for slot-cars
Readme
Types Slot Cars
TypeScript type definitions and Zod schemas for slot car racing data.
Features
- Complete TypeScript definitions for slot cars, categories, and related entities
- Zod schemas for runtime validation
- Type-safe operations on slot car data
Installation
# Using Bun
bun add types-slot-cars
# Using npm
npm install types-slot-cars
# Using yarn
yarn add types-slot-carsUsage
Working with Car Schema
import { CarSchema, Car, CATEGORIES } from 'types-slot-cars';
// Create a car object
const car: Car = {
id: "123e4567-e89b-12d3-a456-426614174000",
name: "Mercedes-AMG GT3",
make: "Mercedes",
model: "AMG GT3",
brand: "Carrera",
year: 2020,
reference: "CA-27622",
scale: "1:32",
images: {
perspective_front: "https://example.com/images/mercedes-amg-front.jpg",
perspective_rear: "https://example.com/images/mercedes-amg-rear.jpg"
},
category: [CATEGORIES.MODERN_GT]
};
// Validate the car using Zod schema
const validatedCar = CarSchema.parse(car);
console.log(validatedCar);
// Type-check partial car data
const partialCarData: Partial<Car> = {
name: "Porsche 911 GT3",
brand: "Scalextric"
};Working with Categories
import { Category, CATEGORIES } from 'types-slot-cars';
// Available categories
console.log(Object.values(CATEGORIES));
// Output: ["Classic DTM", "Group C", "Classic", ...]
// Create a category
const category: Category = {
id: "550e8400-e29b-41d4-a716-446655440000",
name: CATEGORIES.RALLY,
description: "Modern rally cars from WRC and similar competitions"
};Development
Prerequisites
- Bun v0.6.0 or higher
- Git
Setup
- Clone the repository
- Install dependencies:
bun install - Build the package:
bun run build
Available Scripts
bun run build- Transpile TypeScript to JavaScriptbun run publish:patch- Publish a patch versionbun run publish:minor- Publish a minor versionbun run publish:major- Publish a major version
License
MIT
