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

@thrivereflections/realtime-store-prisma

v0.1.0

Published

Prisma-based persistence store for the Thrive Realtime Voice Platform

Readme

@thrive/realtime-store-prisma

Prisma-based persistence store for the Thrive Realtime Voice Platform.

Overview

This package provides a Prisma-based implementation of the PersistenceStore interface, enabling database persistence for voice sessions, transcripts, tool events, and summaries.

Features

  • Database Persistence: Store sessions, transcripts, tool events, and summaries
  • Consent Management: Respect user consent before persisting data
  • PII Redaction: Redact sensitive information before storage
  • Graceful Fallback: Falls back to memory store when database is unavailable
  • Type Safety: Full TypeScript support with Prisma-generated types

Installation

pnpm add @thrive/realtime-store-prisma

Usage

Basic Setup

import { createPrismaStore } from "@thrive/realtime-store-prisma";
import { redact } from "@thrive/realtime-security";

const config = {
  databaseUrl: process.env.DATABASE_URL!,
  logLevel: "warn" as const
};

const deps = {
  redact: redact
};

const store = createPrismaStore(config, deps);

Database Setup

  1. Install Prisma CLI:

    pnpm add -D prisma
  2. Set up environment variables:

    DATABASE_URL="postgresql://user:password@localhost:5432/voice_app"
    DIRECT_URL="postgresql://user:password@localhost:5432/voice_app"
  3. Generate Prisma client:

    pnpm db:generate
  4. Run migrations:

    pnpm db:migrate

Configuration

The store accepts the following configuration:

interface PrismaStoreConfig {
  databaseUrl: string;           // PostgreSQL connection string
  logLevel?: "error" | "warn" | "info" | "query"; // Prisma log level
}

Dependencies

The store requires a PII redaction function:

interface PrismaStoreDeps {
  redact: (text: string) => string; // Function to redact PII
}

API Reference

createPrismaStore(config, deps)

Creates a Prisma-based persistence store.

Parameters:

  • config: Database configuration
  • deps: Required dependencies (redaction function)

Returns: PersistenceStore implementation

Store Methods

The store implements the PersistenceStore interface:

  • saveSessionMeta(sessionId, user, config, timings, consent): Save session metadata
  • appendTranscript(sessionId, segment): Append transcript segment
  • appendToolEvent(sessionId, event): Append tool event
  • persistSummary(sessionId, summary): Persist session summary

Database Schema

The package includes a Prisma schema with the following models:

  • AppUser: User accounts and authentication
  • Session: Voice session metadata
  • Transcript: Conversation transcripts
  • ToolEvent: Tool call events and results
  • Summary: Session summaries
  • UsageEvent: Usage tracking and analytics

Consent Management

The store respects user consent settings:

  • Only persists data when consent === "ACCEPTED"
  • Skips persistence when consent is declined
  • Defaults to DECLINED for new users

PII Protection

All text data is redacted before storage:

  • Phone numbers, emails, addresses are masked
  • Sensitive information is replaced with placeholders
  • Redaction is applied to transcripts and summaries

Error Handling

The store includes comprehensive error handling:

  • Graceful fallback when database is unavailable
  • Validation of date fields
  • Duplicate prevention for sessions
  • Detailed logging for debugging

Development

Scripts

  • pnpm build: Build the package
  • pnpm typecheck: Run TypeScript type checking
  • pnpm lint: Run ESLint
  • pnpm db:generate: Generate Prisma client
  • pnpm db:push: Push schema to database
  • pnpm db:migrate: Run database migrations
  • pnpm db:studio: Open Prisma Studio

Testing

# Run tests
pnpm test

# Run tests with database
DATABASE_URL="postgresql://..." pnpm test

Dependencies

  • @prisma/client: Prisma database client
  • @thrive/realtime-contracts: Shared type definitions

License

MIT