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

@patternmeshjs/streams

v0.9.1

Published

Typed DynamoDB Streams decoding utilities for @patternmeshjs/core entities.

Readme

@patternmeshjs/streams

npm version License: Apache-2.0 CI Docs

Typed DynamoDB Streams decoding for @patternmeshjs/core entity shapes.

This package is intentionally small: decode stream records, enforce stream view contracts, and route by entity discriminator.

Install

pnpm add @patternmeshjs/streams

Requirements:

  • Node 18+
  • ESM-only
  • no @types/aws-lambda dependency is required for consumers

Exports

  • decodeStreamRecord(record, options)
  • decodeStreamEvent(event, options)
  • handleStreamByEntity(event, options)
  • isTtlRemove(record)
  • StreamDecodeError
  • StreamViewTypeError
  • UnknownEntityError

Example

import { decodeStreamEvent, isTtlRemove } from "@patternmeshjs/streams";

const decoded = decodeStreamEvent(event, {
  decoders: {
    User: (item) => item,
    Order: (item) => item,
  },
  requiredViewType: ["NEW_AND_OLD_IMAGES"],
  unknownEntityMode: "strict",
});

const ttlRemovals = event.Records.filter(isTtlRemove);

Lambda handler example

import type { DynamoDBStreamHandler } from "aws-lambda";
import { handleStreamByEntity } from "@patternmeshjs/streams";

export const handler: DynamoDBStreamHandler = async (event) => {
  await handleStreamByEntity(event, {
    decoders: {
      User: (item) => item,
    },
    requiredViewType: ["NEW_IMAGE", "NEW_AND_OLD_IMAGES"],
    handlers: {
      INSERT: async (evt) => {
        console.log("created", evt.entityName, evt.newItem);
      },
      MODIFY: async (evt) => {
        console.log("changed", evt.entityName, evt.oldItem, evt.newItem);
      },
      REMOVE: async (evt) => {
        console.log("removed", evt.entityName, evt.oldItem);
      },
    },
  });
};

View type rules

  • default requiredViewType is ["NEW_AND_OLD_IMAGES"]
  • set requiredViewType: "any" to opt out explicitly
  • newItem consumers typically want NEW_IMAGE or NEW_AND_OLD_IMAGES
  • oldItem consumers typically want OLD_IMAGE or NEW_AND_OLD_IMAGES
  • mismatches throw StreamViewTypeError

Unknown entity behavior

  • unknownEntityMode: "strict" is the default
  • strict mode throws UnknownEntityError
  • tolerant mode passes through the logical item without typed decoding

TTL behavior

DynamoDB TTL removals appear as service-originated REMOVE records. Use isTtlRemove(record) to distinguish them from user-initiated deletes.

Non-Lambda usage

The decode functions operate on the event shape, not on Lambda runtime globals. Anything that provides a DynamoDBStreamEvent-compatible object can use this package: Lambda, local tests, replay tools, or custom consumers.

Non-goals

  • shard polling / checkpoint orchestration
  • retry frameworks
  • cross-region stream abstractions
  • event bus or worker runtime management

Operational caveats

  • stream retention is typically up to 24 hours
  • ordering is shard-scoped, not global
  • KEYS_ONLY streams will fail by default unless you opt out with requiredViewType: "any"

See also