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

@astralibx/email-rule-engine

v14.0.3

Published

Email automation engine — thin wrapper over @astralibx/rule-engine with MJML rendering

Downloads

4,054

Readme

@astralibx/email-rule-engine

Email automation wrapper over @astralibx/rule-engine

npm version License: MIT

What This Package Does

@astralibx/email-rule-engine is a thin wrapper over @astralibx/rule-engine. It adds MJML rendering and email-specific Handlebars helpers (currency, formatDate) on top of the core rule engine, adapting the generic send adapter into an email-aware sendEmail adapter that receives rendered htmlBody and textBody instead of raw template output.

What It Adds Over Core

  • MJML to HTML conversion — body content is auto-wrapped in a full MJML structure and compiled to cross-client HTML
  • HTML to plain text conversion — a textBody is automatically generated from rendered HTML via html-to-text
  • currency Handlebars helper — formats numbers as INR (e.g. ₹1,234)
  • formatDate Handlebars helper — formats dates in en-IN locale (e.g. 19 Mar 2026)
  • sendEmail adapter mapping — converts the core's generic send adapter to an email-specific signature with htmlBody, textBody, and subject

Quick Start

import { createEmailRuleEngine } from '@astralibx/email-rule-engine';

const engine = createEmailRuleEngine({
  db: { connection },
  redis: { connection: redis },
  adapters: {
    queryUsers: async (target, limit) => {
      return User.find({ role: target.role }).limit(limit).lean();
    },
    resolveData: (user) => ({
      user: { name: user.name, email: user.email },
      platform: { name: 'MyApp', domain: 'myapp.com' },
    }),
    sendEmail: async (params) => {
      await transporter.sendMail({
        to: params.identifierId,
        subject: params.subject,
        html: params.htmlBody,
        text: params.textBody,
      });
    },
    selectAgent: async () => ({ accountId: 'default', contactValue: '[email protected]', metadata: {} }),
    findIdentifier: async (email) => {
      const contact = await Contact.findOne({ email });
      return contact ? { id: contact._id.toString(), contactId: contact._id.toString() } : null;
    },
  },
});

app.use('/api/email-rules', engine.routes);

Redis Key Prefix (Required for Multi-Project Deployments)

WARNING: If multiple projects share the same Redis server, set a unique keyPrefix per project. Without this, run locks and cancel flags will collide between projects.

const engine = createEmailRuleEngine({
  redis: { connection: redis, keyPrefix: 'myproject:' },
  // ...
});

Configuration

See docs/configuration.md for the EmailRuleEngineConfig interface and how sendEmail maps to the core's generic send.

Core Documentation

For templates, rules, conditions, collections, joins, throttling, hooks, and the full API reference, see the core documentation:

License

MIT