@welldot/core 0.1.0 → 0.2.2

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 CHANGED
@@ -8,15 +8,18 @@ TypeScript types, Zod validators, and serialization utilities for the `.well` op
8
8
 
9
9
  ## What is `.well`?
10
10
 
11
- `.well` is an open file format for encoding the complete static record of a water well as a single, self-describing JSON document. A `.well` file contains:
11
+ `.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:
12
12
 
13
13
  - **Constructive data** — borehole geometry, casing strings, screens, reducers, gravel packs, and cement pads
14
14
  - **Geologic data** — lithological column, discrete fractures, and cave zones
15
- - **Administrative metadata** — name, driller, construction date, geographic coordinates, and elevation
15
+ - **Administrative metadata** — well identity, 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
17
+ - **Aquifer analysis** — interpreted parameter sets: transmissivity, specific capacity, storativity, and Jacob loss coefficients
18
+ - **Operational history** — timestamped log of maintenance, inspections, and incidents with HTTPS attachment references
16
19
 
17
20
  The format is designed for three use cases: visualization of technical well profiles, registration with regulatory bodies, and hydrogeological research.
18
21
 
19
- See the [full format specification](./well-specifications.md) for the complete schema reference and design rationale.
22
+ See the [v2 format specification](./docs/spec/v2/overview.md) for the complete schema reference and design rationale. The [v1 spec](./docs/spec/v1/well-format.md) remains available for reference.
20
23
 
21
24
  ## Installation
22
25
 
@@ -67,43 +70,79 @@ const empty = isWellEmpty(well);
67
70
 
68
71
  All types are exported as TypeScript type-only exports (zero runtime cost).
69
72
 
70
- | Type | Description |
71
- |------|-------------|
72
- | `Well` | Complete static record of a water well |
73
- | `BoreHole` | A drilled interval with diameter and optional drilling method |
74
- | `WellCase` | Steel or plastic casing installed in the borehole |
75
- | `Reduction` | Transition piece between different casing diameters |
76
- | `WellScreen` | Slotted screen section for water intake |
77
- | `SurfaceCase` | Protective casing near the surface |
78
- | `HoleFill` | Annular fill material (`gravel_pack` or `seal`) |
79
- | `CementPad` | Concrete wellhead pad dimensions |
80
- | `Lithology` | Geological description of a depth interval |
81
- | `Fracture` | A discrete fracture or fracture zone |
82
- | `Cave` | A cavity or void zone |
83
- | `Constructive` | Grouped type: borehole + casings + screens + fills |
84
- | `Geologic` | Grouped type: lithology + fractures + caves |
85
- | `Units` | `{ length: 'm' \| 'ft'; diameter: 'mm' \| 'inches' }` |
86
- | `LengthUnits` | `'m' \| 'ft'` |
87
- | `DiameterUnits` | `'mm' \| 'inches'` |
88
- | `UnitsTypes` | `'metric' \| 'imperial'` |
73
+ | Type | Description |
74
+ | ----------------------- | ------------------------------------------------------------------------------- |
75
+ | `Well` | Complete static record of a water well (v2) |
76
+ | `BoreHole` | A drilled interval with diameter and optional drilling method |
77
+ | `WellCase` | Steel or plastic casing installed in the borehole |
78
+ | `Reduction` | Transition piece between different casing diameters |
79
+ | `WellScreen` | Slotted screen section for water intake (`screen_slot` in mm) |
80
+ | `SurfaceCase` | Protective casing near the surface |
81
+ | `HoleFill` | Annular fill material (`gravel_pack` or `seal`) |
82
+ | `CementPad` | Concrete wellhead pad dimensions |
83
+ | `Lithology` | Geological description of a depth interval |
84
+ | `Texture` | `{ code: string \| number; vocabulary?: string }` — lithology texture reference |
85
+ | `Fracture` | A discrete fracture or fracture zone |
86
+ | `Cave` | A cavity or void zone |
87
+ | `Constructive` | Grouped type: borehole + casings + screens + fills |
88
+ | `Geologic` | Grouped type: lithology + fractures + caves |
89
+ | `WellId` | Authority-scoped well identifier `{ authority, id, primary? }` |
90
+ | `Location` | Geographic location with optional elevation and CRS properties |
91
+ | `LocationProperties` | CRS, datum, and precision metadata for a `Location` |
92
+ | `LevelReading` | A single depth/time reading during a pumping or recovery phase |
93
+ | `RecoveryPhase` | Time-series of level readings after pump shutdown |
94
+ | `PumpingStep` | One flow-rate step in a pumping test |
95
+ | `HydrodynamicEventBase` | Common fields shared by all hydrodynamic event types |
96
+ | `SpotMeasurementEvent` | A single static water level reading |
97
+ | `ConstantRateEvent` | A constant-rate pumping test |
98
+ | `StepDrawdownEvent` | A step-drawdown pumping test |
99
+ | `AirliftEvent` | An air-lift development or test |
100
+ | `RecoveryOnlyEvent` | Recovery measurements without drawdown data |
101
+ | `HydrodynamicEvent` | Discriminated union of all event types + x- custom events |
102
+ | `AquiferAnalysis` | An interpreted set of aquifer parameters |
103
+ | `Attachment` | An HTTPS-referenced file attached to a history log entry |
104
+ | `HistoryLogEntry` | One entry in the operational history log |
105
+ | `Units` | `{ length: 'm' \| 'ft'; diameter: 'mm' \| 'inches' }` |
106
+ | `LengthUnits` | `'m' \| 'ft'` |
107
+ | `DiameterUnits` | `'mm' \| 'inches'` |
108
+ | `UnitsTypes` | `'metric' \| 'imperial'` |
109
+ | `TextureType` | `{ code: TextureCode; label: string }` — a single FGDC texture entry (lookup) |
110
+ | `TextureCode` | `number \| string` — numeric FGDC code or custom string code |
89
111
 
90
112
  ### Validators
91
113
 
92
114
  Each schema validates its corresponding type at runtime. All schemas are Zod objects and compose with standard Zod methods (`.parse`, `.safeParse`, `.extend`, etc.).
93
115
 
94
- | Export | Validates |
95
- |--------|-----------|
96
- | `WellSchema` | `Well` (the complete document) |
97
- | `BoreHoleSchema` | `BoreHole` |
98
- | `WellCaseSchema` | `WellCase` |
99
- | `ReductionSchema` | `Reduction` |
100
- | `WellScreenSchema` | `WellScreen` |
101
- | `SurfaceCaseSchema` | `SurfaceCase` |
102
- | `HoleFillSchema` | `HoleFill` |
103
- | `CementPadSchema` | `CementPad` |
104
- | `LithologySchema` | `Lithology` |
105
- | `FractureSchema` | `Fracture` |
106
- | `CaveSchema` | `Cave` |
116
+ | Export | Validates |
117
+ | ----------------------------- | ----------------------------------------------------------------------- |
118
+ | `WellSchema` | `Well` (the complete document; `.passthrough()` preserves unknown keys) |
119
+ | `BoreHoleSchema` | `BoreHole` |
120
+ | `WellCaseSchema` | `WellCase` |
121
+ | `ReductionSchema` | `Reduction` |
122
+ | `WellScreenSchema` | `WellScreen` |
123
+ | `SurfaceCaseSchema` | `SurfaceCase` |
124
+ | `HoleFillSchema` | `HoleFill` |
125
+ | `CementPadSchema` | `CementPad` |
126
+ | `LithologySchema` | `Lithology` |
127
+ | `TextureSchema` | `Texture` |
128
+ | `FractureSchema` | `Fracture` |
129
+ | `CaveSchema` | `Cave` |
130
+ | `WellIdSchema` | `WellId` |
131
+ | `LocationPropertiesSchema` | `LocationProperties` |
132
+ | `LocationSchema` | `Location` |
133
+ | `LevelReadingSchema` | `LevelReading` |
134
+ | `RecoveryPhaseSchema` | `RecoveryPhase` |
135
+ | `PumpingStepSchema` | `PumpingStep` |
136
+ | `HydrodynamicEventBaseSchema` | `HydrodynamicEventBase` |
137
+ | `SpotMeasurementEventSchema` | `SpotMeasurementEvent` |
138
+ | `ConstantRateEventSchema` | `ConstantRateEvent` |
139
+ | `StepDrawdownEventSchema` | `StepDrawdownEvent` |
140
+ | `AirliftEventSchema` | `AirliftEvent` |
141
+ | `RecoveryOnlyEventSchema` | `RecoveryOnlyEvent` |
142
+ | `HydrodynamicEventSchema` | `HydrodynamicEvent` (discriminated union + x- passthrough) |
143
+ | `AquiferAnalysisSchema` | `AquiferAnalysis` |
144
+ | `AttachmentSchema` | `Attachment` |
145
+ | `HistoryLogEntrySchema` | `HistoryLogEntry` |
107
146
 
108
147
  ### Functions
109
148
 
@@ -113,58 +152,113 @@ Parses a raw JSON string and validates it against `WellSchema`. Throws a `ZodErr
113
152
 
114
153
  #### `serializeWell(well: Well): string`
115
154
 
116
- Serializes a `Well` object to a versioned `.well` JSON string (`"version": 1`). Omits `undefined` optional fields.
155
+ Serializes a `Well` object to a versioned `.well` JSON string (`"version": 2`). Emits `location` when set; does not emit deprecated flat `lat`/`lng`/`elevation`. Omits `undefined` optional fields.
117
156
 
118
157
  #### `deserializeWell(jsonString: string): Well | null`
119
158
 
120
159
  Parses and normalizes a JSON string into a `Well`. Handles multiple formats:
121
160
 
122
- - Current versioned format (`"version": 1`)
161
+ - v2 format (`"version": 2`) — passes v2-specific fields through directly
162
+ - v1 format (`"version": 1`) — applies v1→v2 normalizations: `fgdc_texture` → `texture`, `screen_slot_mm` → `screen_slot`, flat `lat/lng/elevation` → `location`
123
163
  - Legacy formats with `constructive` / `geologic` sub-objects
124
164
  - Legacy `diam_pol` inch diameters → `diameter` mm conversion (`× 25.4`)
125
165
  - Typo `bole_hole` → `bore_hole` compatibility
126
166
 
127
- Returns `null` if the parsed data is empty.
167
+ Returns `null` if the parsed data is empty. Throws on unrecognized version numbers.
128
168
 
129
169
  #### `isWellEmpty(well: Well | null | undefined): boolean`
130
170
 
131
171
  Returns `true` when all constructive and geologic arrays are empty. Accepts `null` and `undefined` (both treated as empty).
132
172
 
173
+ ## FGDC Texture Patterns
174
+
175
+ `FGDC_TEXTURES_OPTIONS` is a typed array of 284 texture pattern entries drawn from the **FGDC Digital Cartographic Standard for Geologic Map Symbolization (FGDC-STD-013-2006)**. Assign a `code` to the `texture` field of a `Lithology` record to attach a standardized fill pattern to a depth interval.
176
+
177
+ ```typescript
178
+ import { FGDC_TEXTURES_OPTIONS } from '@welldot/core';
179
+ import type { Texture, TextureCode } from '@welldot/core';
180
+
181
+ // Lookup by code
182
+ const sandstone = FGDC_TEXTURES_OPTIONS.find(t => t.code === 607);
183
+ // { code: 607, label: 'Massive sand or sandstone' }
184
+
185
+ // Build a select list for a UI
186
+ const options = FGDC_TEXTURES_OPTIONS.map(t => ({
187
+ value: t.code,
188
+ label: t.label,
189
+ }));
190
+ ```
191
+
192
+ Codes are grouped by series:
193
+
194
+ | Series | Category |
195
+ | ------ | ------------------------------------------------------ |
196
+ | 100 | Surficial deposits |
197
+ | 200 | Sedimentary patterns |
198
+ | 300 | Igneous patterns |
199
+ | 400 | Miscellaneous / Metamorphic patterns |
200
+ | 500 | Glacial / Periglacial patterns |
201
+ | 600 | Sedimentary lithology _(most useful for well logging)_ |
202
+ | 700 | Metamorphic and igneous lithology |
203
+
204
+ See [fgdc-textures.md](./docs/reference/fgdc-textures.md) for the complete annotated list of all 284 codes.
205
+
133
206
  ## `.well` Format Overview
134
207
 
135
208
  All depths are in **meters** from ground level (0 = surface). All diameters are in **millimeters**. Geographic coordinates use WGS84 decimal degrees. The MIME type is `application/vnd.well+json`.
136
209
 
137
- A minimal `.well` document:
210
+ A minimal v2 `.well` document:
138
211
 
139
212
  ```json
140
213
  {
141
- "version": 1,
214
+ "version": 2,
142
215
  "well_type": "tubular",
143
216
  "name": "PP-01",
144
- "lat": -1.4558,
145
- "lng": -48.5039,
146
- "elevation": 12.5,
147
- "bore_hole": [{ "from": 0, "to": 80, "diameter": 250, "drilling_method": "rotary" }],
217
+ "location": { "lat": -1.4558, "lng": -48.5039, "elevation": 12.5 },
218
+ "bore_hole": [
219
+ { "from": 0, "to": 80, "diameter": 250, "drilling_method": "rotary" }
220
+ ],
148
221
  "well_case": [{ "from": 0, "to": 60, "type": "steel", "diameter": 200 }],
149
222
  "reduction": [],
150
- "well_screen": [{ "from": 60, "to": 80, "type": "wire_wound", "diameter": 150, "screen_slot_mm": 0.5 }],
223
+ "well_screen": [
224
+ {
225
+ "from": 60,
226
+ "to": 80,
227
+ "type": "wire_wound",
228
+ "diameter": 150,
229
+ "screen_slot": 0.5
230
+ }
231
+ ],
151
232
  "surface_case": [{ "from": 0, "to": 3, "diameter": 300 }],
152
- "hole_fill": [{ "from": 60, "to": 80, "type": "gravel_pack", "diameter": 250, "description": "2-4mm gravel" }],
153
- "cement_pad": { "type": "square", "width": 1.0, "thickness": 0.15, "length": 1.0 },
233
+ "hole_fill": [
234
+ {
235
+ "from": 60,
236
+ "to": 80,
237
+ "type": "gravel_pack",
238
+ "diameter": 250,
239
+ "description": "2-4mm gravel"
240
+ }
241
+ ],
242
+ "cement_pad": {
243
+ "type": "square",
244
+ "width": 1.0,
245
+ "thickness": 0.15,
246
+ "length": 1.0
247
+ },
154
248
  "lithology": [],
155
249
  "fractures": [],
156
250
  "caves": []
157
251
  }
158
252
  ```
159
253
 
160
- For the complete schema reference, field vocabulary, design rationale, and versioning policy see the [`.well` format specification](./well-specifications.md).
254
+ For the complete schema reference, field vocabulary, and design rationale see the [`.well` v2 format specification](./docs/spec/v2/overview.md). The [v1 spec](./docs/spec/v1/well-format.md) remains available for reference.
161
255
 
162
256
  ## Contributing
163
257
 
164
- Issues and pull requests are welcome. The source lives in `packages/core` within the [well-profiler monorepo](https://github.com/rafaeelneto/well-profiler).
258
+ Issues and pull requests are welcome. The source lives in `packages/core` within the [well-profiler monorepo](https://github.com/rafaeelneto/welldot).
165
259
 
166
260
  ```bash
167
- git clone https://github.com/rafaeelneto/well-profiler.git
261
+ git clone https://github.com/rafaeelneto/welldot.git
168
262
  cd well-profiler
169
263
  pnpm install
170
264
  cd packages/core
@@ -175,5 +269,3 @@ pnpm test
175
269
  ## License
176
270
 
177
271
  [Apache 2.0](./LICENSE) — see `LICENSE` for the full text.
178
-
179
- The broader well-profiler application is licensed separately under [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).