Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

NEW-HEAT/strata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@new-heat/strata

Archived. The concepts explored here were discovered to already exist in @sqlrooms/noodles — under active maintenance and prioritized over an internal approach. No further development planned.


Shared spatiotemporal data infrastructure for NEW HEAT and Agroview.

Strata gives your app three things: a DuckDB schema for client-side spatial data, Zustand slices for state management, and shared types with validation.

Install

{
  "dependencies": {
    "@new-heat/strata": "file:../strata"
  }
}

What's in the box

@new-heat/strata/sql      DuckDB tables, views, query builders
@new-heat/strata/slices   Zustand slices (sources, timeline, colors, compute)
@new-heat/strata/core     Source/Group types, Zod schemas, STP protocol
@new-heat/strata/colors   Color themes and palettes
@new-heat/strata/ai       Date tools, geocoding, activity utils, graph mods
@new-heat/strata/operators Arrow operator logic (pure functions + noodles wrappers)

Quick Start

1. Set up DuckDB

import { initAll, sourcesQuery } from '@new-heat/strata/sql';

// Create all tables and views
await db.exec(initAll());

// Query with type-safe filters
const sql = sourcesQuery({
  types: ['motion'],
  uploaderId: 'user-1',
  timeRange: { start: 1704067200000, end: 1704153600000 },
});
const result = await db.query(sql);

2. Wire up state

import {
  createSourcesSlice,
  createTimelineSlice,
  createColorsSlice,
  createComputeSlice,
} from '@new-heat/strata/slices';

// Each slice is a function: (set, get) => sliceState
// Compose into your Zustand store however you like
const useStore = create((set, get) => ({
  ...createSourcesSlice()(set, get),
  ...createTimelineSlice()(set, get),
  ...createColorsSlice()(set, get),
  ...createComputeSlice()(set, get),
}));

// Slices give you actions + SQL generators
const sql = useStore.getState().filteredSourcesSql();
const temporalFilter = useStore.getState().temporalFilterSql();
const colorExpr = useStore.getState().colorExpressionSql();

3. Validate data at boundaries

import { sourceSchema, parseSTP, buildSTP } from '@new-heat/strata/core';

// Validate untrusted source data
const source = sourceSchema.parse(untrustedJson);

// Parse/build STP protocol URIs
const parsed = parseSTP('stp://group/g1/motions');
const uri = buildSTP({ kind: 'group', groupId: 'g1', filter: 'motions' });

Package Structure

src/
  core/       Types, Zod schemas, STP protocol, geo validation
  sql/        DuckDB table DDL, views, query builders
  slices/     Zustand slice creators (no zustand dependency)
  colors/     Color theme data and types
  ai/         Date tools, geocode, activity utils, graph modifications
  operators/  Arrow operator logic + noodles.gl wrappers

Scripts

pnpm test        # 211 tests (vitest)
pnpm build       # Build (tsc)
pnpm typecheck   # Type check
pnpm clean       # Remove dist/

Architecture

  • core/ has zero external dependencies (just zod)
  • sql/ depends only on core types
  • slices/ are pure functions — no zustand dependency, consumers pass set/get
  • ai/ is mostly pure utilities; apply-modifications requires noodles-gl runtime
  • operators/ logic functions are pure; operator classes require noodles-gl runtime
  • Bare noodles-gl/* imports resolve through the consumer's bundler via Vite alias

License

MIT — NEW HEAT, Inc.

About

Spatiotemporal data infrastructure: DuckDB schema, Zustand slices, types, and AI utilities

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors