@bedrock-engineer/bro-xml-parser 0.6.0 → 0.7.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 +12 -4
- package/dist/browser.d.ts +2 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/colors.d.ts +17 -16
- package/dist/colors.d.ts.map +1 -1
- package/dist/colors.js +6 -6
- package/dist/colors.js.map +1 -1
- package/dist/core/producer.d.ts +13 -4
- package/dist/core/producer.d.ts.map +1 -1
- package/dist/core/producer.js.map +1 -1
- package/dist/core/schema-parser.d.ts +14 -0
- package/dist/core/schema-parser.d.ts.map +1 -1
- package/dist/core/schema-parser.js +44 -11
- 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 +93 -93
- package/dist/core/version-detector.js.map +1 -1
- package/dist/namespaces.d.ts +21 -0
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +36 -0
- package/dist/namespaces.js.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js.map +1 -1
- package/dist/parser.d.ts +16 -2
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +44 -44
- package/dist/parser.js.map +1 -1
- package/dist/producers.d.ts +3 -5
- package/dist/producers.d.ts.map +1 -1
- package/dist/producers.js +3 -5
- package/dist/producers.js.map +1 -1
- package/dist/reference-codes/describe.d.ts +4 -0
- package/dist/reference-codes/describe.d.ts.map +1 -1
- package/dist/reference-codes/describe.js +8 -4
- package/dist/reference-codes/describe.js.map +1 -1
- package/dist/schemas/bhrg-schema.d.ts +483 -483
- package/dist/schemas/bhrg-schema.js +1 -1
- package/dist/schemas/bhrg-types.d.ts +18 -18
- package/dist/schemas/bhrg-types.d.ts.map +1 -1
- package/dist/schemas/bhrgt-analysis.d.ts +53 -53
- package/dist/schemas/bhrgt-analysis.js +3 -3
- package/dist/schemas/bhrgt-analysis.js.map +1 -1
- package/dist/schemas/bore-schema.d.ts +99 -99
- package/dist/schemas/bore-schema.js +1 -1
- package/dist/schemas/bore-schema.js.map +1 -1
- package/dist/schemas/bore-types.d.ts +18 -18
- package/dist/schemas/bore-types.d.ts.map +1 -1
- package/dist/schemas/common-fields.d.ts +4 -61
- package/dist/schemas/common-fields.d.ts.map +1 -1
- package/dist/schemas/common-fields.js +5 -47
- package/dist/schemas/common-fields.js.map +1 -1
- package/dist/schemas/cpt-schema.d.ts +27 -27
- package/dist/schemas/gld-schema.d.ts +12 -12
- package/dist/schemas/gmw-schema.d.ts +60 -60
- package/dist/types/index.d.ts +44 -17
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,89 +7,100 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { BROParseError } from "../types/index.js";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Additional entries are known older/newer versions that may
|
|
14
|
-
* be parseable with warnings.
|
|
10
|
+
* The registration-type registry: version facts per {@link DataType}, the single
|
|
11
|
+
* source of truth the detector reads. (Producers live in `BROParser`, keyed by the
|
|
12
|
+
* same union — see the split rationale in the parser.)
|
|
15
13
|
*/
|
|
16
|
-
const
|
|
17
|
-
CPT:
|
|
18
|
-
|
|
14
|
+
const REGISTRATIONS = {
|
|
15
|
+
CPT: {
|
|
16
|
+
urnFragment: "/dscpt/",
|
|
17
|
+
primary: {
|
|
19
18
|
namespace: "http://www.broservices.nl/xsd/dscpt/1.1",
|
|
20
19
|
version: "1.1",
|
|
21
20
|
majorVersion: 1,
|
|
22
21
|
description: "Dispatch CPT schema version 1.1",
|
|
23
22
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
alsoKnown: [
|
|
24
|
+
{
|
|
25
|
+
namespace: "http://www.broservices.nl/xsd/dscpt/1.0",
|
|
26
|
+
version: "1.0",
|
|
27
|
+
majorVersion: 1,
|
|
28
|
+
description: "Dispatch CPT schema version 1.0",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
"BHR-GT": {
|
|
33
|
+
urnFragment: "/dsbhr-gt/",
|
|
34
|
+
primary: {
|
|
34
35
|
namespace: "http://www.broservices.nl/xsd/dsbhr-gt/2.1",
|
|
35
36
|
version: "2.1",
|
|
36
37
|
majorVersion: 2,
|
|
37
38
|
description: "Dispatch BHR-GT schema version 2.1",
|
|
38
39
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
alsoKnown: [
|
|
41
|
+
{
|
|
42
|
+
namespace: "http://www.broservices.nl/xsd/dsbhr-gt/2.0",
|
|
43
|
+
version: "2.0",
|
|
44
|
+
majorVersion: 2,
|
|
45
|
+
description: "Dispatch BHR-GT schema version 2.0",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
"BHR-G": {
|
|
50
|
+
urnFragment: "/dsbhrg/",
|
|
51
|
+
primary: {
|
|
49
52
|
namespace: "http://www.broservices.nl/xsd/dsbhrg/3.1",
|
|
50
53
|
version: "3.1",
|
|
51
54
|
majorVersion: 3,
|
|
52
55
|
description: "Dispatch BHR-G schema version 3.1",
|
|
53
56
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
alsoKnown: [
|
|
58
|
+
{
|
|
59
|
+
namespace: "http://www.broservices.nl/xsd/dsbhrg/3.0",
|
|
60
|
+
version: "3.0",
|
|
61
|
+
majorVersion: 3,
|
|
62
|
+
description: "Dispatch BHR-G schema version 3.0",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
GMW: {
|
|
67
|
+
urnFragment: "/dsgmw/",
|
|
68
|
+
primary: {
|
|
64
69
|
namespace: "http://www.broservices.nl/xsd/dsgmw/1.1",
|
|
65
70
|
version: "1.1",
|
|
66
71
|
majorVersion: 1,
|
|
67
72
|
description: "Dispatch GMW schema version 1.1",
|
|
68
73
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
alsoKnown: [
|
|
75
|
+
{
|
|
76
|
+
namespace: "http://www.broservices.nl/xsd/dsgmw/1.0",
|
|
77
|
+
version: "1.0",
|
|
78
|
+
majorVersion: 1,
|
|
79
|
+
description: "Dispatch GMW schema version 1.0",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
GLD: {
|
|
84
|
+
urnFragment: "/dsgld/",
|
|
85
|
+
primary: {
|
|
79
86
|
namespace: "http://www.broservices.nl/xsd/dsgld/1.0",
|
|
80
87
|
version: "1.0",
|
|
81
88
|
majorVersion: 1,
|
|
82
89
|
description: "Dispatch GLD schema version 1.0",
|
|
83
90
|
},
|
|
84
|
-
|
|
91
|
+
alsoKnown: [],
|
|
92
|
+
},
|
|
85
93
|
};
|
|
94
|
+
/** Every known version for a type, primary first. */
|
|
95
|
+
function knownVersions(dataType) {
|
|
96
|
+
const reg = REGISTRATIONS[dataType];
|
|
97
|
+
return [reg.primary, ...reg.alsoKnown];
|
|
98
|
+
}
|
|
86
99
|
/**
|
|
87
100
|
* Get the supported (primary) version for a data type
|
|
88
101
|
*/
|
|
89
102
|
function getSupportedVersion(dataType) {
|
|
90
|
-
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
92
|
-
return KNOWN_VERSIONS[dataType][0];
|
|
103
|
+
return REGISTRATIONS[dataType].primary;
|
|
93
104
|
}
|
|
94
105
|
/**
|
|
95
106
|
* Exported for backward compatibility
|
|
@@ -102,11 +113,12 @@ export const SUPPORTED_VERSIONS = {
|
|
|
102
113
|
GLD: getSupportedVersion("GLD"),
|
|
103
114
|
};
|
|
104
115
|
/**
|
|
105
|
-
* Extract version from namespace URI
|
|
106
|
-
*
|
|
116
|
+
* Extract version from namespace URI. Accepts both the documented
|
|
117
|
+
* `major.minor` form and the bare-major form several BRO REST services return.
|
|
118
|
+
* e.g. `.../dscpt/1.1` -> "1.1", `.../dsbhrg/3` -> "3"
|
|
107
119
|
*/
|
|
108
120
|
function extractVersionFromNamespace(namespace) {
|
|
109
|
-
const match = /\/(\d
|
|
121
|
+
const match = /\/(\d+(?:\.\d+)?)$/.exec(namespace);
|
|
110
122
|
return match?.[1] ?? "unknown";
|
|
111
123
|
}
|
|
112
124
|
/**
|
|
@@ -118,43 +130,18 @@ function extractMajorVersion(version) {
|
|
|
118
130
|
return match?.[1] ? parseInt(match[1], 10) : 0;
|
|
119
131
|
}
|
|
120
132
|
/**
|
|
121
|
-
* Detect schema type from namespace
|
|
133
|
+
* Detect schema type from a namespace by matching its version-independent family
|
|
134
|
+
* fragment (e.g. `/dscpt/`) against the registry. `dsbhr-gt` and `dsbhrg` stay
|
|
135
|
+
* distinct because their fragments carry the hyphen.
|
|
122
136
|
*/
|
|
123
137
|
function detectDataTypeFromNamespace(namespace) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return "BHR-GT";
|
|
129
|
-
}
|
|
130
|
-
if (namespace.includes("/dsbhrg/")) {
|
|
131
|
-
return "BHR-G";
|
|
132
|
-
}
|
|
133
|
-
if (namespace.includes("/dsgmw/")) {
|
|
134
|
-
return "GMW";
|
|
135
|
-
}
|
|
136
|
-
if (namespace.includes("/dsgld/")) {
|
|
137
|
-
return "GLD";
|
|
138
|
+
for (const [type, reg] of Object.entries(REGISTRATIONS)) {
|
|
139
|
+
if (namespace.includes(reg.urnFragment)) {
|
|
140
|
+
return type;
|
|
141
|
+
}
|
|
138
142
|
}
|
|
139
143
|
return null;
|
|
140
144
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Get the parser method name for a data type
|
|
143
|
-
*/
|
|
144
|
-
function getParserMethodName(dataType) {
|
|
145
|
-
switch (dataType) {
|
|
146
|
-
case "CPT":
|
|
147
|
-
return "parseCPT";
|
|
148
|
-
case "BHR-GT":
|
|
149
|
-
return "parseBHRGT";
|
|
150
|
-
case "BHR-G":
|
|
151
|
-
return "parseBHRG";
|
|
152
|
-
case "GMW":
|
|
153
|
-
return "parseGMW";
|
|
154
|
-
case "GLD":
|
|
155
|
-
return "parseGLD";
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
145
|
/**
|
|
159
146
|
* Detect and validate the BRO schema version from XML document
|
|
160
147
|
*
|
|
@@ -190,8 +177,7 @@ export function detectAndValidateVersion(doc, expectedType) {
|
|
|
190
177
|
};
|
|
191
178
|
}
|
|
192
179
|
// Check if it's a known version for the expected type
|
|
193
|
-
const
|
|
194
|
-
const knownVersion = knownVersions.find((v) => v.namespace === namespace);
|
|
180
|
+
const knownVersion = knownVersions(expectedType).find((v) => v.namespace === namespace);
|
|
195
181
|
if (knownVersion) {
|
|
196
182
|
// Known version but not the primary supported one
|
|
197
183
|
warnings.push(`Parsing with schema version ${knownVersion.version}, ` +
|
|
@@ -212,7 +198,7 @@ export function detectAndValidateVersion(doc, expectedType) {
|
|
|
212
198
|
expected: expectedType,
|
|
213
199
|
actual: detectedType,
|
|
214
200
|
namespace,
|
|
215
|
-
hint: `
|
|
201
|
+
hint: `Document is ${detectedType}, not ${expectedType}. Use the ${detectedType} parser.`,
|
|
216
202
|
});
|
|
217
203
|
}
|
|
218
204
|
// Check if it's the same type but unknown version
|
|
@@ -221,6 +207,20 @@ export function detectAndValidateVersion(doc, expectedType) {
|
|
|
221
207
|
const detectedMajor = extractMajorVersion(detectedVersion);
|
|
222
208
|
const supportedMajor = supportedVersion.majorVersion;
|
|
223
209
|
if (detectedMajor === supportedMajor) {
|
|
210
|
+
// A bare-major namespace (e.g. `.../dsbhrg/3`) is the whole-major form
|
|
211
|
+
// several BRO REST services return for the very schema family we
|
|
212
|
+
// support. It resolves cleanly, so accept it without warning. A specific
|
|
213
|
+
// but unrecognized minor (e.g. `3.2`) is genuinely unverified and still
|
|
214
|
+
// warns below.
|
|
215
|
+
const isBareMajor = /\/\d+$/.test(namespace);
|
|
216
|
+
if (isBareMajor) {
|
|
217
|
+
return {
|
|
218
|
+
dataType: expectedType,
|
|
219
|
+
version: detectedVersion,
|
|
220
|
+
namespace,
|
|
221
|
+
warnings: [],
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
224
|
// Same major version - attempt parsing with warning
|
|
225
225
|
warnings.push(`Unknown schema version ${detectedVersion} for ${expectedType}. ` +
|
|
226
226
|
`This library supports version ${supportedVersion.version}. ` +
|
|
@@ -272,11 +272,11 @@ export function getVersionInfo(doc) {
|
|
|
272
272
|
return null;
|
|
273
273
|
}
|
|
274
274
|
// Check all known versions
|
|
275
|
-
for (const
|
|
276
|
-
for (const info of
|
|
275
|
+
for (const type of Object.keys(REGISTRATIONS)) {
|
|
276
|
+
for (const info of knownVersions(type)) {
|
|
277
277
|
if (namespace === info.namespace) {
|
|
278
278
|
return {
|
|
279
|
-
type
|
|
279
|
+
type,
|
|
280
280
|
version: info.version,
|
|
281
281
|
namespace: info.namespace,
|
|
282
282
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-detector.js","sourceRoot":"","sources":["../../src/core/version-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"version-detector.js","sourceRoot":"","sources":["../../src/core/version-detector.ts"],"names":[],"mappings":"A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AO,CAAC,CAAC;IAEpD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2BAA2B;IAC3B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAoB,EAAE,CAAC;QACjE,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,IAAI,SAAS,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjC,OAAO;oBACL,IAAI;oBACJ,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,SAAS,EAAE,IAAI,CAAC,SAAS;iBAC1B,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,uCAAuC;IACvC,MAAM,YAAY,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAC5D,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,OAAO;YACP,SAAS;SACV,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/namespaces.d.ts
CHANGED
|
@@ -13,4 +13,25 @@ export declare const BRO_NAMESPACES: Namespaces;
|
|
|
13
13
|
* Used by NodeXMLAdapter for pre-populating the xpath library's namespace map
|
|
14
14
|
*/
|
|
15
15
|
export declare const KNOWN_BRO_PREFIXES: ReadonlyArray<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Strip a trailing schema version from a namespace URI, yielding its "family".
|
|
18
|
+
*
|
|
19
|
+
* BRO publishes the same schema under several version suffixes — e.g.
|
|
20
|
+
* `.../dsbhrg/3.1` (the documented XSD) and `.../dsbhrg/3` (returned by several
|
|
21
|
+
* REST services); both share the family `.../dsbhrg`. Only a trailing
|
|
22
|
+
* `/<major>` or `/<major>.<minor>` is removed, so a URI like
|
|
23
|
+
* `.../1999/xlink` (version-free) is returned unchanged.
|
|
24
|
+
*/
|
|
25
|
+
export declare function namespaceFamily(uri: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Re-point the configured namespace URIs at the versions a document declares.
|
|
28
|
+
*
|
|
29
|
+
* The XPath resolver binds each prefix to one exact URI, so a document that
|
|
30
|
+
* declares `.../dsbhrg/3` never matches queries bound to `.../dsbhrg/3.1`. For
|
|
31
|
+
* every configured prefix whose family also appears among `declaredUris`, adopt
|
|
32
|
+
* the document's URI; leave the rest untouched. Matching by family means a
|
|
33
|
+
* major-3 BHR-G parses whether it arrives as `/3`, `/3.0`, or `/3.1`, without
|
|
34
|
+
* the schema (which is prefix-keyed) needing to know which minor it got.
|
|
35
|
+
*/
|
|
36
|
+
export declare function adaptNamespacesToDocument(defaults: Namespaces, declaredUris: Iterable<string>): Namespaces;
|
|
16
37
|
//# sourceMappingURL=namespaces.d.ts.map
|
package/dist/namespaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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;AAEX;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAC7B,UAAU,CAcZ"}
|
package/dist/namespaces.js
CHANGED
|
@@ -61,4 +61,40 @@ export const KNOWN_BRO_PREFIXES = [
|
|
|
61
61
|
"wml2",
|
|
62
62
|
"xlink",
|
|
63
63
|
];
|
|
64
|
+
/**
|
|
65
|
+
* Strip a trailing schema version from a namespace URI, yielding its "family".
|
|
66
|
+
*
|
|
67
|
+
* BRO publishes the same schema under several version suffixes — e.g.
|
|
68
|
+
* `.../dsbhrg/3.1` (the documented XSD) and `.../dsbhrg/3` (returned by several
|
|
69
|
+
* REST services); both share the family `.../dsbhrg`. Only a trailing
|
|
70
|
+
* `/<major>` or `/<major>.<minor>` is removed, so a URI like
|
|
71
|
+
* `.../1999/xlink` (version-free) is returned unchanged.
|
|
72
|
+
*/
|
|
73
|
+
export function namespaceFamily(uri) {
|
|
74
|
+
return uri.replace(/\/\d+(?:\.\d+)?$/, "");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Re-point the configured namespace URIs at the versions a document declares.
|
|
78
|
+
*
|
|
79
|
+
* The XPath resolver binds each prefix to one exact URI, so a document that
|
|
80
|
+
* declares `.../dsbhrg/3` never matches queries bound to `.../dsbhrg/3.1`. For
|
|
81
|
+
* every configured prefix whose family also appears among `declaredUris`, adopt
|
|
82
|
+
* the document's URI; leave the rest untouched. Matching by family means a
|
|
83
|
+
* major-3 BHR-G parses whether it arrives as `/3`, `/3.0`, or `/3.1`, without
|
|
84
|
+
* the schema (which is prefix-keyed) needing to know which minor it got.
|
|
85
|
+
*/
|
|
86
|
+
export function adaptNamespacesToDocument(defaults, declaredUris) {
|
|
87
|
+
const byFamily = new Map();
|
|
88
|
+
for (const uri of declaredUris) {
|
|
89
|
+
byFamily.set(namespaceFamily(uri), uri);
|
|
90
|
+
}
|
|
91
|
+
const adapted = { ...defaults };
|
|
92
|
+
for (const [prefix, uri] of Object.entries(defaults)) {
|
|
93
|
+
const declared = byFamily.get(namespaceFamily(uri));
|
|
94
|
+
if (declared) {
|
|
95
|
+
adapted[prefix] = declared;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return adapted;
|
|
99
|
+
}
|
|
64
100
|
//# 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,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"}
|
|
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;AAEX;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAoB,EACpB,YAA8B;IAE9B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,OAAO,GAAe,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/node.d.ts
CHANGED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
export { BROParser } from "./parser.js";
|
|
15
15
|
export { NodeXMLAdapter as XMLAdapter } from "./adapters/node-adapter.js";
|
|
16
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 "./
|
|
17
|
+
export type { RegistrationHistory } from "./types/index.js";
|
|
18
18
|
export { BROParseError } from "./types/index.js";
|
|
19
19
|
export { SUPPORTED_VERSIONS } from "./core/version-detector.js";
|
|
20
20
|
export type { DataType } from "./core/version-detector.js";
|
|
21
21
|
export { CPT_PRODUCER } from "./schemas/cpt-schema.js";
|
|
22
22
|
export type { DissipationTest, RemovedLayer } from "./types/index.js";
|
|
23
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-types.js";
|
|
24
|
+
export type { BHRGTLayer, BHRGTLayerBase, BHRGTSoilLayer, BHRGTRockLayer, SoilDescription, RockDescription, RockWeatheringDegree, Grainshape, BoredInterval, SampledInterval, SamplerDetails, CoreRecovery, CompletedInterval, PostSedimentaryDiscontinuity, ExcavatedLayer, BoringVelocityMeasurement, NotDescribedInterval, FluidMudLayer, } from "./schemas/bore-types.js";
|
|
25
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
26
|
export type { GLDObservation, GLDObservationPoint, GroundwaterMonitoringTubeRef, } from "./schemas/gld-types.js";
|
|
27
27
|
export { BHRG_PRODUCER } from "./schemas/bhrg-schema.js";
|
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,sBAAsB,EACtB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,MAAM,
|
|
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,sBAAsB,EACtB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,YAAY,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,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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;AA6DzD,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,sFAAsF;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,6CAA6C;AAC7C,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -37,6 +37,20 @@ export declare class BROParser {
|
|
|
37
37
|
* Create ParseMeta from version detection result
|
|
38
38
|
*/
|
|
39
39
|
private createMeta;
|
|
40
|
+
/**
|
|
41
|
+
* The one body behind every `parse*` method: validate the version, run the
|
|
42
|
+
* type's producer, fold warnings into `meta`. Takes an already-parsed `doc` so
|
|
43
|
+
* {@link parse} detects and parses without re-parsing the XML.
|
|
44
|
+
*
|
|
45
|
+
* The cast bridges one TS limitation only: it cannot relate a spread of the
|
|
46
|
+
* generic `value` to the indexed access `DataByType[T]` (it collapses the union
|
|
47
|
+
* to `never` on the conflicting `dataType` literals), so a direct `as` is
|
|
48
|
+
* refused and `as unknown as` is the idiom. Soundness rests entirely on guards
|
|
49
|
+
* elsewhere — the {@link PRODUCERS} map is type-checked against
|
|
50
|
+
* {@link DataByType}, and each `parse*` one-liner re-checks the concrete
|
|
51
|
+
* `DataByType[K]` against its declared `*Data` return type at the call site.
|
|
52
|
+
*/
|
|
53
|
+
private parseAs;
|
|
40
54
|
/**
|
|
41
55
|
* Parse CPT data from BRO/XML string
|
|
42
56
|
*
|
|
@@ -171,8 +185,8 @@ export declare class BROParser {
|
|
|
171
185
|
* const parser = new BROParser(new XMLAdapter());
|
|
172
186
|
* const data = parser.parse(xmlString);
|
|
173
187
|
*
|
|
174
|
-
* //
|
|
175
|
-
* switch (data.
|
|
188
|
+
* // Discriminate on the top-level dataType (narrows the union)
|
|
189
|
+
* switch (data.dataType) {
|
|
176
190
|
* case 'CPT':
|
|
177
191
|
* console.log(data.finalDepth);
|
|
178
192
|
* break;
|
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;AAcH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,
|
|
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,EAEP,SAAS,EACT,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAA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CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,WAAW,GACrB,CAAC,GAAG;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE;IAU1B,iFAAiF;IACjF,OAAO,CAAC,WAAW;IAgBnB;;;OAGG;IACH,UAAU,IAAI,UAAU;CAGzB"}
|
package/dist/parser.js
CHANGED
|
@@ -15,6 +15,23 @@ import { GLD_PRODUCER } from "./schemas/gld-schema.js";
|
|
|
15
15
|
import { BRO_NAMESPACES } from "./namespaces.js";
|
|
16
16
|
import { BROParseError } from "./types/index.js";
|
|
17
17
|
import { object } from "./core/producer.js";
|
|
18
|
+
/**
|
|
19
|
+
* The producer for each registration type. Its value type is checked against
|
|
20
|
+
* {@link DataByType} — file a producer under the wrong key (or omit a key) and it
|
|
21
|
+
* fails to compile. This is the guard that makes the one cast in {@link
|
|
22
|
+
* BROParser.parseAs} a sound bridge (over TS's inability to type a generic spread)
|
|
23
|
+
* rather than an unchecked assertion.
|
|
24
|
+
*
|
|
25
|
+
* Version facts for the same types live in the registry in `version-detector`;
|
|
26
|
+
* producers stay here so that module keeps zero dependency on the schemas.
|
|
27
|
+
*/
|
|
28
|
+
const PRODUCERS = {
|
|
29
|
+
CPT: CPT_PRODUCER,
|
|
30
|
+
"BHR-GT": BORE_PRODUCER,
|
|
31
|
+
"BHR-G": BHRG_PRODUCER,
|
|
32
|
+
GMW: GMW_PRODUCER,
|
|
33
|
+
GLD: GLD_PRODUCER,
|
|
34
|
+
};
|
|
18
35
|
/**
|
|
19
36
|
* Main BRO Parser class
|
|
20
37
|
*
|
|
@@ -59,6 +76,25 @@ export class BROParser {
|
|
|
59
76
|
warnings: versionResult.warnings,
|
|
60
77
|
};
|
|
61
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* The one body behind every `parse*` method: validate the version, run the
|
|
81
|
+
* type's producer, fold warnings into `meta`. Takes an already-parsed `doc` so
|
|
82
|
+
* {@link parse} detects and parses without re-parsing the XML.
|
|
83
|
+
*
|
|
84
|
+
* The cast bridges one TS limitation only: it cannot relate a spread of the
|
|
85
|
+
* generic `value` to the indexed access `DataByType[T]` (it collapses the union
|
|
86
|
+
* to `never` on the conflicting `dataType` literals), so a direct `as` is
|
|
87
|
+
* refused and `as unknown as` is the idiom. Soundness rests entirely on guards
|
|
88
|
+
* elsewhere — the {@link PRODUCERS} map is type-checked against
|
|
89
|
+
* {@link DataByType}, and each `parse*` one-liner re-checks the concrete
|
|
90
|
+
* `DataByType[K]` against its declared `*Data` return type at the call site.
|
|
91
|
+
*/
|
|
92
|
+
parseAs(doc, type) {
|
|
93
|
+
const meta = this.createMeta(detectAndValidateVersion(doc, type));
|
|
94
|
+
const { value, warnings } = this.parser.produce(doc, PRODUCERS[type], "dispatchDocument");
|
|
95
|
+
meta.warnings.push(...warnings);
|
|
96
|
+
return { dataType: type, meta, ...value };
|
|
97
|
+
}
|
|
62
98
|
/**
|
|
63
99
|
* Parse CPT data from BRO/XML string
|
|
64
100
|
*
|
|
@@ -82,12 +118,7 @@ export class BROParser {
|
|
|
82
118
|
* ```
|
|
83
119
|
*/
|
|
84
120
|
parseCPT(xmlText) {
|
|
85
|
-
|
|
86
|
-
const versionResult = detectAndValidateVersion(doc, "CPT");
|
|
87
|
-
const meta = this.createMeta(versionResult);
|
|
88
|
-
const { value, warnings } = this.parser.produce(doc, CPT_PRODUCER, "dispatchDocument");
|
|
89
|
-
meta.warnings.push(...warnings);
|
|
90
|
-
return { meta, ...value };
|
|
121
|
+
return this.parseAs(this.adapter.parseXML(xmlText), "CPT");
|
|
91
122
|
}
|
|
92
123
|
/**
|
|
93
124
|
* Parse Bore (borehole) data from BRO/XML string
|
|
@@ -112,12 +143,7 @@ export class BROParser {
|
|
|
112
143
|
* ```
|
|
113
144
|
*/
|
|
114
145
|
parseBHRGT(xmlText) {
|
|
115
|
-
|
|
116
|
-
const versionResult = detectAndValidateVersion(doc, "BHR-GT");
|
|
117
|
-
const meta = this.createMeta(versionResult);
|
|
118
|
-
const { value, warnings } = this.parser.produce(doc, BORE_PRODUCER, "dispatchDocument");
|
|
119
|
-
meta.warnings.push(...warnings);
|
|
120
|
-
return { meta, ...value };
|
|
146
|
+
return this.parseAs(this.adapter.parseXML(xmlText), "BHR-GT");
|
|
121
147
|
}
|
|
122
148
|
/**
|
|
123
149
|
* Parse BHR-G (Geological Borehole) data from BRO/XML string
|
|
@@ -142,12 +168,7 @@ export class BROParser {
|
|
|
142
168
|
* ```
|
|
143
169
|
*/
|
|
144
170
|
parseBHRG(xmlText) {
|
|
145
|
-
|
|
146
|
-
const versionResult = detectAndValidateVersion(doc, "BHR-G");
|
|
147
|
-
const meta = this.createMeta(versionResult);
|
|
148
|
-
const { value, warnings } = this.parser.produce(doc, BHRG_PRODUCER, "dispatchDocument");
|
|
149
|
-
meta.warnings.push(...warnings);
|
|
150
|
-
return { meta, ...value };
|
|
171
|
+
return this.parseAs(this.adapter.parseXML(xmlText), "BHR-G");
|
|
151
172
|
}
|
|
152
173
|
/**
|
|
153
174
|
* Parse GMW (groundwater monitoring well) data from BRO/XML string
|
|
@@ -172,12 +193,7 @@ export class BROParser {
|
|
|
172
193
|
* ```
|
|
173
194
|
*/
|
|
174
195
|
parseGMW(xmlText) {
|
|
175
|
-
|
|
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 };
|
|
196
|
+
return this.parseAs(this.adapter.parseXML(xmlText), "GMW");
|
|
181
197
|
}
|
|
182
198
|
/**
|
|
183
199
|
* Parse GLD (groundwater level research) data from BRO/XML string
|
|
@@ -205,12 +221,7 @@ export class BROParser {
|
|
|
205
221
|
* ```
|
|
206
222
|
*/
|
|
207
223
|
parseGLD(xmlText) {
|
|
208
|
-
|
|
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 };
|
|
224
|
+
return this.parseAs(this.adapter.parseXML(xmlText), "GLD");
|
|
214
225
|
}
|
|
215
226
|
/**
|
|
216
227
|
* Parse any BRO XML document, auto-detecting the data type
|
|
@@ -228,8 +239,8 @@ export class BROParser {
|
|
|
228
239
|
* const parser = new BROParser(new XMLAdapter());
|
|
229
240
|
* const data = parser.parse(xmlString);
|
|
230
241
|
*
|
|
231
|
-
* //
|
|
232
|
-
* switch (data.
|
|
242
|
+
* // Discriminate on the top-level dataType (narrows the union)
|
|
243
|
+
* switch (data.dataType) {
|
|
233
244
|
* case 'CPT':
|
|
234
245
|
* console.log(data.finalDepth);
|
|
235
246
|
* break;
|
|
@@ -248,18 +259,7 @@ export class BROParser {
|
|
|
248
259
|
code: "UNKNOWN_DATA_TYPE",
|
|
249
260
|
});
|
|
250
261
|
}
|
|
251
|
-
|
|
252
|
-
case "CPT":
|
|
253
|
-
return this.parseCPT(xmlText);
|
|
254
|
-
case "BHR-GT":
|
|
255
|
-
return this.parseBHRGT(xmlText);
|
|
256
|
-
case "BHR-G":
|
|
257
|
-
return this.parseBHRG(xmlText);
|
|
258
|
-
case "GMW":
|
|
259
|
-
return this.parseGMW(xmlText);
|
|
260
|
-
case "GLD":
|
|
261
|
-
return this.parseGLD(xmlText);
|
|
262
|
-
}
|
|
262
|
+
return this.parseAs(doc, versionInfo.type);
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* Parse BRO XML with a custom schema for selective extraction
|