@welldot/core 0.4.0-next.20261015.d7c7365 → 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.
Files changed (36) hide show
  1. package/README.md +59 -19
  2. package/dist/index.cjs +344 -178
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +9203 -5704
  5. package/dist/index.d.ts +9203 -5704
  6. package/dist/index.js +334 -178
  7. package/dist/index.js.map +1 -1
  8. package/docs/reference/fgdc-textures.md +15 -0
  9. package/docs/schema/v2/well.schema.json +128 -11
  10. package/docs/spec/v1/well-format.md +26 -0
  11. package/docs/spec/v2/format-reference.md +170 -45
  12. package/docs/spec/v2/interoperability.md +25 -4
  13. package/docs/spec/v2/object-schemas.md +243 -96
  14. package/docs/spec/v2/overview.md +92 -9
  15. package/docs/spec/v2/water-quality.md +26 -3
  16. package/examples/README.md +12 -0
  17. package/examples/belem-pa-condominio-outorga.well +2 -1
  18. package/examples/belem-pa-monitoramento-posto.well +2 -1
  19. package/examples/belem-pa-pirabas-abastecimento.well +2 -2
  20. package/examples/belem-pa-poco-colmatado.well +2 -1
  21. package/examples/belem-pa-poco-raso-abandonado.well +2 -1
  22. package/examples/belem-pa-qualidade-agua-acida.well +2 -1
  23. package/examples/colatina-es-gnaisse-rural.well +2 -2
  24. package/examples/coluna-mg-cristalino-abastecimento.well +2 -2
  25. package/examples/estrela-doeste-sp-bauru-serra-geral.well +2 -1
  26. package/examples/extremoz-rn-barreiras-raso.well +2 -1
  27. package/examples/gastao-vidigal-sp-dados-inconsistentes.well +2 -1
  28. package/examples/irece-ba-carste-bambui.well +2 -1
  29. package/examples/lagoa-santa-mg-carste-abastecimento.well +2 -2
  30. package/examples/minas-novas-mg-cadastro-incompleto.well +2 -1
  31. package/examples/quixeramobim-ce-cristalino-salobro.well +2 -2
  32. package/examples/rinopolis-sp-estratigrafico-guarani.well +2 -1
  33. package/examples/santarem-pa-jorrante-alter-do-chao.well +2 -1
  34. package/examples/sao-gabriel-rs-cacimba.well +2 -1
  35. package/examples/sete-lagoas-mg-carste-industrial.well +2 -1
  36. package/package.json +1 -1
package/README.md CHANGED
@@ -4,8 +4,30 @@
4
4
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-3178c6.svg)](https://www.typescriptlang.org/)
6
6
 
7
+ ## Overview
8
+
7
9
  TypeScript types, Zod validators, and serialization utilities for the `.well` open format — a JSON-based standard for representing water well data.
8
10
 
11
+ This README covers installation, a quick start, the API (types, validators, functions and unit conversion), the water quality and recommended vocabularies, the FGDC texture codes and a short tour of the format. The normative specification lives in [docs/spec/v2](./docs/spec/v2/overview.md).
12
+
13
+ ## Table of contents
14
+
15
+ - [What is `.well`?](#what-is-well)
16
+ - [Example wells](#example-wells)
17
+ - [Installation](#installation)
18
+ - [Quick Start](#quick-start)
19
+ - [API Reference](#api-reference)
20
+ - [Types](#types)
21
+ - [Validators](#validators)
22
+ - [Functions](#functions)
23
+ - [Water Quality Vocabulary and Limit Sets _(v2.3)_](#water-quality-vocabulary-and-limit-sets-v23)
24
+ - [Recommended Vocabularies _(v2.3)_](#recommended-vocabularies-v23)
25
+ - [Closed vocabularies](#closed-vocabularies)
26
+ - [FGDC Texture Patterns](#fgdc-texture-patterns)
27
+ - [`.well` Format Overview](#well-format-overview)
28
+ - [Contributing](#contributing)
29
+ - [License](#license)
30
+
9
31
  ## What is `.well`?
10
32
 
11
33
  `.well` is an open file format for encoding the complete record of a water well as a single, self-describing JSON document. A `.well` file contains:
@@ -13,18 +35,18 @@ TypeScript types, Zod validators, and serialization utilities for the `.well` op
13
35
  - **Constructive data** — borehole geometry, casing strings, screens, reducers, gravel packs, centralizers, and cement pads
14
36
  - **Geologic data** — lithological column, discrete fractures, and cave zones
15
37
  - **Administrative metadata** — well identity, construction type and purpose (`well_type`, `well_purpose`), authority-scoped IDs (`well_id`), driller, construction date, and geographic coordinates with explicit CRS
16
- - **Hydrodynamic events** — append-only ledger of static level readings, pumping tests (constant-rate, step-drawdown, airlift), and recovery phases
38
+ - **Hydrodynamic events** — ledger of static level readings, pumping tests (constant-rate, step-drawdown, airlift), and recovery phases
17
39
  - **Aquifer analysis** — interpreted parameter sets: transmissivity, specific capacity, storativity, and Jacob loss coefficients
18
40
  - **Operational history** — timestamped log of maintenance, inspections, incidents, status changes and permit condition fulfillment, with HTTPS attachment references
19
41
  - **Pump installations** — installation history of the well's pumps: nameplate data, intake depth, riser and electrical data (v2.3)
20
42
  - **Permits** — legal instruments governing abstraction (outorgas): validity, granted flow and daily operating time, volume limits, monthly schedule, and conditions (condicionantes) whose deadlines are derived from ISO 8601 date durations, with their fulfillments, an administrative status (requested, suspended…) and an administrative history (v2.3)
21
- - **Meters, production and operating regime** — totalizer (hidrômetro) installation history, an append-only production ledger of meter readings and declared volumes (volumes are derived, never stored as totals), and the declared operating regime in force from a given instant (v2.3)
43
+ - **Meters, production and operating regime** — totalizer (hidrômetro) installation history, a production ledger of meter readings and declared volumes (volumes are derived, never stored as totals), and the declared operating regime in force from a given instant (v2.3)
22
44
  - **Water quality** — a `water_samples` ledger of samples, each with its field and laboratory results, sampling point and depth, purge and stabilization readings, laboratory and chain of custody, field QA/QC (duplicates, splits, blanks), per-result filtration, lab flags and data validation. Parameters are identified by `{ code, vocabulary }` against a versioned vocabulary of 98 `welldot` codes (plus CAS numbers and `x-` codes), and units come from the code. Limits are never stored in the file (v2.3)
23
- - **Attachments** — HTTPS-referenced files typed by `document_type`: a root-level `attachments` array for general files about the well (e.g. the drilling report), plus per-record attachments on pumps, events, analyses and log entries. The root array does not collect the per-record ones (v2.3)
45
+ - **Attachments** — HTTPS-referenced files typed by `document_type`: a root-level `attachments` array for general files about the well (e.g. the drilling report), plus per-record attachments on log entries, permits (and their history steps and condition fulfillments), pumps, meters, events, analyses and water samples. The root array does not collect the per-record ones (v2.3)
24
46
 
25
47
  The format is designed for three use cases: visualization of technical well profiles, registration with regulatory bodies, and hydrogeological research.
26
48
 
27
- See the [v2 format specification](./docs/spec/v2/overview.md) (current revision: v2.3) for the complete schema reference and design rationale. The [v1 spec](./docs/spec/v1/well-format.md) remains available for reference.
49
+ See the [v2 format specification](./docs/spec/v2/overview.md) (current revision: v2.4) for the complete schema reference and design rationale. The [v1 spec](./docs/spec/v1/well-format.md) remains available for reference.
28
50
 
29
51
  ### Example wells
30
52
 
@@ -111,6 +133,10 @@ All types are exported as TypeScript type-only exports (zero runtime cost).
111
133
  | `StepDrawdownEvent` | A step-drawdown pumping test |
112
134
  | `AirliftEvent` | An air-lift development or test |
113
135
  | `RecoveryOnlyEvent` | Recovery measurements without drawdown data |
136
+ | `LoggerSeriesEvent` | Continuous level series recorded by an installed sensor (v2.4) |
137
+ | `LoggerReading` | A `logger_series` reading, located by `datetime` (v2.4) |
138
+ | `BarometricCompensation` | `logger_series.barometric_compensation` values (v2.4) |
139
+ | `ReadingAggregation` | `logger_series.aggregation` values (v2.4) |
114
140
  | `HydrodynamicEvent` | Discriminated union of all event types + x- custom events |
115
141
  | `AquiferAnalysis` | An interpreted set of aquifer parameters |
116
142
  | `Attachment` | An HTTPS-referenced document, typed by `document_type` (common type since v2.3) |
@@ -190,7 +216,9 @@ Each schema validates its corresponding type at runtime. All schemas are Zod obj
190
216
  | `StepDrawdownEventSchema` | `StepDrawdownEvent` |
191
217
  | `AirliftEventSchema` | `AirliftEvent` |
192
218
  | `RecoveryOnlyEventSchema` | `RecoveryOnlyEvent` |
193
- | `HydrodynamicEventSchema` | `HydrodynamicEvent` (discriminated union + x- passthrough) |
219
+ | `LoggerSeriesEventSchema` | `LoggerSeriesEvent` |
220
+ | `LoggerReadingSchema` | `LoggerReading` |
221
+ | `HydrodynamicEventSchema` | `HydrodynamicEvent` (discriminated union; only `x-` types pass through) |
194
222
  | `AquiferAnalysisSchema` | `AquiferAnalysis` |
195
223
  | `AttachmentSchema` | `Attachment` |
196
224
  | `PumpInstallationSchema` | `PumpInstallation` |
@@ -207,7 +235,7 @@ Each schema validates its corresponding type at runtime. All schemas are Zod obj
207
235
  | `MeterReadingSchema` | `MeterReading` |
208
236
  | `EstimatedVolumeSchema` | `EstimatedVolume` |
209
237
  | `ProductionEntrySchema` | `ProductionEntry` (discriminated union + x- passthrough; a known type missing required fields is rejected) |
210
- | `OperatingRegimeSchema` | `OperatingRegime` (`daily_operating_time` 0–24, integer `days_per_week` 1–7) |
238
+ | `OperatingRegimeSchema` | `OperatingRegime` (non-negative `daily_operating_time`, integer `days_per_week` 1–7) |
211
239
  | `HistoryLogEntrySchema` | `HistoryLogEntry` |
212
240
  | `WaterSampleSchema` | `WaterSample` (`results` must have at least one entry) |
213
241
  | `SamplingPointSchema` | `SamplingPoint` (`depth` and `from`/`to` are mutually exclusive) |
@@ -229,13 +257,13 @@ Parses a raw JSON string and validates it against `WellSchema`. Throws a `ZodErr
229
257
 
230
258
  #### `serializeWell(well: Well): string`
231
259
 
232
- Serializes a `Well` object to a versioned `.well` JSON string (`"version": 2`). Emits `location` when set; does not emit deprecated flat `lat`/`lng`/`elevation` or other legacy v1 keys. Omits `undefined` optional fields. Root members the spec does not define (`x-` fields and blocks, foreign members) are written unchanged after the spec blocks, as the spec requires.
260
+ Serializes a `Well` object to a versioned `.well` JSON string (`"version": "2.4"`, `WELL_FORMAT_VERSION`). Omits `null` members outside `x-` fields and `@context`. Emits `location` when set; does not emit deprecated flat `lat`/`lng`/`elevation` or other legacy v1 keys. Omits `undefined` optional fields. Root members the spec does not define (`x-` fields and blocks, foreign members) are written unchanged after the spec blocks, as the spec requires.
233
261
 
234
262
  #### `deserializeWell(jsonString: string): Well | null`
235
263
 
236
264
  Parses and normalizes a JSON string into a `Well`. Handles multiple formats:
237
265
 
238
- - v2 format (`"version": 2`) — passes v2-specific fields through directly
266
+ - v2 format (`"version": 2` or `"2.x"`) — passes v2-specific fields through directly
239
267
  - v1 format (`"version": 1`) — applies v1→v2 normalizations: `fgdc_texture` → `texture`, `screen_slot_mm` → `screen_slot`, flat `lat/lng/elevation` → `location`
240
268
  - Legacy formats with `constructive` / `geologic` sub-objects
241
269
  - Legacy `diam_pol` inch diameters → `diameter` mm conversion (`× 25.4`)
@@ -243,6 +271,16 @@ Parses and normalizes a JSON string into a `Well`. Handles multiple formats:
243
271
 
244
272
  Returns `null` if the parsed data is empty. Throws on unrecognized version numbers.
245
273
 
274
+ #### Format version and time zone _(v2.4)_
275
+
276
+ | Export | Description |
277
+ | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
278
+ | `WELL_FORMAT_VERSION` | The version `serializeWell` writes: `"2.4"`. |
279
+ | `parseFormatVersion(value)` | Parses `2` or `"M.m"` into a `FormatVersion` (`{ major, minor }`); `undefined` for `2.4`, `"2.4.1"`, `"v2.4"` and other values. |
280
+ | `compareFormatVersions(a, b)` | Compares two `"M.m"` strings as two integers (`"2.10"` is after `"2.9"`); throws on malformed input. |
281
+ | `isIanaTimeZone(value)` | Whether `value` is an IANA time zone name (`America/Belem`), for `location.properties.timezone`. Offsets are not valid. |
282
+ | `LoggerSeriesEvent` / `LoggerReading` | Types of the `logger_series` hydrodynamic event and its readings; validated by `LoggerSeriesEventSchema` / `LoggerReadingSchema`. |
283
+
246
284
  #### `isWellEmpty(well: Well | null | undefined): boolean`
247
285
 
248
286
  Returns `true` when all constructive and geologic arrays are empty. Accepts `null` and `undefined` (both treated as empty).
@@ -371,17 +409,19 @@ getVocabLabel(PERMIT_TYPES, 'x-special', 'pt'); // 'x-special'
371
409
 
372
410
  Fields whose values the schema fixes (no free text, no `x-`) ship in the same shape as the open vocabularies — `VocabEntry` lists with `en`/`pt` labels — so `getVocabLabel` labels any value without consumer translations. Each list is checked at compile time against its type, so it cannot drift from the schema. The `*_VALUES` lists are the bare values.
373
411
 
374
- | Vocabulary | Field |
375
- | -------------------------------------------------- | --------------------------------------------- |
376
- | `WELL_STATUSES` (`WELL_STATUS_VALUES`) | `history_logs[].status` (`status_change`) |
377
- | `PERMIT_ADMINISTRATIVE_STATUSES` | `permits[].status` |
378
- | `VOLUME_LIMIT_PERIODS` | `permits[].volume_limits[].period` |
379
- | `PRODUCTION_ENTRY_TYPES` | `production[].type` |
380
- | `RESULT_QUALIFIERS` (`QUALIFIER_VALUES`) | result `qualifier` |
381
- | `RESULT_FRACTIONS` (`FRACTION_VALUES`) | result `fraction` |
382
- | `MEASUREMENT_LOCATIONS` | result `measured_in`, `filtration.location` |
383
- | `VALIDATION_STATUSES` (`VALIDATION_STATUS_VALUES`) | result `validation.status` |
384
- | `PARAMETER_GROUPS` (`PARAMETER_GROUP_VALUES`) | parameter vocabulary groups, in display order |
412
+ | Vocabulary | Field |
413
+ | ------------------------------------------------------------- | --------------------------------------------- |
414
+ | `WELL_STATUSES` (`WELL_STATUS_VALUES`) | `history_logs[].status` (`status_change`) |
415
+ | `PERMIT_ADMINISTRATIVE_STATUSES` | `permits[].status` |
416
+ | `VOLUME_LIMIT_PERIODS` | `permits[].volume_limits[].period` |
417
+ | `PRODUCTION_ENTRY_TYPES` | `production[].type` |
418
+ | `RESULT_QUALIFIERS` (`QUALIFIER_VALUES`) | result `qualifier` |
419
+ | `RESULT_FRACTIONS` (`FRACTION_VALUES`) | result `fraction` |
420
+ | `MEASUREMENT_LOCATIONS` | result `measured_in`, `filtration.location` |
421
+ | `VALIDATION_STATUSES` (`VALIDATION_STATUS_VALUES`) | result `validation.status` |
422
+ | `PARAMETER_GROUPS` (`PARAMETER_GROUP_VALUES`) | parameter vocabulary groups, in display order |
423
+ | `BAROMETRIC_COMPENSATIONS` (`BAROMETRIC_COMPENSATION_VALUES`) | `logger_series.barometric_compensation` |
424
+ | `READING_AGGREGATIONS` (`READING_AGGREGATION_VALUES`) | `logger_series.aggregation` |
385
425
 
386
426
  Value rules without labels: `NUMERIC_QUALIFIERS`, `PARENT_SAMPLE_TYPES`, `BLANK_SAMPLE_TYPES`. Parameter names: `getParameterLabel(parameter, locale)` (CAS numbers resolve through the published equivalences; unknown codes are returned as-is).
387
427