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

@benhall-7/cube-ts

v0.1.0

Published

A TypeScript utility for handling type-safe interactions with cube.js cubes

Readme

cube-ts

A utility for working with Cube.js queries in TypeScript.

Features

Cube declaration

You can declare a cube and its allowed members in code:

import { CubeDef, m } from "cube-ts";

const myCube = new CubeDef({
  name: "MyCube",
  measures: {
    myNumber: m.number,
    myString: m.string,
  },
  dimensions: {
    myTimeDimension: m.time,
  },
  segments: ["segment1"],
});

There are two main exports from cube-ts: a class to define cube schemas with, and a set of predefined "members types" that can be assigned to each member, behind the "m" export. For example, you can use m.number to provide the default behavior for dealing with numeric cube members.

Query creation

You can use the cube definition to saturate the Query object when running a load query. This grants the user strong typing support and lets them use native types in filters instead of only strings:

const query = {
  measures: [cube.measure("myNumber"), cube.measure("myString")],
  dimensions: [cube.dimension("myStringDimension")],
  timeDimensions: [
    cube.timeDimension({
      dimension: "myTimeDimension",
      granularity: "hour",
      // notice the use of Date objects
      dateRange: [new Date("2025-01-01"), new Date("2025-02-09")],
    }),
  ] as const,
  segments: [cube.segment("segment1")],
  filters: [
    cube.binaryFilter({
      member: "myNumber",
      operator: "gte",
      // notice the true numbers instead of strings
      values: [100],
    }),
  ],
};

Result parsing

The Cube.js client library supports automatic type inference in ResultSet objects, but this only extends to the rawData method; not to other methods such as tablePivot. To alleviate this limitation, the CubeDef class contains a "deserializer" method that accepts a list of measures, dimensions, and timeDimensions and produces a function that will validate and parse the expected type:

const deserializer = cube.deserializer({
  measures: ["myNumber", "myString"],
  dimensions: ["myStringDimension"],
  timeDimensions: [["myTimeDimension", "day"]],
});

const result = deserializer(response);
console.log(
  result.myNumber, // a number
  result.myString, // a string
  result.myStringDimension, // a string
  result["myTimeDimension.day"] // a Date
);

This does come at the cost of some redundancy, because it requires the user to specify the measures, dimensions, and time dimensions in both the query, and the deserializer

Customization

Because the cube member type is designed to be generic, a user can choose to define their own and use that instead. For example, you could use dayjs instead of Date; or you could create a type with custom serialization/deserialization, like so:

import { elideMember } from "cube-ts";

const myCBool = elideMember({
  filter: "none",
  deserialize(input: unknown) {
    return input === "1";
  },
  serialize(input: boolean) {
    return input ? "1" : "0";
  },
});

and this new type can be used for the given member of the cube.