@dbsp/nql 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Olivier Orabona
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @dbsp/nql
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@dbsp/nql.svg)](https://www.npmjs.com/package/@dbsp/nql)
4
+ [![license](https://img.shields.io/npm/l/@dbsp/nql.svg)](LICENSE)
5
+
6
+ NQL (Natural Query Language) — a human- and LLM-friendly pipe-based query language that compiles to `IntentAST` for `@dbsp/core`.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pnpm add @dbsp/nql
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```typescript
17
+ // doctest: skip — exec-only operation; compile from @dbsp/nql is not in doctest preamble and orm.from(intent).all() requires a real PostgreSQL connection
18
+ import { compile } from '@dbsp/nql';
19
+
20
+ // Compile an NQL query to IntentAST
21
+ const intent = compile(
22
+ "users | where active = true | select name, email | order name asc | limit 20",
23
+ schema
24
+ );
25
+
26
+ // Pass the intent to the ORM
27
+ const users = await orm.from(intent).all();
28
+ ```
29
+
30
+ ## Syntax overview
31
+
32
+ ```nql
33
+ -- Basic selection with filter
34
+ users | where status = 'active'
35
+
36
+ -- Computed columns and ordering
37
+ orders | select id, total, tax | order total desc | limit 10
38
+
39
+ -- Relations (auto-resolved from schema refs)
40
+ posts | include author | where published = true
41
+
42
+ -- CTEs (WITH clause)
43
+ with recent AS (orders | where createdAt > '2024-01-01')
44
+ recent | select id, total
45
+
46
+ -- Aggregation
47
+ orders | group customerId | select customerId, sum(total) as revenue
48
+ ```
49
+
50
+ ## Key features
51
+
52
+ - **Pipe syntax** — Readable left-to-right data flow (`table | filter | select | order`)
53
+ - **SQL-style literals** — Single-quoted strings (`'value'`), not double-quoted
54
+ - **CTE support** — `WITH name AS (subquery)` for named subqueries
55
+ - **Schema-aware** — Validates column names and relation paths against `ModelIR` at parse time
56
+ - **LLM-friendly** — Concise syntax designed for AI-generated queries
57
+ - **Chevrotain-based** — Robust lexer + parser with structured error recovery
58
+ - **Composable** — Output `IntentAST` is the same type used by the TypeScript fluent builders
59
+
60
+ ## Documentation
61
+
62
+ - [Guides](https://oorabona.github.io/db-semantic-planner/guide/)
63
+ - [Full-text search guide](https://oorabona.github.io/db-semantic-planner/guide/full-text-search)
64
+
65
+ ## License
66
+
67
+ MIT