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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@horizon-apps/domain-schema-core

v1.4.2

Published

Core domain schema utilities for Horizon Platform - Schema generators, data enrichers, converters and specifications

Readme

@horizon-apps/domain-schema-core

Utilitários centrais para esquemas de domínio da Plataforma Horizon - Geradores de schema, enriquecedores de dados, conversores e especificações.

📦 Instalação

npm install @horizon-apps/domain-schema-core
# ou
pnpm add @horizon-apps/domain-schema-core

🚀 Módulos e Exemplos

🎨 Enriquecedor de Dados

Transforma dados brutos em objetos enriquecidos para UI com formatação e localização.

import { domainDataDisplayEnricher, formatters } from '@horizon-apps/domain-schema-core'

// Enriquecer dados com metadata
const enriched = domainDataDisplayEnricher({
  data: { valor_venda: 850000, dormitorios: 3, ativo: true },
  metadata: [
    { key: 'valor_venda', format: 'currency', unit: 'BRL' },
    { key: 'dormitorios', format: 'count' },
    { key: 'ativo', type: 'Boolean' }
  ]
})
// enriched.valor_venda.valueLabel = "R$ 850.000,00"
// enriched.ativo.valueLabel = "Sim"

// Formatadores individuais
formatters.currency(850000, 'BRL') // "R$ 850.000,00"

🔍 Filtros de Dados

Filtra campos por categoria ou chaves específicas (remove valores nulos/vazios).

import { getFieldsByCategory, getFieldsByKeys } from '@horizon-apps/domain-schema-core'

const fields = [
  { key: 'valor_venda', value: 850000, category: 'pricing' },
  { key: 'area_total', value: 120, category: 'dimensions' },
  { key: 'descricao', value: null, category: 'info' }
]

// Filtrar por categoria
const pricing = getFieldsByCategory(fields, 'pricing')
// [{ key: 'valor_venda', value: 850000, category: 'pricing' }]

// Filtrar por chaves (remove valores nulos)
const selected = getFieldsByKeys(fields, ['valor_venda', 'descricao'])
// [{ key: 'valor_venda', value: 850000, category: 'pricing' }]
// 'descricao' foi filtrado por ter value: null

🔄 Transformadores de Dados

Transforma estruturas (arrays para campos booleanos individuais, ordenação multi-campo).

import { expandArrayFieldToBoolean, sortFields } from '@horizon-apps/domain-schema-core'

// Expandir array para campos booleanos
const amenities = ['Piscina', 'Academia', 'Portaria 24h']
const booleanFields = expandArrayFieldToBoolean(amenities)
// [
//   { key: 'Piscina', value: true, type: 'Boolean', label: 'Piscina' },
//   { key: 'Academia', value: true, type: 'Boolean', label: 'Academia' },
//   { key: 'Portaria 24h', value: true, type: 'Boolean', label: 'Portaria 24h' }
// ]

// Ordenar por múltiplos campos
const properties = [
  { name: "Casa A", price: 300000, area: 120 },
  { name: "Casa B", price: 250000, area: 100 },
  { name: "Casa A", price: 280000, area: 110 }
]
const sorted = sortFields(properties, ["name:asc", "price:desc"])
// Resultado: Casa A (300k), Casa A (280k), Casa B (250k)

⚡ Gerador Zod

Converte schemas Horizon para validação Zod.

import { JsonToZodGenerator } from '@horizon-apps/domain-schema-core'

const fields = [
  { key: 'nome', type: 'String', validation: { required: true, maxLength: 100 } },
  { key: 'preco', type: 'Number', validation: { min: 0 } }
]

const zodCode = JsonToZodGenerator.generate(fields, {
  schemaName: 'Property'
})
// Gera código Zod: z.object({ nome: z.string().max(100), preco: z.number().min(0).optional() })

🔧 Desenvolvimento

# Instalar dependências
pnpm install

# Build
pnpm build

# Executar testes
pnpm test

# Verificação de tipos
pnpm typecheck

# Modo watch
pnpm dev

📄 Licença

MIT


Parte do ecossistema da Plataforma Horizon