Skip to content

Commit 2e2a32d

Browse files
committed
fixes @gnata -> @gnata-sqlite
updates markdown
1 parent 57bd9c2 commit 2e2a32d

12 files changed

Lines changed: 178 additions & 50 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug
4+
labels: bug
5+
---
6+
7+
**What happened?**
8+
9+
**Expected behavior**
10+
11+
**Reproduction**
12+
13+
Minimal JSONata expression and input that triggers the bug:
14+
15+
```
16+
Expression:
17+
Input:
18+
```
19+
20+
**Environment**
21+
- OS:
22+
- Go version:
23+
- gnata-sqlite version/commit:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a feature
4+
labels: enhancement
5+
---
6+
7+
**What problem does this solve?**
8+
9+
**Proposed solution**
10+
11+
**Alternatives considered**

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## What
2+
3+
Brief description.
4+
5+
## Why
6+
7+
Context and motivation.
8+
9+
## How
10+
11+
Implementation approach.
12+
13+
## Test plan
14+
15+
How this was tested.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ skills-lock.json
88
.DS_Store
99
node_modules/
1010
editor/codemirror/dist/
11+
lsp-wasm_exec.js
12+
wasm_exec.js

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Contributing
2+
3+
## Development Setup
4+
5+
```bash
6+
git clone git@github.com:rbbydotdev/gnata-sqlite.git
7+
cd gnata-sqlite
8+
go build ./...
9+
go test -race ./...
10+
```
11+
12+
### Optional: SQLite Extension
13+
14+
Requires CGo:
15+
16+
```bash
17+
go build -buildmode=c-shared -o gnata_jsonata.dylib ./sqlite
18+
```
19+
20+
### Optional: WASM LSP
21+
22+
Requires [TinyGo](https://tinygo.org):
23+
24+
```bash
25+
tinygo build -o gnata-lsp.wasm -target wasm ./editor
26+
```
27+
28+
### Optional: CodeMirror Package
29+
30+
```bash
31+
cd editor/codemirror && npm install && npm run build
32+
```
33+
34+
## Project Structure
35+
36+
| Directory | Purpose |
37+
|-----------|---------|
38+
| Root `.go` files | Core JSONata 2.x engine (parser, evaluator, streaming) |
39+
| `functions/` | 50+ stdlib function implementations |
40+
| `internal/` | Lexer, parser, evaluator, query planner internals |
41+
| `sqlite/` | Loadable SQLite extension (CGo) |
42+
| `editor/` | CodeMirror 6 language support + WASM LSP |
43+
| `wasm/` | WASM build entry point |
44+
| `testdata/` | JSONata conformance test suite (1,778 cases) |
45+
46+
## Making Changes
47+
48+
1. Fork the repo
49+
2. Create a branch (`git checkout -b feat/my-feature`)
50+
3. Make changes and add tests
51+
4. Run `go test -race ./...`
52+
5. Run `golangci-lint run` if you have it installed
53+
6. Commit with a descriptive message
54+
7. Open a PR
55+
56+
## Code Style
57+
58+
- Follow standard Go conventions (`gofmt`, `go vet`)
59+
- Linting config is in `.golangci.yaml`
60+
- Tests live alongside the code they test (`*_test.go`)
61+
- Conformance tests use JSON datasets in `testdata/`

README.md

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
# gnata-sqlite
22

3-
A full [JSONata 2.x](https://jsonata.org) implementation in Go with SQLite integration, editor tooling, and query optimization.
3+
Full [JSONata 2.x](https://jsonata.org) implementation in Go with a loadable SQLite extension, streaming query optimizer, and 85KB WASM LSP.
44

5-
## Fork Notice
6-
7-
Forked from [RecoLabs/gnata](https://github.com/RecoLabs/gnata), which provides a production-grade JSONata 2.x engine in pure Go. This project extends the core engine with a loadable SQLite extension, a CodeMirror 6 editor with TinyGo WASM LSP, and a query planner that decomposes JSONata into streaming SQL-friendly operations.
8-
9-
## Packages
5+
[![CI](https://github.com/rbbydotdev/gnata-sqlite/actions/workflows/ci.yml/badge.svg)](https://github.com/rbbydotdev/gnata-sqlite/actions/workflows/ci.yml)
6+
[![Go Reference](https://pkg.go.dev/badge/github.com/rbbydotdev/gnata-sqlite.svg)](https://pkg.go.dev/github.com/rbbydotdev/gnata-sqlite)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8+
[![Go 1.25](https://img.shields.io/badge/Go-1.25-00ADD8.svg)](https://go.dev)
109

11-
| Package | Description | Docs |
12-
|---------|-------------|------|
13-
| `gnata` (root) | Core JSONata 2.x engine -- full spec, two-tier eval, streaming | [Core features below](#core-engine) |
14-
| `sqlite/` | SQLite extension -- `jsonata()`, `jsonata_query()`, `jsonata_each()`, mutations | [sqlite/README.md](sqlite/README.md) |
15-
| `editor/` | CodeMirror 6 language support + TinyGo WASM LSP | [editor/README.md](editor/README.md) |
10+
## Highlights
1611

17-
## Core Engine
12+
- **5M+ eval ops/sec** — two-tier evaluator with GJSON fast path hitting 10M+ ops/sec for simple paths
13+
- **Full JSONata 2.x spec** — paths, wildcards, lambdas, closures, higher-order functions, 50+ stdlib functions. 1,778 conformance tests, 0 failures
14+
- **SQLite extension**`jsonata()`, `jsonata_query()`, `jsonata_each()` as loadable functions with a built-in query planner
15+
- **85KB WASM LSP** — TinyGo-compiled language server for in-browser diagnostics and autocomplete
16+
- **Lock-free streaming**`StreamEvaluator` with schema-keyed plan caching for high-throughput batch workloads
1817

19-
The root package implements the full JSONata 2.x specification in pure Go:
20-
21-
- **Full JSONata 2.x** -- paths, wildcards, lambdas, closures, higher-order functions, 50+ stdlib functions
22-
- **Two-tier evaluation** -- GJSON fast path for simple expressions, full AST interpreter for complex ones
23-
- **Lock-free `StreamEvaluator`** -- batch evaluation with schema-keyed plan caching for high-throughput workloads
24-
- **1,778 test cases** from the official jsonata-js conformance suite (0 failures, 0 skips)
18+
## Quick Start
2519

2620
```go
2721
import "github.com/rbbydotdev/gnata-sqlite"
@@ -33,8 +27,6 @@ fmt.Println(result) // [34.45 21.67]
3327

3428
## SQLite Extension
3529

36-
A loadable SQLite extension that brings JSONata expressions into SQL queries. Query, transform, and aggregate JSON data directly from SQLite.
37-
3830
```sql
3931
.load ./gnata_jsonata sqlite3_jsonata_init
4032

@@ -45,27 +37,43 @@ SELECT jsonata_query('$sum(amount)', data) FROM orders;
4537
-- 4250
4638
```
4739

48-
Key functions:
40+
| Function | Description |
41+
|----------|-------------|
42+
| `jsonata(json, expr)` | Evaluate expression against JSON |
43+
| `jsonata_query(expr, json)` | Expression-first argument order |
44+
| `jsonata_each(expr, json)` | Expand results into rows (table-valued) |
45+
| `jsonata_set(json, path, val)` | Set a value at a path |
46+
| `jsonata_delete(json, path)` | Delete a value at a path |
47+
48+
See [sqlite/README.md](sqlite/README.md) for full docs. Query optimization details in [sqlite/OPTIMIZATION.md](sqlite/OPTIMIZATION.md).
4949

50-
- `jsonata(json, expr)` -- evaluate a JSONata expression against a JSON value
51-
- `jsonata_query(expr, json)` -- same operation, expression-first argument order
52-
- `jsonata_each(expr, json)` -- expand results into rows (table-valued function)
53-
- `jsonata_set(json, path, value)` -- set a value at a path
54-
- `jsonata_delete(json, path)` -- delete a value at a path
50+
## Benchmarks
5551

56-
The built-in query planner decomposes JSONata expressions into streaming SQL-friendly operations for better performance on large datasets. See [sqlite/OPTIMIZATION.md](sqlite/OPTIMIZATION.md) and [sqlite/BLOGPOST.md](sqlite/BLOGPOST.md) for details.
52+
![Eval Performance](assets/benchmark-eval.png)
5753

58-
See [sqlite/README.md](sqlite/README.md) for full documentation.
54+
![GJSON Fast Path](assets/benchmark-fastpath.png)
5955

60-
## Editor / LSP
56+
<details>
57+
<summary>Raw numbers (Apple M1)</summary>
6158

62-
CodeMirror 6 language support and LSP server for JSONata, powered by gnata's parser.
59+
| Benchmark | ops/sec | ns/op | allocs/op |
60+
|-----------|---------|-------|-----------|
61+
| Eval `Account.Name` | **5,037,783** | 198 | 4 |
62+
| Eval `Order.Product.SKU` | 2,160,554 | 463 | 10 |
63+
| Eval `Product[Price>50].SKU` | 895,255 | 1,117 | 26 |
64+
| Eval `$sum(Product.*)` | 654,006 | 1,529 | 44 |
65+
| EvalBytes `Account.Name` | **10,280,965** | 97 | 2 |
66+
| Compile `Account.Name` | 1,757,469 | 569 | 13 |
6367

64-
- **TinyGo WASM LSP** -- 182 KB module (85 KB gzipped) for in-browser diagnostics and autocomplete
65-
- **CodeMirror 6 npm package** -- `@gnata/codemirror` with syntax highlighting, error diagnostics, context-aware autocomplete, and hover documentation
66-
- **Native LSP server** -- stdio JSON-RPC for VS Code, Neovim, and other editors
68+
</details>
6769

68-
See [editor/README.md](editor/README.md) for full documentation.
70+
## Packages
71+
72+
| Package | Description |
73+
|---------|-------------|
74+
| `gnata` (root) | Core JSONata 2.x engine — full spec, two-tier eval, streaming |
75+
| [`sqlite/`](sqlite/README.md) | SQLite extension — loadable functions, query planner, mutations |
76+
| [`editor/`](editor/README.md) | CodeMirror 6 language support + TinyGo WASM LSP |
6977

7078
## Building
7179

@@ -85,8 +93,16 @@ cd editor/codemirror && npm install && npm run build
8593

8694
## Playground
8795

88-
Open `playground.html` for interactive testing of JSONata expressions and the SQLite extension in the browser.
96+
Open `playground.html` or visit the [live playground](https://rbbydotdev.github.io/gnata-sqlite/) for interactive testing of JSONata expressions and the SQLite extension.
97+
98+
## Contributing
99+
100+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
101+
102+
## Fork Notice
103+
104+
Forked from [RecoLabs/gnata](https://github.com/RecoLabs/gnata), which provides a production-grade JSONata 2.x engine in pure Go. This project extends the core engine with a SQLite extension, editor tooling, and query optimizer.
89105

90106
## License
91107

92-
MIT. Based on [RecoLabs/gnata](https://github.com/RecoLabs/gnata).
108+
[MIT](LICENSE)

assets/benchmark-eval.png

79.2 KB
Loading

assets/benchmark-fastpath.png

57.3 KB
Loading

editor/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Two delivery modes from the same codebase:
1313

1414
```typescript
1515
import { EditorView, basicSetup } from "codemirror"
16-
import { jsonataFull, initWasm } from "@gnata/codemirror"
16+
import { jsonataFull, initWasm } from "@gnata-sqlite/codemirror"
1717

1818
// Load the WASM module (182 KB, 85 KB gzipped).
1919
await initWasm("/gnata-lsp.wasm", "/lsp-wasm_exec.js")
@@ -169,7 +169,7 @@ Pass the schema when the LSP client initializes:
169169
Syntax highlighting only. No WASM required.
170170

171171
```typescript
172-
import { jsonata } from "@gnata/codemirror"
172+
import { jsonata } from "@gnata-sqlite/codemirror"
173173
// extensions: [basicSetup, jsonata()]
174174
```
175175

@@ -178,7 +178,7 @@ import { jsonata } from "@gnata/codemirror"
178178
Full support: syntax highlighting + WASM linter + autocomplete.
179179

180180
```typescript
181-
import { jsonataFull } from "@gnata/codemirror"
181+
import { jsonataFull } from "@gnata-sqlite/codemirror"
182182
// extensions: [basicSetup, jsonataFull({ schema: '...' })]
183183
```
184184

@@ -254,7 +254,7 @@ npm run build
254254
```tsx
255255
import { useEffect, useRef } from "react"
256256
import { EditorView, basicSetup } from "codemirror"
257-
import { jsonataFull, initWasm } from "@gnata/codemirror"
257+
import { jsonataFull, initWasm } from "@gnata-sqlite/codemirror"
258258

259259
export function JsonataEditor({ schema }: { schema: string }) {
260260
const ref = useRef<HTMLDivElement>(null)
@@ -278,7 +278,7 @@ export function JsonataEditor({ schema }: { schema: string }) {
278278
<div id="editor"></div>
279279
<script type="module">
280280
import { EditorView, basicSetup } from "codemirror"
281-
import { jsonata, initWasm, jsonataLint } from "@gnata/codemirror"
281+
import { jsonata, initWasm, jsonataLint } from "@gnata-sqlite/codemirror"
282282
283283
// Syntax highlighting works immediately.
284284
const view = new EditorView({
@@ -303,7 +303,7 @@ editor/
303303
funcinfo.go # Built-in function catalog (70+ functions)
304304
schema.go # Schema JSON parser (no encoding/json)
305305
marshal.go # Reflect-free AST → JSON serializer
306-
codemirror/ # npm package (@gnata/codemirror)
306+
codemirror/ # npm package (@gnata-sqlite/codemirror)
307307
src/
308308
jsonata.grammar # Lezer grammar for syntax highlighting
309309
highlight.js # CodeMirror style tag mappings

editor/codemirror/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @gnata/codemirror
1+
# @gnata-sqlite/codemirror
22

33
CodeMirror 6 language support for [JSONata](https://jsonata.org) expressions — syntax highlighting, error diagnostics, autocomplete, and hover documentation, powered by a 85KB WASM module.
44

@@ -12,7 +12,7 @@ CodeMirror 6 language support for [JSONata](https://jsonata.org) expressions —
1212
## Install
1313

1414
```bash
15-
npm install @gnata/codemirror
15+
npm install @gnata-sqlite/codemirror
1616
```
1717

1818
You also need the WASM files served from your app:
@@ -23,7 +23,7 @@ You also need the WASM files served from your app:
2323

2424
```ts
2525
import { EditorView, basicSetup } from "codemirror"
26-
import { initWasm, jsonataFull } from "@gnata/codemirror"
26+
import { initWasm, jsonataFull } from "@gnata-sqlite/codemirror"
2727

2828
// 1. Load WASM (once, at startup)
2929
await initWasm("/gnata-lsp.wasm", "/lsp-wasm_exec.js")
@@ -73,7 +73,7 @@ import {
7373
jsonataLint, // error diagnostics
7474
jsonataCompletion, // autocomplete
7575
jsonataHover, // hover tooltips
76-
} from "@gnata/codemirror"
76+
} from "@gnata-sqlite/codemirror"
7777

7878
extensions: [
7979
jsonata(),
@@ -357,7 +357,7 @@ A complete working example using ESM imports (no build step):
357357
│ Your App (browser) │ │ gnata-lsp.wasm (85KB) │
358358
│ │ │ TinyGo WASM module │
359359
│ CodeMirror Editor │────▶│ │
360-
│ + @gnata/codemirror │ │ _gnataDiagnostics(expr) │
360+
│ + @gnata-sqlite/codemirror │ │ _gnataDiagnostics(expr) │
361361
│ │◀────│ _gnataCompletions(...) │
362362
│ │ │ _gnataHover(expr, pos) │
363363
└─────────────────────────┘ └──────────────────────────┘

0 commit comments

Comments
 (0)