@digitalculture/ochre-sdk 0.17.13 → 0.17.15

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
@@ -710,8 +710,14 @@ type Website = {
710
710
  defaultTheme: "light" | "dark" | null;
711
711
  logoUrl: string | null;
712
712
  itemPage: {
713
- iiifViewer: "universal-viewer" | "clover";
713
+ isMainContentDisplayed: boolean;
714
+ isDescriptionDisplayed: boolean;
715
+ isDocumentDisplayed: boolean;
716
+ isNotesDisplayed: boolean;
717
+ isPropertiesDisplayed: boolean;
718
+ isBibliographyDisplayed: boolean;
714
719
  isPropertyValuesGrouped: boolean;
720
+ iiifViewer: "universal-viewer" | "clover";
715
721
  };
716
722
  options: {
717
723
  contexts: PropertyContexts | null;
@@ -725,6 +731,7 @@ type Website = {
725
731
  type Webpage = {
726
732
  title: string;
727
733
  slug: string;
734
+ publicationDateTime: Date | null;
728
735
  properties: {
729
736
  displayedInHeader: boolean;
730
737
  width: "full" | "large" | "narrow" | "default";
@@ -950,7 +957,7 @@ type WebElementComponent = {
950
957
  timelineId: string;
951
958
  } | {
952
959
  component: "video";
953
- isChaptersDislayed: boolean;
960
+ isChaptersDisplayed: boolean;
954
961
  };
955
962
  /**
956
963
  * Represents an image used in web elements
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as z from "zod";
2
+ import { UTCDate } from "@date-fns/utc";
3
+ import { parseISO, set } from "date-fns";
2
4
 
3
5
  //#region src/utils/internal.ts
4
6
  /**
@@ -1116,7 +1118,7 @@ function parseMetadata(metadata) {
1116
1118
  function parseContextItem(contextItem) {
1117
1119
  return {
1118
1120
  uuid: contextItem.uuid,
1119
- publicationDateTime: contextItem.publicationDateTime != null ? new Date(contextItem.publicationDateTime) : null,
1121
+ publicationDateTime: contextItem.publicationDateTime != null ? parseISO(contextItem.publicationDateTime) : null,
1120
1122
  number: contextItem.n,
1121
1123
  content: parseFakeString(contextItem.content)
1122
1124
  };
@@ -1169,7 +1171,7 @@ function parsePerson(person, metadata, persistentUrl, belongsTo) {
1169
1171
  category: "person",
1170
1172
  belongsTo: belongsTo ?? null,
1171
1173
  metadata: metadata ?? null,
1172
- publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
1174
+ publicationDateTime: person.publicationDateTime != null ? parseISO(person.publicationDateTime) : null,
1173
1175
  persistentUrl: persistentUrl ?? null,
1174
1176
  type: person.type ?? null,
1175
1177
  number: person.n ?? null,
@@ -1228,7 +1230,7 @@ function parseLink(linkRaw) {
1228
1230
  description: "description" in link && link.description != null ? parseStringContent(link.description) : null,
1229
1231
  image: null,
1230
1232
  bibliographies: "bibliography" in linkRaw ? parseBibliographies(Array.isArray(linkRaw.bibliography) ? linkRaw.bibliography : [linkRaw.bibliography]) : null,
1231
- publicationDateTime: link.publicationDateTime != null ? new Date(link.publicationDateTime) : null
1233
+ publicationDateTime: link.publicationDateTime != null ? parseISO(link.publicationDateTime) : null
1232
1234
  };
1233
1235
  if ("height" in link && link.height != null && link.width != null && link.heightPreview != null && link.widthPreview != null) returnLink.image = {
1234
1236
  isInline: link.rend === "inline",
@@ -1278,7 +1280,7 @@ function parseDocument(document, language = "eng") {
1278
1280
  */
1279
1281
  function parseImage(image) {
1280
1282
  return {
1281
- publicationDateTime: image.publicationDateTime != null ? new Date(image.publicationDateTime) : null,
1283
+ publicationDateTime: image.publicationDateTime != null ? parseISO(image.publicationDateTime) : null,
1282
1284
  identification: image.identification ? parseIdentification(image.identification) : null,
1283
1285
  url: image.href ?? (image.htmlImgSrcPrefix == null && image.content != null ? parseFakeString(image.content) : null),
1284
1286
  htmlPrefix: image.htmlImgSrcPrefix ?? null,
@@ -1424,17 +1426,17 @@ function parseObservations(observations) {
1424
1426
  function parseEvents(events) {
1425
1427
  const returnEvents = [];
1426
1428
  for (const event of events) returnEvents.push({
1427
- dateTime: event.dateTime != null ? new Date(event.dateTime) : null,
1429
+ dateTime: event.dateTime != null ? parseISO(event.dateTime) : null,
1428
1430
  date: event.partialDates?.year != null ? `${event.partialDates.year}-01-01/${event.partialDates.endYear ?? event.partialDates.year}-12-31` : null,
1429
1431
  label: parseStringContent(event.label),
1430
1432
  location: event.location ? {
1431
1433
  uuid: event.location.uuid,
1432
- publicationDateTime: event.location.publicationDateTime != null ? new Date(event.location.publicationDateTime) : null,
1434
+ publicationDateTime: event.location.publicationDateTime != null ? parseISO(event.location.publicationDateTime) : null,
1433
1435
  content: parseStringContent(event.location)
1434
1436
  } : null,
1435
1437
  agent: event.agent ? {
1436
1438
  uuid: event.agent.uuid,
1437
- publicationDateTime: event.agent.publicationDateTime != null ? new Date(event.agent.publicationDateTime) : null,
1439
+ publicationDateTime: event.agent.publicationDateTime != null ? parseISO(event.agent.publicationDateTime) : null,
1438
1440
  content: parseStringContent(event.agent)
1439
1441
  } : null,
1440
1442
  comment: event.comment ? parseStringContent(event.comment) : null,
@@ -1524,7 +1526,7 @@ function parseProperty(property, language = "eng") {
1524
1526
  category: value.category ?? null,
1525
1527
  type: value.type ?? null,
1526
1528
  uuid: value.uuid ?? null,
1527
- publicationDateTime: value.publicationDateTime != null ? new Date(value.publicationDateTime) : null,
1529
+ publicationDateTime: value.publicationDateTime != null ? parseISO(value.publicationDateTime) : null,
1528
1530
  unit: value.unit ?? null,
1529
1531
  height: value.height ?? null,
1530
1532
  width: value.width ?? null,
@@ -1586,7 +1588,7 @@ function parseImageMap(imageMap) {
1586
1588
  const imageMapAreasToParse = Array.isArray(imageMap.area) ? imageMap.area : [imageMap.area];
1587
1589
  for (const area of imageMapAreasToParse) returnImageMap.area.push({
1588
1590
  uuid: area.uuid,
1589
- publicationDateTime: area.publicationDateTime != null ? new Date(area.publicationDateTime) : null,
1591
+ publicationDateTime: area.publicationDateTime != null ? parseISO(area.publicationDateTime) : null,
1590
1592
  category: area.type,
1591
1593
  title: parseFakeString(area.title),
1592
1594
  shape: area.shape === "rect" ? "rectangle" : area.shape === "circle" ? "circle" : "polygon",
@@ -1607,7 +1609,7 @@ function parsePeriod(period, metadata, persistentUrl, belongsTo) {
1607
1609
  category: "period",
1608
1610
  belongsTo: belongsTo ?? null,
1609
1611
  metadata: metadata ?? null,
1610
- publicationDateTime: period.publicationDateTime != null ? new Date(period.publicationDateTime) : null,
1612
+ publicationDateTime: period.publicationDateTime != null ? parseISO(period.publicationDateTime) : null,
1611
1613
  persistentUrl: persistentUrl ?? null,
1612
1614
  type: period.type ?? null,
1613
1615
  number: period.n ?? null,
@@ -1640,7 +1642,7 @@ function parseBibliography(bibliography, metadata, persistentUrl, belongsTo) {
1640
1642
  for (const resource of resourcesToParse) sourceResources.push({
1641
1643
  uuid: resource.uuid,
1642
1644
  category: "resource",
1643
- publicationDateTime: new Date(resource.publicationDateTime),
1645
+ publicationDateTime: parseISO(resource.publicationDateTime),
1644
1646
  type: resource.type,
1645
1647
  identification: parseIdentification(resource.identification),
1646
1648
  href: resource.href ?? null
@@ -1664,7 +1666,7 @@ function parseBibliography(bibliography, metadata, persistentUrl, belongsTo) {
1664
1666
  zoteroId: bibliography.zoteroId ?? null,
1665
1667
  category: "bibliography",
1666
1668
  metadata: metadata ?? null,
1667
- publicationDateTime: bibliography.publicationDateTime != null ? new Date(bibliography.publicationDateTime) : null,
1669
+ publicationDateTime: bibliography.publicationDateTime != null ? parseISO(bibliography.publicationDateTime) : null,
1668
1670
  persistentUrl: persistentUrl ?? null,
1669
1671
  type: bibliography.type ?? null,
1670
1672
  number: bibliography.n ?? null,
@@ -1680,7 +1682,11 @@ function parseBibliography(bibliography, metadata, persistentUrl, belongsTo) {
1680
1682
  },
1681
1683
  publicationInfo: {
1682
1684
  publishers: bibliography.publicationInfo?.publishers ? parsePersons(Array.isArray(bibliography.publicationInfo.publishers.publishers.person) ? bibliography.publicationInfo.publishers.publishers.person : [bibliography.publicationInfo.publishers.publishers.person]) : [],
1683
- startDate: bibliography.publicationInfo?.startDate ? new Date(bibliography.publicationInfo.startDate.year, bibliography.publicationInfo.startDate.month, bibliography.publicationInfo.startDate.day) : null
1685
+ startDate: bibliography.publicationInfo?.startDate ? set(new UTCDate(0, 0, 0, 0, 0, 0, 0), {
1686
+ year: bibliography.publicationInfo.startDate.year,
1687
+ month: bibliography.publicationInfo.startDate.month,
1688
+ date: bibliography.publicationInfo.startDate.day
1689
+ }) : null
1684
1690
  },
1685
1691
  entryInfo: bibliography.entryInfo ? {
1686
1692
  startIssue: parseFakeString(bibliography.entryInfo.startIssue),
@@ -1718,7 +1724,7 @@ function parsePropertyValue(propertyValue, metadata, persistentUrl, belongsTo) {
1718
1724
  belongsTo: belongsTo ?? null,
1719
1725
  metadata: metadata ?? null,
1720
1726
  number: propertyValue.n,
1721
- publicationDateTime: propertyValue.publicationDateTime ? new Date(propertyValue.publicationDateTime) : null,
1727
+ publicationDateTime: propertyValue.publicationDateTime ? parseISO(propertyValue.publicationDateTime) : null,
1722
1728
  persistentUrl: persistentUrl ?? null,
1723
1729
  context: propertyValue.context ? parseContext(propertyValue.context) : null,
1724
1730
  availability: propertyValue.availability ? parseLicense(propertyValue.availability) : null,
@@ -1754,7 +1760,7 @@ function parseText(text, metadata, persistentUrl, belongsTo) {
1754
1760
  category: "text",
1755
1761
  belongsTo: belongsTo ?? null,
1756
1762
  metadata: metadata ?? null,
1757
- publicationDateTime: text.publicationDateTime ? new Date(text.publicationDateTime) : null,
1763
+ publicationDateTime: text.publicationDateTime ? parseISO(text.publicationDateTime) : null,
1758
1764
  persistentUrl: persistentUrl ?? null,
1759
1765
  type: text.type ?? null,
1760
1766
  language: text.language ?? null,
@@ -1883,7 +1889,7 @@ function parseTree(tree, itemCategories, metadata, persistentUrl, belongsTo) {
1883
1889
  category: "tree",
1884
1890
  belongsTo: belongsTo ?? null,
1885
1891
  metadata: metadata ?? null,
1886
- publicationDateTime: new Date(tree.publicationDateTime),
1892
+ publicationDateTime: parseISO(tree.publicationDateTime),
1887
1893
  persistentUrl: persistentUrl ?? null,
1888
1894
  identification: parseIdentification(tree.identification),
1889
1895
  creators,
@@ -1957,7 +1963,7 @@ function parseSet(set, itemCategories, metadata, persistentUrl, belongsTo) {
1957
1963
  belongsTo: belongsTo ?? null,
1958
1964
  metadata: metadata ?? null,
1959
1965
  itemCategories: parsedItemCategories,
1960
- publicationDateTime: set.publicationDateTime ? new Date(set.publicationDateTime) : null,
1966
+ publicationDateTime: set.publicationDateTime ? parseISO(set.publicationDateTime) : null,
1961
1967
  persistentUrl: persistentUrl ?? null,
1962
1968
  date: set.date ?? null,
1963
1969
  license: parseLicense(set.availability),
@@ -1997,7 +2003,7 @@ function parseResource(resource, metadata, persistentUrl, belongsTo) {
1997
2003
  category: "resource",
1998
2004
  belongsTo: belongsTo ?? null,
1999
2005
  metadata: metadata ?? null,
2000
- publicationDateTime: resource.publicationDateTime ? new Date(resource.publicationDateTime) : null,
2006
+ publicationDateTime: resource.publicationDateTime ? parseISO(resource.publicationDateTime) : null,
2001
2007
  persistentUrl: persistentUrl ?? null,
2002
2008
  type: resource.type,
2003
2009
  number: resource.n,
@@ -2053,7 +2059,7 @@ function parseSpatialUnit(spatialUnit, metadata, persistentUrl, belongsTo) {
2053
2059
  category: "spatialUnit",
2054
2060
  belongsTo: belongsTo ?? null,
2055
2061
  metadata: metadata ?? null,
2056
- publicationDateTime: spatialUnit.publicationDateTime != null ? new Date(spatialUnit.publicationDateTime) : null,
2062
+ publicationDateTime: spatialUnit.publicationDateTime != null ? parseISO(spatialUnit.publicationDateTime) : null,
2057
2063
  persistentUrl: persistentUrl ?? null,
2058
2064
  number: spatialUnit.n,
2059
2065
  context: "context" in spatialUnit && spatialUnit.context ? parseContext(spatialUnit.context) : null,
@@ -2097,7 +2103,7 @@ function parseConcept(concept, metadata, persistentUrl, belongsTo) {
2097
2103
  category: "concept",
2098
2104
  belongsTo: belongsTo ?? null,
2099
2105
  metadata: metadata ?? null,
2100
- publicationDateTime: concept.publicationDateTime ? new Date(concept.publicationDateTime) : null,
2106
+ publicationDateTime: concept.publicationDateTime ? parseISO(concept.publicationDateTime) : null,
2101
2107
  persistentUrl: persistentUrl ?? null,
2102
2108
  number: concept.n,
2103
2109
  license: "availability" in concept && concept.availability ? parseLicense(concept.availability) : null,
@@ -2645,10 +2651,10 @@ function parseWebElementProperties(componentProperty, elementResource) {
2645
2651
  case "video": {
2646
2652
  const videoLink = links.find((link) => link.type === "video");
2647
2653
  if (!videoLink) throw new Error(`Video link not found for the following component: “${componentName}”`);
2648
- let isChaptersDislayed = getPropertyValueByLabel(componentProperty.properties, "chapters-displayed");
2649
- isChaptersDislayed ??= true;
2654
+ let isChaptersDisplayed = getPropertyValueByLabel(componentProperty.properties, "chapters-displayed");
2655
+ isChaptersDisplayed ??= true;
2650
2656
  properties.videoId = videoLink.uuid;
2651
- properties.isChaptersDislayed = isChaptersDislayed === true;
2657
+ properties.isChaptersDisplayed = isChaptersDisplayed === true;
2652
2658
  break;
2653
2659
  }
2654
2660
  default:
@@ -2821,6 +2827,7 @@ function parseWebpage(webpageResource) {
2821
2827
  return {
2822
2828
  title: identification.label,
2823
2829
  slug,
2830
+ publicationDateTime: webpageResource.publicationDateTime ? parseISO(webpageResource.publicationDateTime) : null,
2824
2831
  items,
2825
2832
  properties: {
2826
2833
  displayedInHeader,
@@ -3163,10 +3170,16 @@ function parseWebsiteProperties(properties, websiteTree) {
3163
3170
  let isHeaderProjectDisplayed = true;
3164
3171
  let isFooterDisplayed = true;
3165
3172
  let isSidebarDisplayed = false;
3166
- let iiifViewer = "universal-viewer";
3167
- let isPropertyValuesGrouped = true;
3168
3173
  let supportsThemeToggle = true;
3169
3174
  let defaultTheme = null;
3175
+ let isMainContentDisplayed = true;
3176
+ let isDescriptionDisplayed = true;
3177
+ let isDocumentDisplayed = true;
3178
+ let isNotesDisplayed = true;
3179
+ let isPropertiesDisplayed = true;
3180
+ let isBibliographyDisplayed = true;
3181
+ let isPropertyValuesGrouped = true;
3182
+ let iiifViewer = "universal-viewer";
3170
3183
  const headerProperty = websiteProperties.find((property) => property.label === "navbar-displayed")?.values[0];
3171
3184
  if (headerProperty) isHeaderDisplayed = headerProperty.content === true;
3172
3185
  const headerVariantProperty = websiteProperties.find((property) => property.label === "navbar-variant")?.values[0];
@@ -3180,10 +3193,25 @@ function parseWebsiteProperties(properties, websiteTree) {
3180
3193
  const sidebarProperty = websiteProperties.find((property) => property.label === "sidebar-displayed")?.values[0];
3181
3194
  if (sidebarProperty) isSidebarDisplayed = sidebarProperty.content === true;
3182
3195
  const headerSearchBarBoundElementUuid = websiteProperties.find((property) => property.label === "bound-element-navbar-search-bar")?.values[0]?.uuid ?? null;
3183
- const iiifViewerProperty = websiteProperties.find((property) => property.label === "iiif-viewer")?.values[0];
3184
- if (iiifViewerProperty) iiifViewer = iiifViewerProperty.content;
3185
- const isPropertyValuesGroupedProperty = websiteProperties.find((property) => property.label === "is-property-values-grouped")?.values[0];
3186
- if (isPropertyValuesGroupedProperty) isPropertyValuesGrouped = isPropertyValuesGroupedProperty.content === true;
3196
+ const itemPageTypeProperty = websiteProperties.find((property) => property.label === "page-type" && property.values[0]?.content === "item-page");
3197
+ if (itemPageTypeProperty) {
3198
+ const isItemPageMainContentDisplayedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-main-content-displayed")?.values[0];
3199
+ if (isItemPageMainContentDisplayedProperty) isMainContentDisplayed = isItemPageMainContentDisplayedProperty.content === true;
3200
+ const isItemPageDescriptionDisplayedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-description-displayed")?.values[0];
3201
+ if (isItemPageDescriptionDisplayedProperty) isDescriptionDisplayed = isItemPageDescriptionDisplayedProperty.content === true;
3202
+ const isItemPageDocumentDisplayedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-document-displayed")?.values[0];
3203
+ if (isItemPageDocumentDisplayedProperty) isDocumentDisplayed = isItemPageDocumentDisplayedProperty.content === true;
3204
+ const isItemPageNotesDisplayedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-notes-displayed")?.values[0];
3205
+ if (isItemPageNotesDisplayedProperty) isNotesDisplayed = isItemPageNotesDisplayedProperty.content === true;
3206
+ const isItemPagePropertiesDisplayedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-properties-displayed")?.values[0];
3207
+ if (isItemPagePropertiesDisplayedProperty) isPropertiesDisplayed = isItemPagePropertiesDisplayedProperty.content === true;
3208
+ const isItemPageBibliographyDisplayedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-bibliography-displayed")?.values[0];
3209
+ if (isItemPageBibliographyDisplayedProperty) isBibliographyDisplayed = isItemPageBibliographyDisplayedProperty.content === true;
3210
+ const isItemPagePropertyValuesGroupedProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-property-values-grouped")?.values[0];
3211
+ if (isItemPagePropertyValuesGroupedProperty) isPropertyValuesGrouped = isItemPagePropertyValuesGroupedProperty.content === true;
3212
+ const isItemPageIiifViewerProperty = itemPageTypeProperty.properties.find((property) => property.label === "item-page-iiif-viewer")?.values[0];
3213
+ if (isItemPageIiifViewerProperty) iiifViewer = isItemPageIiifViewerProperty.content;
3214
+ }
3187
3215
  const supportsThemeToggleProperty = websiteProperties.find((property) => property.label === "supports-theme-toggle")?.values[0];
3188
3216
  if (supportsThemeToggleProperty) supportsThemeToggle = supportsThemeToggleProperty.content === true;
3189
3217
  const defaultThemeProperty = websiteProperties.find((property) => property.label === "default-theme")?.values[0];
@@ -3232,8 +3260,14 @@ function parseWebsiteProperties(properties, websiteTree) {
3232
3260
  defaultTheme,
3233
3261
  logoUrl: logoUuid !== null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${logoUuid}&load` : null,
3234
3262
  itemPage: {
3235
- iiifViewer,
3236
- isPropertyValuesGrouped
3263
+ isMainContentDisplayed,
3264
+ isDescriptionDisplayed,
3265
+ isDocumentDisplayed,
3266
+ isNotesDisplayed,
3267
+ isPropertiesDisplayed,
3268
+ isBibliographyDisplayed,
3269
+ isPropertyValuesGrouped,
3270
+ iiifViewer
3237
3271
  },
3238
3272
  options: {
3239
3273
  contexts,
@@ -3287,7 +3321,7 @@ function parseWebsite(websiteTree, metadata, belongsTo, { version = DEFAULT_API_
3287
3321
  version,
3288
3322
  belongsTo: belongsTo ?? null,
3289
3323
  metadata: parseMetadata(metadata),
3290
- publicationDateTime: websiteTree.publicationDateTime ? new Date(websiteTree.publicationDateTime) : null,
3324
+ publicationDateTime: websiteTree.publicationDateTime ? parseISO(websiteTree.publicationDateTime) : null,
3291
3325
  identification: parseIdentification(websiteTree.identification),
3292
3326
  creators: websiteTree.creators ? parsePersons(Array.isArray(websiteTree.creators.creator) ? websiteTree.creators.creator : [websiteTree.creators.creator]) : [],
3293
3327
  license: parseLicense(websiteTree.availability),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.17.13",
3
+ "version": "0.17.15",
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",
@@ -40,6 +40,8 @@
40
40
  "dist"
41
41
  ],
42
42
  "dependencies": {
43
+ "@date-fns/utc": "^2.1.1",
44
+ "date-fns": "^4.1.0",
43
45
  "zod": "^4.3.6"
44
46
  },
45
47
  "devDependencies": {