laterite 0.1.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/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # laterite
2
+
3
+ AGS4 geotechnical data for **Node.js** — read, validate, produce, and query, backed by a Rust engine (the Node port of the [`laterite`](https://pypi.org/project/laterite/) Python toolkit).
4
+
5
+ Born-typed: a `2DP` heading comes back as a JavaScript number, an `ID` as a string, a `DT` as a `Date` — decoded directly from the engine's typed Arrow, the same typing the Python and browser-wasm hosts produce.
6
+
7
+ ```bash
8
+ npm install laterite
9
+ ```
10
+
11
+ Prebuilt native binaries ship for linux-x64-gnu, darwin-arm64, and win32-x64-msvc (auto-selected via `optionalDependencies`).
12
+
13
+ ## Part of the laterite suite
14
+
15
+ One clean-room Rust AGS4 engine, surfaced for every stack:
16
+
17
+ | Surface | Package | Get it |
18
+ |---|---|---|
19
+ | **Python** | [`laterite`](https://pypi.org/project/laterite/) — PyPI | `pip install laterite` |
20
+ | **Node.js** | [`laterite`](https://www.npmjs.com/package/laterite) — npm | `npm install laterite` |
21
+ | **Rust / CLI** | [`ags5db` + `ags4-check`](https://github.com/niko86/laterite/releases) | GitHub Releases |
22
+ | **Browser** | [validator + data explorer](https://niko86.github.io/laterite/) — WASM | open in a browser |
23
+
24
+ ## Read & validate
25
+
26
+ ```ts
27
+ import { read, validate } from "laterite";
28
+
29
+ const ags = read("delivery.ags"); // or read(undefined, { text })
30
+ ags.groups; // ["PROJ", "LOCA", "SAMP", …]
31
+ const loca = ags.table("LOCA"); // a born-typed apache-arrow Table
32
+ loca.getChild("LOCA_GL")?.get(0); // → 12.3 (a number)
33
+
34
+ const report = validate("delivery.ags");
35
+ report.isValid; // boolean
36
+ report.findings; // [{ rule, line?, group, desc, severity? }]
37
+ report.toJson(); // byte-identical to `ags4-check --json`
38
+ ```
39
+
40
+ ## Produce AGS4
41
+
42
+ From per-group data (arrow-js Tables or plain row objects):
43
+
44
+ ```ts
45
+ import { emitAgs4 } from "laterite";
46
+
47
+ const res = emitAgs4(new Map([
48
+ ["PROJ", [{ PROJ_ID: "P1", PROJ_NAME: "Demo" }]],
49
+ ["LOCA", [{ LOCA_ID: "BH01", LOCA_GL: 12.3 }]],
50
+ ]), { edition: "4.1.1", mode: "autofix" });
51
+
52
+ res.text; // the AGS4 document
53
+ res.write("out.ags");
54
+ ```
55
+
56
+ …or from a **typed builder graph** (`import { PROJ, LOCA } from "laterite"`):
57
+
58
+ ```ts
59
+ import { PROJ, LOCA, emitAgs4 } from "laterite";
60
+
61
+ const proj = new PROJ({
62
+ PROJ_ID: "P1",
63
+ PROJ_NAME: "Demo",
64
+ locas: [new LOCA({ LOCA_ID: "BH01", LOCA_GL: 12.3 })],
65
+ });
66
+ emitAgs4(proj); // walks the tree → valid AGS4
67
+ ```
68
+
69
+ ## SQL across groups (optional)
70
+
71
+ `sql()` / `at()` need the optional peer `@duckdb/node-api`:
72
+
73
+ ```bash
74
+ npm install @duckdb/node-api
75
+ ```
76
+
77
+ ```ts
78
+ const ags = read("delivery.ags");
79
+
80
+ // cross-group JOIN — plain JS row objects by default
81
+ const rows = await ags.sql(
82
+ "SELECT * FROM SAMP JOIN LOCA USING (LOCA_ID) WHERE LOCA_GL > 50",
83
+ );
84
+
85
+ // key-filter a location's whole related record set
86
+ const frames = await ags.at("LOCA", ["BH01", "BH02"]).frames();
87
+
88
+ // opt into arrow-js Table output (loads DuckDB's `arrow` community extension)
89
+ const table = await ags.sql("SELECT * FROM LOCA", { arrow: true });
90
+ ```
91
+
92
+ ## Also exported
93
+
94
+ - `agsTypes` — `canonicalType` / `displayHint` / `parseValue`
95
+ - `registry` — `GROUPS`, `childGroups`, `ancestorChain`, …
96
+ - `transport` — `pack` / `unpack` (zstd) + `lock` / `unlock` (age passphrase)
97
+
98
+ ## License
99
+
100
+ MIT