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

@ibm/mapepire-protocol

v0.1.0

Published

Canonical protocol definitions for the Mapepire WebSocket protocol

Readme

@ibm/mapepire-protocol

Canonical protocol definitions for the Mapepire WebSocket protocol.

This package provides:

  • Zod schemas for all 15 Mapepire protocol message types (requests + responses)
  • TypeScript types inferred from schemas for compile-time safety
  • JSON Schema files generated from Zod for cross-language consumption
  • Discriminated union (MapepireRequest) for runtime message parsing and type narrowing
  • PROTOCOL.md — human-readable protocol specification for client implementors

Installation

npm install @ibm/mapepire-protocol zod

zod is a peer dependency — install it alongside this package.

Usage

Parse and validate a request

import { MapepireRequest } from "@ibm/mapepire-protocol";

const message = JSON.parse(rawWebSocketMessage);
const request = MapepireRequest.parse(message);

switch (request.type) {
  case "sql":
    console.log(request.sql); // TypeScript knows this is SqlRequest
    break;
  case "connect":
    console.log(request.technique); // TypeScript knows this is ConnectRequest
    break;
}

Construct a typed request

import { SqlRequest } from "@ibm/mapepire-protocol";

const request: SqlRequest = {
  id: "1",
  type: "sql",
  sql: "SELECT * FROM MYLIB.MYTABLE",
  rows: 100,
};

// Validate at runtime
SqlRequest.parse(request);

Validate a response

import { QueryResult, PingResponse } from "@ibm/mapepire-protocol";

const response = QueryResult.parse(serverMessage);
if (response.has_results) {
  console.log(response.data);
  console.log(response.metadata?.columns);
}

Use JSON Schema (cross-language)

import schema from "@ibm/mapepire-protocol/schemas/requests/sql-request.json";

Or access the combined schema:

import allSchemas from "@ibm/mapepire-protocol/schemas/index.json";

Python: validate messages with JSON Schema

The generated JSON Schema files in schemas/ can be used by any language. For Python, use the jsonschema library to validate outgoing requests and incoming responses at runtime.

First, grab the schema files. You can either vendor them into your project or fetch them from the npm package:

npm pack @ibm/mapepire-protocol && tar -xzf ibm-mapepire-protocol-*.tgz package/schemas

Then validate messages in Python:

import json
from pathlib import Path
from jsonschema import validate, ValidationError

# Load schemas once at import time
SCHEMA_DIR = Path("schemas")

def load_schema(name: str) -> dict:
    return json.loads((SCHEMA_DIR / name).read_text())

sql_request_schema = load_schema("requests/sql-request.json")
query_result_schema = load_schema("responses/query-result.json")

# Validate an outgoing request before sending
request = {
    "id": "1",
    "type": "sql",
    "sql": "SELECT * FROM MYLIB.MYTABLE",
    "rows": 100,
}
validate(instance=request, schema=sql_request_schema)  # raises on invalid

# Validate an incoming response from the server
response = json.loads(websocket.recv())
try:
    validate(instance=response, schema=query_result_schema)
except ValidationError as e:
    print(f"Unexpected server response: {e.message}")

Python: generate dataclasses or Pydantic models

For full type safety, generate Python types directly from the JSON Schema files using datamodel-code-generator:

pip install datamodel-code-generator

# Generate Pydantic v2 models from all request schemas
datamodel-codegen \
    --input schemas/requests/ \
    --output mapepire_protocol/requests.py \
    --output-model-type pydantic_v2.BaseModel

# Generate from a single schema
datamodel-codegen \
    --input schemas/requests/sql-request.json \
    --output mapepire_protocol/sql_request.py \
    --output-model-type pydantic_v2.BaseModel

This produces typed Python classes like:

from pydantic import BaseModel
from typing import Optional

class SqlRequest(BaseModel):
    id: str
    type: str  # const: "sql"
    sql: str
    rows: Optional[int] = None
    terse: Optional[bool] = None

Message Types

| Type | Request Schema | Description | |------|---------------|-------------| | connect | ConnectRequest | Establish JDBC connection | | sql | SqlRequest | Execute SQL statement | | prepare_sql | PrepareSqlRequest | Prepare SQL without executing | | prepare_sql_execute | PrepareSqlExecuteRequest | Prepare and execute in one round-trip | | execute | ExecuteRequest | Execute a prepared statement | | sqlmore | SqlMoreRequest | Fetch next block of rows | | sqlclose | SqlCloseRequest | Close cursor | | cl | ClRequest | Execute CL command | | dove | DoveRequest | Visual Explain | | ping | PingRequest | Health check | | getdbjob | GetDbJobRequest | Get job name | | getversion | GetVersionRequest | Get server version | | setconfig | SetConfigRequest | Configure tracing | | gettracedata | GetTraceDataRequest | Retrieve trace data | | exit | ExitRequest | Disconnect |

See PROTOCOL.md for the full protocol specification.

License

Apache-2.0