ochre-sdk 1.3.24 → 1.3.26
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/dist/categories.d.mts +56 -56
- package/dist/categories.mjs +39 -39
- package/dist/constants.d.mts +8 -8
- package/dist/constants.mjs +6 -6
- package/dist/errors.d.mts +12 -12
- package/dist/errors.mjs +22 -23
- package/dist/fetchers/container-items.d.mts +28 -28
- package/dist/fetchers/container-items.mjs +27 -27
- package/dist/fetchers/gallery.d.mts +13 -13
- package/dist/fetchers/gallery.mjs +2 -2
- package/dist/fetchers/item-children.d.mts +12 -12
- package/dist/fetchers/item-children.mjs +2 -2
- package/dist/fetchers/item-links.d.mts +10 -10
- package/dist/fetchers/item-links.mjs +6 -6
- package/dist/fetchers/item-locations.d.mts +20 -20
- package/dist/fetchers/item-locations.mjs +3 -3
- package/dist/fetchers/item-ocr-data.d.mts +23 -23
- package/dist/fetchers/item-ocr-data.mjs +44 -44
- package/dist/fetchers/item.d.mts +14 -14
- package/dist/fetchers/item.mjs +14 -14
- package/dist/fetchers/map-layers.d.mts +15 -15
- package/dist/fetchers/map-layers.mjs +12 -11
- package/dist/fetchers/request.d.mts +40 -40
- package/dist/fetchers/request.mjs +37 -37
- package/dist/fetchers/set/items.d.mts +15 -15
- package/dist/fetchers/set/items.mjs +1 -1
- package/dist/fetchers/set/property-values.d.mts +16 -16
- package/dist/fetchers/set/property-values.mjs +43 -43
- package/dist/fetchers/tree/items.d.mts +27 -27
- package/dist/fetchers/tree/items.mjs +1 -1
- package/dist/fetchers/website-metadata.d.mts +4 -4
- package/dist/fetchers/website-metadata.mjs +9 -9
- package/dist/fetchers/website.d.mts +10 -10
- package/dist/fetchers/website.mjs +12 -12
- package/dist/getters.d.mts +83 -83
- package/dist/getters.mjs +74 -74
- package/dist/helpers.d.mts +4 -4
- package/dist/helpers.mjs +7 -7
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +5 -5
- package/dist/languages.d.mts +58 -58
- package/dist/languages.mjs +21 -21
- package/dist/ocr.d.mts +27 -27
- package/dist/ocr.mjs +29 -29
- package/dist/parsers/helpers.d.mts +23 -23
- package/dist/parsers/helpers.mjs +8 -8
- package/dist/parsers/index.d.mts +2 -2
- package/dist/parsers/index.mjs +15 -15
- package/dist/parsers/languages.d.mts +49 -49
- package/dist/parsers/languages.mjs +49 -49
- package/dist/parsers/multilingual.d.mts +174 -174
- package/dist/parsers/multilingual.mjs +146 -146
- package/dist/parsers/partial-date.d.mts +12 -12
- package/dist/parsers/partial-date.mjs +11 -11
- package/dist/parsers/property-token.d.mts +20 -20
- package/dist/parsers/property-token.mjs +16 -16
- package/dist/parsers/string.d.mts +33 -33
- package/dist/parsers/string.mjs +62 -64
- package/dist/parsers/website/bounds.d.mts +6 -6
- package/dist/parsers/website/bounds.mjs +5 -5
- package/dist/parsers/website/components.d.mts +50 -31
- package/dist/parsers/website/components.mjs +79 -51
- package/dist/parsers/website/index.d.mts +1 -1
- package/dist/parsers/website/index.mjs +43 -47
- package/dist/parsers/website/links.d.mts +24 -24
- package/dist/parsers/website/links.mjs +18 -18
- package/dist/parsers/website/messages.d.mts +16 -16
- package/dist/parsers/website/messages.mjs +14 -14
- package/dist/parsers/website/options.d.mts +1 -1
- package/dist/parsers/website/properties.d.mts +17 -8
- package/dist/parsers/website/properties.mjs +23 -11
- package/dist/parsers/website/reader.d.mts +55 -46
- package/dist/parsers/website/reader.mjs +64 -46
- package/dist/parsers/website/slug.d.mts +50 -50
- package/dist/parsers/website/slug.mjs +36 -36
- package/dist/parsers/website/styles.d.mts +18 -18
- package/dist/parsers/website/styles.mjs +19 -19
- package/dist/parsers/website/walk.d.mts +46 -46
- package/dist/parsers/website/walk.mjs +34 -34
- package/dist/query.d.mts +63 -63
- package/dist/query.mjs +137 -140
- package/dist/reflection.d.mts +51 -51
- package/dist/reflection.mjs +45 -45
- package/dist/schemas.d.mts +44 -44
- package/dist/schemas.mjs +50 -50
- package/dist/types/index.d.mts +192 -192
- package/dist/types/utilities.d.mts +5 -5
- package/dist/types/website.d.mts +67 -62
- package/dist/xml/dates.d.mts +9 -9
- package/dist/xml/dates.mjs +9 -9
- package/dist/xml/metadata.d.mts +14 -14
- package/dist/xml/metadata.mjs +18 -18
- package/dist/xml/schemas.mjs +24 -24
- package/dist/xml/types.d.mts +9 -9
- package/dist/xquery.d.mts +49 -49
- package/dist/xquery.mjs +50 -50
- package/package.json +10 -10
package/dist/getters.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LanguageCodes, PropertyLike, PropertyValueContent } from "./types/index.mjs";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Options for property search operations.
|
|
4
|
+
*/
|
|
5
5
|
export type PropertyOptions = {
|
|
6
6
|
/**
|
|
7
7
|
Whether to recursively search through nested properties.
|
|
@@ -17,14 +17,14 @@ export type PropertyOptions = {
|
|
|
17
17
|
type PropertyContent<T extends LanguageCodes> = PropertyValueContent<T>["content"];
|
|
18
18
|
type SearchableProperty<T extends LanguageCodes> = PropertyLike<T>;
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
Which property to look for
|
|
21
|
+
|
|
22
|
+
A property is named either by its variable UUID or by its variable label, and
|
|
23
|
+
a label can be narrowed further by the values the property carries. The value
|
|
24
|
+
forms differ in what they compare: `values` and `valueContents` require the
|
|
25
|
+
property to carry exactly that sequence, while `value` and `valueContent`
|
|
26
|
+
only require it to carry that one among others.
|
|
27
|
+
*/
|
|
28
28
|
export type PropertySelector<T extends LanguageCodes = LanguageCodes> = {
|
|
29
29
|
uuid: string;
|
|
30
30
|
} | {
|
|
@@ -43,93 +43,93 @@ export type PropertySelector<T extends LanguageCodes = LanguageCodes> = {
|
|
|
43
43
|
valueContent: PropertyContent<T>;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
Normalize an OCHRE property variable label for comparison
|
|
47
|
+
|
|
48
|
+
OCHRE varies the casing and the word separator of a property label, so every
|
|
49
|
+
comparison against a label goes through here. This is the only rule in the
|
|
50
|
+
SDK for deciding whether a label names a given property.
|
|
51
|
+
@param value - The label to normalize
|
|
52
|
+
@returns The normalized label
|
|
53
|
+
*/
|
|
54
54
|
export declare function normalizePropertyVariableLabel(value: string): string;
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
Keep only the leaf values from an array of property values
|
|
57
|
+
|
|
58
|
+
OCHRE property values form a hierarchy, and a value with children is usually
|
|
59
|
+
a grouping rather than something to show. This asks that of a values array
|
|
60
|
+
the caller already holds; the same filter is available on the lookups
|
|
61
|
+
through `limitToLeafPropertyValues`.
|
|
62
|
+
@param propertyValues - The values to filter
|
|
63
|
+
@returns The values that have no children
|
|
64
|
+
*/
|
|
65
65
|
export declare function getLeafPropertyValues<T extends LanguageCodes = LanguageCodes>(propertyValues: ReadonlyArray<PropertyValueContent<T>>): Array<PropertyValueContent<T>>;
|
|
66
66
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
Find the property a selector names
|
|
68
|
+
|
|
69
|
+
The property is returned exactly as it was found, so its `values` are
|
|
70
|
+
whatever the item carries and `limitToLeafPropertyValues` does not apply.
|
|
71
|
+
Use {@link getPropertyValues} when leaf filtering matters.
|
|
72
|
+
@param properties - The properties to search
|
|
73
|
+
@param selector - Which property to look for
|
|
74
|
+
@param options - Search options
|
|
75
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
76
|
+
@returns The matching property, or null when there is none
|
|
77
|
+
*/
|
|
78
78
|
export declare function getProperty<T extends LanguageCodes = LanguageCodes, TProperty extends PropertyLike<T> = PropertyLike<T>>(properties: ReadonlyArray<TProperty>, selector: PropertySelector<T>, options?: PropertyOptions): TProperty | null;
|
|
79
79
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
Read every value of the property a selector names
|
|
81
|
+
@param properties - The properties to search
|
|
82
|
+
@param selector - Which property to look for
|
|
83
|
+
@param options - Search options
|
|
84
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
85
|
+
@param options.limitToLeafPropertyValues - Whether to keep only leaf values
|
|
86
|
+
@returns The values, or null when no property matched
|
|
87
|
+
*/
|
|
88
88
|
export declare function getPropertyValues<T extends LanguageCodes = LanguageCodes>(properties: ReadonlyArray<SearchableProperty<T>>, selector: PropertySelector<T>, options?: PropertyOptions): Array<PropertyValueContent<T>> | null;
|
|
89
89
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
Read the first value of the property a selector names
|
|
91
|
+
@param properties - The properties to search
|
|
92
|
+
@param selector - Which property to look for
|
|
93
|
+
@param options - Search options
|
|
94
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
95
|
+
@param options.limitToLeafPropertyValues - Whether to keep only leaf values
|
|
96
|
+
@returns The first value, or null when no property matched or it has none
|
|
97
|
+
*/
|
|
98
98
|
export declare function getPropertyValue<T extends LanguageCodes = LanguageCodes>(properties: ReadonlyArray<SearchableProperty<T>>, selector: PropertySelector<T>, options?: PropertyOptions): PropertyValueContent<T> | null;
|
|
99
99
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
Gets all unique properties from an array of properties.
|
|
101
|
+
|
|
102
|
+
Properties are returned exactly as they were found, deduplicated by variable
|
|
103
|
+
UUID, keeping the first occurrence.
|
|
104
|
+
@param properties - Array of properties to get unique properties from
|
|
105
|
+
@param options - Search options
|
|
106
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
107
|
+
@returns Array of unique properties
|
|
108
|
+
*/
|
|
109
109
|
export declare function getUniqueProperties<T extends LanguageCodes = LanguageCodes, TProperty extends PropertyLike<T> = PropertyLike<T>>(properties: ReadonlyArray<TProperty>, options?: PropertyOptions): Array<TProperty>;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
Gets all unique property variable labels from an array of properties.
|
|
112
|
+
@param properties - Array of properties to get unique property variable labels from
|
|
113
|
+
@param options - Search options
|
|
114
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
115
|
+
@returns Array of unique property variable labels
|
|
116
|
+
*/
|
|
117
117
|
export declare function getUniquePropertyVariableLabels<T extends LanguageCodes = LanguageCodes>(properties: ReadonlyArray<SearchableProperty<T>>, options?: PropertyOptions): Array<string>;
|
|
118
118
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
Whether a property matches a variable label and value content criterion.
|
|
120
|
+
|
|
121
|
+
Matching is client-side and deliberately loose: string contents match on a
|
|
122
|
+
case-insensitive substring, numbers and booleans on equality. A
|
|
123
|
+
`variableLabel` of "all fields" matches against every property.
|
|
124
|
+
@param property - The property to test
|
|
125
|
+
@param filter - Filter criteria containing variable label and value to match
|
|
126
|
+
@param filter.variableLabel - The variable label to filter by
|
|
127
|
+
@param filter.value - The value to filter by
|
|
128
|
+
@param options - Search options
|
|
129
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
130
|
+
@param options.limitToLeafPropertyValues - Whether to test only leaf values
|
|
131
|
+
@returns True if the property matches the filter criteria, false otherwise
|
|
132
|
+
*/
|
|
133
133
|
export declare function isPropertyMatchingFilter<T extends LanguageCodes = LanguageCodes>(property: SearchableProperty<T>, filter: {
|
|
134
134
|
variableLabel: string;
|
|
135
135
|
value: PropertyValueContent<T>;
|
package/dist/getters.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepEqual } from "fast-equals";
|
|
2
2
|
// src/getters.ts
|
|
3
3
|
/**
|
|
4
|
-
|
|
4
|
+
The variable label that asks a filter to match against every property
|
|
5
5
|
*/
|
|
6
6
|
const ALL_FIELDS_VARIABLE_LABEL = "all-fields";
|
|
7
7
|
const DEFAULT_OPTIONS = {
|
|
@@ -9,13 +9,13 @@ const DEFAULT_OPTIONS = {
|
|
|
9
9
|
limitToLeafPropertyValues: true
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
19
|
*/
|
|
20
20
|
function normalizePropertyVariableLabel(value) {
|
|
21
21
|
return value.trim().toLocaleLowerCase("en-US").replaceAll(/[\s_]+/g, "-");
|
|
@@ -43,9 +43,9 @@ function hasEqualPropertyValueContents(property, valueContents) {
|
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
49
|
*/
|
|
50
50
|
function createPropertyPredicate(selector) {
|
|
51
51
|
if ("uuid" in selector) {
|
|
@@ -73,10 +73,10 @@ function createPropertyPredicate(selector) {
|
|
|
73
73
|
return hasMatchingLabel;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
Find the first property matching a predicate, descending when asked to
|
|
77
|
+
|
|
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.
|
|
80
80
|
*/
|
|
81
81
|
function findProperty(properties, isMatch, shouldIncludeNestedProperties) {
|
|
82
82
|
for (const property of properties) if (isMatch(property)) return property;
|
|
@@ -89,14 +89,14 @@ function findProperty(properties, isMatch, shouldIncludeNestedProperties) {
|
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
Keep only the leaf values from an array of property values
|
|
93
|
+
|
|
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
|
|
100
100
|
*/
|
|
101
101
|
function getLeafPropertyValues(propertyValues) {
|
|
102
102
|
const leafPropertyValues = [];
|
|
@@ -104,7 +104,7 @@ function getLeafPropertyValues(propertyValues) {
|
|
|
104
104
|
return leafPropertyValues;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
|
|
107
|
+
Project a property's values, copying so callers cannot mutate the source
|
|
108
108
|
*/
|
|
109
109
|
function projectPropertyValues(values, shouldLimitToLeafPropertyValues) {
|
|
110
110
|
const projectedValues = shouldLimitToLeafPropertyValues ? getLeafPropertyValues(values) : values;
|
|
@@ -117,29 +117,29 @@ function visitProperties(properties, shouldIncludeNestedProperties, visit) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
Find the property a selector names
|
|
121
|
+
|
|
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
|
|
130
130
|
*/
|
|
131
131
|
function getProperty(properties, selector, options = DEFAULT_OPTIONS) {
|
|
132
132
|
const { includeNestedProperties } = withDefaultOptions(options);
|
|
133
133
|
return findProperty(properties, createPropertyPredicate(selector), includeNestedProperties);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
|
143
143
|
*/
|
|
144
144
|
function getPropertyValues(properties, selector, options = DEFAULT_OPTIONS) {
|
|
145
145
|
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
|
@@ -147,26 +147,26 @@ function getPropertyValues(properties, selector, options = DEFAULT_OPTIONS) {
|
|
|
147
147
|
return property == null ? null : projectPropertyValues(property.values, limitToLeafPropertyValues);
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
157
157
|
*/
|
|
158
158
|
function getPropertyValue(properties, selector, options = DEFAULT_OPTIONS) {
|
|
159
159
|
return getPropertyValues(properties, selector, options)?.[0] ?? null;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
162
|
+
Gets all unique properties from an array of properties.
|
|
163
|
+
|
|
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
|
|
170
170
|
*/
|
|
171
171
|
function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
|
|
172
172
|
const { includeNestedProperties } = withDefaultOptions(options);
|
|
@@ -180,11 +180,11 @@ function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
|
|
|
180
180
|
return uniqueProperties;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
Gets all unique property variable labels from an array of properties.
|
|
184
|
+
@param properties - Array of properties to get unique property variable labels from
|
|
185
|
+
@param options - Search options
|
|
186
|
+
@param options.includeNestedProperties - Whether to descend into nested properties
|
|
187
|
+
@returns Array of unique property variable labels
|
|
188
188
|
*/
|
|
189
189
|
function getUniquePropertyVariableLabels(properties, options = DEFAULT_OPTIONS) {
|
|
190
190
|
const { includeNestedProperties } = withDefaultOptions(options);
|
|
@@ -204,19 +204,19 @@ function isContentMatchingFilter(content, filterContent) {
|
|
|
204
204
|
return typeof filterContent === "boolean" && content === filterContent;
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
207
|
+
Whether a property matches a variable label and value content criterion.
|
|
208
|
+
|
|
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
|
|
213
|
+
@param filter - Filter criteria containing variable label and value to match
|
|
214
|
+
@param filter.variableLabel - The variable label to filter by
|
|
215
|
+
@param filter.value - The value to filter by
|
|
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
|
|
219
|
+
@returns True if the property matches the filter criteria, false otherwise
|
|
220
220
|
*/
|
|
221
221
|
function isPropertyMatchingFilter(property, filter, options = DEFAULT_OPTIONS) {
|
|
222
222
|
const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
|
package/dist/helpers.d.mts
CHANGED
|
@@ -3,9 +3,9 @@ type FlattenedItem<U, T extends LanguageCodes> = Omit<U, "properties"> & {
|
|
|
3
3
|
properties: Array<SetItemProperty<T>>;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Flatten the properties of an item
|
|
7
|
+
@param item - The item whose properties to flatten
|
|
8
|
+
@returns The item with the properties flattened
|
|
9
|
+
*/
|
|
10
10
|
export declare function flattenItemProperties<U extends ItemCategory = ItemCategory, V extends ContainedItemCategory<U> = ContainedItemCategory<U>, T extends LanguageCodes = LanguageCodes, W extends ItemPayloadKind = "topLevel">(item: Item<U, V, T, W>): FlattenedItem<Item<U, V, T, W>, T>;
|
|
11
11
|
export {};
|
package/dist/helpers.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/helpers.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Flatten the properties of an item
|
|
4
|
+
@param item - The item whose properties to flatten
|
|
5
|
+
@returns The item with the properties flattened
|
|
6
6
|
*/
|
|
7
7
|
function flattenItemProperties(item) {
|
|
8
8
|
const allProperties = [];
|
|
@@ -25,10 +25,10 @@ function flattenItemProperties(item) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
Flatten a properties array
|
|
29
|
+
@param properties - The properties to flatten
|
|
30
|
+
@returns The flattened properties
|
|
31
|
+
@internal
|
|
32
32
|
*/
|
|
33
33
|
function flattenProperties(properties) {
|
|
34
34
|
const result = [];
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
|
|
2
|
-
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, ResponsiveStyles, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebCollectionVariant, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebIiifViewer, WebImage, WebLoadingVariant, WebOptions, WebRelationVariant, 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, DownloadOption, 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, ItemLocation, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, MapLayer, Metadata, Note, Observation, OcrString, PartialDate, PartialDateBound, PartialDateQualifier, PartialDateSeason, PartialDateValue, 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, SetStyle, SetStyleProperty, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
4
1
|
import { DEFAULT_PAGE_SIZE } from "./constants.mjs";
|
|
5
2
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
6
3
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
@@ -18,4 +15,7 @@ import { PropertyOptions, PropertySelector, getLeafPropertyValues, getProperty,
|
|
|
18
15
|
import { flattenItemProperties } from "./helpers.mjs";
|
|
19
16
|
import { OCHRE_LANGUAGES, OchreLanguage, OchreLanguageCode, OchreLanguageKind, OchreLanguageStandard, getOchreLanguage, getOchreLanguageCode, isOchreLanguageCode } from "./languages.mjs";
|
|
20
17
|
import { defineLanguages } from "./parsers/languages.mjs";
|
|
18
|
+
import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
|
|
19
|
+
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, DownloadOption, 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, ItemLocation, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, MapLayer, Metadata, Note, Observation, OcrString, PartialDate, PartialDateBound, PartialDateQualifier, PartialDateSeason, PartialDateValue, 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, SetStyle, SetStyleProperty, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
20
|
+
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, ResponsiveStyles, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebCollectionVariant, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebIiifViewer, WebImage, WebLoadingVariant, WebOptions, WebRelationVariant, WebSectionDisplay, WebSectionVariant, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePrivacy, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
|
|
21
21
|
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 DownloadOption, 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 ItemLocation, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type MapLayer, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, OCHRE_LANGUAGES, type Observation, type OchreLanguage, type OchreLanguageCode, type OchreLanguageKind, type OchreLanguageStandard, type OcrString, type PartialDate, type PartialDateBound, type PartialDateQualifier, type PartialDateSeason, type PartialDateValue, 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 SetStyle, type SetStyleProperty, 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 WebCollectionVariant, type WebElement, type WebElementComponent, type WebElementComponentName, type WebElementComponentOf, type WebElementOf, type WebIiifViewer, type WebImage, type WebLoadingVariant, type WebOptions, type WebRelationVariant, 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, fetchItemLocations, fetchItemOcrData, fetchMapLayers, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getOchreLanguage, getOchreLanguageCode, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isOchreLanguageCode, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
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";
|
|
4
|
-
import { MultilingualString } from "./parsers/multilingual.mjs";
|
|
5
|
-
import { OCHRE_LANGUAGES, getOchreLanguage, getOchreLanguageCode, isOchreLanguageCode } from "./languages.mjs";
|
|
6
|
-
import { defineLanguages } from "./parsers/languages.mjs";
|
|
7
2
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
8
3
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
9
4
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
@@ -16,4 +11,9 @@ import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
|
16
11
|
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
17
12
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
18
13
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
14
|
+
import { getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
15
|
+
import { flattenItemProperties } from "./helpers.mjs";
|
|
16
|
+
import { OCHRE_LANGUAGES, getOchreLanguage, getOchreLanguageCode, isOchreLanguageCode } from "./languages.mjs";
|
|
17
|
+
import { defineLanguages } from "./parsers/languages.mjs";
|
|
18
|
+
import { MultilingualString } from "./parsers/multilingual.mjs";
|
|
19
19
|
export { DEFAULT_PAGE_SIZE, MultilingualString, OCHRE_LANGUAGES, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemLocations, fetchItemOcrData, fetchMapLayers, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getOchreLanguage, getOchreLanguageCode, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isOchreLanguageCode, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|