@devrev/meerkat-core

中文文档
0.0.138发布于 2026/10/15ISCTypeScriptCommonJS构建来源已验证近 30 天下载 2.5万

@devrev/meerkat-core is the foundational library for the Meerkat ecosystem, a TypeScript SDK that seamlessly translates Cube-like queries into DuckDB Abstract Syntax Trees (AST). It provides the core logic for query transformation, designed to be enviro

原始使用文档
文档目录5 节
  1. Key Features
  2. Installation
  3. Core Concepts
  4. Usage
  5. Ecosystem

@devrev/meerkat-core

@devrev/meerkat-core is the foundational library for the Meerkat ecosystem, a TypeScript SDK that seamlessly translates Cube-like queries into DuckDB Abstract Syntax Trees (AST). It provides the core logic for query transformation, designed to be environment-agnostic, running in both Node.js and browser environments.

This package focuses exclusively on generating a DuckDB-compatible AST from a JSON-based query object. It does not handle query execution, which is the responsibility of environment-specific packages like @devrev/meerkat-node and @devrev/meerkat-browser.

Key Features

  • Cube-to-AST Transformation: Converts Cube-style JSON queries into DuckDB-compatible SQL ASTs.
  • Environment Agnostic: Runs in both Node.js and browser environments.
  • Type-Safe: Provides strong TypeScript definitions for queries, schemas, and filters.
  • Advanced Filtering and Joins: Supports complex filters, logical operators, and multi-table joins.
  • Extensible by Design: Leverages DuckDB's native JSON serialization, avoiding the limitations of traditional query builders.

Installation

npm install @devrev/meerkat-core

Core Concepts

meerkat-core revolves around two main objects:

  1. Query: A JSON object that defines your analytics request. It specifies measures, dimensions, filters, and ordering.
  2. TableSchema: Defines the structure of your data tables, including columns, measures, dimensions, and joins.

The library uses these objects to generate a DuckDB AST. This AST can then be passed to an execution engine.

Usage

Here's how to transform a Cube-style query into a DuckDB AST:

import { cubeToDuckdbAST, Query, TableSchema } from '@devrev/meerkat-core';

// 1. Define the schema for your table
const schema: TableSchema = {
  name: 'users',
  sql: 'SELECT * FROM users',
  columns: [
    { name: 'id', type: 'INTEGER' },
    { name: 'name', type: 'VARCHAR' },
    { name: 'city', type: 'VARCHAR' },
    { name: 'signed_up_at', type: 'TIMESTAMP' },
  ],
};

// 2. Define your query
const query: Query = {
  measures: ['users.count'],
  dimensions: ['users.city'],
  filters: [
    {
      member: 'users.city',
      operator: 'equals',
      values: ['New York'],
    },
  ],
  limit: 100,
};

// 3. Generate the DuckDB AST
const ast = cubeToDuckdbAST(query, schema);

// The `ast` can now be deserialized into a SQL string for execution.
console.log(JSON.stringify(ast, null, 2));

Ecosystem

meerkat-core is the foundation for:

  • @devrev/meerkat-node: For server-side analytics in Node.js with @duckdb/node-api.
  • @devrev/meerkat-browser: For client-side analytics in the browser with @duckdb/duckdb-wasm.

版本与发布记录

@devrev/meerkat-core 共发布 57 个版本,首次发布于 2024/09/05;过去 12 个月发布了 30 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.138latest2026/10/1527 天前
0.0.1372026/10/081 个月前
0.0.1362026/09/231 个月前
0.0.1352026/07/273 个月前
0.0.1342026/07/143 个月前
0.0.1332026/06/254 个月前

关于 @devrev/meerkat-core 的常见问题

@devrev/meerkat-core 是什么?

@devrev/meerkat-core is the foundational library for the Meerkat ecosystem, a TypeScript SDK that seamlessly translates Cube-like queries into DuckDB Abstract Syntax Trees (AST). It provides the core logic for query transformation, designed to be enviro

如何安装 @devrev/meerkat-core?

在项目目录运行 npm install @devrev/meerkat-core,或使用 pnpm add / yarn add / bun add。

@devrev/meerkat-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devrev/meerkat-core 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@devrev/meerkat-core 可以商用吗?

@devrev/meerkat-core 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@devrev/meerkat-core 的下载量有多少?

根据 npm 官方下载统计,@devrev/meerkat-core 在 2026/10/12 – 2026/11/10 这 30 天内被下载 24,616 次,日均约 821 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devrev/meerkat-core 还在维护吗?

最新版本 0.0.138 发布于 2026/10/15(27 天前);至今共发布 57 个版本,其中过去 12 个月发布了 30 个;首次发布于 2024/09/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。