Turn a natural-language prompt into a report query through a unified Regex + OpenAI pipeline — with Arabic normalization, fingerprint caching, and a pluggable DSL builder. Minimal tokens, maximal reuse.
Every prompt passes through the same pipeline. The engine produces a DSL only — execution is delegated to dynamic-hybrid-reporting-engine, fed by dual-layer-reporting-engine.
fingerprintBoth parsers return the exact same IntermediateQuery. Only the parser knows its source; the DSL builder and the rest of the app stay source-agnostic.
The parse method is switchable: auto (regex → OpenAI), regex (no tokens), or openai. Every collaborator sits behind an interface.
Deterministic and token-free. Matches editable MongoDB mappings and column concepts. Resolves "students in class 1-A" to a class_id filter via a pluggable EntityResolver.
Runs only when regex can't match. Returns strict JSON — never DSL, never raw SQL. Tracks latency and token usage for the execution log.
Equivalent prompts (spacing, tashkeel, alef variants) share one fingerprint, so a repeated question skips parsing entirely and costs zero tokens.
Inject the pipeline, get a DSL, hand it to the reporting engine.
Alef/teh-marbuta unify, tashkeel & punctuation stripped.
SHA-256 of the normalized prompt — zero tokens on repeats.
Regex & AI return the same IntermediateQuery.
The single place that emits an executable DSL.
Every collaborator is a swappable interface.
Editable mappings, concepts & prompt cache.
Map names ("class 1-A") to ids for filtering.
Parser, cache hit, ms, tokens, generated DSL.
Both reporting packages are hard requirements and are pulled in automatically.
mostafax/dynamic-hybrid-reporting-engine — executes the DSL.
mostafax/dual-layer-reporting-engine — replicates data for reporting.
auto — regex first, OpenAI on miss (recommended).
regex — local only, no tokens.
openai — AI only.