ochre-sdk 1.3.25 → 1.3.27
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 +23 -18
- package/dist/fetchers/item.mjs +15 -15
- 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 +46 -31
- package/dist/parsers/website/components.mjs +84 -51
- package/dist/parsers/website/index.d.mts +2 -2
- package/dist/parsers/website/index.mjs +45 -48
- 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 +31 -10
- package/dist/parsers/website/reader.d.mts +55 -47
- package/dist/parsers/website/reader.mjs +66 -51
- 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 +74 -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/categories.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ContextItemCategory, HeadingItemCategory, ItemCategory, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLinkCategory, TreeItemCategory } from "./types/index.mjs";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Every category an item hierarchy entry can carry, including the
|
|
4
|
+
pseudo-category OCHRE uses to group entries
|
|
5
|
+
*/
|
|
6
6
|
export type HierarchyEntryCategory = ItemLinkCategory | "heading";
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
The one table describing the OCHRE item categories
|
|
9
|
+
@internal
|
|
10
|
+
*/
|
|
11
11
|
export declare const ITEM_CATEGORY_FACTS: {
|
|
12
12
|
readonly tree: {
|
|
13
13
|
readonly aliases: readonly ["tree"];
|
|
@@ -154,9 +154,9 @@ export declare const ITEM_CATEGORY_FACTS: {
|
|
|
154
154
|
};
|
|
155
155
|
};
|
|
156
156
|
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
Every element name OCHRE serves an item category under, canonical name first
|
|
158
|
+
@internal
|
|
159
|
+
*/
|
|
160
160
|
export declare const ITEM_CATEGORY_ALIASES: {
|
|
161
161
|
readonly tree: readonly ["tree"];
|
|
162
162
|
readonly bibliography: readonly ["bibliography"];
|
|
@@ -172,76 +172,76 @@ export declare const ITEM_CATEGORY_ALIASES: {
|
|
|
172
172
|
readonly dictionaryUnit: readonly ["dictionaryUnit"];
|
|
173
173
|
};
|
|
174
174
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
The canonical category each element name maps to
|
|
176
|
+
@internal
|
|
177
|
+
*/
|
|
178
178
|
export declare const ITEM_CATEGORY_BY_ALIAS: ReadonlyMap<string, HierarchyEntryCategory>;
|
|
179
179
|
/**
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
The OCHRE collections an item document can live in
|
|
181
|
+
|
|
182
|
+
Document URIs are bare item UUIDs, so a lookup by UUID does not need these.
|
|
183
|
+
A search does: `fn:collection("ochre/<category>")`.
|
|
184
|
+
@internal
|
|
185
|
+
*/
|
|
186
186
|
export declare const OCHRE_COLLECTION_CATEGORIES: Array<ItemCategory>;
|
|
187
187
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
The item categories that can sit directly inside a Tree
|
|
189
|
+
@internal
|
|
190
|
+
*/
|
|
191
191
|
export declare const TREE_ITEM_CATEGORIES: Array<TreeItemCategory>;
|
|
192
192
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
The item categories that can sit directly inside a Set
|
|
194
|
+
@internal
|
|
195
|
+
*/
|
|
196
196
|
export declare const SET_ITEM_CATEGORIES: Array<ItemCategory>;
|
|
197
197
|
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
The item categories that can sit under a heading
|
|
199
|
+
@internal
|
|
200
|
+
*/
|
|
201
201
|
export declare const HEADING_ITEM_CATEGORIES: Array<HeadingItemCategory>;
|
|
202
202
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
The item categories that hold other items under a `containedItemCategory`
|
|
204
|
+
@internal
|
|
205
|
+
*/
|
|
206
206
|
export declare const ITEM_CONTAINER_CATEGORIES: Array<ItemContainerCategory>;
|
|
207
207
|
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
The item categories that carry an embedded item hierarchy
|
|
209
|
+
@internal
|
|
210
|
+
*/
|
|
211
211
|
export declare const ITEM_CATEGORIES_WITH_EMBEDDED_ITEMS: Array<ItemCategoryWithEmbeddedItems>;
|
|
212
212
|
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
Each element name that can appear in a context path, and the category it means
|
|
214
|
+
@internal
|
|
215
|
+
*/
|
|
216
216
|
export declare const CONTEXT_CATEGORY_ALIASES: ReadonlyArray<{
|
|
217
217
|
alias: string;
|
|
218
218
|
category: ContextItemCategory;
|
|
219
219
|
}>;
|
|
220
220
|
/**
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
Whether an item of this category holds other items
|
|
222
|
+
@param category - The item category
|
|
223
|
+
@returns True when the category accepts a `containedItemCategory`
|
|
224
|
+
@internal
|
|
225
|
+
*/
|
|
226
226
|
export declare function isItemContainerCategory(category: ItemCategory): category is ItemContainerCategory;
|
|
227
227
|
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
Whether an item of this category carries an embedded item hierarchy
|
|
229
|
+
@param category - The item category
|
|
230
|
+
@returns True when the category exposes embedded items
|
|
231
|
+
@internal
|
|
232
|
+
*/
|
|
233
233
|
export declare function isItemCategoryWithEmbeddedItems(category: ItemCategory): category is ItemCategoryWithEmbeddedItems;
|
|
234
234
|
/**
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
Whether an item of this category can sit under a heading
|
|
236
|
+
@param category - The item category
|
|
237
|
+
@returns True when the category is allowed under a heading
|
|
238
|
+
@internal
|
|
239
|
+
*/
|
|
240
240
|
export declare function isHeadingItemCategory(category: TreeItemCategory): category is HeadingItemCategory;
|
|
241
241
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
Resolve an OCHRE element name to the category it means
|
|
243
|
+
@param category - The element name, which may be an alias
|
|
244
|
+
@returns The canonical category, or null when the name is not one
|
|
245
|
+
@internal
|
|
246
|
+
*/
|
|
247
247
|
export declare function normalizeItemCategory(category: string | undefined): ItemCategory | null;
|
package/dist/categories.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/categories.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
The one table describing the OCHRE item categories
|
|
4
|
+
@internal
|
|
5
5
|
*/
|
|
6
6
|
const ITEM_CATEGORY_FACTS = {
|
|
7
7
|
tree: {
|
|
@@ -149,8 +149,8 @@ const ITEM_CATEGORY_FACTS = {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
Every element name OCHRE serves an item category under, canonical name first
|
|
153
|
+
@internal
|
|
154
154
|
*/
|
|
155
155
|
const ITEM_CATEGORY_ALIASES = {
|
|
156
156
|
tree: ITEM_CATEGORY_FACTS.tree.aliases,
|
|
@@ -172,83 +172,83 @@ function categoriesWhere(isIncluded) {
|
|
|
172
172
|
return categories;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
The canonical category each element name maps to
|
|
176
|
+
@internal
|
|
177
177
|
*/
|
|
178
178
|
const ITEM_CATEGORY_BY_ALIAS = new Map(Object.entries(ITEM_CATEGORY_FACTS).flatMap(([category, facts]) => facts.aliases.map((alias) => [alias, category])));
|
|
179
179
|
/**
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
The OCHRE collections an item document can live in
|
|
181
|
+
|
|
182
|
+
Document URIs are bare item UUIDs, so a lookup by UUID does not need these.
|
|
183
|
+
A search does: `fn:collection("ochre/<category>")`.
|
|
184
|
+
@internal
|
|
185
185
|
*/
|
|
186
186
|
const OCHRE_COLLECTION_CATEGORIES = categoriesWhere((facts) => facts.hasCollection);
|
|
187
187
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
The item categories that can sit directly inside a Tree
|
|
189
|
+
@internal
|
|
190
190
|
*/
|
|
191
191
|
const TREE_ITEM_CATEGORIES = categoriesWhere((facts) => facts.isTreeItem);
|
|
192
192
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
The item categories that can sit directly inside a Set
|
|
194
|
+
@internal
|
|
195
195
|
*/
|
|
196
196
|
const SET_ITEM_CATEGORIES = categoriesWhere((facts) => facts.isSetItem);
|
|
197
197
|
/**
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
The item categories that can sit under a heading
|
|
199
|
+
@internal
|
|
200
200
|
*/
|
|
201
201
|
const HEADING_ITEM_CATEGORIES = categoriesWhere((facts) => facts.isHeadingItem);
|
|
202
202
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
The item categories that hold other items under a `containedItemCategory`
|
|
204
|
+
@internal
|
|
205
205
|
*/
|
|
206
206
|
const ITEM_CONTAINER_CATEGORIES = categoriesWhere((facts) => facts.isContainer);
|
|
207
207
|
/**
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
The item categories that carry an embedded item hierarchy
|
|
209
|
+
@internal
|
|
210
210
|
*/
|
|
211
211
|
const ITEM_CATEGORIES_WITH_EMBEDDED_ITEMS = categoriesWhere((facts) => facts.hasEmbeddedItems);
|
|
212
212
|
/**
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
Each element name that can appear in a context path, and the category it means
|
|
214
|
+
@internal
|
|
215
215
|
*/
|
|
216
216
|
const CONTEXT_CATEGORY_ALIASES = Object.entries(ITEM_CATEGORY_FACTS).flatMap(([category, facts]) => facts.isContextItem ? facts.aliases.map((alias) => ({
|
|
217
217
|
alias,
|
|
218
218
|
category
|
|
219
219
|
})) : []);
|
|
220
220
|
/**
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
Whether an item of this category holds other items
|
|
222
|
+
@param category - The item category
|
|
223
|
+
@returns True when the category accepts a `containedItemCategory`
|
|
224
|
+
@internal
|
|
225
225
|
*/
|
|
226
226
|
function isItemContainerCategory(category) {
|
|
227
227
|
return ITEM_CATEGORY_FACTS[category].isContainer;
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
Whether an item of this category carries an embedded item hierarchy
|
|
231
|
+
@param category - The item category
|
|
232
|
+
@returns True when the category exposes embedded items
|
|
233
|
+
@internal
|
|
234
234
|
*/
|
|
235
235
|
function isItemCategoryWithEmbeddedItems(category) {
|
|
236
236
|
return ITEM_CATEGORY_FACTS[category].hasEmbeddedItems;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
Whether an item of this category can sit under a heading
|
|
240
|
+
@param category - The item category
|
|
241
|
+
@returns True when the category is allowed under a heading
|
|
242
|
+
@internal
|
|
243
243
|
*/
|
|
244
244
|
function isHeadingItemCategory(category) {
|
|
245
245
|
return ITEM_CATEGORY_FACTS[category].isHeadingItem;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
Resolve an OCHRE element name to the category it means
|
|
249
|
+
@param category - The element name, which may be an alias
|
|
250
|
+
@returns The canonical category, or null when the name is not one
|
|
251
|
+
@internal
|
|
252
252
|
*/
|
|
253
253
|
function normalizeItemCategory(category) {
|
|
254
254
|
if (category == null) return null;
|
package/dist/constants.d.mts
CHANGED
|
@@ -3,18 +3,18 @@ export declare const XML_ARRAY_TAGS: ReadonlyArray<string>;
|
|
|
3
3
|
export declare const XML_PARSER_OPTIONS: X2jOptions;
|
|
4
4
|
export declare const DEFAULT_LANGUAGES: readonly ["eng"];
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
The default page size to use for fetching paginated items
|
|
7
|
+
*/
|
|
8
8
|
export declare const DEFAULT_PAGE_SIZE = 48;
|
|
9
9
|
export declare const OCHRE_ENDPOINT = "https://ochre.lib.uchicago.edu/ochre/v2/ochre.php";
|
|
10
10
|
export declare const PERMANENT_IDENTIFICATION_URL_PREFIX = "https://pi.lib.uchicago.edu/1001/org/ochre/";
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
Build the URL of an OCHRE item document
|
|
13
|
+
@param uuid - The UUID of the OCHRE item
|
|
14
|
+
@param searchParameters - Extra query string parameters to append
|
|
15
|
+
@returns The item document URL
|
|
16
|
+
@internal
|
|
17
|
+
*/
|
|
18
18
|
export declare function getOchreItemUrl(uuid: string, searchParameters?: string): string;
|
|
19
19
|
export declare const BELONGS_TO_COLLECTION_UUID = "30054cb2-909a-4f34-8db9-8fe7369d691d";
|
|
20
20
|
export declare const PRESENTATION_ITEM_UUID = "f1c131b6-1498-48a4-95bf-a9edae9fd518";
|
package/dist/constants.mjs
CHANGED
|
@@ -85,17 +85,17 @@ const XML_PARSER_OPTIONS = {
|
|
|
85
85
|
};
|
|
86
86
|
const DEFAULT_LANGUAGES = ["eng"];
|
|
87
87
|
/**
|
|
88
|
-
|
|
88
|
+
The default page size to use for fetching paginated items
|
|
89
89
|
*/
|
|
90
90
|
const DEFAULT_PAGE_SIZE = 48;
|
|
91
91
|
const OCHRE_ENDPOINT = "https://ochre.lib.uchicago.edu/ochre/v2/ochre.php";
|
|
92
92
|
const PERMANENT_IDENTIFICATION_URL_PREFIX = "https://pi.lib.uchicago.edu/1001/org/ochre/";
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
Build the URL of an OCHRE item document
|
|
95
|
+
@param uuid - The UUID of the OCHRE item
|
|
96
|
+
@param searchParameters - Extra query string parameters to append
|
|
97
|
+
@returns The item document URL
|
|
98
|
+
@internal
|
|
99
99
|
*/
|
|
100
100
|
function getOchreItemUrl(uuid, searchParameters) {
|
|
101
101
|
const suffix = searchParameters == null ? "" : `&${searchParameters}`;
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
type SchemaValidationIssue = v.BaseIssue<unknown>;
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
Render an error as a short message and a fully detailed report
|
|
5
|
+
@param error - The thrown value
|
|
6
|
+
@param fallbackMessage - The message to use when the value is not an Error
|
|
7
|
+
@returns The message and the detailed report
|
|
8
|
+
@internal
|
|
9
|
+
*/
|
|
10
10
|
export declare function getErrorOutput(error: unknown, fallbackMessage: string): {
|
|
11
11
|
error: string;
|
|
12
12
|
detailedError: string;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
Wrap schema validation issues in an error {@link getErrorOutput} can render
|
|
16
|
+
@param message - The failure message
|
|
17
|
+
@param issues - The validation issues to carry as the cause
|
|
18
|
+
@returns The error
|
|
19
|
+
@internal
|
|
20
|
+
*/
|
|
21
21
|
export declare function createSchemaValidationError(message: string, issues: ReadonlyArray<SchemaValidationIssue>): Error;
|
|
22
22
|
export {};
|
package/dist/errors.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import { isObject, readEntries } from "./reflection.mjs";
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
// src/errors.ts
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
The shape a valibot issue has to have for this module to render it
|
|
6
|
+
|
|
7
|
+
A schema rather than a hand-written predicate: the fields being checked are
|
|
8
|
+
exactly a shape, and `v.is` narrows without asserting anything unchecked. An
|
|
9
|
+
array cannot pass, because it carries none of these fields.
|
|
10
10
|
*/
|
|
11
11
|
const schemaValidationIssueSchema = v.looseObject({
|
|
12
12
|
kind: v.string(),
|
|
@@ -42,10 +42,9 @@ function appendSchemaValidationIssues(lines, issues, depth = 0, prefix = "") {
|
|
|
42
42
|
if (input != null) lines.push(`${indent} Input: ${input}`);
|
|
43
43
|
const requirement = formatPrimitiveValue(issue.requirement);
|
|
44
44
|
if (requirement != null) lines.push(`${indent} Requirement: ${requirement}`);
|
|
45
|
-
if (issue.issues
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
45
|
+
if (issue.issues == null || issue.issues.length === 0) continue;
|
|
46
|
+
lines.push(`${indent} Nested issues:`);
|
|
47
|
+
appendSchemaValidationIssues(lines, issue.issues, depth + 1, number);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
function formatCauseArray(value) {
|
|
@@ -131,11 +130,11 @@ function getDetailedError(error, fallbackMessage = "Unknown error") {
|
|
|
131
130
|
return lines.join("\n");
|
|
132
131
|
}
|
|
133
132
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
Render an error as a short message and a fully detailed report
|
|
134
|
+
@param error - The thrown value
|
|
135
|
+
@param fallbackMessage - The message to use when the value is not an Error
|
|
136
|
+
@returns The message and the detailed report
|
|
137
|
+
@internal
|
|
139
138
|
*/
|
|
140
139
|
function getErrorOutput(error, fallbackMessage) {
|
|
141
140
|
const message = getErrorMessage(error, fallbackMessage);
|
|
@@ -145,19 +144,19 @@ function getErrorOutput(error, fallbackMessage) {
|
|
|
145
144
|
};
|
|
146
145
|
}
|
|
147
146
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
Wrap schema validation issues in an error {@link getErrorOutput} can render
|
|
148
|
+
@param message - The failure message
|
|
149
|
+
@param issues - The validation issues to carry as the cause
|
|
150
|
+
@returns The error
|
|
151
|
+
@internal
|
|
153
152
|
*/
|
|
154
153
|
function createSchemaValidationError(message, issues) {
|
|
155
154
|
return new Error(message, { cause: issues });
|
|
156
155
|
}
|
|
157
156
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
Validates a pseudo-UUID string
|
|
158
|
+
@param value - The string to validate
|
|
159
|
+
@returns True if the string is a valid pseudo-UUID, false otherwise
|
|
160
|
+
@internal
|
|
162
161
|
*/
|
|
163
162
|
export { createSchemaValidationError, getErrorOutput };
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
+
import { FetchRuntimeOptions } from "../parsers/helpers.mjs";
|
|
1
2
|
import { ItemCategory, Query, SetItem, SetItemsSort } from "../types/index.mjs";
|
|
2
3
|
import { XMLSetItems } from "../xml/types.mjs";
|
|
3
|
-
import { FetchRuntimeOptions } from "../parsers/helpers.mjs";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Whether a container payload carries any item of a category
|
|
6
|
+
@param items - The parsed `<items>` payload
|
|
7
|
+
@param category - The category to look for
|
|
8
|
+
@returns True when the payload carries at least one item of it
|
|
9
|
+
@internal
|
|
10
|
+
*/
|
|
11
11
|
export declare function hasItemsCategory(items: XMLSetItems, category: ItemCategory): boolean;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
Fetch one page of the items a Set or a Tree holds
|
|
14
|
+
|
|
15
|
+
The only thing that differs between the two containers is the searchable
|
|
16
|
+
path {@link compileContainerItemsQuery} picks, so counting, sorting,
|
|
17
|
+
paginating, validating and parsing are written once here and the public
|
|
18
|
+
fetchers are thin wrappers that name their own scope parameter.
|
|
19
|
+
@param parameters - The request parameters
|
|
20
|
+
@param parameters.container - Whether the scope UUIDs name Sets or Trees
|
|
21
|
+
@param parameters.scopeUuids - The container UUIDs to search within
|
|
22
|
+
@param parameters.belongsToCollectionScopeUuids - Collection scope UUIDs to narrow to
|
|
23
|
+
@param parameters.queries - The query tree to filter by, or null to match every item
|
|
24
|
+
@param parameters.sort - The sort applied before pagination
|
|
25
|
+
@param parameters.page - The page number, 1-indexed
|
|
26
|
+
@param parameters.pageSize - The number of items per page
|
|
27
|
+
@param parameters.containedItemCategories - Categories the payload must carry
|
|
28
|
+
@param parameters.label - What is being fetched, used in failure messages
|
|
29
|
+
@param parameters.options - Fetch and parser options
|
|
30
|
+
@returns The page of items, deduplicated by UUID
|
|
31
|
+
@throws When the request fails, validation fails, or a category is missing
|
|
32
|
+
@internal
|
|
33
|
+
*/
|
|
34
34
|
export declare function fetchContainerItems(parameters: {
|
|
35
35
|
container: "set" | "tree";
|
|
36
36
|
scopeUuids: Array<string>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { requestOchre } from "./request.mjs";
|
|
2
|
-
import { parseRequestedLanguages, resolveContentLanguages } from "../parsers/languages.mjs";
|
|
3
2
|
import { parseSetItems } from "../parsers/index.mjs";
|
|
3
|
+
import { parseRequestedLanguages, resolveContentLanguages } from "../parsers/languages.mjs";
|
|
4
|
+
import { compileContainerItemsQuery } from "../query.mjs";
|
|
4
5
|
import { XMLSetItemsData } from "../xml/schemas.mjs";
|
|
5
6
|
import { getContentLanguage, stringLiteral } from "../xquery.mjs";
|
|
6
|
-
import { compileContainerItemsQuery } from "../query.mjs";
|
|
7
7
|
// src/fetchers/container-items.ts
|
|
8
8
|
function hasArray(items) {
|
|
9
9
|
return items != null && items.length > 0;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
Whether a container payload carries any item of a category
|
|
13
|
+
@param items - The parsed `<items>` payload
|
|
14
|
+
@param category - The category to look for
|
|
15
|
+
@returns True when the payload carries at least one item of it
|
|
16
|
+
@internal
|
|
17
17
|
*/
|
|
18
18
|
function hasItemsCategory(items, category) {
|
|
19
19
|
switch (category) {
|
|
@@ -118,26 +118,26 @@ function buildOrderedItemsClause(sort) {
|
|
|
118
118
|
return $item`;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
121
|
+
Fetch one page of the items a Set or a Tree holds
|
|
122
|
+
|
|
123
|
+
The only thing that differs between the two containers is the searchable
|
|
124
|
+
path {@link compileContainerItemsQuery} picks, so counting, sorting,
|
|
125
|
+
paginating, validating and parsing are written once here and the public
|
|
126
|
+
fetchers are thin wrappers that name their own scope parameter.
|
|
127
|
+
@param parameters - The request parameters
|
|
128
|
+
@param parameters.container - Whether the scope UUIDs name Sets or Trees
|
|
129
|
+
@param parameters.scopeUuids - The container UUIDs to search within
|
|
130
|
+
@param parameters.belongsToCollectionScopeUuids - Collection scope UUIDs to narrow to
|
|
131
|
+
@param parameters.queries - The query tree to filter by, or null to match every item
|
|
132
|
+
@param parameters.sort - The sort applied before pagination
|
|
133
|
+
@param parameters.page - The page number, 1-indexed
|
|
134
|
+
@param parameters.pageSize - The number of items per page
|
|
135
|
+
@param parameters.containedItemCategories - Categories the payload must carry
|
|
136
|
+
@param parameters.label - What is being fetched, used in failure messages
|
|
137
|
+
@param parameters.options - Fetch and parser options
|
|
138
|
+
@returns The page of items, deduplicated by UUID
|
|
139
|
+
@throws When the request fails, validation fails, or a category is missing
|
|
140
|
+
@internal
|
|
141
141
|
*/
|
|
142
142
|
async function fetchContainerItems(parameters) {
|
|
143
143
|
const { container, scopeUuids, belongsToCollectionScopeUuids, queries, sort, page, pageSize, containedItemCategories, label, options } = parameters;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Gallery } from "../types/index.mjs";
|
|
2
1
|
import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
|
|
2
|
+
import { Gallery } from "../types/index.mjs";
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
Fetches and parses a gallery from the OCHRE API
|
|
5
|
+
|
|
6
|
+
@param parameters - The parameters for the fetch
|
|
7
|
+
@param parameters.uuid - The UUID of the gallery
|
|
8
|
+
@param parameters.filter - The filter to apply to the gallery
|
|
9
|
+
@param parameters.page - The page number to fetch
|
|
10
|
+
@param parameters.perPage - The number of items per page
|
|
11
|
+
@param options - The options for the fetch
|
|
12
|
+
@param options.languages - Language codes to parse. Inline arrays preserve literal types automatically.
|
|
13
|
+
@param options.fetch - The fetch function to use
|
|
14
|
+
@returns The parsed gallery or an error message if the fetch/parse fails
|
|
15
|
+
*/
|
|
16
16
|
export declare function fetchGallery<const TLanguages extends ReadonlyArray<string> | undefined = undefined>(parameters: {
|
|
17
17
|
uuid: string;
|
|
18
18
|
filter?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getErrorOutput } from "../errors.mjs";
|
|
2
2
|
import { requestOchre } from "./request.mjs";
|
|
3
|
-
import { gallerySchema } from "../schemas.mjs";
|
|
4
|
-
import { parseRequestedLanguages, resolveContentLanguages } from "../parsers/languages.mjs";
|
|
5
3
|
import { parseGallery } from "../parsers/index.mjs";
|
|
4
|
+
import { parseRequestedLanguages, resolveContentLanguages } from "../parsers/languages.mjs";
|
|
5
|
+
import { gallerySchema } from "../schemas.mjs";
|
|
6
6
|
import { XMLGalleryData } from "../xml/schemas.mjs";
|
|
7
7
|
import { OCHRE_RESPONSE_PADDING, compileOchreQuery, getContentLanguage, stringLiteral } from "../xquery.mjs";
|
|
8
8
|
import * as v from "valibot";
|