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

@ultracart/bigquery-sdk

v0.2.0

Published

UltraCart REST API V2 JavaScript SDK — BigQuery extension. Query the UltraCart data warehouse and receive native SDK model instances.

Downloads

74

Readme

UltraCart REST API V2 — JavaScript SDK · BigQuery extension

Query the UltraCart data warehouse directly in BigQuery and get back native UltraCart JS SDK model instances (Order, Customer, AutoOrder, …) — the same objects you already use against the REST API. Ideal for bulk extracts (order history, customer data, loyalty portals) where hammering the REST API would be slow and wasteful.

Status: early release (0.2.0). Core auth + transformer + SDK hydration working and unit-tested. See the CHANGELOG for release notes and CONTRIBUTING to get involved.

Why

The warehouse tables are generated from the same domain model that powers the REST API, so the structures line up 1:1 with the SDK models. Only two structural differences exist between BigQuery and the SDK, which this library handles automatically:

  1. Dates — BigQuery DATETIME (UTC) → ISO 8601 string with Z.
  2. Primitive arraysstring[]/number[] are stored as a REPEATED RECORD { value } and flattened back to a primitive array.

(Plus numeric normalization to JS Number.)

Install

npm install @ultracart/bigquery-sdk ultra_cart_rest_api_v2 @google-cloud/bigquery

Requires Node.js 22 or newer. This follows @google-cloud/bigquery v9, which sets the same floor. Node 18 and 20 are both past end-of-life; if you are still on one of them, stay on @ultracart/[email protected], which tracks @google-cloud/bigquery v8.

Authentication

Uses Google Application Default Credentials (ADC) — no keys in code:

# Developer machine
gcloud auth application-default login

# Server / CI
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

The service-account email is registered in the UltraCart dashboard, which provisions read access to your warehouse project at the assigned taxonomy (PII) level.

Usage

query() returns an async iterator — results stream a page at a time, so the same code handles a small incremental sync and a full-history backfill with constant memory.

const { UltraCartBigQuery } = require('@ultracart/bigquery-sdk');
const UltraCartApi = require('ultra_cart_rest_api_v2');

// Project is derived as ultracart-dw-{merchantId}
const ucbq = new UltraCartBigQuery({ merchantId: 'DEMO' });

const sql = `SELECT * FROM ultracart_dw.uc_orders
             WHERE creation_dts >= @since
             ORDER BY creation_dts`;

for await (const order of ucbq.query(sql, { params: { since: '2025-01-01' }, model: UltraCartApi.Order })) {
  // order is a real UltraCartApi.Order instance:
  //   order.creation_dts      -> "2025-01-15T10:30:00Z"
  //   order.billing.cc_emails -> ["[email protected]", "[email protected]"]  (medium/high datasets)
  //   order.items[0]          -> OrderItem instance
}

Omit model to stream plain SDK-shaped objects instead of hydrated instances.

Estimate cost before a big extract

LIMIT does not reduce bytes scanned, so estimate first:

const est = await ucbq.dryRun(sql, { params: { since: '2025-01-01' } });
console.log(`${est.gigabytesProcessed.toFixed(2)} GB (~$${est.estimatedCostUsd.toFixed(2)})`);

Every query is capped at 10 GB billed by default (overridable per call with maxBytesBilled, or 0 to disable) — a runaway SELECT * aborts instead of billing a fortune.

Datasets & linked (parent) accounts

  • Base ultracart_dw holds a single account's data with no PII (PII fields appear only as *_hash).
  • Parent/umbrella accounts keep data in the ultracart_dw_linked* datasets, which span all of the parent's merchant ids — query those (and filter by merchant_id) to cover every account.
  • Customer PII (names, emails, addresses, raw cc_emails) lives only in the _medium / _high taxonomy datasets, e.g. ultracart_dw_linked_medium.

Develop

npm test   # no-network unit tests (synthetic BigQuery rows -> SDK instances)

Schema drift guard

This library relies on SDK model field names matching BigQuery columns 1:1. A guard verifies that and fails on drift (e.g. the SDK regenerates with a new field that the warehouse lacks):

# Live check against a PII-tier dataset (so real fields are present, not just *_hash)
npm run check:schema -- --project=ultracart-dw-<merchant> --dataset=ultracart_dw_high

# After an intentional, reviewed change, refresh the accepted-exclusions baseline
npm run baseline:schema -- --project=ultracart-dw-<merchant> --dataset=ultracart_dw_high

Known, reviewed SDK-only fields (recursive nesting like customer_profile.orders, and sensitive write-only fields like password) are recorded in schemas/known-sdk-only.json; the check fails only on new drift. The pure diff logic is covered by npm test; CI runs the live check on a schedule when GCP credentials are configured.