@yorm/core
v0.1.0
Published
Deterministic object→rows projection engine for YORM: the mapping DSL, projection planner, provenance tags, and store contracts. Zero runtime dependencies.
Readme
@yorm/core
The deterministic object→rows projection engine of YORM. Pure functions and types — zero runtime dependencies (no Hono, Drizzle, or Yjs imports).
What lives here:
mapping/— the mapping DSL:defineMapping,one(...),many(...), versioned and frozen mapping contracts.planner/—planProjection(mapping, input): turns a materialized object into a deterministicProjectionPlanof upserts and scoped reconciliation deletes, plus a checkpoint.provenance/— theOrigintag (yjs,sql,replay, …) carried by every plan and update.stores/— theDocumentStore,ProjectionStore, andRuntimecontracts that adapters implement.
Usage
import { defineMapping, many, one, planProjection } from "@yorm/core";
const patientMapping = defineMapping<{ id: string; active?: boolean }>({
name: "fhir.Patient",
version: 1,
documentType: "Patient",
projections: [
one("patient", {
key: ({ object }) => ({ id: object.id }),
values: ({ object }) => ({ active: object.active ?? null }),
}),
],
});
const plan = planProjection(patientMapping, {
object: { id: "p1", active: true },
documentId: "p1",
documentVersion: 1,
origin: "yjs",
});
// → { operations: [{ kind: "upsert", table: "patient", ... }], checkpoint: { ... } }Adapters apply plans transactionally; core never performs I/O. See the root README for the full design (stable identity, column ownership, reconciliation semantics).
