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

@synapsemedcom/contacts-types

v1.0.1

Published

Shared types and schemas for Synapse Contacts API

Readme

@synapsemedcom/contacts-types

Shared TypeScript types and Zod schemas for the Synapse Contacts API.

Installation

npm install @synapsemedcom/contacts-types
# or
yarn add @synapsemedcom/contacts-types
# or  
bun add @synapsemedcom/contacts-types

Usage

Import Types and Schemas

import { 
  // Request/Response types
  Contact,
  CreateContact,
  UpdateContact,
  Interaction,
  CreateInteraction,
  
  // Zod schemas for validation
  createContactSchema,
  updateContactSchema,
  contactResponseSchema,
  
  // Auth helpers
  generateServiceAuthHeaders,
  createAuthenticatedFetch
} from '@synapsemedcom/contacts-types';

Validate API Requests

import { createContactSchema } from '@synapsemedcom/contacts-types';

// Validate user input before sending to API
const contactData = createContactSchema.parse({
  firstName: 'John',
  lastName: 'Doe', 
  email: '[email protected]'
});

Validate API Responses

import { contactResponseSchema } from '@synapsemedcom/contacts-types';

const response = await fetch('/api/contacts/123');
const data = await response.json();

// Ensure API response matches expected shape
const contact = contactResponseSchema.parse(data);

Service-to-Service Authentication

import { generateServiceAuthHeaders, createAuthenticatedFetch } from '@synapsemedcom/contacts-types';

// Option 1: Generate headers manually
const headers = generateServiceAuthHeaders('email-service', process.env.API_SECRET);
const response = await fetch('/api/contacts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    ...headers
  },
  body: JSON.stringify(contactData)
});

// Option 2: Use authenticated fetch helper  
const authenticatedFetch = createAuthenticatedFetch(
  'https://contacts-api.vercel.app',
  'email-service', 
  process.env.CONTACTS_API_SECRET
);

const response = await authenticatedFetch('/api/contacts', {
  method: 'POST',
  body: JSON.stringify(contactData)
});

Example: Email Service Integration

import { 
  Contact, 
  CreateInteraction, 
  createAuthenticatedFetch,
  listContactsQuerySchema 
} from '@synapsemedcom/contacts-types';

class EmailService {
  private contactsAPI = createAuthenticatedFetch(
    process.env.CONTACTS_API_URL!,
    'email-service',
    process.env.CONTACTS_API_SECRET!
  );

  async sendCampaignToSpecialty(specialty: string) {
    // Get contacts - validated query params
    const query = listContactsQuerySchema.parse({ 
      specialty, 
      limit: '100' 
    });
    
    const response = await this.contactsAPI(
      `/api/contacts?${new URLSearchParams(query as any).toString()}`
    );
    
    const { contacts } = await response.json();
    
    for (const contact of contacts) {
      await this.sendEmail(contact.email);
      
      // Log interaction
      const interaction: CreateInteraction = {
        type: 'email',
        content: `Sent campaign: ${specialty} specialists`,
        metadata: { campaignId: '2025-trial' }
      };
      
      await this.contactsAPI(`/api/contacts/${contact.id}/interactions`, {
        method: 'POST',
        body: JSON.stringify(interaction)
      });
    }
  }
}

Available Types

Request Types

  • CreateContact - For POST /api/contacts
  • UpdateContact - For PUT /api/contacts/:id
  • CreateInteraction - For POST /api/contacts/:id/interactions
  • CreateTag - For POST /api/tags
  • ListContactsQuery - Query parameters for GET /api/contacts

Response Types

  • Contact - Contact record with all fields
  • Interaction - Interaction/note record
  • Tag - Tag record
  • ContactListResponse - Paginated contacts list
  • InteractionListResponse - List of interactions

Configuration

  • ContactsAPIConfig - API configuration interface

Available Schemas

All Zod schemas for request/response validation:

  • createContactSchema
  • updateContactSchema
  • contactResponseSchema
  • createInteractionSchema
  • interactionResponseSchema
  • listContactsQuerySchema
  • And more...

Auth Helpers

  • generateServiceAuthHeaders(serviceId, apiSecret) - Generate HMAC headers
  • createAuthenticatedFetch(baseUrl, serviceId, apiSecret) - Get authenticated fetch function