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

@teracrafts/huefy-sdk-js

v2.1.4

Published

JavaScript/TypeScript SDK for Huefy - App Mail Templates with dynamic email sending

Readme

Huefy SDK for JavaScript/TypeScript

The official JavaScript/TypeScript SDK for Huefy - App Mail Templates. Create and manage email templates for your applications with dynamic data and multi-provider sending capabilities.

Installation

npm install @teracrafts/huefy-sdk-js

Quick Start

import { HuefyClient } from '@teracrafts/huefy-sdk-js';

const huefy = new HuefyClient({
  apiKey: 'your-api-key'
});

// Send an email
const result = await huefy.sendEmail('welcome-email', {
  name: 'John Doe',
  company: 'Acme Corp'
}, '[email protected]');

console.log('Email sent:', result.messageId);

Features

  • Type Safe - Full TypeScript support with comprehensive type definitions
  • Error Handling - Detailed error types with retry logic
  • Multiple Providers - Support for SES, SendGrid, Mailgun, Mailchimp
  • Retry Logic - Automatic retries with exponential backoff
  • Bulk Sending - Send multiple emails efficiently
  • Validation - Input validation for all parameters
  • Node.js & Browser - Works in both environments

Configuration

const huefy = new HuefyClient({
  apiKey: 'your-api-key',
  timeout: 30000, // Optional, default 30 seconds
  retryAttempts: 3, // Optional, default 3
  retryDelay: 1000, // Optional, default 1 second
});

Sending Emails

Basic Usage

// Send with default SES provider
await huefy.sendEmail('welcome-email', {
  name: 'John Doe',
  company: 'Acme Corp'
}, '[email protected]');

Custom Provider

// Send with specific provider
await huefy.sendEmail('newsletter', {
  name: 'Jane Smith',
  unsubscribe_url: 'https://app.example.com/unsubscribe'
}, '[email protected]', {
  provider: 'sendgrid'
});

Bulk Sending

const results = await huefy.sendBulkEmails([
  {
    templateKey: 'welcome-email',
    data: { name: 'John Doe' },
    recipient: '[email protected]'
  },
  {
    templateKey: 'welcome-email',
    data: { name: 'Jane Smith' },
    recipient: '[email protected]',
    options: { provider: 'mailgun' }
  }
]);

results.forEach(result => {
  if (result.success) {
    console.log(`Email sent to ${result.email}: ${result.result?.messageId}`);
  } else {
    console.error(`Failed to send to ${result.email}: ${result.error?.message}`);
  }
});

Error Handling

import { 
  HuefyError, 
  TemplateNotFoundError, 
  RateLimitError 
} from '@teracrafts/huefy';

try {
  await huefy.sendEmail('template-key', data, '[email protected]');
} catch (error) {
  if (error instanceof TemplateNotFoundError) {
    console.error('Template not found:', error.details.template_key);
  } else if (error instanceof RateLimitError) {
    console.error('Rate limit exceeded, retry after:', error.details.reset_at);
  } else if (error instanceof HuefyError) {
    console.error('Huefy API error:', error.code, error.message);
  } else {
    console.error('Unexpected error:', error);
  }
}

Event Callbacks

const huefy = new HuefyClient(config, {
  onSendStart: (request) => {
    console.log('Sending email:', request.template_key);
  },
  onSendSuccess: (response) => {
    console.log('Email sent successfully:', response.message_id);
  },
  onSendError: (error) => {
    console.error('Email send failed:', error.message);
  },
  onRetry: (attempt, error) => {
    console.log(`Retry attempt ${attempt}:`, error.message);
  }
});

Available Providers

  • ses - Amazon SES (default)
  • sendgrid - SendGrid
  • mailgun - Mailgun
  • mailchimp - Mailchimp

API Reference

HuefyClient

Constructor

  • new HuefyClient(config: HuefyConfig, callbacks?: HuefyEventCallbacks)

Methods

  • sendEmail(templateKey: string, data: EmailData, recipient: string, options?: SendEmailOptions): Promise<SendEmailResponse>
  • sendBulkEmails(emails: BulkEmailRequest[]): Promise<BulkEmailResult[]>
  • healthCheck(): Promise<HealthResponse>
  • validateTemplate(templateKey: string, testData: EmailData): Promise<boolean>
  • getConfig(): ClientConfig

Types

See the full type definitions for comprehensive TypeScript support.

Examples

Check out the examples directory for complete working examples.

Development

# Install dependencies
npm install

# Build the SDK
npm run build

# Run tests
npm test

# Run linter
npm run lint

# Type check
npm run typecheck

License

MIT - see LICENSE for details.