SIAX Technology AB focuses on agentic process automation: process analysis, operational improvement, data and system integration.
@siax/analytical-context (0.6.0)
Published 2026-11-06 17:52:01 +00:00 by admin
Installation
@siax:registry=https://git.cloud.siax.io/api/packages/sax3l/npm/npm install @siax/analytical-context@0.6.0"@siax/analytical-context": "0.6.0"About this package
SIAX analytical kernel — a typed analytical intent (AnalyticalContext) with a fail-closed AST, deterministic normalization/hashing, injection-safe URL/SQL/DuckDB/grid projections and an immutable AnalysisSession (snapshot + append-only delta log) for undo/redo/share/reproduce.
@siax/analytical-context
The semantic kernel of the SIAX analytical plane. A typed analytical intent
(AnalyticalContext) is compiled — deterministically and injection-safely — to
URL / SQL / DuckDB / grid projections, and can be captured in an immutable
AnalysisSession for undo/redo/share/reproduce.
Zero runtime dependencies (only node:crypto for hashing). Pure ESM .js with
hand-written .d.ts.
Typed AST
FilterExpr = Eq | In | Range | Exists | Text | Temporal | Spatial | And | Or | Not
SelectionExpr · CompareExpr · SortExpr · GroupingExpr
AnalyticalContext = {
filters, selection, compare, sorting, grouping,
temporal, spatial, dataset, sourceVersion
}
Constructors: eq, inSet, range, exists, text, temporal, spatial,
and, or, not, select, compare, sort, group.
API
| Group | Functions |
|---|---|
| Canonical | normalize/normalizeContext, serialize, deserialize, hash, equals, diff, merge, validate, invert |
| Compile | compileToUrl, parseAnalyticalUrl, compileToSql, compileToDuckDb, compileToGrid |
| Session | createSession, forkSession, diffSessions, restoreSession, appendEdit, undoSession, redoSession, createDelta, applyDelta, revertDelta |
| Loop guard | canonicalHash, analysisEventEnvelope, shouldEmitEvent |
Guarantees
- Deterministic —
hash({country=SE AND year=2026})equalshash({year=2026 AND country=SE}): And/Or operands are deduped and sorted. - Fail-closed — unknown nodes/fields and invalid identifiers throw.
- Injection-safe — identifiers are whitelisted; values are bound parameters
(
compileToSql) or escaped literals (compileToDuckDb); user text is never interpolated raw.
Example
import {
and, eq, range, select, sort, group,
normalizeContext, hash, compileToSql, compileToUrl,
} from '@siax/analytical-context';
const ctx = {
dataset: 'sales',
filters: and([eq('country', 'SE'), range('year', { min: 2020, max: 2026 })]),
selection: select(['year', { field: 'revenue', aggregate: 'sum', alias: 'total' }]),
grouping: group(['year']),
sorting: sort([{ field: 'year', direction: 'asc' }]),
};
hash(ctx); // stable sha-256
compileToUrl(ctx); // /analytics?dataset=sales&ctx=...
compileToSql(ctx, { table: 'sales' }); // { sql, params, ... } — bound values
Tests
pnpm --filter @siax/analytical-context test
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| typescript | ^5.7.2 |
| vitest | ^3.0.0 |
Details
Assets (1)
Versions (7)
View all
analytical-context-0.6.0.tgz
38 KiB