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

@phoekerson/piedpiper

v1.0.0

Published

Import users in bulk from CSV/Excel files, normalize data, prepare SSO-ready access, and optionally send onboarding emails

Readme

PiedPiper

A TypeScript Node.js library for importing users in bulk from CSV or Excel files, normalizing data, preparing SSO-ready access, and optionally sending onboarding emails.

Features

  • Import from CSV/Excel: Parse and import users from CSV or Excel files
  • Data Normalization: Automatically normalize user data with flexible field mapping
  • SSO Provider Detection: Automatically detects Google, Microsoft, or passwordless authentication providers
  • Database Adapter Pattern: Flexible database integration via adapters (Prisma, TypeORM, etc.)
  • Optional Email Notifications: Send onboarding emails to imported users
  • Validation & Error Handling: Comprehensive validation and error reporting
  • TypeScript: Fully typed for better developer experience

Installation

npm install piedpiper

Quick Start

import { piedPiper } from 'piedpiper';

// Basic usage
const result = await piedPiper('./users.csv');
console.log(`Imported ${result.imported} users`);

Usage

Basic Import

import { piedPiper } from 'piedpiper';

const result = await piedPiper('./users.csv');

console.log(result);
// {
//   imported: 10,
//   skipped: 2,
//   errors: [
//     { row: 3, error: "Email is required" },
//     { row: 7, error: "Invalid email format: invalid-email" }
//   ]
// }

With Database Adapter

import { piedPiper, DatabaseAdapter, NormalizedUser } from 'piedpiper';
import { PrismaClient } from '@prisma/client';

// Create your database adapter
class PrismaAdapter implements DatabaseAdapter {
  constructor(private prisma: PrismaClient) {}

  async insertUsers(users: NormalizedUser[]): Promise<void> {
    await this.prisma.user.createMany({
      data: users.map(user => ({
        email: user.email,
        firstName: user.firstName,
        lastName: user.lastName,
        provider: user.provider,
        status: user.status,
      })),
    });
  }

  async userExists(email: string): Promise<boolean> {
    const user = await this.prisma.user.findUnique({
      where: { email },
    });
    return !!user;
  }
}

// Use with adapter
const prisma = new PrismaClient();
const adapter = new PrismaAdapter(prisma);

const result = await piedPiper('./users.xlsx', {
  databaseAdapter: adapter,
  skipDuplicates: true,
});

With Email Notifications

import { piedPiper } from 'piedpiper';

const result = await piedPiper('./users.csv', {
  emailConfig: {
    smtp: {
      host: 'smtp.gmail.com',
      port: 587,
      secure: false,
      auth: {
        user: '[email protected]',
        pass: 'your-app-password',
      },
    },
    options: {
      subject: 'Welcome to our platform!',
      textTemplate: (user) => 
        `Hello ${user.firstName || 'there'},\n\n` +
        `Your account has been created. You can sign in using ${user.provider} authentication.\n\n` +
        `Email: ${user.email}\n\n` +
        `Best regards`
    },
  },
});

Complete Example

import { piedPiper, DatabaseAdapter, NormalizedUser } from 'piedpiper';

class MyDatabaseAdapter implements DatabaseAdapter {
  async insertUsers(users: NormalizedUser[]): Promise<void> {
    // Your database insertion logic
    for (const user of users) {
      await db.users.insert(user);
    }
  }

  async userExists(email: string): Promise<boolean> {
    const user = await db.users.findOne({ email });
    return !!user;
  }
}

const result = await piedPiper('./users.csv', {
  databaseAdapter: new MyDatabaseAdapter(),
  skipDuplicates: true,
  validateEmails: true,
  emailConfig: {
    smtp: {
      host: 'smtp.example.com',
      port: 587,
      auth: {
        user: '[email protected]',
        pass: 'password',
      },
    },
  },
});

console.log(`✅ Imported: ${result.imported}`);
console.log(`⏭️  Skipped: ${result.skipped}`);
if (result.errors.length > 0) {
  console.log(`❌ Errors:`, result.errors);
}

CSV/Excel Format

Your CSV or Excel file should contain user data with flexible column names. The library recognizes common variations:

Supported Column Names

  • Email: email, mail, Email Address
  • First Name: firstName, Prenom, first_name
  • Last Name: lastName, Nom, last_name
  • Password: password, Pass (optional, for passwordless/SSO)

Example CSV

email,firstName,lastName
[email protected],John,Doe
[email protected],Jane,Smith
[email protected],Admin,User

API Reference

piedPiper(filePath, options?)

Main function to import users from a file.

Parameters:

  • filePath (string): Path to CSV or Excel file (.csv, .xlsx, .xls)
  • options (ImportOptions, optional): Import configuration

Returns: Promise<ImportResult>

ImportOptions

interface ImportOptions {
  databaseAdapter?: DatabaseAdapter;  // Custom database adapter
  emailConfig?: {                      // Email configuration
    smtp: SMTPConfig;
    options?: EmailOptions;
  };
  skipDuplicates?: boolean;            // Skip existing users (default: false)
  validateEmails?: boolean;            // Validate email format (default: true)
}

DatabaseAdapter

Interface for database adapters:

interface DatabaseAdapter {
  insertUsers(users: NormalizedUser[]): Promise<void>;
  userExists(email: string): Promise<boolean>;
}

NormalizedUser

interface NormalizedUser {
  email: string;
  firstName: string | null;
  lastName: string | null;
  password: string | null;
  provider: "google" | "microsoft" | "passwordless";
  status: "pending" | "active";
}

SSO Provider Detection

The library automatically detects SSO providers based on email domains:

  • Google: gmail.com, googlemail.com, google.com
  • Microsoft: outlook.com, hotmail.com, live.com, msn.com, microsoft.com, office365.com
  • Passwordless: All other domains

Important Notes

⚠️ This library does NOT manage authentication or passwords directly. It only prepares user access and delegates authentication to providers like Google, Microsoft, or Magic Link.

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.