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.
Files changed (97) hide show
  1. package/dist/categories.d.mts +56 -56
  2. package/dist/categories.mjs +39 -39
  3. package/dist/constants.d.mts +8 -8
  4. package/dist/constants.mjs +6 -6
  5. package/dist/errors.d.mts +12 -12
  6. package/dist/errors.mjs +22 -23
  7. package/dist/fetchers/container-items.d.mts +28 -28
  8. package/dist/fetchers/container-items.mjs +27 -27
  9. package/dist/fetchers/gallery.d.mts +13 -13
  10. package/dist/fetchers/gallery.mjs +2 -2
  11. package/dist/fetchers/item-children.d.mts +12 -12
  12. package/dist/fetchers/item-children.mjs +2 -2
  13. package/dist/fetchers/item-links.d.mts +10 -10
  14. package/dist/fetchers/item-links.mjs +6 -6
  15. package/dist/fetchers/item-locations.d.mts +20 -20
  16. package/dist/fetchers/item-locations.mjs +3 -3
  17. package/dist/fetchers/item-ocr-data.d.mts +23 -23
  18. package/dist/fetchers/item-ocr-data.mjs +44 -44
  19. package/dist/fetchers/item.d.mts +14 -14
  20. package/dist/fetchers/item.mjs +14 -14
  21. package/dist/fetchers/map-layers.d.mts +15 -15
  22. package/dist/fetchers/map-layers.mjs +12 -11
  23. package/dist/fetchers/request.d.mts +40 -40
  24. package/dist/fetchers/request.mjs +37 -37
  25. package/dist/fetchers/set/items.d.mts +15 -15
  26. package/dist/fetchers/set/items.mjs +1 -1
  27. package/dist/fetchers/set/property-values.d.mts +16 -16
  28. package/dist/fetchers/set/property-values.mjs +43 -43
  29. package/dist/fetchers/tree/items.d.mts +27 -27
  30. package/dist/fetchers/tree/items.mjs +1 -1
  31. package/dist/fetchers/website-metadata.d.mts +4 -4
  32. package/dist/fetchers/website-metadata.mjs +9 -9
  33. package/dist/fetchers/website.d.mts +10 -10
  34. package/dist/fetchers/website.mjs +12 -12
  35. package/dist/getters.d.mts +83 -83
  36. package/dist/getters.mjs +74 -74
  37. package/dist/helpers.d.mts +4 -4
  38. package/dist/helpers.mjs +7 -7
  39. package/dist/index.d.mts +3 -3
  40. package/dist/index.mjs +5 -5
  41. package/dist/languages.d.mts +58 -58
  42. package/dist/languages.mjs +21 -21
  43. package/dist/ocr.d.mts +27 -27
  44. package/dist/ocr.mjs +29 -29
  45. package/dist/parsers/helpers.d.mts +23 -23
  46. package/dist/parsers/helpers.mjs +8 -8
  47. package/dist/parsers/index.d.mts +2 -2
  48. package/dist/parsers/index.mjs +15 -15
  49. package/dist/parsers/languages.d.mts +49 -49
  50. package/dist/parsers/languages.mjs +49 -49
  51. package/dist/parsers/multilingual.d.mts +174 -174
  52. package/dist/parsers/multilingual.mjs +146 -146
  53. package/dist/parsers/partial-date.d.mts +12 -12
  54. package/dist/parsers/partial-date.mjs +11 -11
  55. package/dist/parsers/property-token.d.mts +20 -20
  56. package/dist/parsers/property-token.mjs +16 -16
  57. package/dist/parsers/string.d.mts +33 -33
  58. package/dist/parsers/string.mjs +62 -64
  59. package/dist/parsers/website/bounds.d.mts +6 -6
  60. package/dist/parsers/website/bounds.mjs +5 -5
  61. package/dist/parsers/website/components.d.mts +50 -31
  62. package/dist/parsers/website/components.mjs +79 -51
  63. package/dist/parsers/website/index.d.mts +1 -1
  64. package/dist/parsers/website/index.mjs +43 -47
  65. package/dist/parsers/website/links.d.mts +24 -24
  66. package/dist/parsers/website/links.mjs +18 -18
  67. package/dist/parsers/website/messages.d.mts +16 -16
  68. package/dist/parsers/website/messages.mjs +14 -14
  69. package/dist/parsers/website/options.d.mts +1 -1
  70. package/dist/parsers/website/properties.d.mts +17 -8
  71. package/dist/parsers/website/properties.mjs +23 -11
  72. package/dist/parsers/website/reader.d.mts +55 -46
  73. package/dist/parsers/website/reader.mjs +64 -46
  74. package/dist/parsers/website/slug.d.mts +50 -50
  75. package/dist/parsers/website/slug.mjs +36 -36
  76. package/dist/parsers/website/styles.d.mts +18 -18
  77. package/dist/parsers/website/styles.mjs +19 -19
  78. package/dist/parsers/website/walk.d.mts +46 -46
  79. package/dist/parsers/website/walk.mjs +34 -34
  80. package/dist/query.d.mts +63 -63
  81. package/dist/query.mjs +137 -140
  82. package/dist/reflection.d.mts +51 -51
  83. package/dist/reflection.mjs +45 -45
  84. package/dist/schemas.d.mts +44 -44
  85. package/dist/schemas.mjs +50 -50
  86. package/dist/types/index.d.mts +192 -192
  87. package/dist/types/utilities.d.mts +5 -5
  88. package/dist/types/website.d.mts +67 -62
  89. package/dist/xml/dates.d.mts +9 -9
  90. package/dist/xml/dates.mjs +9 -9
  91. package/dist/xml/metadata.d.mts +14 -14
  92. package/dist/xml/metadata.mjs +18 -18
  93. package/dist/xml/schemas.mjs +24 -24
  94. package/dist/xml/types.d.mts +9 -9
  95. package/dist/xquery.d.mts +49 -49
  96. package/dist/xquery.mjs +50 -50
  97. package/package.json +10 -10
@@ -13,22 +13,22 @@ function resolveSignal(options) {
13
13
  return signal == null ? timeoutSignal : AbortSignal.any([signal, timeoutSignal]);
14
14
  }
15
15
  /**
16
- * Turn an OCHRE XML response into validated data
17
- *
18
- * The XML parser, the schema check and the metadata graft are one step: the
19
- * graft has to follow validation because `v.safeParse` drops the
20
- * non-enumerable source offsets `fast-xml-parser` records, and skipping it
21
- * leaves a value that is the right shape but has lost its source order. Kept
22
- * separate from the request so a caller holding an XML string, such as a test,
23
- * gets exactly what the network path produces.
24
- * @param parameters - The decode parameters
25
- * @param parameters.xml - The raw XML response body
26
- * @param parameters.schema - The schema the response must satisfy
27
- * @param parameters.label - What is being decoded, used in failure messages
28
- * @param parameters.checkRawData - Guard run against the parsed XML before validation
29
- * @returns The validated response, with XML source metadata restored
30
- * @throws When the query failed on the server, the guard rejects, or validation fails
31
- * @internal
16
+ Turn an OCHRE XML response into validated data
17
+
18
+ The XML parser, the schema check and the metadata graft are one step: the
19
+ graft has to follow validation because `v.safeParse` drops the
20
+ non-enumerable source offsets `fast-xml-parser` records, and skipping it
21
+ leaves a value that is the right shape but has lost its source order. Kept
22
+ separate from the request so a caller holding an XML string, such as a test,
23
+ gets exactly what the network path produces.
24
+ @param parameters - The decode parameters
25
+ @param parameters.xml - The raw XML response body
26
+ @param parameters.schema - The schema the response must satisfy
27
+ @param parameters.label - What is being decoded, used in failure messages
28
+ @param parameters.checkRawData - Guard run against the parsed XML before validation
29
+ @returns The validated response, with XML source metadata restored
30
+ @throws When the query failed on the server, the guard rejects, or validation fails
31
+ @internal
32
32
  */
33
33
  function decodeOchreResponse(parameters) {
34
34
  const { xml, schema, label, checkRawData } = parameters;
@@ -41,19 +41,19 @@ function decodeOchreResponse(parameters) {
41
41
  return output;
42
42
  }
43
43
  /**
44
- * Post an XQuery to the OCHRE API and validate the response
45
- *
46
- * Owns every fact about talking to OCHRE: the endpoint, the request shape and
47
- * the failure policy. Decoding the body is {@link decodeOchreResponse}.
48
- * @param parameters - The request parameters
49
- * @param parameters.xquery - The XQuery to post
50
- * @param parameters.schema - The schema the response must satisfy
51
- * @param parameters.label - What is being fetched, used in failure messages
52
- * @param parameters.options - Transport options
53
- * @param parameters.checkRawData - Guard run against the parsed XML before validation
54
- * @returns The validated response, with XML source metadata restored
55
- * @throws When the request fails, the guard rejects, or validation fails
56
- * @internal
44
+ Post an XQuery to the OCHRE API and validate the response
45
+
46
+ Owns every fact about talking to OCHRE: the endpoint, the request shape and
47
+ the failure policy. Decoding the body is {@link decodeOchreResponse}.
48
+ @param parameters - The request parameters
49
+ @param parameters.xquery - The XQuery to post
50
+ @param parameters.schema - The schema the response must satisfy
51
+ @param parameters.label - What is being fetched, used in failure messages
52
+ @param parameters.options - Transport options
53
+ @param parameters.checkRawData - Guard run against the parsed XML before validation
54
+ @returns The validated response, with XML source metadata restored
55
+ @throws When the request fails, the guard rejects, or validation fails
56
+ @internal
57
57
  */
58
58
  async function requestOchre(parameters) {
59
59
  const { xquery, schema, label, options, checkRawData } = parameters;
@@ -72,14 +72,14 @@ async function requestOchre(parameters) {
72
72
  });
73
73
  }
74
74
  /**
75
- * Post a JSON payload to the OCHRE API
76
- * @param parameters - The request parameters
77
- * @param parameters.body - The JSON payload to post
78
- * @param parameters.label - What is being posted, used in failure messages
79
- * @param parameters.options - Transport options
80
- * @returns Whether the API accepted the payload
81
- * @throws When the request cannot be completed at all
82
- * @internal
75
+ Post a JSON payload to the OCHRE API
76
+ @param parameters - The request parameters
77
+ @param parameters.body - The JSON payload to post
78
+ @param parameters.label - What is being posted, used in failure messages
79
+ @param parameters.options - Transport options
80
+ @returns Whether the API accepted the payload
81
+ @throws When the request cannot be completed at all
82
+ @internal
83
83
  */
84
84
  async function isOchreJsonAccepted(parameters) {
85
85
  const { body, label, options } = parameters;
@@ -1,21 +1,21 @@
1
- import { Query, SetItem, SetItemCategory, SetItemsSort } from "../../types/index.mjs";
2
1
  import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
2
+ import { Query, SetItem, SetItemCategory, SetItemsSort } from "../../types/index.mjs";
3
3
  type FetchSetItemsCategory<TContainedItemCategories extends ReadonlyArray<SetItemCategory> | undefined> = TContainedItemCategories extends ReadonlyArray<infer U> ? Extract<U, SetItemCategory> : SetItemCategory;
4
4
  /**
5
- * Fetches and parses Set items from the OCHRE API
6
- *
7
- * @param parameters - The parameters for the fetch
8
- * @param parameters.setScopeUuids - The Set scope UUIDs to filter by
9
- * @param parameters.queries - Recursive query tree used to filter matching items
10
- * @param parameters.sort - Optional sorting configuration applied before pagination.
11
- * For propertyValue sorting, dataType is required and the sort key uses the first valid leaf value (value[not(@i)]).
12
- * @param parameters.page - The page number (1-indexed)
13
- * @param parameters.pageSize - The number of items per page
14
- * @param containedItemCategories - The categories of the items to fetch
15
- * @param options - Options for the fetch
16
- * @param options.fetch - The fetch function to use
17
- * @returns The parsed Set items or null if the fetch/parse fails
18
- */
5
+ Fetches and parses Set items from the OCHRE API
6
+
7
+ @param parameters - The parameters for the fetch
8
+ @param parameters.setScopeUuids - The Set scope UUIDs to filter by
9
+ @param parameters.queries - Recursive query tree used to filter matching items
10
+ @param parameters.sort - Optional sorting configuration applied before pagination.
11
+ For propertyValue sorting, dataType is required and the sort key uses the first valid leaf value (value[not(@i)]).
12
+ @param parameters.page - The page number (1-indexed)
13
+ @param parameters.pageSize - The number of items per page
14
+ @param containedItemCategories - The categories of the items to fetch
15
+ @param options - Options for the fetch
16
+ @param options.fetch - The fetch function to use
17
+ @returns The parsed Set items or null if the fetch/parse fails
18
+ */
19
19
  export declare function fetchSetItems<const TContainedItemCategories extends ReadonlyArray<SetItemCategory> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(parameters: {
20
20
  setScopeUuids: Array<string>;
21
21
  queries?: Query | null;
@@ -1,6 +1,6 @@
1
1
  import { getErrorOutput } from "../../errors.mjs";
2
- import { setItemsParametersSchema } from "../../schemas.mjs";
3
2
  import { fetchContainerItems } from "../container-items.mjs";
3
+ import { setItemsParametersSchema } from "../../schemas.mjs";
4
4
  import * as v from "valibot";
5
5
  // src/fetchers/set/items.ts
6
6
  async function fetchSetItems(parameters, containedItemCategories, options) {
@@ -1,21 +1,21 @@
1
- import { PropertyValueQueryItem, Query, SetAttributeValueQueryItem } from "../../types/index.mjs";
2
1
  import { OchreRequestOptions } from "../request.mjs";
2
+ import { PropertyValueQueryItem, Query, SetAttributeValueQueryItem } from "../../types/index.mjs";
3
3
  /**
4
- * Fetches and parses Set property values from the OCHRE API
5
- *
6
- * @param parameters - The parameters for the fetch
7
- * @param parameters.setScopeUuids - An array of set scope UUIDs to filter by
8
- * @param parameters.queries - Recursive query tree used to filter matching items
9
- * @param parameters.attributes - Whether to return values for bibliographies and periods
10
- * @param parameters.attributes.bibliographies - Whether to return values for bibliographies
11
- * @param parameters.attributes.periods - Whether to return values for periods
12
- * @param parameters.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
13
- * @param parameters.language - Language of the text value, bibliography, and period labels that facets are keyed by (defaults to `"eng"`)
14
- * @param options - Options for the fetch
15
- * @param options.fetch - The fetch function to use
16
- * @returns Parsed Set property values and requested attribute values.
17
- * Returns empty arrays/objects when no matches are found, and null outputs on fetch/parse errors.
18
- */
4
+ Fetches and parses Set property values from the OCHRE API
5
+
6
+ @param parameters - The parameters for the fetch
7
+ @param parameters.setScopeUuids - An array of set scope UUIDs to filter by
8
+ @param parameters.queries - Recursive query tree used to filter matching items
9
+ @param parameters.attributes - Whether to return values for bibliographies and periods
10
+ @param parameters.attributes.bibliographies - Whether to return values for bibliographies
11
+ @param parameters.attributes.periods - Whether to return values for periods
12
+ @param parameters.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
13
+ @param parameters.language - Language of the text value, bibliography, and period labels that facets are keyed by (defaults to `"eng"`)
14
+ @param options - Options for the fetch
15
+ @param options.fetch - The fetch function to use
16
+ @returns Parsed Set property values and requested attribute values.
17
+ Returns empty arrays/objects when no matches are found, and null outputs on fetch/parse errors.
18
+ */
19
19
  export declare function fetchSetPropertyValues(parameters: {
20
20
  setScopeUuids: Array<string>;
21
21
  queries?: Query | null;
@@ -2,10 +2,10 @@ import { DEFAULT_LANGUAGES } from "../../constants.mjs";
2
2
  import { getErrorOutput } from "../../errors.mjs";
3
3
  import { requestOchre } from "../request.mjs";
4
4
  import { MultilingualString } from "../../parsers/multilingual.mjs";
5
- import { setPropertyValuesParametersSchema } from "../../schemas.mjs";
6
5
  import { parseXMLContent } from "../../parsers/string.mjs";
7
- import { stringLiteral } from "../../xquery.mjs";
8
6
  import { compileContainerItemsQuery, getItemFilterQueries, getPropertyFacetSelectors } from "../../query.mjs";
7
+ import { setPropertyValuesParametersSchema } from "../../schemas.mjs";
8
+ import { stringLiteral } from "../../xquery.mjs";
9
9
  import * as v from "valibot";
10
10
  // src/fetchers/set/property-values.ts
11
11
  function getLabelContentLanguages(content) {
@@ -24,11 +24,11 @@ function parsePropertyValueLabel(content, text) {
24
24
  return MultilingualString.fromObject({ [DEFAULT_LANGUAGES[0]]: parsedText });
25
25
  }
26
26
  /**
27
- * The prefix OCHRE puts on every `dataType` attribute
28
- *
29
- * Kept as a constant because the facet XQuery has to strip the same prefix
30
- * server-side: it compares `@dataType` against the unprefixed names, so a
31
- * prefixed value falls through every typed branch.
27
+ The prefix OCHRE puts on every `dataType` attribute
28
+
29
+ Kept as a constant because the facet XQuery has to strip the same prefix
30
+ server-side: it compares `@dataType` against the unprefixed names, so a
31
+ prefixed value falls through every typed branch.
32
32
  */
33
33
  const XML_SCHEMA_TYPE_PREFIX = "xs:";
34
34
  function normalizePropertyValueDataType(dataType) {
@@ -74,12 +74,12 @@ const propertyValueLabelContentSchema = v.object({
74
74
  string: v.array(propertyValueLabelStringSchema)
75
75
  });
76
76
  /**
77
- * Give the canonical value the type its `dataType` implies
78
- *
79
- * Which value a facet stands for is decided once, server-side, by
80
- * `local:value-content`, and travels back as `canonicalValue`. This only gives
81
- * that string a TypeScript type: re-deriving it here from `rawValue`, `uuid`
82
- * and the label is what let the facet key and the facet content disagree.
77
+ Give the canonical value the type its `dataType` implies
78
+
79
+ Which value a facet stands for is decided once, server-side, by
80
+ `local:value-content`, and travels back as `canonicalValue`. This only gives
81
+ that string a TypeScript type: re-deriving it here from `rawValue`, `uuid`
82
+ and the label is what let the facet key and the facet content disagree.
83
83
  */
84
84
  function typePropertyValueContent(dataType, canonicalValue) {
85
85
  if (canonicalValue == null || canonicalValue === "") return null;
@@ -95,7 +95,7 @@ function typePropertyValueContent(dataType, canonicalValue) {
95
95
  }
96
96
  }
97
97
  /**
98
- * Schema for a single property value query item in the OCHRE API response
98
+ Schema for a single property value query item in the OCHRE API response
99
99
  */
100
100
  const propertyValueQueryItemSchema = v.pipe(v.object({
101
101
  uuid: v.optional(v.string(), ""),
@@ -133,7 +133,7 @@ const attributeValueQueryItemSchema = v.pipe(v.object({
133
133
  label: parsePropertyValueLabel(value.content, value.key)
134
134
  })));
135
135
  /**
136
- * Schema for the property values OCHRE API response
136
+ Schema for the property values OCHRE API response
137
137
  */
138
138
  const responseSchema = v.object({ result: v.object({ ochre: v.object({
139
139
  payload: v.optional(v.string()),
@@ -141,18 +141,18 @@ const responseSchema = v.object({ result: v.object({ ochre: v.object({
141
141
  attributeValue: v.optional(v.union([v.array(attributeValueQueryItemSchema), attributeValueQueryItemSchema]))
142
142
  }) }) });
143
143
  /**
144
- * Build an XQuery string to fetch property values from the OCHRE API
145
- * @param parameters - The parameters for the fetch
146
- * @param parameters.setScopeUuids - An array of set scope UUIDs to filter by
147
- * @param parameters.belongsToCollectionScopeUuids - An array of collection scope UUIDs to filter by
148
- * @param parameters.queries - Recursive query tree used to filter matching items
149
- * @param parameters.propertyFacetSelectors - Property variable/relation selectors to aggregate, if any
150
- * @param parameters.attributes - Whether to return values for bibliographies and periods
151
- * @param parameters.attributes.bibliographies - Whether to return values for bibliographies
152
- * @param parameters.attributes.periods - Whether to return values for periods
153
- * @param parameters.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
154
- * @param parameters.language - Language of the text value, bibliography, and period labels that facets are keyed by (defaults to `"eng"`)
155
- * @returns An XQuery string
144
+ Build an XQuery string to fetch property values from the OCHRE API
145
+ @param parameters - The parameters for the fetch
146
+ @param parameters.setScopeUuids - An array of set scope UUIDs to filter by
147
+ @param parameters.belongsToCollectionScopeUuids - An array of collection scope UUIDs to filter by
148
+ @param parameters.queries - Recursive query tree used to filter matching items
149
+ @param parameters.propertyFacetSelectors - Property variable/relation selectors to aggregate, if any
150
+ @param parameters.attributes - Whether to return values for bibliographies and periods
151
+ @param parameters.attributes.bibliographies - Whether to return values for bibliographies
152
+ @param parameters.attributes.periods - Whether to return values for periods
153
+ @param parameters.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
154
+ @param parameters.language - Language of the text value, bibliography, and period labels that facets are keyed by (defaults to `"eng"`)
155
+ @returns An XQuery string
156
156
  */
157
157
  function buildXQuery(parameters) {
158
158
  const { setScopeUuids, belongsToCollectionScopeUuids, queries, propertyFacetSelectors, attributes, isLimitedToLeafPropertyValues, language } = parameters;
@@ -399,8 +399,8 @@ function collectPropertyValues(parsedPropertyValues) {
399
399
  const existingGlobalPropertyValue = flattenedPropertyValuesByKey.get(globalPropertyValueKey);
400
400
  if (existingGlobalPropertyValue == null) flattenedPropertyValuesByKey.set(globalPropertyValueKey, globalPropertyValueItem);
401
401
  else if (existingGlobalPropertyValue.label == null && globalPropertyValueItem.label != null) existingGlobalPropertyValue.label = globalPropertyValueItem.label;
402
- if (propertyValue.scope === "global") continue;
403
- if (propertyValue.variableUuid != null) (propertyValuesByPropertyVariableUuid[propertyValue.variableUuid] ??= []).push(propertyValueItem);
402
+ if (propertyValue.scope === "global" || propertyValue.variableUuid == null) continue;
403
+ (propertyValuesByPropertyVariableUuid[propertyValue.variableUuid] ??= []).push(propertyValueItem);
404
404
  }
405
405
  for (const [propertyVariableUuid, values] of Object.entries(propertyValuesByPropertyVariableUuid)) propertyValuesByPropertyVariableUuid[propertyVariableUuid] = sortPropertyValues(values);
406
406
  return {
@@ -424,20 +424,20 @@ function collectAttributeValues(parsedAttributeValues) {
424
424
  return attributeValuesByType;
425
425
  }
426
426
  /**
427
- * Fetches and parses Set property values from the OCHRE API
428
- *
429
- * @param parameters - The parameters for the fetch
430
- * @param parameters.setScopeUuids - An array of set scope UUIDs to filter by
431
- * @param parameters.queries - Recursive query tree used to filter matching items
432
- * @param parameters.attributes - Whether to return values for bibliographies and periods
433
- * @param parameters.attributes.bibliographies - Whether to return values for bibliographies
434
- * @param parameters.attributes.periods - Whether to return values for periods
435
- * @param parameters.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
436
- * @param parameters.language - Language of the text value, bibliography, and period labels that facets are keyed by (defaults to `"eng"`)
437
- * @param options - Options for the fetch
438
- * @param options.fetch - The fetch function to use
439
- * @returns Parsed Set property values and requested attribute values.
440
- * Returns empty arrays/objects when no matches are found, and null outputs on fetch/parse errors.
427
+ Fetches and parses Set property values from the OCHRE API
428
+
429
+ @param parameters - The parameters for the fetch
430
+ @param parameters.setScopeUuids - An array of set scope UUIDs to filter by
431
+ @param parameters.queries - Recursive query tree used to filter matching items
432
+ @param parameters.attributes - Whether to return values for bibliographies and periods
433
+ @param parameters.attributes.bibliographies - Whether to return values for bibliographies
434
+ @param parameters.attributes.periods - Whether to return values for periods
435
+ @param parameters.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
436
+ @param parameters.language - Language of the text value, bibliography, and period labels that facets are keyed by (defaults to `"eng"`)
437
+ @param options - Options for the fetch
438
+ @param options.fetch - The fetch function to use
439
+ @returns Parsed Set property values and requested attribute values.
440
+ Returns empty arrays/objects when no matches are found, and null outputs on fetch/parse errors.
441
441
  */
442
442
  async function fetchSetPropertyValues(parameters, options) {
443
443
  try {
@@ -1,33 +1,33 @@
1
- import { Query, SetItem, SetItemsSort, TreeItemCategory } from "../../types/index.mjs";
2
1
  import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
2
+ import { Query, SetItem, SetItemsSort, TreeItemCategory } from "../../types/index.mjs";
3
3
  type FetchTreeItemsCategory<TContainedItemCategories extends ReadonlyArray<TreeItemCategory> | undefined> = TContainedItemCategories extends ReadonlyArray<infer U> ? Extract<U, TreeItemCategory> : TreeItemCategory;
4
4
  /**
5
- * Fetches and parses Tree items from the OCHRE API
6
- *
7
- * The counterpart of {@link fetchSetItems} for a Tree, and the way to read a
8
- * Tree too large to fetch whole: a Tree of tens of thousands of items is one
9
- * OCHRE document, so counting, filtering and sorting run inside it rather than
10
- * over one document per item.
11
- *
12
- * Items nested under headings are returned flat, in document order, because a
13
- * heading groups items for display rather than identifying them. What the
14
- * returned items carry is whatever the Tree payload carries: OCHRE publishes
15
- * Tree items as identification-only stubs unless the Tree is published with
16
- * item properties, so a `property` query or a `propertyValue` sort only works
17
- * on a Tree that carries them.
18
- *
19
- * @param parameters - The parameters for the fetch
20
- * @param parameters.treeScopeUuids - The Tree scope UUIDs to filter by
21
- * @param parameters.queries - Recursive query tree used to filter matching items
22
- * @param parameters.sort - Optional sorting configuration applied before pagination.
23
- * For propertyValue sorting, dataType is required and the sort key uses the first valid leaf value (value[not(@i)]).
24
- * @param parameters.page - The page number (1-indexed)
25
- * @param parameters.pageSize - The number of items per page
26
- * @param containedItemCategories - The categories of the items to fetch
27
- * @param options - Options for the fetch
28
- * @param options.fetch - The fetch function to use
29
- * @returns The parsed Tree items or null if the fetch/parse fails
30
- */
5
+ Fetches and parses Tree items from the OCHRE API
6
+
7
+ The counterpart of {@link fetchSetItems} for a Tree, and the way to read a
8
+ Tree too large to fetch whole: a Tree of tens of thousands of items is one
9
+ OCHRE document, so counting, filtering and sorting run inside it rather than
10
+ over one document per item.
11
+
12
+ Items nested under headings are returned flat, in document order, because a
13
+ heading groups items for display rather than identifying them. What the
14
+ returned items carry is whatever the Tree payload carries: OCHRE publishes
15
+ Tree items as identification-only stubs unless the Tree is published with
16
+ item properties, so a `property` query or a `propertyValue` sort only works
17
+ on a Tree that carries them.
18
+
19
+ @param parameters - The parameters for the fetch
20
+ @param parameters.treeScopeUuids - The Tree scope UUIDs to filter by
21
+ @param parameters.queries - Recursive query tree used to filter matching items
22
+ @param parameters.sort - Optional sorting configuration applied before pagination.
23
+ For propertyValue sorting, dataType is required and the sort key uses the first valid leaf value (value[not(@i)]).
24
+ @param parameters.page - The page number (1-indexed)
25
+ @param parameters.pageSize - The number of items per page
26
+ @param containedItemCategories - The categories of the items to fetch
27
+ @param options - Options for the fetch
28
+ @param options.fetch - The fetch function to use
29
+ @returns The parsed Tree items or null if the fetch/parse fails
30
+ */
31
31
  export declare function fetchTreeItems<const TContainedItemCategories extends ReadonlyArray<TreeItemCategory> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(parameters: {
32
32
  treeScopeUuids: Array<string>;
33
33
  queries?: Query | null;
@@ -1,6 +1,6 @@
1
1
  import { getErrorOutput } from "../../errors.mjs";
2
- import { treeItemsParametersSchema } from "../../schemas.mjs";
3
2
  import { fetchContainerItems } from "../container-items.mjs";
3
+ import { treeItemsParametersSchema } from "../../schemas.mjs";
4
4
  import * as v from "valibot";
5
5
  // src/fetchers/tree/items.ts
6
6
  async function fetchTreeItems(parameters, containedItemCategories, options) {
@@ -1,9 +1,9 @@
1
- import { WebsiteMetadata } from "../types/website.mjs";
2
1
  import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
2
+ import { WebsiteMetadata } from "../types/website.mjs";
3
3
  /**
4
- * Fetches and parses a page-scoped website metadata projection from the OCHRE
5
- * API.
6
- */
4
+ Fetches and parses a page-scoped website metadata projection from the OCHRE
5
+ API.
6
+ */
7
7
  export declare function fetchWebsiteMetadata<const TLanguages extends ReadonlyArray<string> | undefined = undefined>(abbreviation: string, options: FetchBaseOptions<TLanguages> & {
8
8
  slug: string;
9
9
  }): Promise<{
@@ -1,20 +1,20 @@
1
1
  import { getErrorOutput } from "../errors.mjs";
2
2
  import { requestOchre } from "./request.mjs";
3
3
  import { parseStringLike } from "../parsers/helpers.mjs";
4
- import { parseMetadataLanguages, parseRequestedLanguages, resolveLanguages } from "../parsers/languages.mjs";
5
4
  import { parseIdentification, parseSimplifiedProperties } from "../parsers/index.mjs";
6
- import { XMLWebsiteData } from "../xml/schemas.mjs";
7
- import { OCHRE_RESPONSE_PADDING, compileOchreQuery, stringLiteral } from "../xquery.mjs";
5
+ import { parseMetadataLanguages, parseRequestedLanguages, resolveLanguages } from "../parsers/languages.mjs";
8
6
  import { websitePresentationReader } from "../parsers/website/reader.mjs";
9
7
  import { WEBSITE_WALK_DECLARATIONS } from "../parsers/website/walk.mjs";
8
+ import { XMLWebsiteData } from "../xml/schemas.mjs";
9
+ import { OCHRE_RESPONSE_PADDING, compileOchreQuery, stringLiteral } from "../xquery.mjs";
10
10
  // src/fetchers/website-metadata.ts
11
11
  /**
12
- * The presentation properties the metadata projection carries
13
- *
14
- * The XQuery whitelists exactly these labels and the parser reads exactly
15
- * these labels, so they come from one list: whitelisting a label the parser
16
- * ignores is dead weight, and reading one the whitelist drops silently yields
17
- * the default.
12
+ The presentation properties the metadata projection carries
13
+
14
+ The XQuery whitelists exactly these labels and the parser reads exactly
15
+ these labels, so they come from one list: whitelisting a label the parser
16
+ ignores is dead weight, and reading one the whitelist drops silently yields
17
+ the default.
18
18
  */
19
19
  const METADATA_PRESENTATION_LABELS = {
20
20
  privacy: "privacy",
@@ -1,15 +1,15 @@
1
- import { ProtectedWebsite, Website } from "../types/website.mjs";
2
- import { LanguageCodes } from "../types/index.mjs";
3
1
  import { OchreRequestOptions } from "./request.mjs";
2
+ import { LanguageCodes } from "../types/index.mjs";
3
+ import { ProtectedWebsite, Website } from "../types/website.mjs";
4
4
  /**
5
- * Fetches and parses a website configuration from the OCHRE API.
6
- *
7
- * For password-protected or OCHRE-credential-protected websites, if no credentials
8
- * are provided the function returns a minimal `protectedWebsite` object instead of
9
- * the full website. Pass `credentials` (a shared password string, or an object with
10
- * `username` and `password` for OCHRE accounts) to authenticate and receive the full
11
- * website data.
12
- */
5
+ Fetches and parses a website configuration from the OCHRE API.
6
+
7
+ For password-protected or OCHRE-credential-protected websites, if no credentials
8
+ are provided the function returns a minimal `protectedWebsite` object instead of
9
+ the full website. Pass `credentials` (a shared password string, or an object with
10
+ `username` and `password` for OCHRE accounts) to authenticate and receive the full
11
+ website data.
12
+ */
13
13
  export declare function fetchWebsite<const T extends LanguageCodes = LanguageCodes>(abbreviation: string, options?: OchreRequestOptions & {
14
14
  languages?: T;
15
15
  credentials?: string | {
@@ -1,9 +1,9 @@
1
1
  import { getErrorOutput } from "../errors.mjs";
2
2
  import { isOchreJsonAccepted, requestOchre } from "./request.mjs";
3
3
  import { parseLanguages } from "../parsers/languages.mjs";
4
+ import { parseWebsite } from "../parsers/website/index.mjs";
4
5
  import { XMLWebsiteData } from "../xml/schemas.mjs";
5
6
  import { OCHRE_RESPONSE_PADDING, compileOchreQuery, stringLiteral } from "../xquery.mjs";
6
- import { parseWebsite } from "../parsers/website/index.mjs";
7
7
  // src/fetchers/website.ts
8
8
  async function areWebsiteCredentialsValid(uuid, credentials, options) {
9
9
  const security = typeof credentials === "string" ? { validate: credentials } : {
@@ -20,10 +20,10 @@ async function areWebsiteCredentialsValid(uuid, credentials, options) {
20
20
  });
21
21
  }
22
22
  /**
23
- * Build an XQuery string to fetch a website tree document by abbreviation.
24
- *
25
- * @param abbreviation - The lowercased website abbreviation to match
26
- * @returns An XQuery string
23
+ Build an XQuery string to fetch a website tree document by abbreviation.
24
+
25
+ @param abbreviation - The lowercased website abbreviation to match
26
+ @returns An XQuery string
27
27
  */
28
28
  function buildXQuery(abbreviation) {
29
29
  return compileOchreQuery({ body: ({ omitSupplemental }) => `let $ochre := collection("ochre/tree")/ochre[tree/identification/abbreviation/content/string = ${stringLiteral(abbreviation)}][1]
@@ -41,13 +41,13 @@ return
41
41
  }` });
42
42
  }
43
43
  /**
44
- * Fetches and parses a website configuration from the OCHRE API.
45
- *
46
- * For password-protected or OCHRE-credential-protected websites, if no credentials
47
- * are provided the function returns a minimal `protectedWebsite` object instead of
48
- * the full website. Pass `credentials` (a shared password string, or an object with
49
- * `username` and `password` for OCHRE accounts) to authenticate and receive the full
50
- * website data.
44
+ Fetches and parses a website configuration from the OCHRE API.
45
+
46
+ For password-protected or OCHRE-credential-protected websites, if no credentials
47
+ are provided the function returns a minimal `protectedWebsite` object instead of
48
+ the full website. Pass `credentials` (a shared password string, or an object with
49
+ `username` and `password` for OCHRE accounts) to authenticate and receive the full
50
+ website data.
51
51
  */
52
52
  async function fetchWebsite(abbreviation, options) {
53
53
  try {