@x12i/memorix-mapping
v3.0.2
Published
Shared deterministic Memorix mapping AST and execution core (source, abstract, completion).
Readme
@x12i/memorix-mapping
Shared deterministic mapping AST and execution core for Memorix (source maps, abstract reverse maps, completion-style transforms).
Mappings are declared in metadata; this package validates and executes them. No network I/O and no Mongo.
Install
npm install @x12i/[email protected]| Audience | Use this package? | |----------|-------------------| | Remote app | Prefer pipelines / HTTP — maps run inside the platform | | Pipeline / transform authors | Yes — validate, execute, simulate | | Pack-only authors | Keep maps in metadata; runtime uses this under the hood |
Core API
import {
validateMappingDocument,
executeMapping,
executeReverseMapping,
simulateMapping,
createDefaultRegistry,
} from "@x12i/memorix-mapping";| Function | Role |
|----------|------|
| validateMappingDocument | Structural AST validation |
| executeMapping | Forward map: input → output object |
| executeReverseMapping | Reverse path for abstract write / completion |
| simulateMapping | Dry-run with diagnostics |
| createDefaultRegistry | Built-in transform registry |
Quick example
import { executeMapping, validateMappingDocument } from "@x12i/memorix-mapping";
const doc = /* MappingDocument from metadata */;
const v = validateMappingDocument(doc);
if (!v.ok) throw new Error(v.errors.map((e) => e.message).join("; "));
const result = executeMapping(doc, sourcePayload);
if (!result.ok) throw new Error(result.errors.map((e) => e.message).join("; "));
// result.value → mapped objectHow it fits
metadata (mappings kind) → pipeline map-normalize / abstract reverse-write → this packageHTTP surface: maps are invoked via memorix-service pipelines and data APIs, not as a standalone public map endpoint.
