npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

perfumario-schemas

v2.0.0

Published

A package that contains all the schemas that will be used by both the frontend and backend of Perfumario

Readme

Perfumario Schemas

Un paquete npm que contiene todos los schemas y tipos que serán utilizados tanto en el frontend como en el backend de Perfumario.

Instalación

npm install perfumario-schemas

Uso

Importar schemas y tipos

import {
  PerfumeSchema,
  type Perfume,
  type PerfumeWithBrand,
  BrandSchema,
  type Brand,
  type Gender,
  validatePerfume,
  validatePartialPerfume,
  validateBrand,
  validatePartialBrand,
} from "perfumario-schemas";

Validación con Zod

Validación completa

import { validatePerfume, validateBrand } from "perfumario-schemas";

// Validar datos de entrada (para creación - id, createdAt, updatedAt son opcionales)
const perfumeData = {
  name: "Chanel No. 5",
  gender: "female", // "male", "female", o "unisex"
  brandId: "123e4567-e89b-12d3-a456-426614174002", // ID de la marca
  stock: 50,
  // id, createdAt, updatedAt son opcionales y se pueden omitir
};

// Validar perfume completo
const result = validatePerfume(perfumeData);

if (result.success) {
  console.log("Datos válidos:", result.data);
} else {
  console.error("Errores de validación:", result.error.errors);
}

Validación parcial (para actualizaciones)

import {
  validatePartialPerfume,
  validatePartialBrand,
} from "perfumario-schemas";

// Validar solo algunos campos (útil para actualizaciones)
const partialPerfumeData = {
  name: "Nuevo nombre",
  stock: 25,
};

const partialResult = validatePartialPerfume(partialPerfumeData);

if (partialResult.success) {
  console.log("Datos parciales válidos:", partialResult.data);
} else {
  console.error("Errores de validación:", partialResult.error.errors);
}

Validación de marcas

import { validateBrand } from "perfumario-schemas";

// Validar marca (id es opcional)
const brandData = {
  name: "Nueva Marca", // id se genera automáticamente
};

const brandResult = validateBrand(brandData);

if (brandResult.success) {
  console.log("Marca válida:", brandResult.data);
} else {
  console.error("Errores de validación:", brandResult.error.errors);
}

Uso de tipos TypeScript

import {
  type Perfume,
  type PerfumeWithBrand,
  type Brand,
  type Gender,
} from "perfumario-schemas";

// Para almacenamiento (usa brandId)
function createPerfume(perfume: Perfume): void {
  console.log(
    `Creando perfume: ${perfume.name} con marca ID: ${perfume.brandId}`,
  );
}

// Para presentación (usa objeto brand completo)
function displayPerfume(perfume: PerfumeWithBrand): void {
  console.log(
    `Perfume: ${perfume.name} de ${perfume.brand.name} para ${perfume.gender}`,
  );
}

// Ejemplo de uso del tipo Gender
const targetGender: Gender = "unisex"; // "male" | "female" | "unisex"

// Ejemplo de creación de perfume (campos opcionales omitidos)
const newPerfume: Perfume = {
  name: "Nuevo Perfume",
  gender: "female",
  brandId: "uuid-de-la-marca", // ID de la marca
  stock: 10,
  // id, createdAt, updatedAt son opcionales
};

// Ejemplo de perfume con objeto brand completo (para presentación)
const perfumeWithBrand: PerfumeWithBrand = {
  id: "uuid-del-perfume",
  name: "Nuevo Perfume",
  gender: "female",
  brand: { id: "uuid-de-la-marca", name: "Marca" },
  stock: 10,
  createdAt: new Date(),
  updatedAt: new Date(),
};

Schemas disponibles

PerfumeSchema

  • id: UUID del perfume (opcional - se genera automáticamente)
  • name: Nombre del perfume (string, requerido)
  • gender: Género del perfume ("male" | "female" | "unisex", requerido)
  • brandId: UUID de la marca (requerido)
  • stock: Cantidad en stock (number, requerido)
  • createdAt: Fecha de creación (Date, opcional - se genera automáticamente)
  • updatedAt: Fecha de última actualización (Date, opcional - se genera automáticamente)

PerfumeWithBrand (Tipo)

  • Extiende Perfume pero reemplaza brandId con objeto brand completo
  • Útil para casos donde necesitas la información completa de la marca
  • Ideal para presentación de datos o APIs que requieren datos relacionados

BrandSchema

  • id: UUID de la marca (opcional - se genera automáticamente)
  • name: Nombre de la marca (string, requerido)

Gender (Tipo)

  • Union type: "male" | "female" | "unisex"
  • Representa las opciones de género disponibles para los perfumes

Funciones de validación

validatePerfume(perfume: unknown)

  • Valida un objeto perfume completo
  • Retorna ZodSafeParseResult<Perfume>
  • Útil para validar datos de entrada en APIs

validatePartialPerfume(perfume: unknown)

  • Valida un objeto perfume parcial (algunos campos opcionales)
  • Retorna ZodSafeParseResult<Partial<Perfume>>
  • Útil para validar actualizaciones parciales

validateBrand(brand: unknown)

  • Valida un objeto brand completo
  • Retorna ZodSafeParseResult<Brand> (tipado explícito)
  • Útil para validar datos de marca

validatePartialBrand(brand: unknown)

  • Valida un objeto brand parcial (algunos campos opcionales)
  • Retorna ZodSafeParseResult<Partial<Brand>>
  • Útil para validar actualizaciones parciales de marca

Desarrollo

Construir el proyecto

npm run build

Publicar el paquete

npm publish

Licencia

ISC