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

@pksep/contracts

v1.0.1

Published

Shared contracts for sep microservices RabbitMQ

Readme

@pksep/contracts

Unified messaging contracts for sep-chat microservices.

Exchange = домен. Routing key = entity.event. Суффикс .rpc только для request/reply.

import { ERP, routingKey } from '@pksep/contracts';

amqp.publish(ERP, routingKey('user', 'create'), event);
// exchange: 'erp', routing key: 'user.create'

Install

bun add @pksep/contracts

Architecture

| Exchange | Routing Key | Описание | |----------|-------------|----------| | erp | user.create | Новый пользователь | | erp | user.change | Изменение полей (field diff) | | erp | user.delete | Удаление | | erp | user.ban | Блокировка/разблокировка | | chat | message.new | Новое сообщение | | chat | message.edit | Редактирование | | chat | message.delete | Удаление сообщения | | chat.rpc | message.send | RPC: бот → сообщение | | chat.rpc | user.create | RPC: создать бота | | system | erp.release | Обновление ERP |

Wildcard

user.*       → все события user (create, change, delete, ban)
*.create     → все create в exchange
#            → всё

Examples

Create Event

import { ERP, routingKey, UserCreateEvent } from '@pksep/contracts';

const event: UserCreateEvent = {
  initiatorUserId: 'uuid-admin',
  timestamp: new Date().toISOString(),
  entity: {
    id: 'uuid-new-user',
    initials: 'Иванов И.И.',
    nickname: 'ivanov',
    isBot: false
  }
};

await amqp.publish(ERP, routingKey('user', 'create'), event);

Change Event (field-level diff)

import { ERP, routingKey, EntityChangeEvent } from '@pksep/contracts';

const event: EntityChangeEvent = {
  initiatorUserId: 'uuid-admin',
  timestamp: new Date().toISOString(),
  entity: {
    id: 'uuid-user',
    changeFields: [
      { fieldName: 'nickname', lastValue: 'old_nick', currentValue: 'new_nick' },
      { fieldName: 'avatarUrl', lastValue: null, currentValue: 'https://cdn.example.com/photo.jpg' }
    ]
  }
};

await amqp.publish(ERP, routingKey('user', 'change'), event);

Delete Event

import { ERP, routingKey, EntityDeleteEvent } from '@pksep/contracts';

const event: EntityDeleteEvent = {
  initiatorUserId: 'uuid-admin',
  timestamp: new Date().toISOString(),
  entity: { id: 'uuid-deleted-user' }
};

await amqp.publish(ERP, routingKey('user', 'delete'), event);

Ban Event

import { ERP, routingKey, EntityBanEvent } from '@pksep/contracts';

// Заблокировать
await amqp.publish(ERP, routingKey('user', 'ban'), {
  initiatorUserId: 'uuid-admin',
  timestamp: new Date().toISOString(),
  entity: { id: 'uuid-user', banned: true }
});

// Разблокировать — banned: false

Subscribe (NestJS + @golevelup/nestjs-rabbitmq)

import { ERP, wildcard, EntityCreateEvent, EntityChangeEvent, UserPayload } from '@pksep/contracts';

// Все user events
@RabbitSubscribe({
  exchange: ERP,
  routingKey: wildcard('user'),   // → 'user.*'
  queue: 'my-service.user-events'
})
handleUserEvent(event: EntityCreateEvent<UserPayload> | EntityChangeEvent) { ... }

// Только user.create
@RabbitSubscribe({
  exchange: ERP,
  routingKey: routingKey('user', 'create'),
  queue: 'my-service.user-created'
})
handleUserCreated(event: EntityCreateEvent<UserPayload>) { ... }

// Все create в ERP
@RabbitSubscribe({
  exchange: ERP,
  routingKey: '*.create',
  queue: 'audit.all-creates'
})
handleAnyCreate(event: EntityCreateEvent<{ id: string }>) { ... }

Chat Events

import { CHAT, MessageNewEvent } from '@pksep/contracts';

@RabbitSubscribe({
  exchange: CHAT,
  routingKey: 'message.new',
  queue: 'bot-gateway.chat-events'
})
handleNewMessage(event: MessageNewEvent) { ... }

Bot RPC Commands

import { CHAT_RPC, routingKey, SendMessagePayload, BotCommandResponse } from '@pksep/contracts';

const payload: SendMessagePayload = {
  senderUserId: 'uuid-bot',
  topicId: 'uuid-topic',
  text: 'Hello from bot!'
};

const result = await amqp.request<BotCommandResponse>({
  exchange: CHAT_RPC,
  routingKey: routingKey('message', 'send'),
  payload
});

System Events

import { SYSTEM, routingKey, ReleaseEvent } from '@pksep/contracts';

const release: ReleaseEvent = {
  service: 'erp',
  event: 'release',
  timestamp: new Date().toISOString(),
  data: { version: '2.1.0', severity: 'info' }
};

await amqp.publish(SYSTEM, routingKey('erp', 'release'), release);

Routing Helpers

import { routingKey, wildcard } from '@pksep/contracts';

routingKey('user', 'create')   // → 'user.create'
routingKey('message', 'new')   // → 'message.new'

wildcard('user')               // → 'user.*'
wildcard()                     // → '#'

Structure

src/
├── exchanges.ts        ← ERP, CHAT, CHAT_RPC, SYSTEM
├── routing.ts          ← routingKey(), wildcard()
├── types.ts            ← EntityEvent, FieldChange, SystemEvent, RpcResponse
├── chat/
│   ├── message.ts      ← MessageNewEvent, MessageEditEvent, ...
│   └── rpc.ts          ← SendMessagePayload, BotCommandResponse, queues
├── erp/
│   └── user.ts         ← UserPayload, UserCreateEvent, ...
└── system/
    └── events.ts       ← ReleaseEvent

Docs

  • doc/development-guide.md — архитектура, добавление сущностей/доменов, правила именования, чеклист

Publish

npm version patch
bun run build
npm publish --access restricted