@cereusdb/standard

中文文档
0.4.0发布于 2026/10/06Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 6635

Standard CereusDB browser package with GEOS and PROJ support

原始使用文档
文档目录9 节
  1. Install
  2. Parquet support
  3. SQL function availability
  4. Object storage support
  5. Persistent databases (OPFS)
  6. GeoParquet export
  7. Loading the WASM module
  8. JS / TS API
  9. Example

@cereusdb/standard

Standard CereusDB browser package. Everything in @cereusdb/minimal, plus PROJ-backed ST_Transform and CRS-aware reprojection support.

This package includes browser object stores for ranged remote Parquet reads and S3/GCS/Azure/HTTP providers.

Install

npm install @cereusdb/standard

Parquet support

Parquet files compressed with Snappy, Gzip, Brotli, LZ4, or ZSTD can be registered.

SQL function availability

Current runtime surface:

  • 151 runtime ST_* names
  • 0 runtime RS_* names

Included function families:

  • Everything from @cereusdb/minimal: core SedonaDB functions, geo functions, GEOS predicates/operations, relation joins, distance joins, and ST_KNN.
  • PROJ-backed CRS transformation with ST_Transform.

Examples of available functions:

  • Core and geo: ST_Point, ST_GeomFromWKT, ST_AsText, ST_SRID, ST_Buffer, ST_Distance, ST_DWithin, ST_AsGeoJSON
  • GEOS: ST_Contains, ST_Within, ST_Crosses, ST_Touches, ST_Union, ST_Difference, ST_MakeValid, ST_Polygonize
  • PROJ: ST_Transform

Not included in this package:

  • S2 geography kernels
  • Raster RS_* functions

Object storage support

Browser object stores are included in @cereusdb/standard. Use registerObjectStores() to configure http, s3, gcs, or azure providers, then registerParquetTable() to register an exact Parquet object or provider-backed prefix.

Persistent databases (OPFS)

Tables normally live in memory. Persistent databases are stored in the browser's Origin Private File System and survive page reloads:

const db = await CereusDB.create({ attach: ['opfs://mydb'] }); // opens or creates mydb

await db.sqlJSON(`CREATE TABLE mydb.public.cities AS SELECT 1 AS id, 'Berlin' AS name, ST_Point(13.4, 52.5) AS geom`);
await db.sqlJSON(`INSERT INTO mydb.public.cities VALUES (2, 'Paris', ST_Point(2.35, 48.86))`);
await db.sqlJSON(`USE mydb`); // `cities` now resolves to mydb.public.cities

SQL: CREATE DATABASE 'opfs://mydb', ATTACH 'opfs://mydb' [AS name], DETACH name, DROP DATABASE name, USE name, ALTER TABLE ... RENAME TO | ADD COLUMN | DROP COLUMN | RENAME COLUMN, and SELECT * FROM cereusdb_databases(). Databases appear as catalogs in information_schema and db.catalog(). A table's data is loaded the first time it is used. See the persistent databases guide.

GeoParquet export

const bytes = await db.exportGeoParquet('mydb.public.cities'); // Uint8Array
await db.downloadGeoParquet('mydb.public.cities');            // downloads cities.parquet
await db.sqlJSON(`COPY (SELECT * FROM cities WHERE id > 1) TO 'some.parquet'`);

See the GeoParquet export guide.

Loading the WASM module

The wasm binary ships as a separate file, dist/wasm/cereusdb_bg.wasm. The default entry finds it automatically, and bundlers emit it as an asset.

If you host the wasm yourself, or your bundler inlines assets into large data:application/wasm;base64,... strings, use the external entry. It has no built-in wasm reference and requires wasmUrl or wasmSource:

import { CereusDB } from '@cereusdb/standard/external';

const db = await CereusDB.create({ wasmUrl: '/wasm/cereusdb_bg.wasm' });

Copy node_modules/@cereusdb/standard/dist/wasm/cereusdb_bg.wasm to your static assets, or import its URL with Vite: import wasmUrl from '@cereusdb/standard/wasm?url'. See the WASM loading guide for details.

JS / TS API

Exports:

  • CereusDB
  • CereusDBOptions
  • ObjectStoreRegistryConfig
  • ObjectStoreConfig
  • ObjectStoreProvider
  • RegisterParquetTableOptions
  • RasterFormat
  • QueryResult
  • MemoryStorageBackend, OPFSStorageBackend, StorageBackend, StorageOptions
  • CreateDatabaseOptions, AttachDatabaseOptions, DatabaseListing
  • CatalogDatabase, CatalogSchema, CatalogTable, CatalogColumn
  • CreateTableDefinition, CreateTableOptions, AlterTableOperation
  • GeoParquetExportOptions, DownloadGeoParquetOptions, ExportHandler
  • downloadFile, PARQUET_MIME_TYPE

Main types:

interface StorageOptions {
  opfs?: StorageBackend | false; // default: OPFSStorageBackend when the browser has OPFS
  [scheme: string]: StorageBackend | false | undefined;
}

interface StorageBackend {
  readFile(path: string): Promise<Uint8Array | null>;
  writeFile(path: string, data: Uint8Array): Promise<void>;
  remove(path: string): Promise<void>;
  list(path: string): Promise<string[]>;
  lock?(name: string): Promise<void>;
  unlock?(name: string): Promise<void>;
}

type ExportHandler = (filename: string, data: Uint8Array, mimeType: string) => void | Promise<void>;

type CreateTableDefinition = { columns: Record<string, string> } | { as: string };

type AlterTableOperation =
  | { renameTo: string }
  | { addColumn: { name: string; type: string; notNull?: boolean; default?: string }; ifNotExists?: boolean }
  | { dropColumn: string | string[]; ifExists?: boolean }
  | { renameColumn: { from: string; to: string } };

interface GeoParquetExportOptions {
  compression?: 'zstd' | 'snappy' | 'lz4' | 'gzip' | 'brotli' | 'uncompressed';
  rowGroupSize?: number;
}

interface DownloadGeoParquetOptions extends GeoParquetExportOptions {
  filename?: string;
}

type RasterFormat = 'geotiff' | 'tiff';
type ObjectStoreProvider = 'http' | 's3' | 'gcs' | 'azure';

interface CereusDBOptions {
  wasmUrl?: string;
  wasmSource?:
    | RequestInfo
    | URL
    | Response
    | BufferSource
    | WebAssembly.Module
    | Promise<Response>;
  objectStores?: ObjectStoreRegistryConfig;
  storage?: StorageOptions;
  attach?: string[];
  onExport?: ExportHandler | false;
}

interface ObjectStoreRegistryConfig {
  maxConcurrency?: number;
  stores: ObjectStoreConfig[];
}

interface ObjectStoreConfig {
  name?: string;
  provider: ObjectStoreProvider;
  url: string;
  options?: Record<string, string | number | boolean>;
}

interface RegisterParquetTableOptions {
  fileExtension?: string;
  targetPartitions?: number;
}

Main API:

class CereusDB {
  static create(options?: CereusDBOptions): Promise<CereusDB>;
  sql(query: string): Promise<Uint8Array>;
  sqlJSON(query: string): Promise<Record<string, unknown>[]>;
  registerRemoteParquet(name: string, url: string): Promise<void>;
  registerObjectStores(config: ObjectStoreRegistryConfig): void;
  registerParquetTable(
    name: string,
    url: string,
    options?: RegisterParquetTableOptions,
  ): Promise<void>;
  registerFile(name: string, file: File): Promise<void>;
  registerGeoJSON(name: string, geojson: string | object): void;
  registerRaster(name: string, data: BufferSource, format: RasterFormat): void;
  registerGeoTIFF(name: string, data: BufferSource): void;
  dropTable(name: string): Promise<void>;
  catalog(): Promise<CatalogDatabase[]>;
  createDatabase(location: string, options?: CreateDatabaseOptions): Promise<string>;
  attachDatabase(location: string, options?: AttachDatabaseOptions): Promise<string>;
  detachDatabase(name: string, options?: { ifExists?: boolean }): Promise<void>;
  dropDatabase(nameOrLocation: string, options?: { ifExists?: boolean }): Promise<void>;
  useDatabase(database: string, schema?: string): Promise<void>;
  listDatabases(): Promise<DatabaseListing[]>;
  createTable(name: string, definition: CreateTableDefinition, options?: CreateTableOptions): Promise<void>;
  alterTable(name: string, operation: AlterTableOperation): Promise<void>;
  insertArrow(table: string, data: BufferSource): Promise<number>;
  compactDatabase(name: string): Promise<void>;
  flush(): Promise<void>;
  exportGeoParquet(queryOrTable: string, options?: GeoParquetExportOptions): Promise<Uint8Array>;
  downloadGeoParquet(queryOrTable: string, options?: DownloadGeoParquetOptions): Promise<string>;
  tables(options?: { qualified?: boolean }): string[];
  version(): string;
}

API notes:

  • sql() returns Arrow IPC bytes as Uint8Array.
  • sqlJSON() returns parsed JSON rows.
  • registerFile() supports .parquet, .geoparquet, .geojson, and .json in this package.
  • registerObjectStores() and registerParquetTable() support browser-backed ranged Parquet reads for http, s3, gcs, and azure providers.
  • S3 temporary credentials use access_key_id, secret_access_key, and token, where token is the STS SessionToken.
  • S3-compatible endpoints can be configured with endpoint; use allow_http: true for local HTTP endpoints such as MinIO or LocalStack.
  • registerRaster() and registerGeoTIFF() are part of the shared wrapper, but raster registration requires @cereusdb/full.
  • Persistent databases (createDatabase() and related methods), ALTER TABLE, insertArrow(), catalog() and GeoParquet export are available in every package.
  • downloadGeoParquet() and COPY ... TO pass the file to the onExport handler: a browser download by default on the main thread; pass your own handler in Web Workers or Node.js.

Example

import { CereusDB } from '@cereusdb/standard';

const db = await CereusDB.create();

const rows = await db.sqlJSON(`
  SELECT ST_AsText(
    ST_Transform(
      ST_GeomFromWKT('POINT(13.4 52.5)'),
      'EPSG:4326',
      'EPSG:3857'
    )
  ) AS geom
`);

console.log(rows);

版本与发布记录

@cereusdb/standard 共发布 6 个版本,首次发布于 2026/04/11;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.0latest2026/10/061 个月前
0.3.02026/10/021 个月前
0.2.02026/06/204 个月前
0.1.22026/04/146 个月前
0.1.12026/04/146 个月前
0.1.02026/04/116 个月前

关于 @cereusdb/standard 的常见问题

@cereusdb/standard 是什么?

Standard CereusDB browser package with GEOS and PROJ support

如何安装 @cereusdb/standard?

在项目目录运行 npm install @cereusdb/standard,或使用 pnpm add / yarn add / bun add。

@cereusdb/standard 支持 TypeScript 吗?

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

@cereusdb/standard 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cereusdb/standard 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cereusdb/standard 可以商用吗?

@cereusdb/standard 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cereusdb/standard 的下载量有多少?

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

@cereusdb/standard 还在维护吗?

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