ochre-sdk 1.0.79 → 1.1.1
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 +60 -3
- package/dist/_virtual/_rolldown/runtime.mjs +13 -0
- package/dist/categories.d.mts +249 -0
- package/dist/categories.mjs +259 -0
- package/dist/constants.d.mts +14 -0
- package/dist/constants.mjs +18 -1
- package/dist/errors.d.mts +23 -0
- package/dist/{utilities.mjs → errors.mjs} +33 -84
- package/dist/fetchers/gallery.mjs +15 -51
- package/dist/fetchers/item-children.mjs +20 -66
- package/dist/fetchers/item-links.mjs +26 -79
- package/dist/fetchers/item-ocr-data.d.mts +2 -2
- package/dist/fetchers/item-ocr-data.mjs +11 -15
- package/dist/fetchers/item.d.mts +0 -15
- package/dist/fetchers/item.mjs +20 -72
- package/dist/fetchers/request.d.mts +70 -0
- package/dist/fetchers/request.mjs +100 -0
- package/dist/fetchers/set/items.mjs +27 -73
- package/dist/fetchers/set/property-values.d.mts +2 -3
- package/dist/fetchers/set/property-values.mjs +96 -130
- package/dist/fetchers/website-metadata.mjs +35 -57
- package/dist/fetchers/website.d.mts +2 -3
- package/dist/fetchers/website.mjs +22 -31
- package/dist/getters.d.mts +86 -145
- package/dist/getters.mjs +136 -207
- package/dist/helpers.d.mts +0 -4
- package/dist/helpers.mjs +19 -6
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +6 -4
- package/dist/ocr.d.mts +37 -0
- package/dist/ocr.mjs +52 -0
- package/dist/parsers/helpers.d.mts +21 -1
- package/dist/parsers/helpers.mjs +26 -6
- package/dist/parsers/index.d.mts +0 -8
- package/dist/parsers/index.mjs +118 -259
- package/dist/parsers/languages.d.mts +72 -0
- package/dist/parsers/languages.mjs +132 -0
- package/dist/parsers/multilingual.d.mts +134 -58
- package/dist/parsers/multilingual.mjs +191 -143
- package/dist/parsers/property-token.d.mts +34 -0
- package/dist/parsers/property-token.mjs +29 -0
- package/dist/parsers/string.d.mts +19 -0
- package/dist/parsers/string.mjs +45 -25
- package/dist/parsers/website/bounds.d.mts +10 -0
- package/dist/parsers/website/bounds.mjs +28 -0
- package/dist/parsers/website/components.d.mts +91 -0
- package/dist/parsers/website/components.mjs +681 -0
- package/dist/parsers/website/index.d.mts +0 -7
- package/dist/parsers/website/index.mjs +92 -1153
- package/dist/parsers/website/links.d.mts +36 -0
- package/dist/parsers/website/links.mjs +58 -0
- package/dist/parsers/website/messages.d.mts +24 -0
- package/dist/parsers/website/messages.mjs +31 -0
- package/dist/parsers/website/options.d.mts +6 -0
- package/dist/parsers/website/options.mjs +114 -0
- package/dist/parsers/website/properties.d.mts +12 -0
- package/dist/parsers/website/properties.mjs +158 -0
- package/dist/parsers/website/reader.d.mts +54 -4
- package/dist/parsers/website/reader.mjs +65 -20
- package/dist/parsers/website/slug.d.mts +64 -0
- package/dist/parsers/website/slug.mjs +82 -0
- package/dist/parsers/website/styles.d.mts +28 -0
- package/dist/parsers/website/styles.mjs +103 -0
- package/dist/parsers/website/walk.d.mts +68 -0
- package/dist/parsers/website/walk.mjs +116 -0
- package/dist/query.d.mts +66 -21
- package/dist/query.mjs +178 -44
- package/dist/reflection.d.mts +64 -0
- package/dist/reflection.mjs +79 -0
- package/dist/schemas.d.mts +7 -0
- package/dist/schemas.mjs +12 -3
- package/dist/types/index.d.mts +31 -31
- package/dist/types/utilities.d.mts +9 -0
- package/dist/types/utilities.mjs +1 -0
- package/dist/types/website.d.mts +54 -58
- package/dist/xml/metadata.d.mts +16 -0
- package/dist/xml/metadata.mjs +32 -11
- package/dist/xml/schemas.d.mts +5970 -3
- package/dist/xml/schemas.mjs +43 -45
- package/dist/xml/types.d.mts +14 -30
- package/dist/xquery.d.mts +46 -0
- package/dist/xquery.mjs +66 -0
- package/package.json +3 -3
- package/dist/utilities.d.mts +0 -54
package/dist/getters.mjs
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { deepEqual } from "fast-equals";
|
|
2
2
|
//#region src/getters.ts
|
|
3
|
+
/**
|
|
4
|
+
* The variable label that asks a filter to match against every property
|
|
5
|
+
*/
|
|
6
|
+
const ALL_FIELDS_VARIABLE_LABEL = "all-fields";
|
|
3
7
|
const DEFAULT_OPTIONS = {
|
|
4
8
|
includeNestedProperties: false,
|
|
5
9
|
limitToLeafPropertyValues: true
|
|
6
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Normalize an OCHRE property variable label for comparison
|
|
13
|
+
*
|
|
14
|
+
* OCHRE varies the casing and the word separator of a property label, so every
|
|
15
|
+
* comparison against a label goes through here. This is the only rule in the
|
|
16
|
+
* SDK for deciding whether a label names a given property.
|
|
17
|
+
* @param value - The label to normalize
|
|
18
|
+
* @returns The normalized label
|
|
19
|
+
*/
|
|
20
|
+
function normalizePropertyVariableLabel(value) {
|
|
21
|
+
return value.trim().toLocaleLowerCase("en-US").replaceAll(/[\s_]+/g, "-");
|
|
22
|
+
}
|
|
7
23
|
function withDefaultOptions(options) {
|
|
8
24
|
return {
|
|
9
25
|
includeNestedProperties: options.includeNestedProperties ?? false,
|
|
10
26
|
limitToLeafPropertyValues: options.limitToLeafPropertyValues ?? true
|
|
11
27
|
};
|
|
12
28
|
}
|
|
13
|
-
function findPropertyByVariableUuid(properties, variableUuid) {
|
|
14
|
-
for (const property of properties) if (property.variable.uuid === variableUuid) return property;
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
function findPropertyByVariableLabel(properties, variableLabel) {
|
|
18
|
-
for (const property of properties) if (getPropertyVariableLabel(property) === variableLabel) return property;
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
29
|
function getPropertyVariableLabel(property) {
|
|
22
30
|
return typeof property.variable.label === "string" ? property.variable.label : property.variable.label.getText();
|
|
23
31
|
}
|
|
@@ -34,270 +42,191 @@ function hasEqualPropertyValueContents(property, valueContents) {
|
|
|
34
42
|
for (const [index, value] of property.values.entries()) if (!deepEqual(value.content, valueContents[index])) return false;
|
|
35
43
|
return true;
|
|
36
44
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (transformedResult !== null) return transformedResult;
|
|
45
|
+
/**
|
|
46
|
+
* Compile a selector into a predicate over one property
|
|
47
|
+
*
|
|
48
|
+
* The label is normalized once here rather than once per candidate property.
|
|
49
|
+
*/
|
|
50
|
+
function createPropertyPredicate(selector) {
|
|
51
|
+
if ("uuid" in selector) {
|
|
52
|
+
const { uuid } = selector;
|
|
53
|
+
return (property) => property.variable.uuid === uuid;
|
|
47
54
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return [...values];
|
|
54
|
-
}
|
|
55
|
-
function clonePropertyValues(values) {
|
|
56
|
-
return Array.from(values, (value) => ({ ...value }));
|
|
57
|
-
}
|
|
58
|
-
function getNormalizedProperty(property, shouldLimitToLeafPropertyValues, transformValues) {
|
|
59
|
-
if (!shouldLimitToLeafPropertyValues) return property;
|
|
60
|
-
const values = getLeafPropertyValues(property.values);
|
|
61
|
-
return {
|
|
62
|
-
...property,
|
|
63
|
-
values: transformValues != null ? transformValues(values) : values
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function getFirstPropertyValueResult(values, shouldLimitToLeafPropertyValues) {
|
|
67
|
-
if (shouldLimitToLeafPropertyValues) return getLeafPropertyValues(values)[0] ?? null;
|
|
68
|
-
return values[0] ?? null;
|
|
69
|
-
}
|
|
70
|
-
function getFirstPropertyValueContentResult(values, shouldLimitToLeafPropertyValues) {
|
|
71
|
-
if (shouldLimitToLeafPropertyValues) return getLeafPropertyValues(values)[0]?.content ?? null;
|
|
72
|
-
return values[0]?.content ?? null;
|
|
73
|
-
}
|
|
74
|
-
function visitProperties(properties, shouldIncludeNestedProperties, visit) {
|
|
75
|
-
for (const property of properties) {
|
|
76
|
-
visit(property);
|
|
77
|
-
if (shouldIncludeNestedProperties && "properties" in property) visitProperties(property.properties, shouldIncludeNestedProperties, visit);
|
|
55
|
+
const normalizedLabel = normalizePropertyVariableLabel(selector.label);
|
|
56
|
+
const hasMatchingLabel = (property) => normalizePropertyVariableLabel(getPropertyVariableLabel(property)) === normalizedLabel;
|
|
57
|
+
if ("values" in selector) {
|
|
58
|
+
const { values } = selector;
|
|
59
|
+
return (property) => hasMatchingLabel(property) && deepEqual(property.values, values);
|
|
78
60
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
61
|
+
if ("valueContents" in selector) {
|
|
62
|
+
const { valueContents } = selector;
|
|
63
|
+
return (property) => hasMatchingLabel(property) && hasEqualPropertyValueContents(property, valueContents);
|
|
64
|
+
}
|
|
65
|
+
if ("value" in selector) {
|
|
66
|
+
const { value } = selector;
|
|
67
|
+
return (property) => hasMatchingLabel(property) && hasPropertyValue(property, value);
|
|
68
|
+
}
|
|
69
|
+
if ("valueContent" in selector) {
|
|
70
|
+
const { valueContent } = selector;
|
|
71
|
+
return (property) => hasMatchingLabel(property) && hasPropertyValueContent(property, valueContent);
|
|
72
|
+
}
|
|
73
|
+
return hasMatchingLabel;
|
|
83
74
|
}
|
|
84
75
|
/**
|
|
85
|
-
*
|
|
76
|
+
* Find the first property matching a predicate, descending when asked to
|
|
86
77
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @param options - Search options, including whether to include nested properties
|
|
90
|
-
* @returns Array of property values, or null if property not found
|
|
78
|
+
* Every property at one level is tested before descending, so a match on the
|
|
79
|
+
* item's own properties always wins over one on a nested property.
|
|
91
80
|
*/
|
|
92
|
-
function
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
function findProperty(properties, isMatch, shouldIncludeNestedProperties) {
|
|
82
|
+
for (const property of properties) if (isMatch(property)) return property;
|
|
83
|
+
if (!shouldIncludeNestedProperties) return null;
|
|
84
|
+
for (const property of properties) {
|
|
85
|
+
if (!("properties" in property)) continue;
|
|
86
|
+
const nestedProperty = findProperty(property.properties, isMatch, true);
|
|
87
|
+
if (nestedProperty !== null) return nestedProperty;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
99
90
|
}
|
|
100
91
|
/**
|
|
101
|
-
*
|
|
92
|
+
* Keep only the leaf values from an array of property values
|
|
102
93
|
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
94
|
+
* OCHRE property values form a hierarchy, and a value with children is usually
|
|
95
|
+
* a grouping rather than something to show. This asks that of a values array
|
|
96
|
+
* the caller already holds; the same filter is available on the lookups
|
|
97
|
+
* through `limitToLeafPropertyValues`.
|
|
98
|
+
* @param propertyValues - The values to filter
|
|
99
|
+
* @returns The values that have no children
|
|
107
100
|
*/
|
|
108
|
-
function
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (property == null) return null;
|
|
113
|
-
return Array.from(getPropertyValuesResult(property.values, limitToLeafPropertyValues, false), (value) => value.content);
|
|
114
|
-
});
|
|
101
|
+
function getLeafPropertyValues(propertyValues) {
|
|
102
|
+
const leafPropertyValues = [];
|
|
103
|
+
for (const value of propertyValues) if (value.hierarchy.isLeaf) leafPropertyValues.push(value);
|
|
104
|
+
return leafPropertyValues;
|
|
115
105
|
}
|
|
116
106
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param properties - Array of properties to search through
|
|
120
|
-
* @param variableUuid - The property variable UUID to search for
|
|
121
|
-
* @param options - Search options, including whether to include nested properties
|
|
122
|
-
* @returns The first property value, or null if property not found
|
|
107
|
+
* Project a property's values, copying so callers cannot mutate the source
|
|
123
108
|
*/
|
|
124
|
-
function
|
|
125
|
-
const
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
}, (nestedResult) => getFirstPropertyValueResult([nestedResult], limitToLeafPropertyValues));
|
|
109
|
+
function projectPropertyValues(values, shouldLimitToLeafPropertyValues) {
|
|
110
|
+
const projectedValues = shouldLimitToLeafPropertyValues ? getLeafPropertyValues(values) : values;
|
|
111
|
+
return Array.from(projectedValues, (value) => ({ ...value }));
|
|
112
|
+
}
|
|
113
|
+
function visitProperties(properties, shouldIncludeNestedProperties, visit) {
|
|
114
|
+
for (const property of properties) {
|
|
115
|
+
visit(property);
|
|
116
|
+
if (shouldIncludeNestedProperties && "properties" in property) visitProperties(property.properties, shouldIncludeNestedProperties, visit);
|
|
117
|
+
}
|
|
134
118
|
}
|
|
135
119
|
/**
|
|
136
|
-
*
|
|
120
|
+
* Find the property a selector names
|
|
137
121
|
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* @
|
|
141
|
-
* @
|
|
122
|
+
* The property is returned exactly as it was found, so its `values` are
|
|
123
|
+
* whatever the item carries and `limitToLeafPropertyValues` does not apply.
|
|
124
|
+
* Use {@link getPropertyValues} when leaf filtering matters.
|
|
125
|
+
* @param properties - The properties to search
|
|
126
|
+
* @param selector - Which property to look for
|
|
127
|
+
* @param options - Search options
|
|
128
|
+
* @param options.includeNestedProperties - Whether to descend into nested properties
|
|
129
|
+
* @returns The matching property, or null when there is none
|
|
142
130
|
*/
|
|
143
|
-
function
|
|
144
|
-
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
145
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
146
|
-
const values = getPropertyValuesByVariableUuid(currentProperties, variableUuid, {
|
|
147
|
-
includeNestedProperties: false,
|
|
148
|
-
limitToLeafPropertyValues
|
|
149
|
-
});
|
|
150
|
-
if (values === null || values.length === 0) return null;
|
|
151
|
-
return getFirstPropertyValueContentResult(values, limitToLeafPropertyValues);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function getPropertyByVariableLabel(properties, variableLabel, options = DEFAULT_OPTIONS) {
|
|
131
|
+
function getProperty(properties, selector, options = DEFAULT_OPTIONS) {
|
|
155
132
|
const { includeNestedProperties } = withDefaultOptions(options);
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
function getPropertyByVariableLabelAndValues(properties, variableLabel, values, options = DEFAULT_OPTIONS) {
|
|
159
|
-
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
160
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
161
|
-
for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && deepEqual(property.values, values)) return getNormalizedProperty(property, limitToLeafPropertyValues);
|
|
162
|
-
return null;
|
|
163
|
-
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
164
|
-
}
|
|
165
|
-
function getPropertyByVariableLabelAndValueContents(properties, variableLabel, valueContents, options = DEFAULT_OPTIONS) {
|
|
166
|
-
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
167
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
168
|
-
for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && hasEqualPropertyValueContents(property, valueContents)) return getNormalizedProperty(property, limitToLeafPropertyValues, clonePropertyValues);
|
|
169
|
-
return null;
|
|
170
|
-
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
171
|
-
}
|
|
172
|
-
function getPropertyByVariableLabelAndValue(properties, variableLabel, value, options = DEFAULT_OPTIONS) {
|
|
173
|
-
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
174
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
175
|
-
for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && hasPropertyValue(property, value)) return getNormalizedProperty(property, limitToLeafPropertyValues);
|
|
176
|
-
return null;
|
|
177
|
-
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
178
|
-
}
|
|
179
|
-
function getPropertyByVariableLabelAndValueContent(properties, variableLabel, valueContent, options = DEFAULT_OPTIONS) {
|
|
180
|
-
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
181
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
182
|
-
for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && hasPropertyValueContent(property, valueContent)) return getNormalizedProperty(property, limitToLeafPropertyValues);
|
|
183
|
-
return null;
|
|
184
|
-
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
133
|
+
return findProperty(properties, createPropertyPredicate(selector), includeNestedProperties);
|
|
185
134
|
}
|
|
186
135
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* @param
|
|
190
|
-
* @param
|
|
191
|
-
* @param options -
|
|
192
|
-
* @
|
|
136
|
+
* Read every value of the property a selector names
|
|
137
|
+
* @param properties - The properties to search
|
|
138
|
+
* @param selector - Which property to look for
|
|
139
|
+
* @param options - Search options
|
|
140
|
+
* @param options.includeNestedProperties - Whether to descend into nested properties
|
|
141
|
+
* @param options.limitToLeafPropertyValues - Whether to keep only leaf values
|
|
142
|
+
* @returns The values, or null when no property matched
|
|
193
143
|
*/
|
|
194
|
-
function
|
|
144
|
+
function getPropertyValues(properties, selector, options = DEFAULT_OPTIONS) {
|
|
195
145
|
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (property == null) return null;
|
|
199
|
-
return getPropertyValuesResult(property.values, limitToLeafPropertyValues, false);
|
|
200
|
-
}, (nestedResult) => getPropertyValuesResult(nestedResult, limitToLeafPropertyValues, false));
|
|
146
|
+
const property = findProperty(properties, createPropertyPredicate(selector), includeNestedProperties);
|
|
147
|
+
return property == null ? null : projectPropertyValues(property.values, limitToLeafPropertyValues);
|
|
201
148
|
}
|
|
202
149
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* @param
|
|
206
|
-
* @param
|
|
207
|
-
* @param options -
|
|
208
|
-
* @
|
|
150
|
+
* Read the first value of the property a selector names
|
|
151
|
+
* @param properties - The properties to search
|
|
152
|
+
* @param selector - Which property to look for
|
|
153
|
+
* @param options - Search options
|
|
154
|
+
* @param options.includeNestedProperties - Whether to descend into nested properties
|
|
155
|
+
* @param options.limitToLeafPropertyValues - Whether to keep only leaf values
|
|
156
|
+
* @returns The first value, or null when no property matched or it has none
|
|
209
157
|
*/
|
|
210
|
-
function
|
|
211
|
-
|
|
212
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
213
|
-
const values = getPropertyValuesByVariableLabel(currentProperties, variableLabel, {
|
|
214
|
-
includeNestedProperties: false,
|
|
215
|
-
limitToLeafPropertyValues
|
|
216
|
-
});
|
|
217
|
-
if (values === null || values.length === 0) return null;
|
|
218
|
-
return getFirstPropertyValueResult(values, limitToLeafPropertyValues);
|
|
219
|
-
}, (nestedResult) => getFirstPropertyValueResult([nestedResult], limitToLeafPropertyValues));
|
|
158
|
+
function getPropertyValue(properties, selector, options = DEFAULT_OPTIONS) {
|
|
159
|
+
return getPropertyValues(properties, selector, options)?.[0] ?? null;
|
|
220
160
|
}
|
|
221
161
|
/**
|
|
222
|
-
* Gets
|
|
162
|
+
* Gets all unique properties from an array of properties.
|
|
223
163
|
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* @param
|
|
227
|
-
* @
|
|
164
|
+
* Properties are returned exactly as they were found, deduplicated by variable
|
|
165
|
+
* UUID, keeping the first occurrence.
|
|
166
|
+
* @param properties - Array of properties to get unique properties from
|
|
167
|
+
* @param options - Search options
|
|
168
|
+
* @param options.includeNestedProperties - Whether to descend into nested properties
|
|
169
|
+
* @returns Array of unique properties
|
|
228
170
|
*/
|
|
229
|
-
function getPropertyValueContentByVariableLabel(properties, variableLabel, options = DEFAULT_OPTIONS) {
|
|
230
|
-
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
231
|
-
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
232
|
-
const values = getPropertyValuesByVariableLabel(currentProperties, variableLabel, {
|
|
233
|
-
includeNestedProperties: false,
|
|
234
|
-
limitToLeafPropertyValues
|
|
235
|
-
});
|
|
236
|
-
if (values === null || values.length === 0) return null;
|
|
237
|
-
return getFirstPropertyValueContentResult(values, limitToLeafPropertyValues);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
171
|
function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
|
|
241
|
-
const { includeNestedProperties
|
|
172
|
+
const { includeNestedProperties } = withDefaultOptions(options);
|
|
242
173
|
const uniqueProperties = [];
|
|
174
|
+
const seenVariableUuids = /* @__PURE__ */ new Set();
|
|
243
175
|
visitProperties(properties, includeNestedProperties, (property) => {
|
|
244
|
-
|
|
176
|
+
if (seenVariableUuids.has(property.variable.uuid)) return;
|
|
177
|
+
seenVariableUuids.add(property.variable.uuid);
|
|
245
178
|
uniqueProperties.push(property);
|
|
246
179
|
});
|
|
247
|
-
if (limitToLeafPropertyValues) return Array.from(uniqueProperties, (property) => getNormalizedProperty(property, limitToLeafPropertyValues));
|
|
248
180
|
return uniqueProperties;
|
|
249
181
|
}
|
|
250
182
|
/**
|
|
251
183
|
* Gets all unique property variable labels from an array of properties.
|
|
252
|
-
*
|
|
253
184
|
* @param properties - Array of properties to get unique property variable labels from
|
|
254
|
-
* @param options - Search options
|
|
185
|
+
* @param options - Search options
|
|
186
|
+
* @param options.includeNestedProperties - Whether to descend into nested properties
|
|
255
187
|
* @returns Array of unique property variable labels
|
|
256
188
|
*/
|
|
257
189
|
function getUniquePropertyVariableLabels(properties, options = DEFAULT_OPTIONS) {
|
|
258
190
|
const { includeNestedProperties } = withDefaultOptions(options);
|
|
259
191
|
const uniquePropertyVariableLabels = [];
|
|
192
|
+
const seenLabels = /* @__PURE__ */ new Set();
|
|
260
193
|
visitProperties(properties, includeNestedProperties, (property) => {
|
|
261
194
|
const variableLabel = getPropertyVariableLabel(property);
|
|
262
|
-
if (
|
|
195
|
+
if (seenLabels.has(variableLabel)) return;
|
|
196
|
+
seenLabels.add(variableLabel);
|
|
263
197
|
uniquePropertyVariableLabels.push(variableLabel);
|
|
264
198
|
});
|
|
265
199
|
return uniquePropertyVariableLabels;
|
|
266
200
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Get the leaf property values from an array of property values.
|
|
269
|
-
*
|
|
270
|
-
* @param propertyValues - The array of property values to get the leaf property values from
|
|
271
|
-
* @returns The array of leaf property values
|
|
272
|
-
*/
|
|
273
|
-
function getLeafPropertyValues(propertyValues) {
|
|
274
|
-
const leafPropertyValues = [];
|
|
275
|
-
for (const value of propertyValues) if (value.hierarchy.isLeaf) leafPropertyValues.push(value);
|
|
276
|
-
return leafPropertyValues;
|
|
277
|
-
}
|
|
278
201
|
function isContentMatchingFilter(content, filterContent) {
|
|
279
202
|
if (typeof content === "string") return typeof filterContent === "string" && content.toLocaleLowerCase("en-US").includes(filterContent.toLocaleLowerCase("en-US"));
|
|
280
203
|
if (typeof content === "number") return typeof filterContent === "number" && content === filterContent;
|
|
281
204
|
return typeof filterContent === "boolean" && content === filterContent;
|
|
282
205
|
}
|
|
283
206
|
/**
|
|
284
|
-
*
|
|
207
|
+
* Whether a property matches a variable label and value content criterion.
|
|
285
208
|
*
|
|
286
|
-
*
|
|
209
|
+
* Matching is client-side and deliberately loose: string contents match on a
|
|
210
|
+
* case-insensitive substring, numbers and booleans on equality. A
|
|
211
|
+
* `variableLabel` of "all fields" matches against every property.
|
|
212
|
+
* @param property - The property to test
|
|
287
213
|
* @param filter - Filter criteria containing variable label and value to match
|
|
288
214
|
* @param filter.variableLabel - The variable label to filter by
|
|
289
215
|
* @param filter.value - The value to filter by
|
|
290
|
-
* @param options - Search options
|
|
216
|
+
* @param options - Search options
|
|
217
|
+
* @param options.includeNestedProperties - Whether to descend into nested properties
|
|
218
|
+
* @param options.limitToLeafPropertyValues - Whether to test only leaf values
|
|
291
219
|
* @returns True if the property matches the filter criteria, false otherwise
|
|
292
220
|
*/
|
|
293
|
-
function
|
|
221
|
+
function isPropertyMatchingFilter(property, filter, options = DEFAULT_OPTIONS) {
|
|
294
222
|
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
295
|
-
|
|
296
|
-
|
|
223
|
+
const normalizedFilterLabel = normalizePropertyVariableLabel(filter.variableLabel);
|
|
224
|
+
if (normalizedFilterLabel === ALL_FIELDS_VARIABLE_LABEL || normalizePropertyVariableLabel(getPropertyVariableLabel(property)) === normalizedFilterLabel) {
|
|
225
|
+
const values = limitToLeafPropertyValues ? getLeafPropertyValues(property.values) : property.values;
|
|
297
226
|
for (const value of values) if (isContentMatchingFilter(value.content, filter.value.content)) return true;
|
|
298
227
|
}
|
|
299
228
|
if (includeNestedProperties && "properties" in property) {
|
|
300
|
-
for (const nestedProperty of property.properties) if (
|
|
229
|
+
for (const nestedProperty of property.properties) if (isPropertyMatchingFilter(nestedProperty, filter, {
|
|
301
230
|
includeNestedProperties: true,
|
|
302
231
|
limitToLeafPropertyValues
|
|
303
232
|
})) return true;
|
|
@@ -305,4 +234,4 @@ function filterProperties(property, filter, options = DEFAULT_OPTIONS) {
|
|
|
305
234
|
return false;
|
|
306
235
|
}
|
|
307
236
|
//#endregion
|
|
308
|
-
export {
|
|
237
|
+
export { getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/helpers.d.mts
CHANGED
|
@@ -3,10 +3,6 @@ import { ContainedItemCategory, Item, ItemCategory, ItemPayloadKind, LanguageCod
|
|
|
3
3
|
type FlattenedItem<U, T extends LanguageCodes> = Omit<U, "properties"> & {
|
|
4
4
|
properties: Array<SetItemProperty<T>>;
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
7
|
-
* The default page size to use for fetching paginated items
|
|
8
|
-
*/
|
|
9
|
-
export declare const DEFAULT_PAGE_SIZE = 48;
|
|
10
6
|
/**
|
|
11
7
|
* Flatten the properties of an item
|
|
12
8
|
* @param item - The item whose properties to flatten
|
package/dist/helpers.mjs
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { flattenProperties } from "./utilities.mjs";
|
|
2
1
|
//#region src/helpers.ts
|
|
3
2
|
/**
|
|
4
|
-
* The default page size to use for fetching paginated items
|
|
5
|
-
*/
|
|
6
|
-
const DEFAULT_PAGE_SIZE = 48;
|
|
7
|
-
/**
|
|
8
3
|
* Flatten the properties of an item
|
|
9
4
|
* @param item - The item whose properties to flatten
|
|
10
5
|
* @returns The item with the properties flattened
|
|
@@ -29,5 +24,23 @@ function flattenItemProperties(item) {
|
|
|
29
24
|
properties: flattenProperties(allProperties)
|
|
30
25
|
};
|
|
31
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Flatten a properties array
|
|
29
|
+
* @param properties - The properties to flatten
|
|
30
|
+
* @returns The flattened properties
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
function flattenProperties(properties) {
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const property of properties) {
|
|
36
|
+
result.push({
|
|
37
|
+
variable: property.variable,
|
|
38
|
+
values: property.values,
|
|
39
|
+
comment: property.comment
|
|
40
|
+
});
|
|
41
|
+
if ("properties" in property) result.push(...flattenProperties(property.properties));
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
32
45
|
//#endregion
|
|
33
|
-
export {
|
|
46
|
+
export { flattenItemProperties };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
|
|
2
|
-
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebOptions, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
|
|
3
|
-
import { AnyBibliography, AnyConcept, AnyItem, AnyPeriod, AnyPerson, AnyPropertyValue, AnyPropertyVariable, AnyResource, AnySet, AnySpatialUnit, AnyText, AnyTree, BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, ContainedItemCategory, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Context, ContextItem, ContextItemCategory, ContextNode, Coordinates, CoordinatesSource, DictionaryUnitItemLink, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, Metadata, Note, Observation, OcrString, Period, PeriodItemLink, Person, PersonItemLink,
|
|
2
|
+
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, ResponsiveStyles, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebIiifViewer, WebImage, WebLoadingVariant, WebOptions, WebSectionDisplay, WebSectionVariant, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePrivacy, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
|
|
3
|
+
import { AnyBibliography, AnyConcept, AnyItem, AnyPeriod, AnyPerson, AnyPropertyValue, AnyPropertyVariable, AnyResource, AnySet, AnySpatialUnit, AnyText, AnyTree, BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, ContainedItemCategory, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Context, ContextItem, ContextItemCategory, ContextNode, Coordinates, CoordinatesSource, DictionaryUnitItemLink, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, Metadata, Note, Observation, OcrString, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, PropertyRelation, PropertyValue, PropertyValueContent, PropertyValueDataType, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, QueryablePropertyValueDataType, RecursiveItemCategory, Resource, ResourceItemLink, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
4
|
+
import { DEFAULT_PAGE_SIZE } from "./constants.mjs";
|
|
4
5
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
5
6
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
6
7
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
7
8
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
8
|
-
import {
|
|
9
|
+
import { fetchItem } from "./fetchers/item.mjs";
|
|
9
10
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
10
11
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
11
12
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
12
13
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
13
|
-
import { PropertyOptions,
|
|
14
|
-
import {
|
|
15
|
-
|
|
14
|
+
import { PropertyOptions, PropertySelector, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
15
|
+
import { flattenItemProperties } from "./helpers.mjs";
|
|
16
|
+
import { defineLanguages } from "./parsers/languages.mjs";
|
|
17
|
+
export { type AccordionWebBlock, type AnyBibliography, type AnyConcept, type AnyItem, type AnyPeriod, type AnyPerson, type AnyPropertyValue, type AnyPropertyVariable, type AnyResource, type AnySet, type AnySpatialUnit, type AnyText, type AnyTree, type BaseItem, type BaseItemLink, type BelongsTo, type Bibliography, type BibliographyEntryInfo, type BibliographyItemLink, type BibliographySourceDocument, type Concept, type ConceptItemLink, type ContainedItemCategory, type ContainedItemCategoryFromOption, type ContainedItemCategoryOption, type Context, type ContextItem, type ContextItemCategory, type ContextNode, type ContextTree, type ContextTreeFilterLevel, type ContextTreeFilterVariant, type ContextTreeLevel, type ContextTreeLevelItem, type Coordinates, type CoordinatesSource, DEFAULT_PAGE_SIZE, type DictionaryUnitItemLink, type EmbeddedBibliography, type EmbeddedConcept, type EmbeddedItem, type EmbeddedPeriod, type EmbeddedPerson, type EmbeddedPropertyValue, type EmbeddedPropertyVariable, type EmbeddedResource, type EmbeddedSet, type EmbeddedSpatialUnit, type EmbeddedText, type EmbeddedTree, type Event, type Gallery, type Heading, type HeadingItemCategory, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type Item, type ItemCategory, type ItemCategoryFromOption, type ItemCategoryOption, type ItemCategoryWithEmbeddedItems, type ItemContainerCategory, type ItemLink, type ItemLinkCategory, type ItemLinks, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, type Observation, type OcrString, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Property, type PropertyLike, type PropertyOptions, type PropertyRelation, type PropertySelector, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type ProtectedWebsite, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, type ResponsiveStyles, type Scope, type Section, type Set, type SetAttributeValueQueryItem, type SetBibliography, type SetConcept, type SetItem, type SetItemCategory, type SetItemLink, type SetItemProperty, type SetItemSimplifiedProperty, type SetItemsSort, type SetItemsSortDirection, type SetPeriod, type SetResource, type SetSpatialUnit, type SetTree, type SimplifiedProperty, type SpatialUnit, type SpatialUnitItemLink, type Style, type StylesheetCategory, type StylesheetItem, type Text, type TextItemLink, type TopLevelItem, type Tree, type TreeItemCategory, type TreeItemLink, type WebAccordionItem, type WebBlock, type WebBlockByLayout, type WebBlockItem, type WebBlockLayout, type WebElement, type WebElementComponent, type WebElementComponentName, type WebElementComponentOf, type WebElementOf, type WebIiifViewer, type WebImage, type WebLoadingVariant, type WebOptions, type WebSectionDisplay, type WebSectionVariant, type WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePrivacy, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DEFAULT_PAGE_SIZE } from "./constants.mjs";
|
|
2
|
+
import { getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
3
|
+
import { flattenItemProperties } from "./helpers.mjs";
|
|
3
4
|
import { MultilingualString } from "./parsers/multilingual.mjs";
|
|
5
|
+
import { defineLanguages } from "./parsers/languages.mjs";
|
|
4
6
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
5
7
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
6
8
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
7
9
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
8
|
-
import {
|
|
10
|
+
import { fetchItem } from "./fetchers/item.mjs";
|
|
9
11
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
10
12
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
11
13
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
12
14
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
13
|
-
export { DEFAULT_PAGE_SIZE, MultilingualString, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata,
|
|
15
|
+
export { DEFAULT_PAGE_SIZE, MultilingualString, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/ocr.d.mts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/ocr.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The name of the element wrapping an OCR layer inside an OCHRE document
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const OCR_LAYER_ELEMENT_NAME = "ocr";
|
|
7
|
+
/**
|
|
8
|
+
* The attribute an OCR word element holds its word in
|
|
9
|
+
*
|
|
10
|
+
* The word is in the attribute rather than in the element's text content.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const OCR_WORD_CONTENT_ATTRIBUTE = "CONTENT";
|
|
14
|
+
/**
|
|
15
|
+
* An XQuery sequence of every QName an OCR word element can carry
|
|
16
|
+
*
|
|
17
|
+
* Use with the `cts:element-*` query constructors, which need concrete QNames
|
|
18
|
+
* and cannot match on a case-folded local name the way {@link buildOcrWordPath}
|
|
19
|
+
* does. This has to stay in agreement with that path: a word element the
|
|
20
|
+
* narrowing misses is a document the search silently drops.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare const OCR_WORD_QNAMES: string;
|
|
24
|
+
/**
|
|
25
|
+
* Build an XQuery path selecting every OCR word element beneath a node
|
|
26
|
+
*
|
|
27
|
+
* Matches the layer and the word elements on a case-folded `local-name()`
|
|
28
|
+
* rather than a name test, because a name test silently matches nothing when
|
|
29
|
+
* OCHRE varies the casing or serves the elements in a namespace. Word elements
|
|
30
|
+
* are selected at any depth, because the hierarchy between the layer and its
|
|
31
|
+
* words is irregular and is not parsed.
|
|
32
|
+
* @param rootExpression - The XQuery expression to select from
|
|
33
|
+
* @returns The XQuery path
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildOcrWordPath(rootExpression: string): string;
|
|
37
|
+
//#endregion
|