laterite 0.1.0 → 0.5.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/index.d.ts CHANGED
@@ -67,11 +67,12 @@ export interface GroupMeta {
67
67
  lineNumbers: Array<number>
68
68
  }
69
69
  /**
70
- * Parse an AGS4 file (`path`) or in-memory `text` into a `Reading` handle.
71
- * `encoding`: `"utf-8"` (default) / `"windows-1252"` / a label. Throws the
72
- * classified `kind␟code␟message` (see the error-protocol note) on bad input.
70
+ * Parse an AGS4 file (`path`), in-memory `text`, or raw `data` bytes into a
71
+ * `Reading` handle. `encoding`: `"utf-8"` (default) / `"windows-1252"` / a label
72
+ * applies to `path` / `data` (text is already decoded). Throws the classified
73
+ * `kind␟code␟message` (see the error-protocol note) on bad input.
73
74
  */
74
- export declare function parseArrow(path?: string | undefined | null, text?: string | undefined | null, encoding?: string | undefined | null): Reading
75
+ export declare function parseArrow(path?: string | undefined | null, text?: string | undefined | null, data?: Uint8Array | undefined | null, encoding?: string | undefined | null): Reading
75
76
  /** One rule violation (omitting `severity` ⇒ error, matching the engine). */
76
77
  export interface Finding {
77
78
  rule: string
@@ -85,7 +86,7 @@ export interface Finding {
85
86
  * `ok` is **false only for un-validatable input** (the TS `raiseFor` raises
86
87
  * then); rule *violations* come back in `findings` with `ok:true`. `Report`'s
87
88
  * `isValid` is the separate `count == 0`. `json`/`ndjson` are byte-identical
88
- * to `ags4-check --json` / `--ndjson`.
89
+ * to `lat-check --json` / `--ndjson`.
89
90
  */
90
91
  export interface ValidationReport {
91
92
  ok: boolean
@@ -96,7 +97,7 @@ export interface ValidationReport {
96
97
  errorKind?: string
97
98
  error?: string
98
99
  /**
99
- * Mirrors the `ags4-check` binary: 0 valid / 1 findings on success;
100
+ * Mirrors the `lat-check` binary: 0 valid / 1 findings on success;
100
101
  * 3 not-found/io, 4 not-utf8/not-ags4/bad-edition, 5 bad-dict on failure.
101
102
  */
102
103
  exitCode: number
@@ -112,8 +113,56 @@ export interface ValidationReport {
112
113
  * Validate an AGS4 file (`path`) or `text` against the AGS4 rules. `dict_version`
113
114
  * `None`/`"auto"` auto-detects from `TRAN_AGS`, else forces an edition. Returns
114
115
  * the `{ok:false}` failure report (not a throw) for un-validatable input.
116
+ *
117
+ * Severity tiers track importance (like a compiler): errors **and WARNINGs** are
118
+ * returned by default (`includeWarnings` defaults to `true`); pass `false` for
119
+ * errors-only. `includeFyi` (default `false`) adds the low-signal FYI tier.
115
120
  */
116
- export declare function runCheck(path?: string | undefined | null, text?: string | undefined | null, dictVersion?: string | undefined | null, includeWarnings?: boolean | undefined | null, includeFyi?: boolean | undefined | null, checkFiles?: boolean | undefined | null, encoding?: string | undefined | null): ValidationReport
121
+ export declare function runCheck(path?: string | undefined | null, text?: string | undefined | null, data?: Uint8Array | undefined | null, dictVersion?: string | undefined | null, includeWarnings?: boolean | undefined | null, includeFyi?: boolean | undefined | null, checkFiles?: boolean | undefined | null, encoding?: string | undefined | null): ValidationReport
122
+ /**
123
+ * The AGS4 rule catalogue as the gated `rules_meta.json` — byte-identical to
124
+ * laterite-py's `list_rules()` and `lat-check --list-rules --json`. The TS
125
+ * layer parses it into typed `RuleMeta[]`. No input file.
126
+ */
127
+ export declare function listRules(): string
128
+ /**
129
+ * One applied fix — the Node mirror of laterite-py's `applied[]` entries.
130
+ * `kind`/`risk` are the serde snake_case strings (`strip_bom`, `safe`, …) so
131
+ * the shape is identical across Python / CLI / Node.
132
+ */
133
+ export interface AppliedFix {
134
+ kind: string
135
+ label: string
136
+ rule: string
137
+ line?: number
138
+ risk: string
139
+ }
140
+ /**
141
+ * The repair report — the Node mirror of laterite-py's `fix_file` dict. `ok` is
142
+ * false only for un-fixable input (the TS layer raises then). `fixed` is the
143
+ * repaired bytes (the original verbatim when nothing applied); `residual` is
144
+ * what could *not* be mechanically fixed.
145
+ */
146
+ export interface FixReport {
147
+ ok: boolean
148
+ errorKind?: string
149
+ error?: string
150
+ exitCode: number
151
+ fixed: Buffer
152
+ dictVersion: string
153
+ resolution: string
154
+ fixesApplied: number
155
+ applied: Array<AppliedFix>
156
+ residual: Array<Finding>
157
+ }
158
+ /**
159
+ * Mechanically repair an AGS4 file (`path`) / `text` / `data`: apply the SAFE
160
+ * fixes (plus the risky set when `includeRisky`), re-validate, and return the
161
+ * fixed bytes + residual findings. Mirrors laterite-py's `fix()` /
162
+ * `lat-check --fix`; the single `fix_document` orchestration is shared. The TS
163
+ * layer wraps this into a `FixResult` (`.bytes` / `.text` / `.save(path)`).
164
+ */
165
+ export declare function fixFile(path?: string | undefined | null, text?: string | undefined | null, data?: Uint8Array | undefined | null, dictVersion?: string | undefined | null, encoding?: string | undefined | null, includeRisky?: boolean | undefined | null): FixReport
117
166
  /**
118
167
  * One group of columnar input — its code + an Arrow IPC stream (`Buffer`)
119
168
  * whose column names are the AGS headings.
@@ -133,12 +182,12 @@ export interface EmitResult {
133
182
  }
134
183
  /**
135
184
  * Build valid AGS4 from per-group **Arrow IPC** streams (the columnar
136
- * producer; the read boundary reversed). = `ags4-wasm`'s `to_ags4_ipc`.
185
+ * producer; the read boundary reversed). = `laterite-ags4-wasm`'s `to_ags4_ipc`.
137
186
  */
138
187
  export declare function emitAgs4FromIpc(groups: Array<GroupIpc>, edition?: string | undefined | null, mode?: string | undefined | null): EmitResult
139
188
  /**
140
189
  * A parsed AGS4 file held native-side — the Node analog of laterite-py's
141
- * `Reading` handle (and `ags4-wasm`'s `ParsedDataset`). Each group's typed
190
+ * `Reading` handle (and `laterite-ags4-wasm`'s `ParsedDataset`). Each group's typed
142
191
  * `RecordBatch` is built lazily on `tableIpc(code)` and dropped after the
143
192
  * bytes are returned, so peak residency is one batch.
144
193
  */
@@ -155,7 +204,7 @@ export declare class Reading {
155
204
  /**
156
205
  * One group's rows as an Arrow **IPC stream** (`Buffer`), columns already
157
206
  * correctly typed. The Node analog of the pyo3-arrow capsule: the typed
158
- * columns come from the one shared emitter (`ags5_types::arrow_cols`), the
207
+ * columns come from the one shared emitter (`laterite_types::arrow_cols`), the
159
208
  * SAME casting Python/wasm use — so a file types byte-identically across
160
209
  * hosts. Returns `null` if the code isn't in the file.
161
210
  */
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { canonicalType, displayHint, parseValue, transportPack, transportUnpack, transportLock, transportUnlock, version, Reading, parseArrow, runCheck, emitAgs4FromIpc } = nativeBinding
313
+ const { canonicalType, displayHint, parseValue, transportPack, transportUnpack, transportLock, transportUnlock, version, Reading, parseArrow, runCheck, listRules, fixFile, emitAgs4FromIpc } = nativeBinding
314
314
 
315
315
  module.exports.canonicalType = canonicalType
316
316
  module.exports.displayHint = displayHint
@@ -323,4 +323,6 @@ module.exports.version = version
323
323
  module.exports.Reading = Reading
324
324
  module.exports.parseArrow = parseArrow
325
325
  module.exports.runCheck = runCheck
326
+ module.exports.listRules = listRules
327
+ module.exports.fixFile = fixFile
326
328
  module.exports.emitAgs4FromIpc = emitAgs4FromIpc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laterite",
3
- "version": "0.1.0",
3
+ "version": "0.5.0",
4
4
  "description": "AGS4 geotechnical data for Node.js — read, validate, produce, and query (the Node port of the laterite Python toolkit, Rust-backed).",
5
5
  "license": "MIT",
6
6
  "author": "niko86",
@@ -77,9 +77,9 @@
77
77
  "apache-arrow": "^21.1.0"
78
78
  },
79
79
  "optionalDependencies": {
80
- "@laterite/native-linux-x64-gnu": "0.1.0",
81
- "@laterite/native-darwin-arm64": "0.1.0",
82
- "@laterite/native-win32-x64-msvc": "0.1.0"
80
+ "@laterite/native-linux-x64-gnu": "0.5.0",
81
+ "@laterite/native-darwin-arm64": "0.5.0",
82
+ "@laterite/native-win32-x64-msvc": "0.5.0"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@duckdb/node-api": ">=1.5.0"