@bedrock-engineer/bro-xml-parser 0.3.0 → 0.4.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 +21 -12
- package/dist/browser.d.ts +15 -5
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +7 -5
- package/dist/browser.js.map +1 -1
- package/dist/core/columns.d.ts +80 -0
- package/dist/core/columns.d.ts.map +1 -0
- package/dist/core/columns.js +100 -0
- package/dist/core/columns.js.map +1 -0
- package/dist/core/producer.d.ts +216 -0
- package/dist/core/producer.d.ts.map +1 -0
- package/dist/core/producer.js +85 -0
- package/dist/core/producer.js.map +1 -0
- package/dist/core/schema-parser.d.ts +41 -17
- package/dist/core/schema-parser.d.ts.map +1 -1
- package/dist/core/schema-parser.js +178 -73
- package/dist/core/schema-parser.js.map +1 -1
- package/dist/core/version-detector.d.ts +3 -1
- package/dist/core/version-detector.d.ts.map +1 -1
- package/dist/core/version-detector.js +37 -0
- package/dist/core/version-detector.js.map +1 -1
- package/dist/decoders/constants.d.ts +2 -0
- package/dist/decoders/constants.d.ts.map +1 -0
- package/dist/decoders/constants.js +2 -0
- package/dist/decoders/constants.js.map +1 -0
- package/dist/decoders/type-decoders.d.ts +38 -0
- package/dist/decoders/type-decoders.d.ts.map +1 -0
- package/dist/decoders/type-decoders.js +134 -0
- package/dist/decoders/type-decoders.js.map +1 -0
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +16 -0
- package/dist/namespaces.js.map +1 -1
- package/dist/node.d.ts +15 -5
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +7 -5
- package/dist/node.js.map +1 -1
- package/dist/parser.d.ts +69 -19
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +103 -29
- package/dist/parser.js.map +1 -1
- package/dist/producers.d.ts +36 -0
- package/dist/producers.d.ts.map +1 -0
- package/dist/producers.js +35 -0
- package/dist/producers.js.map +1 -0
- package/dist/resolvers/gld-resolvers.d.ts +30 -0
- package/dist/resolvers/gld-resolvers.d.ts.map +1 -0
- package/dist/resolvers/gld-resolvers.js +76 -0
- package/dist/resolvers/gld-resolvers.js.map +1 -0
- package/dist/resolvers/gmw-resolvers.d.ts +37 -0
- package/dist/resolvers/gmw-resolvers.d.ts.map +1 -0
- package/dist/resolvers/gmw-resolvers.js +101 -0
- package/dist/resolvers/gmw-resolvers.js.map +1 -0
- package/dist/resolvers.d.ts +2 -0
- package/dist/resolvers.d.ts.map +1 -1
- package/dist/resolvers.js +4 -0
- package/dist/resolvers.js.map +1 -1
- package/dist/schema-presets.d.ts +67 -16
- package/dist/schema-presets.d.ts.map +1 -1
- package/dist/schema-presets.js +51 -114
- package/dist/schema-presets.js.map +1 -1
- package/dist/schemas/bhrg-schema.d.ts +528 -9
- package/dist/schemas/bhrg-schema.d.ts.map +1 -1
- package/dist/schemas/bhrg-schema.js +330 -189
- package/dist/schemas/bhrg-schema.js.map +1 -1
- package/dist/schemas/bhrgt-analysis.d.ts +1057 -0
- package/dist/schemas/bhrgt-analysis.d.ts.map +1 -0
- package/dist/schemas/bhrgt-analysis.js +454 -0
- package/dist/schemas/bhrgt-analysis.js.map +1 -0
- package/dist/schemas/bore-schema.d.ts +773 -9
- package/dist/schemas/bore-schema.d.ts.map +1 -1
- package/dist/schemas/bore-schema.js +344 -292
- package/dist/schemas/bore-schema.js.map +1 -1
- package/dist/schemas/common-fields.d.ts +50 -5
- package/dist/schemas/common-fields.d.ts.map +1 -1
- package/dist/schemas/common-fields.js +70 -19
- package/dist/schemas/common-fields.js.map +1 -1
- package/dist/schemas/cpt-schema.d.ts +126 -9
- package/dist/schemas/cpt-schema.d.ts.map +1 -1
- package/dist/schemas/cpt-schema.js +182 -285
- package/dist/schemas/cpt-schema.js.map +1 -1
- package/dist/schemas/generated/gld.generated.d.ts +9 -0
- package/dist/schemas/generated/gld.generated.d.ts.map +1 -0
- package/dist/schemas/generated/gld.generated.js +19 -0
- package/dist/schemas/generated/gld.generated.js.map +1 -0
- package/dist/schemas/gld-schema.d.ts +92 -0
- package/dist/schemas/gld-schema.d.ts.map +1 -0
- package/dist/schemas/gld-schema.js +88 -0
- package/dist/schemas/gld-schema.js.map +1 -0
- package/dist/schemas/gmw-schema.d.ts +180 -0
- package/dist/schemas/gmw-schema.d.ts.map +1 -0
- package/dist/schemas/gmw-schema.js +131 -0
- package/dist/schemas/gmw-schema.js.map +1 -0
- package/dist/types/index.d.ts +51 -1421
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type decoder functions for converting XML values to JavaScript types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parse float, handle null values and -999999 sentinel
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseFloat(value: string | null | undefined): number | null;
|
|
8
|
+
export declare function parseInt(value: string | null | undefined): number | null;
|
|
9
|
+
export declare function parseBoolean(value: string | null | undefined): boolean | null;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a BRO temporal value to a precision-preserving ISO 8601 string.
|
|
12
|
+
*
|
|
13
|
+
* BRO date/dateTime elements are a choice of full date (`YYYY-MM-DD`),
|
|
14
|
+
* year-month (`YYYY-MM`), year (`YYYY`), full `dateTime`, or a `voidReason`
|
|
15
|
+
* code (e.g. "onbekend") when the value is unknown. The exact lexical value is
|
|
16
|
+
* returned unchanged so no precision or timezone information is lost;
|
|
17
|
+
* `voidReason` codes and any unrecognized input yield `null`.
|
|
18
|
+
*
|
|
19
|
+
* Timezone handling (per BRO): `dateTime` values carry a mandatory offset, which
|
|
20
|
+
* for Dutch data is the seasonal `+01:00` (winter) / `+02:00` (summer) — never
|
|
21
|
+
* `Z`. BRO derives the calendar date from the *Dutch-local* time, so the
|
|
22
|
+
* intended date is simply the lexical `YYYY-MM-DD` prefix of the string. We keep
|
|
23
|
+
* the string verbatim precisely to avoid a UTC conversion silently shifting the
|
|
24
|
+
* date across midnight (BRO's own worked example of the pitfall). Consumers can
|
|
25
|
+
* build a `Date`/`Temporal` when needed, but beware: `new Date("YYYY-MM-DD")` on
|
|
26
|
+
* a date-only value is parsed as UTC midnight and can render as the previous day
|
|
27
|
+
* in negative-offset zones — treat date-only values as plain calendar dates.
|
|
28
|
+
* @see https://www.bro-productomgeving.nl/bpo/release-2.5_2024_Q4/informatie-voor-softwareleveranciers/het-afhandelen-van-tijdstippen
|
|
29
|
+
*
|
|
30
|
+
* Unlike the numeric decoders this does not warn on non-matching input,
|
|
31
|
+
* because `voidReason` is a legitimate and common value in archive data.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseDate(value: string | null | undefined): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Parse quality class (handles "klasse2" or "2" format)
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseQualityClass(value: string | null): number | null;
|
|
38
|
+
//# sourceMappingURL=type-decoders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-decoders.d.ts","sourceRoot":"","sources":["../../src/decoders/type-decoders.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAmB1E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAiBxE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAgB7E;AAgBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAezE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAcrE"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type decoder functions for converting XML values to JavaScript types
|
|
3
|
+
*/
|
|
4
|
+
import { SENTINEL } from "./constants.js";
|
|
5
|
+
/**
|
|
6
|
+
* BRO uses two different missing-value conventions depending on the record
|
|
7
|
+
* type: CPT measurement CSVs use the -999999 sentinel, while the BHR-GT-BMA lab
|
|
8
|
+
* value tables (settlement/consolidation time-series) use the literal "NaN".
|
|
9
|
+
* The latter should resolve to null rather than being warned about as a parse
|
|
10
|
+
* error.
|
|
11
|
+
*/
|
|
12
|
+
function isMissingNumber(value) {
|
|
13
|
+
return value.trim().toLowerCase() === "nan";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse float, handle null values and -999999 sentinel
|
|
17
|
+
*/
|
|
18
|
+
export function parseFloat(value) {
|
|
19
|
+
// BRO encodes a missing numeric value as an empty string, the -999999
|
|
20
|
+
// sentinel, or the literal "NaN" (common in embedded measurement CSVs).
|
|
21
|
+
if (!value || value.trim() === "" || value === String(SENTINEL) || isMissingNumber(value)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const num = Number.parseFloat(value);
|
|
26
|
+
if (isNaN(num)) {
|
|
27
|
+
console.warn(`Failed to parse float value: "${value}"`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return num;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
console.warn(`Failed to parse float value: "${value}" - ${message}`);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function parseInt(value) {
|
|
39
|
+
if (!value || value.trim() === "" || value === String(SENTINEL) || isMissingNumber(value)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const num = Number.parseInt(value, 10);
|
|
44
|
+
if (isNaN(num)) {
|
|
45
|
+
console.warn(`Failed to parse integer value: "${value}"`);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return num;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
console.warn(`Failed to parse integer value: "${value}" - ${message}`);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function parseBoolean(value) {
|
|
57
|
+
if (!value) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const normalized = value.trim().toLowerCase();
|
|
61
|
+
if (normalized === "ja" || normalized === "true" || normalized === "1") {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (normalized === "nee" || normalized === "false" || normalized === "0") {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* BRO temporal lexical forms, ordered most-specific first.
|
|
71
|
+
* xs:dateTime YYYY-MM-DDThh:mm:ss(.sss)?(Z|±hh:mm)?
|
|
72
|
+
* xs:date YYYY-MM-DD
|
|
73
|
+
* yearMonth YYYY-MM
|
|
74
|
+
* year YYYY
|
|
75
|
+
*/
|
|
76
|
+
const BRO_DATE_FORMATS = [
|
|
77
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/,
|
|
78
|
+
/^\d{4}-\d{2}-\d{2}$/,
|
|
79
|
+
/^\d{4}-\d{2}$/,
|
|
80
|
+
/^\d{4}$/,
|
|
81
|
+
];
|
|
82
|
+
/**
|
|
83
|
+
* Normalize a BRO temporal value to a precision-preserving ISO 8601 string.
|
|
84
|
+
*
|
|
85
|
+
* BRO date/dateTime elements are a choice of full date (`YYYY-MM-DD`),
|
|
86
|
+
* year-month (`YYYY-MM`), year (`YYYY`), full `dateTime`, or a `voidReason`
|
|
87
|
+
* code (e.g. "onbekend") when the value is unknown. The exact lexical value is
|
|
88
|
+
* returned unchanged so no precision or timezone information is lost;
|
|
89
|
+
* `voidReason` codes and any unrecognized input yield `null`.
|
|
90
|
+
*
|
|
91
|
+
* Timezone handling (per BRO): `dateTime` values carry a mandatory offset, which
|
|
92
|
+
* for Dutch data is the seasonal `+01:00` (winter) / `+02:00` (summer) — never
|
|
93
|
+
* `Z`. BRO derives the calendar date from the *Dutch-local* time, so the
|
|
94
|
+
* intended date is simply the lexical `YYYY-MM-DD` prefix of the string. We keep
|
|
95
|
+
* the string verbatim precisely to avoid a UTC conversion silently shifting the
|
|
96
|
+
* date across midnight (BRO's own worked example of the pitfall). Consumers can
|
|
97
|
+
* build a `Date`/`Temporal` when needed, but beware: `new Date("YYYY-MM-DD")` on
|
|
98
|
+
* a date-only value is parsed as UTC midnight and can render as the previous day
|
|
99
|
+
* in negative-offset zones — treat date-only values as plain calendar dates.
|
|
100
|
+
* @see https://www.bro-productomgeving.nl/bpo/release-2.5_2024_Q4/informatie-voor-softwareleveranciers/het-afhandelen-van-tijdstippen
|
|
101
|
+
*
|
|
102
|
+
* Unlike the numeric decoders this does not warn on non-matching input,
|
|
103
|
+
* because `voidReason` is a legitimate and common value in archive data.
|
|
104
|
+
*/
|
|
105
|
+
export function parseDate(value) {
|
|
106
|
+
if (!value) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const trimmed = value.trim();
|
|
110
|
+
if (trimmed === "") {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
if (BRO_DATE_FORMATS.some((format) => format.test(trimmed))) {
|
|
114
|
+
return trimmed;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parse quality class (handles "klasse2" or "2" format)
|
|
120
|
+
*/
|
|
121
|
+
export function parseQualityClass(value) {
|
|
122
|
+
if (!value) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
// Handle "klasse2" format
|
|
126
|
+
const regex = /klasse(\d+)/i;
|
|
127
|
+
const match = regex.exec(value);
|
|
128
|
+
if (match?.[1]) {
|
|
129
|
+
return Number.parseInt(match[1], 10);
|
|
130
|
+
}
|
|
131
|
+
// Handle plain number
|
|
132
|
+
return parseInt(value);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=type-decoders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-decoders.js","sourceRoot":"","sources":["../../src/decoders/type-decoders.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgC;IACzD,sEAAsE;IACtE,wEAAwE;IACxE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,iCAAiC,KAAK,GAAG,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,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"file":"namespaces.d.ts","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,UAiC5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAqB3C,CAAC"}
|
package/dist/namespaces.js
CHANGED
|
@@ -19,11 +19,21 @@ export const BRO_NAMESPACES = {
|
|
|
19
19
|
// BHR-G namespaces (dsbhrg/3.1)
|
|
20
20
|
dsbhrg: "http://www.broservices.nl/xsd/dsbhrg/3.1",
|
|
21
21
|
bhrgcom: "http://www.broservices.nl/xsd/bhrgcommon/3.1",
|
|
22
|
+
// GMW namespaces (Grondwatermonitoringput, dsgmw/1.1)
|
|
23
|
+
dsgmw: "http://www.broservices.nl/xsd/dsgmw/1.1",
|
|
24
|
+
gmwcommon: "http://www.broservices.nl/xsd/gmwcommon/1.1",
|
|
25
|
+
// GLD namespaces (Grondwaterstandonderzoek, dsgld/1.0)
|
|
26
|
+
dsgld: "http://www.broservices.nl/xsd/dsgld/1.0",
|
|
27
|
+
gldcommon: "http://www.broservices.nl/xsd/gldcommon/1.0",
|
|
22
28
|
// Common geospatial namespaces
|
|
23
29
|
gml: "http://www.opengis.net/gml/3.2",
|
|
24
30
|
swe: "http://www.opengis.net/swe/2.0",
|
|
25
31
|
om: "http://www.opengis.net/om/2.0",
|
|
26
32
|
sampling: "http://www.opengis.net/sampling/2.0",
|
|
33
|
+
// OGC WaterML 2.0 - GLD groundwater level time-series (docs use prefix "waterml";
|
|
34
|
+
// XPath binds by URI, so "wml2" here resolves those elements regardless).
|
|
35
|
+
wml2: "http://www.opengis.net/waterml/2.0",
|
|
36
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
27
37
|
};
|
|
28
38
|
/**
|
|
29
39
|
* List of known BRO namespace prefixes
|
|
@@ -44,5 +54,11 @@ export const KNOWN_BRO_PREFIXES = [
|
|
|
44
54
|
"bhrgtcom",
|
|
45
55
|
"dsbhrg",
|
|
46
56
|
"bhrgcom",
|
|
57
|
+
"dsgmw",
|
|
58
|
+
"gmwcommon",
|
|
59
|
+
"dsgld",
|
|
60
|
+
"gldcommon",
|
|
61
|
+
"wml2",
|
|
62
|
+
"xlink",
|
|
47
63
|
];
|
|
48
64
|
//# sourceMappingURL=namespaces.js.map
|
package/dist/namespaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaces.js","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,iBAAiB;IACjB,KAAK,EAAE,yCAAyC;IAChD,MAAM,EAAE,6CAA6C;IACrD,SAAS,EAAE,6CAA6C;IAExD,wCAAwC;IACxC,OAAO,EAAE,4CAA4C;IACrD,SAAS,EAAE,6CAA6C;IACxD,KAAK,EAAE,yCAAyC;IAChD,QAAQ,EAAE,+CAA+C;IAEzD,gCAAgC;IAChC,MAAM,EAAE,0CAA0C;IAClD,OAAO,EAAE,8CAA8C;IAEvD,+BAA+B;IAC/B,GAAG,EAAE,gCAAgC;IACrC,GAAG,EAAE,gCAAgC;IACrC,EAAE,EAAE,+BAA+B;IACnC,QAAQ,EAAE,qCAAqC;
|
|
1
|
+
{"version":3,"file":"namespaces.js","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,iBAAiB;IACjB,KAAK,EAAE,yCAAyC;IAChD,MAAM,EAAE,6CAA6C;IACrD,SAAS,EAAE,6CAA6C;IAExD,wCAAwC;IACxC,OAAO,EAAE,4CAA4C;IACrD,SAAS,EAAE,6CAA6C;IACxD,KAAK,EAAE,yCAAyC;IAChD,QAAQ,EAAE,+CAA+C;IAEzD,gCAAgC;IAChC,MAAM,EAAE,0CAA0C;IAClD,OAAO,EAAE,8CAA8C;IAEvD,sDAAsD;IACtD,KAAK,EAAE,yCAAyC;IAChD,SAAS,EAAE,6CAA6C;IAExD,uDAAuD;IACvD,KAAK,EAAE,yCAAyC;IAChD,SAAS,EAAE,6CAA6C;IAExD,+BAA+B;IAC/B,GAAG,EAAE,gCAAgC;IACrC,GAAG,EAAE,gCAAgC;IACrC,EAAE,EAAE,+BAA+B;IACnC,QAAQ,EAAE,qCAAqC;IAC/C,kFAAkF;IAClF,0EAA0E;IAC1E,IAAI,EAAE,oCAAoC;IAC1C,KAAK,EAAE,8BAA8B;CACtC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B;IACvD,OAAO;IACP,QAAQ;IACR,WAAW;IACX,KAAK;IACL,KAAK;IACL,IAAI;IACJ,UAAU;IACV,OAAO;IACP,SAAS;IACT,WAAW;IACX,OAAO;IACP,UAAU;IACV,QAAQ;IACR,SAAS;IACT,OAAO;IACP,WAAW;IACX,OAAO;IACP,WAAW;IACX,MAAM;IACN,OAAO;CACC,CAAC"}
|
package/dist/node.d.ts
CHANGED
|
@@ -13,15 +13,25 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { BROParser } from "./parser.js";
|
|
15
15
|
export { NodeXMLAdapter as XMLAdapter } from "./adapters/node-adapter.js";
|
|
16
|
-
export type { CPTData, CPTMeasurement,
|
|
16
|
+
export type { CPTData, CPTMeasurement, DissipationMeasurement, BHRGTData, BHRGData, GMWData, GLDData, BROData, BROFileType, Location, ParseMeta, Namespaces, QualityRegime, } from "./types/index.js";
|
|
17
|
+
export type { RegistrationHistory } from "./schemas/common-fields.js";
|
|
17
18
|
export { BROParseError } from "./types/index.js";
|
|
18
19
|
export { SUPPORTED_VERSIONS } from "./core/version-detector.js";
|
|
19
20
|
export type { DataType } from "./core/version-detector.js";
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
21
|
+
export { CPT_PRODUCER } from "./schemas/cpt-schema.js";
|
|
22
|
+
export type { DissipationTest, RemovedLayer } from "./schemas/cpt-schema.js";
|
|
23
|
+
export { BORE_PRODUCER } from "./schemas/bore-schema.js";
|
|
24
|
+
export type { BHRGTLayer, BHRGTLayerBase, BHRGTSoilLayer, BHRGTRockLayer, RockDescription, RockWeatheringDegree, Grainshape, BoredInterval, SampledInterval, SamplerDetails, CoreRecovery, CompletedInterval, PostSedimentaryDiscontinuity, ExcavatedLayer, BoringVelocityMeasurement, NotDescribedInterval, FluidMudLayer, } from "./schemas/bore-schema.js";
|
|
25
|
+
export type { HeightAtSpecificTime, StressAtSpecificSettlement, VolumeChangeAtSpecificTime, ShearStressAtSpecificStrain, HorizontalDeformationDataPoint, BoreholeSampleAnalysis, InvestigatedInterval, WaterContentDetermination, VolumetricMassDensityDetermination, OrganicMatterContentDetermination, CarbonateContentDetermination, VolumetricMassDensityOfSolidsDetermination, MaximumUndrainedShearStrengthDetermination, ParticleSizeDistributionDetermination, ConsistencyLimitsDetermination, SettlementCharacteristicsDetermination, SettlementDeterminationStep, SaturationStageAtCompression, SaturatedPermeabilityDetermination, ShearStressChangeDuringLoadingDetermination, ConsolidationStepAtHorizontalDeformation, ShearStressChangeDuringHorizontalDeformationDetermination, PlasticityAtSpecificWaterContent, SaturatedPermeabilityAtSpecificDensity, SaturatedPermeabilityAtSpecificLoad, MembraneCorrection, DrainageStripCorrection, SpecimenMadeForLoading, SaturationStageAtLoading, ConsolidationStageAtLoading, LoadStage, ConsolidationStageAtHorizontalDeformation, ShearStageAtHorizontalDeformation, } from "./schemas/bhrgt-analysis.js";
|
|
26
|
+
export type { GLDObservation, GLDObservationPoint, GroundwaterMonitoringTubeRef, } from "./schemas/gld-schema.js";
|
|
27
|
+
export { BHRG_PRODUCER } from "./schemas/bhrg-schema.js";
|
|
28
|
+
export type { BHRGLayer, MunsellColour, SandFraction, SandConstituent, ShellFraction, ShellConstituent, GravelFraction, GravelConstituent, PeatFraction, PeatConstituent, Chunk, FractionDistribution, FineFractionDistributionOrganicSoil, FineFractionDistributionShellySoil, Mottle, ThinStratum, ReportHistory, IntermediateEvent, } from "./schemas/bhrg-schema.js";
|
|
29
|
+
export { GMW_PRODUCER } from "./schemas/gmw-schema.js";
|
|
30
|
+
export type { MonitoringTube, GeoOhmCable, Electrode, GMWIntermediateEvent, } from "./schemas/gmw-schema.js";
|
|
31
|
+
export { GLD_PRODUCER } from "./schemas/gld-schema.js";
|
|
23
32
|
export { BRO_NAMESPACES, KNOWN_BRO_PREFIXES } from "./namespaces.js";
|
|
24
33
|
export { BRO_SOIL_COLORS, getSoilColor, isValidSoilColor, getSoilColorNames } from "./colors.js";
|
|
25
|
-
export * as
|
|
34
|
+
export * as producers from "./producers.js";
|
|
35
|
+
export type { Producer, NodeLens, Produced, ProducedFields } from "./core/producer.js";
|
|
26
36
|
export * as presets from "./schema-presets.js";
|
|
27
37
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE1E,YAAY,EACV,OAAO,EACP,cAAc,EACd,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAA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yD,EACzD,gCAAgC,EAChC,sCAAsC,EACtC,mCAAmC,EACnC,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,SAAS,EACT,yCAAyC,EACzC,iCAAiC,GAClC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,KAAK,EACL,oBAAoB,EACpB,mCAAmC,EACnC,kCAAkC,EAClC,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,YAAY,EACV,cAAc,EACd,WAAW,EACX,SAAS,EACT,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGjG,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAG5C,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGvF,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
|
package/dist/node.js
CHANGED
|
@@ -15,13 +15,15 @@ export { BROParser } from "./parser.js";
|
|
|
15
15
|
export { NodeXMLAdapter as XMLAdapter } from "./adapters/node-adapter.js";
|
|
16
16
|
export { BROParseError } from "./types/index.js";
|
|
17
17
|
export { SUPPORTED_VERSIONS } from "./core/version-detector.js";
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
18
|
+
export { CPT_PRODUCER } from "./schemas/cpt-schema.js";
|
|
19
|
+
export { BORE_PRODUCER } from "./schemas/bore-schema.js";
|
|
20
|
+
export { BHRG_PRODUCER } from "./schemas/bhrg-schema.js";
|
|
21
|
+
export { GMW_PRODUCER } from "./schemas/gmw-schema.js";
|
|
22
|
+
export { GLD_PRODUCER } from "./schemas/gld-schema.js";
|
|
21
23
|
export { BRO_NAMESPACES, KNOWN_BRO_PREFIXES } from "./namespaces.js";
|
|
22
24
|
export { BRO_SOIL_COLORS, getSoilColor, isValidSoilColor, getSoilColorNames } from "./colors.js";
|
|
23
|
-
//
|
|
24
|
-
export * as
|
|
25
|
+
// The authoring surface for custom schemas (combinators + domain helpers).
|
|
26
|
+
export * as producers from "./producers.js";
|
|
25
27
|
// Export schema presets for common use cases
|
|
26
28
|
export * as presets from "./schema-presets.js";
|
|
27
29
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAmB1E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA4DzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqBzD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAOvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjG,2EAA2E;AAC3E,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAK5C,6CAA6C;AAC7C,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* The adapter is provided at construction time, making testing and
|
|
6
6
|
* environment-specific behavior explicit.
|
|
7
7
|
*/
|
|
8
|
-
import type { XMLAdapter, Namespaces, CPTData, BHRGTData, BHRGData, BROData, ParseMeta,
|
|
8
|
+
import type { XMLAdapter, Namespaces, CPTData, BHRGTData, BHRGData, GMWData, GLDData, BROData, ParseMeta, BROFileType } from "./types/index.js";
|
|
9
|
+
import type { Producer, ProducedFields, Presence } from "./core/producer.js";
|
|
9
10
|
/**
|
|
10
11
|
* Main BRO Parser class
|
|
11
12
|
*
|
|
@@ -105,6 +106,55 @@ export declare class BROParser {
|
|
|
105
106
|
* ```
|
|
106
107
|
*/
|
|
107
108
|
parseBHRG(xmlText: string): BHRGData;
|
|
109
|
+
/**
|
|
110
|
+
* Parse GMW (groundwater monitoring well) data from BRO/XML string
|
|
111
|
+
*
|
|
112
|
+
* Extracts well metadata and its monitoring tubes following the IMBRO GMW
|
|
113
|
+
* schema (dsgmw/1.1). Works on the public dispatch document (`GMW_PPO`) as
|
|
114
|
+
* well as the `GMW_PO` / `GMW_O` variants, which share one leaf surface.
|
|
115
|
+
*
|
|
116
|
+
* @param xmlText - BRO/XML document as string
|
|
117
|
+
* @returns Parsed GMW data with metadata and monitoring tubes
|
|
118
|
+
* @throws {BROParseError} If parsing fails or required fields are missing
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const parser = new BROParser(new XMLAdapter());
|
|
123
|
+
* const gmw = parser.parseGMW(xmlString);
|
|
124
|
+
*
|
|
125
|
+
* console.log(gmw.broId); // "GMW000000048066"
|
|
126
|
+
* console.log(gmw.numberOfMonitoringTubes); // 1
|
|
127
|
+
* console.log(gmw.monitoringTubes[0].screenLength); // 1.0
|
|
128
|
+
* console.log(gmw.meta.schemaVersion); // "1.1"
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
parseGMW(xmlText: string): GMWData;
|
|
132
|
+
/**
|
|
133
|
+
* Parse GLD (groundwater level research) data from BRO/XML string
|
|
134
|
+
*
|
|
135
|
+
* Extracts the monitoring-point reference, monitoring-net membership and the
|
|
136
|
+
* groundwater level observation time-series following the IMBRO GLD schema
|
|
137
|
+
* (dsgld/1.0).
|
|
138
|
+
*
|
|
139
|
+
* Note: full GLD dispatch documents can be very large (years of time-series
|
|
140
|
+
* measurements). Consider requesting a bounded observation period from the BRO
|
|
141
|
+
* REST API before parsing.
|
|
142
|
+
*
|
|
143
|
+
* @param xmlText - BRO/XML document as string
|
|
144
|
+
* @returns Parsed GLD data with metadata and observation series
|
|
145
|
+
* @throws {BROParseError} If parsing fails or required fields are missing
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const parser = new BROParser(new XMLAdapter());
|
|
150
|
+
* const gld = parser.parseGLD(xmlString);
|
|
151
|
+
*
|
|
152
|
+
* console.log(gld.broId); // "GLD000000010000"
|
|
153
|
+
* console.log(gld.monitoringPoint?.broId); // "GMW000000020142"
|
|
154
|
+
* console.log(gld.observations[0].points.length); // 8760
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
parseGLD(xmlText: string): GLDData;
|
|
108
158
|
/**
|
|
109
159
|
* Parse any BRO XML document, auto-detecting the data type
|
|
110
160
|
*
|
|
@@ -140,35 +190,35 @@ export declare class BROParser {
|
|
|
140
190
|
* This allows you to extract only the fields you need, which can be
|
|
141
191
|
* more efficient and gives you full control over the output structure.
|
|
142
192
|
*
|
|
193
|
+
* Pass a bare map of field name → {@link Producer}, built from the `producers`
|
|
194
|
+
* authoring surface. The return type is inferred from the map: each field's
|
|
195
|
+
* type is its producer's output type, plus a `meta` block. Author the map as
|
|
196
|
+
* an inline literal (or with `satisfies Record<string, Producer<unknown>>`) so
|
|
197
|
+
* the field types are preserved for inference.
|
|
198
|
+
*
|
|
143
199
|
* @param xmlText - BRO/XML document as string
|
|
144
|
-
* @param
|
|
200
|
+
* @param fields - Field name → producer map defining what to extract
|
|
145
201
|
* @param dataType - The BRO data type (for version validation)
|
|
146
|
-
* @returns Object with extracted fields matching your
|
|
202
|
+
* @returns Object with extracted fields matching your map, plus `meta`
|
|
147
203
|
*
|
|
148
204
|
* @example
|
|
149
205
|
* ```typescript
|
|
150
|
-
* import { BROParser,
|
|
206
|
+
* import { BROParser, producers as p } from '@bedrock-engineer/bro-xml-parser';
|
|
151
207
|
*
|
|
152
208
|
* const parser = new BROParser(new XMLAdapter());
|
|
153
209
|
*
|
|
154
210
|
* // Define only the fields you need
|
|
155
|
-
* const
|
|
156
|
-
* id:
|
|
157
|
-
* depth:
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* resolver: resolvers.parseGMLLocation
|
|
164
|
-
* }
|
|
165
|
-
* };
|
|
166
|
-
*
|
|
167
|
-
* const result = parser.parseCustom(xmlText, mySchema, 'CPT');
|
|
168
|
-
* // { id: "CPT000000099543", depth: 25.5, location: { x: 155000, y: 463000, epsg: "EPSG:28992" } }
|
|
211
|
+
* const result = parser.parseCustom(xmlText, {
|
|
212
|
+
* id: p.text('brocom:broId'), // string | null
|
|
213
|
+
* depth: p.number_('./dscpt:conePenetrometerSurvey/cptcommon:trajectory/cptcommon:finalDepth'),
|
|
214
|
+
* location: p.gmlLocation('./dscpt:deliveredLocation/cptcommon:location'),
|
|
215
|
+
* }, 'CPT');
|
|
216
|
+
*
|
|
217
|
+
* result.depth; // number | null — inferred, no casts
|
|
218
|
+
* result.location; // Location | null
|
|
169
219
|
* ```
|
|
170
220
|
*/
|
|
171
|
-
parseCustom(xmlText: string,
|
|
221
|
+
parseCustom<const F extends Record<string, Producer<unknown, Presence>>>(xmlText: string, fields: F, dataType?: BROFileType): ProducedFields<F> & {
|
|
172
222
|
meta: ParseMeta;
|
|
173
223
|
};
|
|
174
224
|
/**
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAcH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,EACT,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,MAAM,CAAe;IAE7B;;;;;OAKG;gBACS,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,UAAU;IAKxD;;OAEG;IACH,OAAO,CAAC,UAAU;IAclB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAYlC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAYtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAYpC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAYlC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAYlC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAwB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,EACrE,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,CAAC,EACT,QAAQ,CAAC,EAAE,WAAW,GACrB,cAAc,CAAC,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE;IA8B1C;;;OAGG;IACH,UAAU,IAAI,UAAU;CAGzB"}
|
package/dist/parser.js
CHANGED
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { SchemaParser } from "./core/schema-parser.js";
|
|
9
9
|
import { detectAndValidateVersion, getVersionInfo, } from "./core/version-detector.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { CPT_PRODUCER } from "./schemas/cpt-schema.js";
|
|
11
|
+
import { BORE_PRODUCER } from "./schemas/bore-schema.js";
|
|
12
|
+
import { BHRG_PRODUCER } from "./schemas/bhrg-schema.js";
|
|
13
|
+
import { GMW_PRODUCER } from "./schemas/gmw-schema.js";
|
|
14
|
+
import { GLD_PRODUCER } from "./schemas/gld-schema.js";
|
|
13
15
|
import { BRO_NAMESPACES } from "./namespaces.js";
|
|
14
16
|
import { BROParseError } from "./types/index.js";
|
|
17
|
+
import { object_ } from "./core/producer.js";
|
|
15
18
|
/**
|
|
16
19
|
* Main BRO Parser class
|
|
17
20
|
*
|
|
@@ -82,8 +85,9 @@ export class BROParser {
|
|
|
82
85
|
const doc = this.adapter.parseXML(xmlText);
|
|
83
86
|
const versionResult = detectAndValidateVersion(doc, "CPT");
|
|
84
87
|
const meta = this.createMeta(versionResult);
|
|
85
|
-
const
|
|
86
|
-
|
|
88
|
+
const { value, warnings } = this.parser.produce(doc, CPT_PRODUCER, "dispatchDocument");
|
|
89
|
+
meta.warnings.push(...warnings);
|
|
90
|
+
return { meta, ...value };
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
93
|
* Parse Bore (borehole) data from BRO/XML string
|
|
@@ -111,8 +115,9 @@ export class BROParser {
|
|
|
111
115
|
const doc = this.adapter.parseXML(xmlText);
|
|
112
116
|
const versionResult = detectAndValidateVersion(doc, "BHR-GT");
|
|
113
117
|
const meta = this.createMeta(versionResult);
|
|
114
|
-
const
|
|
115
|
-
|
|
118
|
+
const { value, warnings } = this.parser.produce(doc, BORE_PRODUCER, "dispatchDocument");
|
|
119
|
+
meta.warnings.push(...warnings);
|
|
120
|
+
return { meta, ...value };
|
|
116
121
|
}
|
|
117
122
|
/**
|
|
118
123
|
* Parse BHR-G (Geological Borehole) data from BRO/XML string
|
|
@@ -140,8 +145,72 @@ export class BROParser {
|
|
|
140
145
|
const doc = this.adapter.parseXML(xmlText);
|
|
141
146
|
const versionResult = detectAndValidateVersion(doc, "BHR-G");
|
|
142
147
|
const meta = this.createMeta(versionResult);
|
|
143
|
-
const
|
|
144
|
-
|
|
148
|
+
const { value, warnings } = this.parser.produce(doc, BHRG_PRODUCER, "dispatchDocument");
|
|
149
|
+
meta.warnings.push(...warnings);
|
|
150
|
+
return { meta, ...value };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Parse GMW (groundwater monitoring well) data from BRO/XML string
|
|
154
|
+
*
|
|
155
|
+
* Extracts well metadata and its monitoring tubes following the IMBRO GMW
|
|
156
|
+
* schema (dsgmw/1.1). Works on the public dispatch document (`GMW_PPO`) as
|
|
157
|
+
* well as the `GMW_PO` / `GMW_O` variants, which share one leaf surface.
|
|
158
|
+
*
|
|
159
|
+
* @param xmlText - BRO/XML document as string
|
|
160
|
+
* @returns Parsed GMW data with metadata and monitoring tubes
|
|
161
|
+
* @throws {BROParseError} If parsing fails or required fields are missing
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const parser = new BROParser(new XMLAdapter());
|
|
166
|
+
* const gmw = parser.parseGMW(xmlString);
|
|
167
|
+
*
|
|
168
|
+
* console.log(gmw.broId); // "GMW000000048066"
|
|
169
|
+
* console.log(gmw.numberOfMonitoringTubes); // 1
|
|
170
|
+
* console.log(gmw.monitoringTubes[0].screenLength); // 1.0
|
|
171
|
+
* console.log(gmw.meta.schemaVersion); // "1.1"
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
parseGMW(xmlText) {
|
|
175
|
+
const doc = this.adapter.parseXML(xmlText);
|
|
176
|
+
const versionResult = detectAndValidateVersion(doc, "GMW");
|
|
177
|
+
const meta = this.createMeta(versionResult);
|
|
178
|
+
const { value, warnings } = this.parser.produce(doc, GMW_PRODUCER, "dispatchDocument");
|
|
179
|
+
meta.warnings.push(...warnings);
|
|
180
|
+
return { meta, ...value };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Parse GLD (groundwater level research) data from BRO/XML string
|
|
184
|
+
*
|
|
185
|
+
* Extracts the monitoring-point reference, monitoring-net membership and the
|
|
186
|
+
* groundwater level observation time-series following the IMBRO GLD schema
|
|
187
|
+
* (dsgld/1.0).
|
|
188
|
+
*
|
|
189
|
+
* Note: full GLD dispatch documents can be very large (years of time-series
|
|
190
|
+
* measurements). Consider requesting a bounded observation period from the BRO
|
|
191
|
+
* REST API before parsing.
|
|
192
|
+
*
|
|
193
|
+
* @param xmlText - BRO/XML document as string
|
|
194
|
+
* @returns Parsed GLD data with metadata and observation series
|
|
195
|
+
* @throws {BROParseError} If parsing fails or required fields are missing
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const parser = new BROParser(new XMLAdapter());
|
|
200
|
+
* const gld = parser.parseGLD(xmlString);
|
|
201
|
+
*
|
|
202
|
+
* console.log(gld.broId); // "GLD000000010000"
|
|
203
|
+
* console.log(gld.monitoringPoint?.broId); // "GMW000000020142"
|
|
204
|
+
* console.log(gld.observations[0].points.length); // 8760
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
parseGLD(xmlText) {
|
|
208
|
+
const doc = this.adapter.parseXML(xmlText);
|
|
209
|
+
const versionResult = detectAndValidateVersion(doc, "GLD");
|
|
210
|
+
const meta = this.createMeta(versionResult);
|
|
211
|
+
const { value, warnings } = this.parser.produce(doc, GLD_PRODUCER, "dispatchDocument");
|
|
212
|
+
meta.warnings.push(...warnings);
|
|
213
|
+
return { meta, ...value };
|
|
145
214
|
}
|
|
146
215
|
/**
|
|
147
216
|
* Parse any BRO XML document, auto-detecting the data type
|
|
@@ -186,6 +255,10 @@ export class BROParser {
|
|
|
186
255
|
return this.parseBHRGT(xmlText);
|
|
187
256
|
case "BHR-G":
|
|
188
257
|
return this.parseBHRG(xmlText);
|
|
258
|
+
case "GMW":
|
|
259
|
+
return this.parseGMW(xmlText);
|
|
260
|
+
case "GLD":
|
|
261
|
+
return this.parseGLD(xmlText);
|
|
189
262
|
}
|
|
190
263
|
}
|
|
191
264
|
/**
|
|
@@ -194,35 +267,35 @@ export class BROParser {
|
|
|
194
267
|
* This allows you to extract only the fields you need, which can be
|
|
195
268
|
* more efficient and gives you full control over the output structure.
|
|
196
269
|
*
|
|
270
|
+
* Pass a bare map of field name → {@link Producer}, built from the `producers`
|
|
271
|
+
* authoring surface. The return type is inferred from the map: each field's
|
|
272
|
+
* type is its producer's output type, plus a `meta` block. Author the map as
|
|
273
|
+
* an inline literal (or with `satisfies Record<string, Producer<unknown>>`) so
|
|
274
|
+
* the field types are preserved for inference.
|
|
275
|
+
*
|
|
197
276
|
* @param xmlText - BRO/XML document as string
|
|
198
|
-
* @param
|
|
277
|
+
* @param fields - Field name → producer map defining what to extract
|
|
199
278
|
* @param dataType - The BRO data type (for version validation)
|
|
200
|
-
* @returns Object with extracted fields matching your
|
|
279
|
+
* @returns Object with extracted fields matching your map, plus `meta`
|
|
201
280
|
*
|
|
202
281
|
* @example
|
|
203
282
|
* ```typescript
|
|
204
|
-
* import { BROParser,
|
|
283
|
+
* import { BROParser, producers as p } from '@bedrock-engineer/bro-xml-parser';
|
|
205
284
|
*
|
|
206
285
|
* const parser = new BROParser(new XMLAdapter());
|
|
207
286
|
*
|
|
208
287
|
* // Define only the fields you need
|
|
209
|
-
* const
|
|
210
|
-
* id:
|
|
211
|
-
* depth:
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* resolver: resolvers.parseGMLLocation
|
|
218
|
-
* }
|
|
219
|
-
* };
|
|
220
|
-
*
|
|
221
|
-
* const result = parser.parseCustom(xmlText, mySchema, 'CPT');
|
|
222
|
-
* // { id: "CPT000000099543", depth: 25.5, location: { x: 155000, y: 463000, epsg: "EPSG:28992" } }
|
|
288
|
+
* const result = parser.parseCustom(xmlText, {
|
|
289
|
+
* id: p.text('brocom:broId'), // string | null
|
|
290
|
+
* depth: p.number_('./dscpt:conePenetrometerSurvey/cptcommon:trajectory/cptcommon:finalDepth'),
|
|
291
|
+
* location: p.gmlLocation('./dscpt:deliveredLocation/cptcommon:location'),
|
|
292
|
+
* }, 'CPT');
|
|
293
|
+
*
|
|
294
|
+
* result.depth; // number | null — inferred, no casts
|
|
295
|
+
* result.location; // Location | null
|
|
223
296
|
* ```
|
|
224
297
|
*/
|
|
225
|
-
parseCustom(xmlText,
|
|
298
|
+
parseCustom(xmlText, fields, dataType) {
|
|
226
299
|
const doc = this.adapter.parseXML(xmlText);
|
|
227
300
|
// Validate version if dataType is provided
|
|
228
301
|
let meta;
|
|
@@ -246,8 +319,9 @@ export class BROParser {
|
|
|
246
319
|
};
|
|
247
320
|
}
|
|
248
321
|
}
|
|
249
|
-
const
|
|
250
|
-
|
|
322
|
+
const { value, warnings } = this.parser.produce(doc, object_({ fields }), "dispatchDocument");
|
|
323
|
+
meta.warnings.push(...warnings);
|
|
324
|
+
return { meta, ...value };
|
|
251
325
|
}
|
|
252
326
|
/**
|
|
253
327
|
* Get the underlying XML adapter
|