SIAX Technology (sax3l)

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}) equals hash({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
npm
2026-11-06 17:52:01 +00:00
1
MIT
latest
38 KiB
Assets (1)
Versions (7) View all
0.6.0 2026-11-06
0.5.1 2026-10-10
0.5.0 2026-10-07
0.4.2 2026-10-04
0.3.1 2026-10-02