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

@openplait/adapter-clickhouse

v0.1.0-alpha.0

Published

ClickHouse datasource adapter for OpenPlait and OpenLIT telemetry schemas.

Readme

@openplait/adapter-clickhouse

The first OpenPlait datasource adapter. It compiles portable semantic queries to parameterized ClickHouse SQL and normalizes ClickHouse responses into @openplait/core dataframes.

The default mappings cover the standard OpenTelemetry ClickHouse tables:

| Logical dataset | Physical table | | --- | --- | | otel.spans | otel_traces | | otel.logs | otel_logs | | otel.metrics.gauge | otel_metrics_gauge | | otel.metrics.sum | otel_metrics_sum | | otel.metrics.histogram | otel_metrics_histogram |

Application-specific mappings are supplied through config.datasets. The package exports OPENLIT_CLICKHOUSE_DATASETS as an optional preset for OpenLIT; it is not part of the adapter's defaults.

Usage

import {
  ClickHouseAdapter,
} from "@openplait/adapter-clickhouse";

const adapter = new ClickHouseAdapter({
  url: "https://clickhouse.example.com:8443",
  username: process.env.CLICKHOUSE_USER,
  password: process.env.CLICKHOUSE_PASSWORD,
  database: "observability",
  httpHeaders: { "X-ClickHouse-Quota": "openlit" },
  maxResultRows: 10_000,
  maxRowsToRead: 10_000_000,
  maxTimeRangeMs: 31 * 24 * 60 * 60 * 1_000,
  queryTimeoutMs: 30_000,
});

const compiled = await adapter.compile(query, {
  variables: {
    __from: "2026-08-05T00:00:00.000Z",
    __to: "2026-08-05T01:00:00.000Z",
  },
});

const result = await adapter.execute(compiled, {
  audit: { requestId: "dashboard-request-123", actorId: "user-42" },
});

await adapter.close();

OpenLIT can opt into its additional logical datasets without changing the generic adapter contract:

import {
  ClickHouseAdapter,
  OPENLIT_CLICKHOUSE_DATASETS,
} from "@openplait/adapter-clickhouse";

const adapter = new ClickHouseAdapter({
  url: clickhouseUrl,
  datasets: [...OPENLIT_CLICKHOUSE_DATASETS],
});

Do not put credentials in dashboard resources. Resolve them on the server and construct each named adapter instance behind the consuming application's server-side datasource registry.

Safety defaults

  • Canonical fields resolve only through the selected dataset's allowlist.
  • Tables are selected only through registered logical datasets.
  • Values use ClickHouse query parameters and are never interpolated into SQL.
  • A time range is required by default and capped at 31 days.
  • Results, rows read, and execution time are capped at both SQL and server setting boundaries.
  • Queries execute with ClickHouse readonly=1.
  • Tenant predicates are adapter-owned and cannot be removed by a query.
  • Compiled queries must originate from the executing adapter instance.
  • Execution requires a safe audit request ID.
  • Native SQL is disabled unless allowNativeQueries: true is set by the server administrator. When enabled, it remains single-statement and read-only, and every declared parameter must be referenced through ClickHouse bindings.

Native mode intentionally bypasses semantic field and table allowlists. Treat it as a privileged server-side feature, never as an end-user SQL console.

Supported semantic operations

Select, recursive filters, aggregation, grouping, time buckets, ordering, limits, percentiles, distinct count, rate, histogram, and arithmetic are supported. Semantic joins are reported as unsupported because the current core join expression cannot identify the left and right operands unambiguously.

discoverSchema() returns the canonical fields and types for all registered datasets. explain() returns the generated SQL, bound parameters, output field contract, and compilation steps without contacting ClickHouse.