@rebasepro/common
Shared utilities, collection registry, data driver adapter, and fluent query builder used across Rebase packages.
Installation
pnpm add @rebasepro/common
ESM-only: "type": "module" with no CommonJS build, so it is loaded with
import. It needs Node >=22.22.0 (its engines floor), where require()
of it resolves too: Node has supported require(esm) since 22.12.
What This Package Does
@rebasepro/common is the lowest-level shared logic layer in the Rebase frontend stack. It provides:
- Collection utilities — collection registry, default collection definitions, path resolution
- Data driver adapter —
buildRebaseData() bridges any DataDriver implementation into a RebaseData proxy with typed collection accessors
- Query builder — fluent
QueryBuilder class plus or(), and(), cond() helpers for composing complex queries
- Entity/property utilities — entity resolution, enum helpers, permission checks, reference/relation helpers, storage path utils, callback utilities
This package has no React dependency — it's pure TypeScript and can be used in both client and server contexts.
Key Exports
Data
buildRebaseData(driver) | Wraps a DataDriver in a Proxy-based RebaseData object. Property access like data.products returns a CollectionAccessor for that collection slug (camelCase → snake_case). |
QueryBuilder<M> | Fluent query builder with .where(), .orderBy(), .limit(), .offset(), .search(), .include(), .find(), and .listen() |
or(...conditions) | Create an OR logical condition |
and(...conditions) | Create an AND logical condition |
cond(column, op, value) | Create a single filter condition |
Collections
CollectionRegistry | Registry for managing collection definitions |
| Default collections | Pre-built collection configurations |
Utilities
collections | Collection config helpers |
common | General-purpose utilities |
entities | Entity value resolution |
enums | Enum type helpers |
paths | Path parsing and manipulation |
resolutions | Property and collection resolution |
permissions | Permission evaluation |
relations | Relation property helpers |
builders | Collection/property builder utilities |
storage | Storage path utilities |
callbacks | Callback composition utilities |
conditions | Conditional logic helpers |
Quick Start
import { buildRebaseData, QueryBuilder, or, cond } from "@rebasepro/common";
const data = buildRebaseData(myDriver);
const { data: products } = await data.products.find({ limit: 10 });
const entity = await data.products.findById("abc-123");
const { data: results } = await data.products
.where("status", "==", "published")
.orderBy("created_at", "desc")
.limit(20)
.find();
const { data: filtered } = await data.products
.where(or(
cond("category", "==", "electronics"),
cond("price", ">=", 100)
))
.find();
Related Packages