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

notification-typescript-sdk

v1.0.1

Published

TypeScript SDK for notification service

Readme

Notification TypeScript SDK

TypeScript SDK for sending notifications (email, SMS, WhatsApp) via the notification service API.

Installation

npm install notification-typescript-sdk

Features

  • Send emails and SMS messages
  • Template management
  • Connection pooling for optimal performance
  • Automatic snake_case ↔ camelCase conversion
  • Type-safe with full TypeScript support
  • Winston logging integration
  • Async and sync methods

Quick Start

import { 
  NotificationClient, 
  Notification, 
  PlatformEnum,
  PathParameters 
} from 'notification-typescript-sdk';

const client = new NotificationClient({
  targetHost: 'http://api.example.com',
  poolConfig: {
    maxTotal: 10,
    maxIdle: 8,
    minIdle: 2
  }
});

const notification = Notification.builder()
  .withCategory('email')
  .withMessage('Hello, this is a test email')
  .withPlatformId(PlatformEnum.ONESTEP)
  .withTo('[email protected]')
  .withFrom('[email protected]')
  .withSubject('Test Email')
  .withMessageType(0)
  .withNotifyType(1)
  .buildNotificationRequest();

const pathParams = new PathParameters(
  PlatformEnum.ONESTEP,
  'testuser',
  '0'
);

const result = await client.sendEmail(notification, pathParams);

if (result.data) {
  console.log('Email sent successfully:', result.data);
} else if (result.error) {
  console.error('Failed to send email:', result.error);
}

Configuration

NotificationClientConfig

interface NotificationClientConfig {
  targetHost: string;                    // API endpoint URL
  poolConfig?: Partial<ClientPoolConfig>; // Optional pool configuration
}

ClientPoolConfig

interface ClientPoolConfig {
  maxTotal: number;           // Maximum total connections
  maxIdle: number;            // Maximum idle connections
  minIdle: number;            // Minimum idle connections
  blockWhenExhausted: boolean; // Block when pool is exhausted
  maxWaitMillis?: number;     // Maximum wait time in milliseconds
}

API Reference

NotificationClient

sendEmail()

Send an email notification.

async sendEmail(
  notification: NotificationRequest,
  pathParameters: PathParameters
): Promise<HttpResponse<Notification>>

sendSyncEmail()

Send an email notification synchronously.

async sendSyncEmail(
  notification: NotificationRequest,
  pathParameters: PathParameters
): Promise<HttpResponse<Notification>>

sendSms()

Send an SMS notification.

async sendSms(
  notification: NotificationRequest,
  pathParameters: PathParameters
): Promise<HttpResponse<Notification>>

getUnsentMessage()

Get unsent messages.

async getUnsentMessage(
  pathParameters: PathParameters
): Promise<HttpResponse<Notification[]>>

retryOldMessage()

Retry failed messages.

async retryOldMessage(
  ids: number[],
  pathParameters: PathParameters
): Promise<HttpResponse<any>>

addTemplate()

Add or update a template.

async addTemplate(
  platformType: PlatformEnum,
  templateName: string,
  type: TemplateType,
  content: string
): Promise<HttpResponse<string>>

Enums

PlatformEnum

enum PlatformEnum {
  ONESTEP = 0,
  BNPL = 1,
  QHT = 2
}

TemplateType

enum TemplateType {
  SMS = 'sms',
  EMAIL = 'email',
  WHATAPPS = 'whatapps'
}

BizType

enum BizType {
  PAY_INTEREST = 'payInterst',
  REGISTER = 'regiester'
}

Usage Examples

Sending an Email

const notification = Notification.builder()
  .withCategory('email')
  .withMessage('Hello World')
  .withPlatformId(PlatformEnum.ONESTEP)
  .withTo('[email protected]')
  .withFrom('[email protected]')
  .withSubject('Welcome')
  .withMessageType(0)
  .withNotifyType(1)
  .buildNotificationRequest();

const pathParams = new PathParameters(PlatformEnum.ONESTEP, 'username');
const result = await client.sendEmail(notification, pathParams);

Sending an SMS

const notification = Notification.builder()
  .withCategory('sms')
  .withMessage('Your verification code is 123456')
  .withPlatformId(PlatformEnum.ONESTEP)
  .withTo('+1234567890')
  .withMessageType(0)
  .withNotifyType(1)
  .buildNotificationRequest();

const pathParams = new PathParameters(PlatformEnum.ONESTEP, 'username');
const result = await client.sendSms(notification, pathParams);

Adding a Template

const result = await client.addTemplate(
  PlatformEnum.ONESTEP,
  'welcome_email',
  TemplateType.EMAIL,
  'Hello ${username}, welcome to our service!'
);

Using Callbacks

await client.sendEmailWithCallback(
  notification,
  pathParams,
  (response) => {
    if (response.data) {
      console.log('Email sent:', response.data);
    } else if (response.error) {
      console.error('Error:', response.error);
    }
  }
);

Getting Unsent Messages

const pathParams = new PathParameters(PlatformEnum.ONESTEP, 'username', '0');
const result = await client.getUnsentMessage(pathParams);

if (result.data) {
  console.log('Unsent messages:', result.data);
}

Retrying Failed Messages

const pathParams = new PathParameters(PlatformEnum.ONESTEP, 'username');
const result = await client.retryOldMessage([1, 2, 3], pathParams);

Building

npm run build

Development

npm run dev

License

MIT