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

@ruvos/handler-sdk

v0.1.22

Published

SDK for building custom pipeline handlers for the Ruvos healthcare data exchange platform

Readme

@ruvos/handler-sdk

npm version

SDK for building custom pipeline handlers for the Ruvos healthcare data exchange platform.

Handlers let you intercept and process FHIR resources at three stages of the Ruvos data pipeline:

  • post_downstream_fetch — after data is fetched from an external source
  • pre_store — before data is encrypted and stored
  • post_store — after data is persisted

Installation

npm install @ruvos/handler-sdk

Quick Start

Scaffold a new handler project

npx @ruvos/handler-sdk create-handler my-handler
cd ruvos-handler-my-handler
npm install

This generates a complete project with TypeScript config, esbuild bundling, Terraform infrastructure, and a GitLab CI pipeline.

Write a handler

import { createHandler, type HandlerInput, type HandlerOutcome } from "@ruvos/handler-sdk";

async function handle(input: HandlerInput): Promise<HandlerOutcome> {
  const { stage, payload, tenantId, connectorType } = input;

  // Transform: modify resources before storage
  if (stage === "pre_store" && payload.resources) {
    const enriched = payload.resources.map((r) => ({
      ...r,
      meta: { ...r.meta, tag: [{ code: "reviewed", display: "Reviewed by handler" }] },
    }));
    return { action: "transform", resources: enriched };
  }

  // Passthrough: continue normal pipeline
  return { action: "passthrough" };
}

export const handler = createHandler({ handlerId: "my-handler" }, handle);

Handler Outcomes

Every handler must return one of five outcomes:

| Outcome | Description | |---|---| | passthrough | Continue normal pipeline processing | | transform | Replace resources with a modified set | | route_to | Forward the payload to an HTTPS URL (skip normal storage) | | requeue | Retry processing later with an optional delay | | fail | Abort the job with a reason |

// passthrough
return { action: "passthrough" };

// transform
return { action: "transform", resources: modifiedResources, metadata: { source: "enriched" } };

// route_to
return { action: "route_to", url: "https://my-service.example.com/ingest", body: payload };

// requeue
return { action: "requeue", delaySeconds: 30 };

// fail
return { action: "fail", reason: "Missing required patient identifier" };

API Reference

createHandler(options, fn)

Wraps a handler function with logging, timeout, and outcome validation.

import { createHandler } from "@ruvos/handler-sdk";

export const handler = createHandler(
  { handlerId: "my-handler", timeoutMs: 60_000 },
  async (input) => { /* ... */ }
);

Options:

  • handlerId — unique identifier for this handler
  • timeoutMs — execution timeout (default: 120,000ms)

parseCcda(xml)

Parses a C-CDA XML document into FHIR resources (Patient + Composition).

import { parseCcda } from "@ruvos/handler-sdk";

const resources = parseCcda(xmlString);
// [{ resourceType: "Patient", ... }, { resourceType: "Composition", ... }]

validateOutcome(value)

Validates that a handler outcome has the correct structure. Called automatically by createHandler, but available for testing.

import { validateOutcome, HandlerValidationError } from "@ruvos/handler-sdk";

try {
  const validated = validateOutcome(result);
} catch (err) {
  if (err instanceof HandlerValidationError) {
    console.error("Invalid outcome:", err.message);
  }
}

createHandlerLogger(context)

Creates a structured JSON logger for use within handlers.

import { createHandlerLogger } from "@ruvos/handler-sdk";

const logger = createHandlerLogger({
  handlerId: "my-handler",
  correlationId: input.correlationId,
  tenantId: input.tenantId,
  stage: input.stage,
});

logger.info("processing_resources", { count: input.payload.resources?.length });

Types

type HookStage = "post_downstream_fetch" | "pre_store" | "post_store";

interface HandlerInput {
  stage: HookStage;
  tenantId: string;
  jobId: string;
  correlationId: string;
  connectorType: string;
  config?: Record<string, unknown>;
  payload: {
    resources?: FHIRResource[];
    metadata?: Record<string, unknown>;
    s3Key?: string;
  };
}

type HandlerOutcome =
  | { action: "passthrough" }
  | { action: "transform"; resources: FHIRResource[]; metadata?: Record<string, unknown> }
  | { action: "route_to"; url: string; method?: string; headers?: Record<string, string>; body: unknown }
  | { action: "requeue"; delaySeconds?: number }
  | { action: "fail"; reason: string };

interface FHIRResource {
  resourceType: string;
  id?: string;
  [key: string]: unknown;
}

License

MIT