ochre-sdk 0.22.20 → 0.22.21

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/index.d.mts CHANGED
@@ -1293,6 +1293,11 @@ declare function fetchGallery(params: {
1293
1293
  * Fetches and parses an OCHRE item from the OCHRE API
1294
1294
  *
1295
1295
  * @param uuid - The UUID of the OCHRE item to fetch
1296
+ * @param category - The category of the OCHRE item to fetch
1297
+ * @param itemCategories - The categories of the OCHRE items to fetch
1298
+ * @param options - The options for the fetch
1299
+ * @param options.fetch - The fetch function to use
1300
+ * @param options.version - The version of the OCHRE API to use
1296
1301
  * @returns Object containing the parsed OCHRE item, or an error message if the fetch/parse fails
1297
1302
  */
1298
1303
  declare function fetchItem<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(uuid: string, category?: T, itemCategories?: U, options?: {
package/dist/index.mjs CHANGED
@@ -2065,6 +2065,11 @@ async function fetchByUuid(uuid, options) {
2065
2065
  * Fetches and parses an OCHRE item from the OCHRE API
2066
2066
  *
2067
2067
  * @param uuid - The UUID of the OCHRE item to fetch
2068
+ * @param category - The category of the OCHRE item to fetch
2069
+ * @param itemCategories - The categories of the OCHRE items to fetch
2070
+ * @param options - The options for the fetch
2071
+ * @param options.fetch - The fetch function to use
2072
+ * @param options.version - The version of the OCHRE API to use
2068
2073
  * @returns Object containing the parsed OCHRE item, or an error message if the fetch/parse fails
2069
2074
  */
2070
2075
  async function fetchItem(uuid, category, itemCategories, options) {
@@ -4050,6 +4055,15 @@ function filterProperties(property, filter, options = DEFAULT_OPTIONS) {
4050
4055
  //#region src/utils/parse/website.ts
4051
4056
  const SEGMENT_UNIQUE_SLUG_PREFIX_REGEX = /^\$[^-]*-/;
4052
4057
  const TRAILING_SLASH_REGEX = /\/$/;
4058
+ function formatRawResourceMetadata(resource) {
4059
+ const metadata = [`label “${parseStringContent(resource.identification.label)}”`, `uuid “${resource.uuid}”`];
4060
+ if (resource.slug != null) metadata.push(`slug “${resource.slug}”`);
4061
+ if (resource.identification.abbreviation != null) metadata.push(`abbreviation “${parseFakeStringOrContent(resource.identification.abbreviation)}”`);
4062
+ return metadata.join(", ");
4063
+ }
4064
+ function formatComponentError(message, componentName, elementResource) {
4065
+ return `${message} for component “${componentName ?? "(unknown)"}” (${formatRawResourceMetadata(elementResource)})`;
4066
+ }
4053
4067
  /**
4054
4068
  * Extracts CSS style properties for a given presentation variant.
4055
4069
  *
@@ -4173,7 +4187,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4173
4187
  switch (componentName) {
4174
4188
  case "3d-viewer": {
4175
4189
  const resourceLink = links.find((link) => link.category === "resource" && link.fileFormat === "model/obj");
4176
- if (resourceLink?.uuid == null) throw new Error(`Resource link not found for the following component: “${componentName}”`);
4190
+ if (resourceLink?.uuid == null) throw new Error(formatComponentError("Resource link not found", componentName, elementResource));
4177
4191
  let isInteractive = getPropertyValueContentByLabel(componentProperty.properties, "is-interactive");
4178
4192
  isInteractive ??= true;
4179
4193
  let isControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "controls-displayed");
@@ -4191,7 +4205,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4191
4205
  const boundElementPropertyUuid = getPropertyByLabel(componentProperty.properties, "bound-element")?.values[0]?.uuid ?? null;
4192
4206
  const linkToProperty = getPropertyByLabel(componentProperty.properties, "link-to");
4193
4207
  const href = linkToProperty?.values[0]?.href != null ? transformPermanentIdentificationUrl(linkToProperty.values[0].href) : linkToProperty?.values[0]?.slug ?? null;
4194
- if (boundElementPropertyUuid == null && href == null) throw new Error(`Bound element or href not found for the following component: “${componentName}”`);
4208
+ if (boundElementPropertyUuid == null && href == null) throw new Error(formatComponentError("Bound element or href not found", componentName, elementResource));
4195
4209
  properties = {
4196
4210
  component: "advanced-search",
4197
4211
  boundElementUuid: boundElementPropertyUuid,
@@ -4201,7 +4215,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4201
4215
  }
4202
4216
  case "annotated-document": {
4203
4217
  const documentLink = links.find((link) => link.type === "internalDocument");
4204
- if (documentLink?.uuid == null) throw new Error(`Document link not found for the following component: “${componentName}”`);
4218
+ if (documentLink?.uuid == null) throw new Error(formatComponentError("Document link not found", componentName, elementResource));
4205
4219
  properties = {
4206
4220
  component: "annotated-document",
4207
4221
  linkUuid: documentLink.uuid
@@ -4210,7 +4224,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4210
4224
  }
4211
4225
  case "annotated-image": {
4212
4226
  const imageLinks = links.filter((link) => link.type === "image" || link.type === "IIIF");
4213
- if (imageLinks.length === 0 || imageLinks[0].uuid == null) throw new Error(`Image link not found for the following component: “${componentName}”`);
4227
+ if (imageLinks.length === 0 || imageLinks[0].uuid == null) throw new Error(formatComponentError("Image link not found", componentName, elementResource));
4214
4228
  let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
4215
4229
  isFilterInputDisplayed ??= true;
4216
4230
  let isOptionsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "options-displayed");
@@ -4231,7 +4245,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4231
4245
  }
4232
4246
  case "audio-player": {
4233
4247
  const audioLink = links.find((link) => link.type === "audio");
4234
- if (audioLink?.uuid == null) throw new Error(`Audio link not found for the following component: “${componentName}”`);
4248
+ if (audioLink?.uuid == null) throw new Error(formatComponentError("Audio link not found", componentName, elementResource));
4235
4249
  let isSpeedControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "speed-controls-displayed");
4236
4250
  isSpeedControlsDisplayed ??= true;
4237
4251
  let isVolumeControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "volume-controls-displayed");
@@ -4250,7 +4264,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4250
4264
  case "bibliography": {
4251
4265
  const itemLinks = links.filter((link) => link.category !== "bibliography");
4252
4266
  const bibliographyLink = links.find((link) => link.category === "bibliography");
4253
- if (itemLinks.length === 0 && bibliographyLink?.bibliographies == null) throw new Error(`No links found for the following component: “${componentName}”`);
4267
+ if (itemLinks.length === 0 && bibliographyLink?.bibliographies == null) throw new Error(formatComponentError("No links found", componentName, elementResource));
4254
4268
  let layout = getPropertyValueContentByLabel(componentProperty.properties, "layout");
4255
4269
  layout ??= "long";
4256
4270
  let isSourceDocumentDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "source-document-displayed");
@@ -4273,7 +4287,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4273
4287
  if (href === null) {
4274
4288
  const linkToProperty = getPropertyByLabel(componentProperty.properties, "link-to");
4275
4289
  href = linkToProperty?.values[0]?.href != null ? transformPermanentIdentificationUrl(linkToProperty.values[0].href) : linkToProperty?.values[0]?.slug ?? null;
4276
- if (href === null) throw new Error(`Properties “navigate-to” or “link-to” not found for the following component: “${componentName}”`);
4290
+ if (href === null) throw new Error(formatComponentError("Properties “navigate-to” or “link-to” not found", componentName, elementResource));
4277
4291
  else isExternal = true;
4278
4292
  }
4279
4293
  let startIcon = getPropertyValueContentByLabel(componentProperty.properties, "start-icon");
@@ -4304,7 +4318,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4304
4318
  }
4305
4319
  case "collection": {
4306
4320
  const setLinks = links.filter((link) => link.category === "set");
4307
- if (setLinks.every((link) => link.uuid === null)) throw new Error(`Set links not found for the following component: “${componentName}”`);
4321
+ if (setLinks.every((link) => link.uuid === null)) throw new Error(formatComponentError("Set links not found", componentName, elementResource));
4308
4322
  const displayedProperties = getPropertyByLabel(componentProperty.properties, "use-property");
4309
4323
  let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
4310
4324
  variant ??= "slide";
@@ -4383,7 +4397,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4383
4397
  }
4384
4398
  case "entries": {
4385
4399
  const entriesLink = links.find((link) => link.category === "tree" || link.category === "set");
4386
- if (entriesLink?.uuid == null) throw new Error(`Entries link not found for the following component: “${componentName}”`);
4400
+ if (entriesLink?.uuid == null) throw new Error(formatComponentError("Entries link not found", componentName, elementResource));
4387
4401
  let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
4388
4402
  variant ??= "entry";
4389
4403
  let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
@@ -4398,7 +4412,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4398
4412
  }
4399
4413
  case "iframe": {
4400
4414
  const href = links.find((link) => link.type === "webpage")?.href;
4401
- if (!href) throw new Error(`URL not found for the following component: “${componentName}”`);
4415
+ if (!href) throw new Error(formatComponentError("URL not found", componentName, elementResource));
4402
4416
  const height = getPropertyValueContentByLabel(componentProperty.properties, "height");
4403
4417
  const width = getPropertyValueContentByLabel(componentProperty.properties, "width");
4404
4418
  properties = {
@@ -4411,7 +4425,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4411
4425
  }
4412
4426
  case "iiif-viewer": {
4413
4427
  const manifestLink = links.find((link) => link.type === "IIIF");
4414
- if (manifestLink?.uuid == null) throw new Error(`Manifest link not found for the following component: “${componentName}”`);
4428
+ if (manifestLink?.uuid == null) throw new Error(formatComponentError("Manifest link not found", componentName, elementResource));
4415
4429
  let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
4416
4430
  variant ??= "universal-viewer";
4417
4431
  properties = {
@@ -4422,7 +4436,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4422
4436
  break;
4423
4437
  }
4424
4438
  case "image": {
4425
- if (links.length === 0) throw new Error(`No links found for the following component: “${componentName}”`);
4439
+ if (links.length === 0) throw new Error(formatComponentError("No links found", componentName, elementResource));
4426
4440
  let imageQuality = getPropertyValueContentByLabel(componentProperty.properties, "image-quality");
4427
4441
  imageQuality ??= "high";
4428
4442
  const images = [];
@@ -4510,7 +4524,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4510
4524
  }
4511
4525
  case "image-gallery": {
4512
4526
  const galleryLink = links.find((link) => link.category === "tree" || link.category === "set");
4513
- if (galleryLink?.uuid == null) throw new Error(`Image gallery link not found for the following component: “${componentName}”`);
4527
+ if (galleryLink?.uuid == null) throw new Error(formatComponentError("Image gallery link not found", componentName, elementResource));
4514
4528
  let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
4515
4529
  isFilterInputDisplayed ??= true;
4516
4530
  properties = {
@@ -4522,7 +4536,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4522
4536
  }
4523
4537
  case "map": {
4524
4538
  const mapLink = links.find((link) => link.category === "set" || link.category === "tree");
4525
- if (mapLink?.uuid == null) throw new Error(`Map link not found for the following component: “${componentName}”`);
4539
+ if (mapLink?.uuid == null) throw new Error(formatComponentError("Map link not found", componentName, elementResource));
4526
4540
  let isInteractive = getPropertyValueContentByLabel(componentProperty.properties, "is-interactive");
4527
4541
  isInteractive ??= true;
4528
4542
  let isClustered = getPropertyValueContentByLabel(componentProperty.properties, "is-clustered");
@@ -4557,17 +4571,17 @@ function parseWebElementProperties(componentProperty, elementResource) {
4557
4571
  }
4558
4572
  case "query": {
4559
4573
  const setLinks = links.filter((link) => link.category === "set");
4560
- if (setLinks.every((link) => link.uuid === null)) throw new Error(`Set links not found for the following component: “${componentName}”`);
4574
+ if (setLinks.every((link) => link.uuid === null)) throw new Error(formatComponentError("Set links not found", componentName, elementResource));
4561
4575
  const items = [];
4562
- if (componentProperty.properties.length === 0) throw new Error(`Query properties not found for the following component: “${componentName}”`);
4576
+ if (componentProperty.properties.length === 0) throw new Error(formatComponentError("Query properties not found", componentName, elementResource));
4563
4577
  for (const queryItem of componentProperty.properties) {
4564
4578
  const querySubProperties = queryItem.properties;
4565
4579
  const label = getPropertyValueContentByLabel(querySubProperties, "query-prompt");
4566
4580
  if (label === null) continue;
4567
4581
  const queries = (getPropertyByLabel(querySubProperties, "use-property")?.values.filter((value) => value.uuid !== null) ?? []).map((propertyVariable) => {
4568
- if (propertyVariable.uuid === null) throw new Error(`Property variable UUID not found for the following component: “${componentName}”`);
4582
+ if (propertyVariable.uuid === null) throw new Error(formatComponentError("Property variable UUID not found", componentName, elementResource));
4569
4583
  const dataType = propertyVariable.dataType;
4570
- if (dataType === "coordinate") throw new Error(`Query prompts with data type "coordinate" are not supported for the following component: “${componentName}”`);
4584
+ if (dataType === "coordinate") throw new Error(formatComponentError("Query prompts with data type \"coordinate\" are not supported", componentName, elementResource));
4571
4585
  return {
4572
4586
  target: "property",
4573
4587
  propertyVariable: propertyVariable.uuid,
@@ -4588,7 +4602,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4588
4602
  endIcon
4589
4603
  });
4590
4604
  }
4591
- if (items.length === 0) throw new Error(`No queries found for the following component: “${componentName}”`);
4605
+ if (items.length === 0) throw new Error(formatComponentError("No queries found", componentName, elementResource));
4592
4606
  const options = {
4593
4607
  scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
4594
4608
  uuid: scope.uuid.content,
@@ -4634,7 +4648,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4634
4648
  }
4635
4649
  case "table": {
4636
4650
  const tableLink = links.find((link) => link.category === "set");
4637
- if (tableLink?.uuid == null) throw new Error(`Table link not found for the following component: “${componentName}”`);
4651
+ if (tableLink?.uuid == null) throw new Error(formatComponentError("Table link not found", componentName, elementResource));
4638
4652
  properties = {
4639
4653
  component: "table",
4640
4654
  linkUuid: tableLink.uuid
@@ -4648,7 +4662,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4648
4662
  const boundElementUuid = getPropertyByLabel(componentProperty.properties, "bound-element")?.values[0]?.uuid ?? null;
4649
4663
  const linkToProperty = getPropertyByLabel(componentProperty.properties, "link-to");
4650
4664
  const href = linkToProperty?.values[0]?.href != null ? transformPermanentIdentificationUrl(linkToProperty.values[0].href) : linkToProperty?.values[0]?.slug ?? null;
4651
- if (!boundElementUuid && !href) throw new Error(`Bound element or href not found for the following component: “${componentName}”`);
4665
+ if (!boundElementUuid && !href) throw new Error(formatComponentError("Bound element or href not found", componentName, elementResource));
4652
4666
  let placeholder = getPropertyValueContentByLabel(componentProperty.properties, "placeholder-text");
4653
4667
  placeholder ??= null;
4654
4668
  let baseFilterQueries = getPropertyValueContentByLabel(componentProperty.properties, "base-filter-queries");
@@ -4665,7 +4679,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4665
4679
  }
4666
4680
  case "text": {
4667
4681
  const content = elementResource.document && "content" in elementResource.document ? parseDocument(elementResource.document.content) : null;
4668
- if (!content) throw new Error(`Content not found for the following component: “${componentName}”`);
4682
+ if (!content) throw new Error(formatComponentError("Content not found", componentName, elementResource));
4669
4683
  let variantName = "block";
4670
4684
  let variant;
4671
4685
  const variantProperty = getPropertyByLabel(componentProperty.properties, "variant");
@@ -4692,7 +4706,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4692
4706
  }
4693
4707
  case "timeline": {
4694
4708
  const timelineLink = links.find((link) => link.category === "tree");
4695
- if (timelineLink?.uuid == null) throw new Error(`Timeline link not found for the following component: “${componentName}”`);
4709
+ if (timelineLink?.uuid == null) throw new Error(formatComponentError("Timeline link not found", componentName, elementResource));
4696
4710
  properties = {
4697
4711
  component: "timeline",
4698
4712
  linkUuid: timelineLink.uuid
@@ -4701,7 +4715,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4701
4715
  }
4702
4716
  case "video": {
4703
4717
  const videoLink = links.find((link) => link.type === "video");
4704
- if (videoLink?.uuid == null) throw new Error(`Video link not found for the following component: “${componentName}”`);
4718
+ if (videoLink?.uuid == null) throw new Error(formatComponentError("Video link not found", componentName, elementResource));
4705
4719
  let isChaptersDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "chapters-displayed");
4706
4720
  isChaptersDisplayed ??= true;
4707
4721
  properties = {
@@ -4715,7 +4729,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
4715
4729
  console.warn(`Invalid or non-implemented component name “${unparsedComponentName?.toString() ?? "(unknown)"}” for the following element: “${parseStringContent(elementResource.identification.label)}”`);
4716
4730
  break;
4717
4731
  }
4718
- if (properties === null) throw new Error(`Properties not found for the following component: “${componentName}”`);
4732
+ if (properties === null) throw new Error(formatComponentError("Properties not found", componentName, elementResource));
4719
4733
  return properties;
4720
4734
  }
4721
4735
  function parseWebTitle(properties, identification, overrides) {
@@ -4751,9 +4765,9 @@ function parseWebElement(elementResource) {
4751
4765
  const identification = parseIdentification(elementResource.identification);
4752
4766
  const elementProperties = elementResource.properties?.property ? parseProperties(Array.isArray(elementResource.properties.property) ? elementResource.properties.property : [elementResource.properties.property]) : [];
4753
4767
  const presentationProperty = getPropertyByLabel(elementProperties, "presentation");
4754
- if (presentationProperty === null) throw new Error(`Presentation property not found for element “${identification.label}”`);
4768
+ if (presentationProperty === null) throw new Error(`Presentation property not found for element (${formatRawResourceMetadata(elementResource)})`);
4755
4769
  const componentProperty = getPropertyByLabel(presentationProperty.properties, "component");
4756
- if (componentProperty === null) throw new Error(`Component for element “${identification.label}” not found`);
4770
+ if (componentProperty === null) throw new Error(`Component property not found for element (${formatRawResourceMetadata(elementResource)})`);
4757
4771
  const properties = parseWebElementProperties(componentProperty, elementResource);
4758
4772
  const cssStyles = parseResponsiveCssStyles(elementProperties);
4759
4773
  const title = parseWebTitle(elementProperties, identification, {
@@ -4810,7 +4824,7 @@ function parseWebpage(webpageResource, slugPrefix) {
4810
4824
  if (webpageProperties.length === 0 || getPropertyValueContentByLabel(webpageProperties, "presentation") !== "page") return null;
4811
4825
  const identification = parseIdentification(webpageResource.identification);
4812
4826
  const slug = webpageResource.slug?.replace(SEGMENT_UNIQUE_SLUG_PREFIX_REGEX, "") ?? null;
4813
- if (slug == null) throw new Error(`Slug not found for page “${identification.label}”`);
4827
+ if (slug == null) throw new Error(`Slug not found for page (${formatRawResourceMetadata(webpageResource)})`);
4814
4828
  const returnWebpage = {
4815
4829
  uuid: webpageResource.uuid,
4816
4830
  type: "page",
@@ -4905,7 +4919,7 @@ function parseWebSegment(segmentResource, slugPrefix) {
4905
4919
  if (webpageProperties.length === 0 || getPropertyValueContentByLabel(webpageProperties, "presentation") !== "segment") return null;
4906
4920
  const identification = parseIdentification(segmentResource.identification);
4907
4921
  const slug = segmentResource.identification.abbreviation != null ? parseFakeStringOrContent(segmentResource.identification.abbreviation) : null;
4908
- if (slug == null) throw new Error(`Slug not found for segment “${identification.label}”`);
4922
+ if (slug == null) throw new Error(`Slug not found for segment (${formatRawResourceMetadata(segmentResource)})`);
4909
4923
  const returnSegment = {
4910
4924
  uuid: segmentResource.uuid,
4911
4925
  type: "segment",
@@ -4942,7 +4956,7 @@ function parseWebSegmentItem(segmentItemResource, slugPrefix) {
4942
4956
  if (webpageProperties.length === 0 || getPropertyValueContentByLabel(webpageProperties, "presentation") !== "segment-item") return null;
4943
4957
  const identification = parseIdentification(segmentItemResource.identification);
4944
4958
  const slug = segmentItemResource.identification.abbreviation != null ? parseFakeStringOrContent(segmentItemResource.identification.abbreviation) : null;
4945
- if (slug == null) throw new Error(`Slug not found for segment item “${identification.label}”`);
4959
+ if (slug == null) throw new Error(`Slug not found for segment item (${formatRawResourceMetadata(segmentItemResource)})`);
4946
4960
  const returnSegmentItem = {
4947
4961
  uuid: segmentItemResource.uuid,
4948
4962
  type: "segment-item",
@@ -5168,9 +5182,9 @@ function parseWebBlock(blockResource) {
5168
5182
  for (const resource of blockResources) {
5169
5183
  const resourceProperties = resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [];
5170
5184
  const resourceType = getPropertyValueContentByLabel(resourceProperties, "presentation");
5171
- if (resourceType !== "element") throw new Error(`Accordion only accepts elements, but got “${resourceType}” for the following resource: “${parseStringContent(resource.identification.label)}”`);
5185
+ if (resourceType !== "element") throw new Error(`Accordion only accepts elements, but got “${resourceType}” (${formatRawResourceMetadata(resource)})`);
5172
5186
  const componentType = getPropertyValueContentByLabel(getPropertyByLabel(resourceProperties, "presentation")?.properties ?? [], "component");
5173
- if (componentType !== "text") throw new Error(`Accordion only accepts text components, but got “${componentType}” for the following resource: “${parseStringContent(resource.identification.label)}”`);
5187
+ if (componentType !== "text") throw new Error(`Accordion only accepts text components, but got “${componentType}” (${formatRawResourceMetadata(resource)})`);
5174
5188
  const element = parseWebElementForAccordion(resource);
5175
5189
  accordionItems.push(element);
5176
5190
  }
@@ -5269,7 +5283,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
5269
5283
  name: contactContent[0],
5270
5284
  email: contactContent[1] ?? null
5271
5285
  };
5272
- else throw new Error(`Contact property must be in the format “name;email”, but got “${contactProperty.values[0]?.content}”`);
5286
+ else throw new Error(`Contact property must use “name;email”, got “${contactProperty.values[0]?.content}” (website uuid “${websiteTree.uuid}”)`);
5273
5287
  }
5274
5288
  returnProperties.loadingVariant = getPropertyValueContentByLabel(websiteProperties, "loading-variant") ?? "spinner";
5275
5289
  returnProperties.theme.isThemeToggleDisplayed = getPropertyValueContentByLabel(websiteProperties, "supports-theme-toggle") ?? true;
@@ -5389,8 +5403,8 @@ function parseFilterContexts(filterContextLevels) {
5389
5403
  return filterContextTreeLevels;
5390
5404
  }
5391
5405
  function parseWebsite(websiteTree, metadata, belongsTo, { version = 2 } = {}) {
5392
- if (!websiteTree.properties) throw new Error("Website properties not found");
5393
- if (typeof websiteTree.items === "string" || !("resource" in websiteTree.items)) throw new Error("Website pages not found");
5406
+ if (!websiteTree.properties) throw new Error(`Website properties not found (website uuid “${websiteTree.uuid}”)`);
5407
+ if (typeof websiteTree.items === "string" || !("resource" in websiteTree.items)) throw new Error(`Website pages not found (website uuid “${websiteTree.uuid}”)`);
5394
5408
  const resources = ensureArray(websiteTree.items.resource);
5395
5409
  const items = [...parseWebpages(resources), ...parseSegments(resources)];
5396
5410
  const sidebar = parseSidebar(resources);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "0.22.20",
3
+ "version": "0.22.21",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",