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

@auto-engineer/message-store

v1.10.0

Published

Message store for commands and events with pluggable backends

Readme

@auto-engineer/message-store

Message store for persisting commands and events with stream-based storage and session tracking.


Purpose

Without @auto-engineer/message-store, you would have to implement your own stream-based message persistence, handle revision tracking, manage sessions, and implement filtering across message types.

This package provides a persistence layer for CQRS/Event Sourcing architectures. It supports stream-based storage with revision tracking, session management, flexible filtering, optimistic concurrency control, and global position tracking.


Installation

pnpm add @auto-engineer/message-store

Quick Start

import { MemoryMessageStore } from '@auto-engineer/message-store';

const store = new MemoryMessageStore();

await store.saveMessage('user-commands', {
  type: 'CreateUser',
  data: { name: 'Alice', email: '[email protected]' },
  requestId: 'req-123',
});

const messages = await store.getMessages('user-commands');
console.log(messages);
// → [{ streamId: 'user-commands', message: {...}, revision: 0n, position: 1n, ... }]

How-to Guides

Save Messages to a Stream

import { MemoryMessageStore } from '@auto-engineer/message-store';

const store = new MemoryMessageStore();

await store.saveMessage('orders-123', {
  type: 'OrderPlaced',
  data: { orderId: 'ord-001', total: 99.99 },
});

Use Sessions

const store = new MemoryMessageStore();

const sessionId = await store.createSession();
await store.saveMessage('commands', { type: 'StartProcess', data: {} });
await store.saveMessage('events', { type: 'ProcessStarted', data: {} });

const sessionMessages = await store.getSessionMessages(sessionId);
await store.endSession(sessionId);

Filter Messages

const recentCommands = await store.getAllCommands({
  fromTimestamp: new Date(Date.now() - 3600000),
  messageNames: ['CreateUser', 'UpdateUser'],
});

const correlatedMessages = await store.getAllMessages({
  correlationId: 'corr-456',
});

Use Optimistic Concurrency

await store.saveMessage('orders-123', command1); // revision becomes 0

try {
  await store.saveMessage('orders-123', command2, BigInt(-1));
} catch (err) {
  // "Expected revision -1 but stream is at revision 0"
}

API Reference

Package Exports

import {
  MemoryMessageStore,
  type IMessageStore,
  type ILocalMessageStore,
  type Message,
  type PositionalMessage,
  type MessageFilter,
  type StreamInfo,
  type SessionInfo,
} from '@auto-engineer/message-store';

IMessageStore Interface

| Method | Description | |--------|-------------| | saveMessage(streamId, message, expectedRevision?) | Save a single message | | saveMessages(streamId, messages, expectedRevision?) | Save multiple messages | | getMessages(streamId, fromRevision?, count?) | Get messages from stream | | getAllMessages(filter?, count?) | Get all messages with filtering | | getAllCommands(filter?, count?) | Get all commands | | getAllEvents(filter?, count?) | Get all events | | getStreamInfo(streamId) | Get stream metadata | | getStreams() | Get all stream IDs | | getSessions() | Get all session info | | getStats() | Get storage statistics |

PositionalMessage

interface PositionalMessage {
  streamId: string;
  message: Message;
  messageType: 'command' | 'event';
  revision: bigint;
  position: bigint;
  timestamp: Date;
  sessionId: string;
}

MessageFilter

interface MessageFilter {
  messageType?: 'command' | 'event';
  messageNames?: string[];
  streamId?: string;
  sessionId?: string;
  correlationId?: string;
  fromPosition?: bigint;
  toPosition?: bigint;
  fromTimestamp?: Date;
  toTimestamp?: Date;
}

Architecture

src/
├── index.ts
├── types.ts
└── MemoryMessageStore.ts

Key Concepts

  • Stream-based storage: Messages organized by streamId
  • Global positioning: Monotonically increasing position across streams
  • Session tracking: Group related messages together
  • Optimistic concurrency: expectedRevision parameter

Dependencies

| Package | Usage | |---------|-------| | @auto-engineer/message-bus | Command and Event types | | debug | Debug logging | | nanoid | Session ID generation |