Declarative logic VM for JSON schemas - reactive validation, temporal routing, and computed state
npm install @dlovans/tenet-coreDeclarative logic VM for JSON schemas. Reactive validation, temporal routing, and computed state.
Pure TypeScript — No WASM, no native dependencies. Works in browsers, Node.js, Deno, Bun.
``bash`
npm install @dlovans/tenet-core
`html`
`javascript
import { run, verify } from '@dlovans/tenet-core';
// Run schema logic - no initialization needed
const result = run(schema, new Date());
if (result.error) {
console.error(result.error);
} else {
console.log(result.result.status); // 'READY', 'INCOMPLETE', or 'INVALID'
console.log(result.result.errors); // Validation errors (if any)
}
// Verify transformation
const verification = verify(newSchema, oldSchema);
console.log(verification.valid);
`
- schema — TenetSchema object or JSON stringdate
- — Effective date for temporal routing (default: now)
Returns { result: TenetSchema } or { error: string }.
Returns { valid: boolean, error?: string }.
. Kept for backwards compatibility.$3
No-op. Kept for backwards compatibility with v0.1.x.Runtime Validation
The VM automatically detects and reports:
- Undefined variables —
{"var": "unknown_field"}
- Unknown operators — {"invalid_op": [...]}
- Temporal conflicts — Overlapping date ranges, same start/end datesAll errors are returned in
result.errors without failing execution.TypeScript
Full type definitions included:
`typescript
import type { TenetSchema, TenetResult, Definition, Rule } from '@dlovans/tenet-core';
`Migration from v0.1.x
`javascript
// Before (v0.1.x with WASM)
import { init, run, lint } from '@dlovans/tenet-core';
await init('./tenet.wasm');
const result = run(schema);
const issues = lint(schema);// After (v0.2.x pure TypeScript)
import { run } from '@dlovans/tenet-core';
const result = run(schema);
// Validation errors are now in result.result.errors
``MIT