laterite 0.4.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
@@ -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.
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.4.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.4.0",
81
- "@laterite/native-darwin-arm64": "0.4.0",
82
- "@laterite/native-win32-x64-msvc": "0.4.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"