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

@mrktg-common/brands-core

v2.0.0

Published

Контракт реестра white-label брендов: типы и функции, не знающие ни одного конкретного бренда. Данные — в региональных репозиториях.

Readme

@mrktg-common/brands-core

Контракт реестра white-label брендов: форма данных и функции над ней. Здесь нет ни одного конкретного бренда, региона, хоста, провайдера или урла — это правило репозитория. Данные живут в региональных репозиториях, каждый собирает свой реестр отсюда.

Исходник — один index.ts. Рядом закоммичен dist/ (index.js + index.d.ts): нода отказывается стрипать типы из файлов под node_modules, поэтому чистый .ts как зависимость работает только через бандлер. Собирает dist автор при изменении (npm run build), потребители ничего не собирают. Тест test/dist.test.ts не даст закоммитить исходник без пересборки.

Подключение

npm i @mrktg-common/brands-core

Ставится из публичного npm, ssh-доступ к GitLab потребителям и раннерам CI больше не нужен. Пакет публикуется собранным: в тарболе только dist/ и этот файл.

Использование в региональном репозитории

import { createRegistry, type IBrand, type IRegion } from '@mrktg-common/brands-core';

type TBrandId = 'alpha' | 'beta-b2b';
type TRegionId = 'north';

// Региональные расширения контракта — здесь, не в core
interface IMyRegion extends IRegion<TRegionId> {
  componentsPackage: string;
}

const REGIONS: Record<TRegionId, IMyRegion> = { north: { id: 'north', host: 'https://…', bucketHost: 'https://…', componentsPackage: '…' } };
const BRANDS: readonly IBrand<TBrandId, TRegionId>[] = [ /* … */ ];

export const registry = createRegistry({ regions: REGIONS, brands: BRANDS });
// registry.getBrand('alpha'), registry.resolveBrand('www.alpha.example'), registry.brandsByRegion('north') …

createRegistry() сначала прогоняет validateRegistry() и падает со списком нарушений, поэтому ошибочные данные не запустятся. В тестах регионального репозитория достаточно assert.deepEqual(validateRegistry(data), []).

Контракт

IBrand: id (название бренда в kebab-case без сокращений — единственное написание в коде), slug (короткое неизменяемое имя для путей и имён файлов инфраструктуры: папки сборок на CDN, папки пакетов; на него ссылаются опубликованные адреса, поэтому при смене id он остаётся прежним), region, title.en / title.ru, siteHost (без протокола, с www. если сайт его использует), siteLang (BCP 47), favicon (href, type), aliases (старые написания id, которые ещё живут в данных).

IRegion: id, host (публичный хост ассетов, без путей), bucketHost (хост бакета минуя CDN; без CDN равен host).

Оба интерфейса расширяются в региональном репозитории. Правило простое: если полю нужно конкретное значение из реальной инфраструктуры, ему не место в core.

IRegistry: brands, regions, brandIds, isBrandId, getBrand, getRegion, getBrandRegion, brandsByRegion, resolveBrand (id, slug, alias или хост сайта; регистр и www. не важны), siteUrl.

Проверки validateRegistry

  • id и slug уникальны и в kebab-case, регион существует, ключ регионов совпадает с id
  • alias не повторяется; slug и alias не совпадают с чужим id, alias или slug — иначе resolveBrand неоднозначен
  • host, bucketHost — https:// без пути; siteHost — без протокола и пути
  • siteLang — BCP 47; favicon.href — https://, favicon.type задан
  • title.en и title.ru заполнены

Разработка

npm test          # build + node --test (проверяет и что dist не отстал)
npm run typecheck

Релиз: npm run build, коммит вместе с dist/, npm version X.Y.Z, git push --follow-tags, npm publish. Права на публикацию — у участников организации mrktg; локально достаточно npm login, токен ляжет в ~/.npmrc и в репозиторий не попадёт.

Только стираемый синтаксис TypeScript: без enum, namespace и parameter properties — иначе нода не запустит файл напрямую.