@digitalculture/ochre-sdk 0.5.9 → 0.5.11

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.cjs CHANGED
@@ -62,6 +62,8 @@ __export(index_exports, {
62
62
  parsePerson: () => parsePerson,
63
63
  parsePersons: () => parsePersons,
64
64
  parseProperties: () => parseProperties,
65
+ parsePropertyValue: () => parsePropertyValue,
66
+ parsePropertyValues: () => parsePropertyValues,
65
67
  parseResource: () => parseResource,
66
68
  parseResources: () => parseResources,
67
69
  parseSet: () => parseSet,
@@ -571,10 +573,10 @@ var componentSchema = import_zod3.z.enum(
571
573
  "iiif-viewer",
572
574
  "image",
573
575
  "image-gallery",
574
- "item-gallery",
575
576
  "n-columns",
576
577
  "n-rows",
577
578
  "network-graph",
579
+ "search-bar",
578
580
  "table",
579
581
  "text",
580
582
  "timeline",
@@ -713,7 +715,7 @@ function parsePersons(persons) {
713
715
  return returnPersons;
714
716
  }
715
717
  function parseLink(linkRaw) {
716
- const links = "resource" in linkRaw ? linkRaw.resource : "spatialUnit" in linkRaw ? linkRaw.spatialUnit : "concept" in linkRaw ? linkRaw.concept : "set" in linkRaw ? linkRaw.set : "tree" in linkRaw ? linkRaw.tree : "person" in linkRaw ? linkRaw.person : "bibliography" in linkRaw ? linkRaw.bibliography : "epigraphicUnit" in linkRaw ? linkRaw.epigraphicUnit : null;
718
+ const links = "resource" in linkRaw ? linkRaw.resource : "spatialUnit" in linkRaw ? linkRaw.spatialUnit : "concept" in linkRaw ? linkRaw.concept : "set" in linkRaw ? linkRaw.set : "tree" in linkRaw ? linkRaw.tree : "person" in linkRaw ? linkRaw.person : "bibliography" in linkRaw ? linkRaw.bibliography : "epigraphicUnit" in linkRaw ? linkRaw.epigraphicUnit : "propertyValue" in linkRaw ? linkRaw.propertyValue : null;
717
719
  if (!links) {
718
720
  throw new Error(
719
721
  `Invalid link provided: ${JSON.stringify(linkRaw, null, 2)}`
@@ -723,7 +725,7 @@ function parseLink(linkRaw) {
723
725
  const returnLinks = [];
724
726
  for (const link of linksToParse) {
725
727
  const returnLink = {
726
- category: "resource" in linkRaw ? "resource" : "spatialUnit" in linkRaw ? "spatialUnit" : "concept" in linkRaw ? "concept" : "set" in linkRaw ? "set" : "person" in linkRaw ? "person" : "tree" in linkRaw ? "tree" : "bibliography" in linkRaw ? "bibliography" : "epigraphicUnit" in linkRaw ? "epigraphicUnit" : null,
728
+ category: "resource" in linkRaw ? "resource" : "spatialUnit" in linkRaw ? "spatialUnit" : "concept" in linkRaw ? "concept" : "set" in linkRaw ? "set" : "person" in linkRaw ? "person" : "tree" in linkRaw ? "tree" : "bibliography" in linkRaw ? "bibliography" : "epigraphicUnit" in linkRaw ? "epigraphicUnit" : "propertyValue" in linkRaw ? "propertyValue" : null,
727
729
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
728
730
  href: "href" in link && link.href != null ? link.href : null,
729
731
  uuid: link.uuid,
@@ -1018,6 +1020,31 @@ function parseBibliographies(bibliographies) {
1018
1020
  }
1019
1021
  return returnBibliographies;
1020
1022
  }
1023
+ function parsePropertyValue(propertyValue) {
1024
+ return {
1025
+ uuid: propertyValue.uuid,
1026
+ category: "propertyValue",
1027
+ n: propertyValue.n,
1028
+ publicationDateTime: propertyValue.publicationDateTime ? new Date(propertyValue.publicationDateTime) : null,
1029
+ identification: parseIdentification(propertyValue.identification),
1030
+ description: ["string", "number", "boolean"].includes(
1031
+ typeof propertyValue.description
1032
+ ) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description),
1033
+ notes: propertyValue.notes ? parseNotes(
1034
+ Array.isArray(propertyValue.notes.note) ? propertyValue.notes.note : [propertyValue.notes.note]
1035
+ ) : [],
1036
+ links: propertyValue.links ? parseLinks(
1037
+ Array.isArray(propertyValue.links) ? propertyValue.links : [propertyValue.links]
1038
+ ) : []
1039
+ };
1040
+ }
1041
+ function parsePropertyValues(propertyValues) {
1042
+ const returnPropertyValues = [];
1043
+ for (const propertyValue of propertyValues) {
1044
+ returnPropertyValues.push(parsePropertyValue(propertyValue));
1045
+ }
1046
+ return returnPropertyValues;
1047
+ }
1021
1048
  function parseTree(tree) {
1022
1049
  let creators = [];
1023
1050
  if (tree.creators) {
@@ -1035,6 +1062,7 @@ function parseTree(tree) {
1035
1062
  let periods = [];
1036
1063
  let bibliographies = [];
1037
1064
  let persons = [];
1065
+ let propertyValues = [];
1038
1066
  if (typeof tree.items !== "string" && "resource" in tree.items) {
1039
1067
  resources = parseResources(
1040
1068
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -1065,6 +1093,11 @@ function parseTree(tree) {
1065
1093
  Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
1066
1094
  );
1067
1095
  }
1096
+ if (typeof tree.items !== "string" && "propertyValue" in tree.items) {
1097
+ propertyValues = parsePropertyValues(
1098
+ Array.isArray(tree.items.propertyValue) ? tree.items.propertyValue : [tree.items.propertyValue]
1099
+ );
1100
+ }
1068
1101
  const returnTree = {
1069
1102
  uuid: tree.uuid,
1070
1103
  category: "tree",
@@ -1081,7 +1114,8 @@ function parseTree(tree) {
1081
1114
  concepts,
1082
1115
  periods,
1083
1116
  bibliographies,
1084
- persons
1117
+ persons,
1118
+ propertyValues
1085
1119
  },
1086
1120
  properties: tree.properties ? parseProperties(
1087
1121
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1096,6 +1130,7 @@ function parseSet(set) {
1096
1130
  let periods = [];
1097
1131
  let bibliographies = [];
1098
1132
  let persons = [];
1133
+ let propertyValues = [];
1099
1134
  if (typeof set.items !== "string" && "resource" in set.items) {
1100
1135
  resources = parseResources(
1101
1136
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1129,6 +1164,11 @@ function parseSet(set) {
1129
1164
  Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1130
1165
  );
1131
1166
  }
1167
+ if (typeof set.items !== "string" && "propertyValue" in set.items) {
1168
+ propertyValues = parsePropertyValues(
1169
+ Array.isArray(set.items.propertyValue) ? set.items.propertyValue : [set.items.propertyValue]
1170
+ );
1171
+ }
1132
1172
  return {
1133
1173
  uuid: set.uuid,
1134
1174
  category: "set",
@@ -1149,7 +1189,8 @@ function parseSet(set) {
1149
1189
  concepts,
1150
1190
  periods,
1151
1191
  bibliographies,
1152
- persons
1192
+ persons,
1193
+ propertyValues
1153
1194
  }
1154
1195
  };
1155
1196
  }
@@ -1668,7 +1709,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1668
1709
  break;
1669
1710
  }
1670
1711
  case "image-gallery": {
1671
- const galleryLink = links.find((link) => link.category === "tree");
1712
+ const galleryLink = links.find(
1713
+ (link) => link.category === "tree" || link.category === "set"
1714
+ );
1672
1715
  if (!galleryLink) {
1673
1716
  throw new Error(
1674
1717
  `Image gallery link not found for the following component: \u201C${componentName}\u201D`
@@ -1682,21 +1725,6 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1682
1725
  properties.isSearchable = isSearchable;
1683
1726
  break;
1684
1727
  }
1685
- case "item-gallery": {
1686
- const galleryLink = links.find((link) => link.category === "tree");
1687
- if (!galleryLink) {
1688
- throw new Error(
1689
- `Item gallery link not found for the following component: \u201C${componentName}\u201D`
1690
- );
1691
- }
1692
- const isSearchable = getPropertyValueByLabel(
1693
- componentProperty.properties,
1694
- "is-searchable"
1695
- ) === "Yes";
1696
- properties.galleryId = galleryLink.uuid;
1697
- properties.isSearchable = isSearchable;
1698
- break;
1699
- }
1700
1728
  case "n-columns": {
1701
1729
  const subElements = elementResource.resource ? await parseWebpageResources(
1702
1730
  Array.isArray(elementResource.resource) ? elementResource.resource : [elementResource.resource],
@@ -1726,6 +1754,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1726
1754
  properties.tableId = tableLink.uuid;
1727
1755
  break;
1728
1756
  }
1757
+ case "search-bar": {
1758
+ let variant = getPropertyValueByLabel(
1759
+ componentProperty.properties,
1760
+ "variant"
1761
+ );
1762
+ variant ??= "default";
1763
+ properties.variant = variant;
1764
+ break;
1765
+ }
1729
1766
  case "text": {
1730
1767
  if (!document) {
1731
1768
  throw new Error(
@@ -2663,6 +2700,8 @@ async function fetchWebsite(abbreviation) {
2663
2700
  parsePerson,
2664
2701
  parsePersons,
2665
2702
  parseProperties,
2703
+ parsePropertyValue,
2704
+ parsePropertyValues,
2666
2705
  parseResource,
2667
2706
  parseResources,
2668
2707
  parseSet,
package/dist/index.d.cts CHANGED
@@ -11,7 +11,7 @@ type Data = {
11
11
  };
12
12
  publicationDateTime: Date;
13
13
  metadata: Metadata;
14
- item: Tree | Set | Resource | SpatialUnit | Concept | Period | Bibliography | Person;
14
+ item: Tree | Set | Resource | SpatialUnit | Concept | Period | Bibliography | Person | PropertyValue;
15
15
  };
16
16
  /**
17
17
  * Basic identification information used across multiple types
@@ -112,7 +112,7 @@ type Link = {
112
112
  uuid: string;
113
113
  publicationDateTime: Date | null;
114
114
  type: string | null;
115
- category: "resource" | "spatialUnit" | "concept" | "set" | "tree" | "person" | "bibliography" | "epigraphicUnit" | null;
115
+ category: "resource" | "spatialUnit" | "concept" | "set" | "tree" | "person" | "bibliography" | "epigraphicUnit" | "propertyValue" | null;
116
116
  identification: Identification | null;
117
117
  content: string | null;
118
118
  href: string | null;
@@ -295,6 +295,7 @@ type Set = {
295
295
  periods: Array<Period>;
296
296
  bibliographies: Array<Bibliography>;
297
297
  persons: Array<Person>;
298
+ propertyValues: Array<PropertyValue>;
298
299
  };
299
300
  };
300
301
  /**
@@ -343,15 +344,24 @@ type Period = {
343
344
  description: string | null;
344
345
  };
345
346
  /**
346
- * Valid types for property values
347
+ * Represents a property value with type information
347
348
  */
348
- type PropertyValueType = "string" | "number" | "integer" | "boolean" | "date" | "dateTime" | "time" | "IDREF";
349
+ type PropertyValue = {
350
+ uuid: string;
351
+ category: "propertyValue";
352
+ n: number;
353
+ publicationDateTime: Date | null;
354
+ identification: Identification;
355
+ description: string;
356
+ notes: Array<Note>;
357
+ links: Array<Link>;
358
+ };
349
359
  /**
350
360
  * Represents a property value with type information
351
361
  */
352
- type PropertyValue = {
362
+ type PropertyValueContent = {
353
363
  content: string;
354
- type: PropertyValueType;
364
+ type: "string" | "number" | "integer" | "boolean" | "date" | "dateTime" | "time" | "IDREF";
355
365
  category: string | null;
356
366
  uuid: string | null;
357
367
  publicationDateTime: Date | null;
@@ -361,7 +371,7 @@ type PropertyValue = {
361
371
  */
362
372
  type Property = {
363
373
  label: string;
364
- values: Array<PropertyValue>;
374
+ values: Array<PropertyValueContent>;
365
375
  comment: string | null;
366
376
  properties: Array<Property>;
367
377
  };
@@ -385,6 +395,7 @@ type Tree = {
385
395
  periods: Array<Period>;
386
396
  bibliographies: Array<Bibliography>;
387
397
  persons: Array<Person>;
398
+ propertyValues: Array<PropertyValue>;
388
399
  };
389
400
  properties: Array<Property>;
390
401
  };
@@ -539,10 +550,6 @@ type WebElementComponent = {
539
550
  component: "image-gallery";
540
551
  galleryId: string;
541
552
  isSearchable: boolean;
542
- } | {
543
- component: "item-gallery";
544
- galleryId: string;
545
- isSearchable: boolean;
546
553
  } | {
547
554
  component: "n-columns";
548
555
  columns: Array<WebElement>;
@@ -551,6 +558,9 @@ type WebElementComponent = {
551
558
  rows: Array<WebElement>;
552
559
  } | {
553
560
  component: "network-graph";
561
+ } | {
562
+ component: "search-bar";
563
+ variant: "default" | "full";
554
564
  } | {
555
565
  component: "table";
556
566
  tableId: string;
@@ -800,6 +810,7 @@ type OchreData = {
800
810
  | { period: OchrePeriod }
801
811
  | { bibliography: OchreBibliography }
802
812
  | { person: OchrePerson }
813
+ | { propertyValue: OchrePropertyValue }
803
814
  );
804
815
  };
805
816
 
@@ -844,7 +855,8 @@ type OchreTree = {
844
855
  | { concept: OchreConcept | Array<OchreConcept> }
845
856
  | { period: OchrePeriod | Array<OchrePeriod> }
846
857
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
847
- | { person: OchrePerson | Array<OchrePerson> };
858
+ | { person: OchrePerson | Array<OchrePerson> }
859
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
848
860
  properties?: { property: OchreProperty | Array<OchreProperty> };
849
861
  };
850
862
 
@@ -869,7 +881,8 @@ type OchreSet = {
869
881
  | { concept: OchreConcept | Array<OchreConcept> }
870
882
  | { period: OchrePeriod | Array<OchrePeriod> }
871
883
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
872
- | { person: OchrePerson | Array<OchrePerson> };
884
+ | { person: OchrePerson | Array<OchrePerson> }
885
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
873
886
  };
874
887
 
875
888
  /**
@@ -966,7 +979,7 @@ type OchreNestedConcept = Omit<OchreConcept, "context" | "availability">;
966
979
  /**
967
980
  * Raw property value structure corresponding to the parsed PropertyValue type
968
981
  */
969
- type OchrePropertyValue = OchreStringContent & {
982
+ type OchrePropertyValueContent = OchreStringContent & {
970
983
  uuid?: string;
971
984
  publicationDateTime?: string; // YYYY-MM-DDThh:mm:ssZ
972
985
  type: string;
@@ -979,7 +992,10 @@ type OchrePropertyValue = OchreStringContent & {
979
992
  */
980
993
  type OchreProperty = {
981
994
  label: OchreStringContent & { uuid: string };
982
- value?: OchrePropertyValue | Array<OchrePropertyValue> | FakeString;
995
+ value?:
996
+ | OchrePropertyValueContent
997
+ | Array<OchrePropertyValueContent>
998
+ | FakeString;
983
999
  comment?: FakeString;
984
1000
  property?: OchreProperty | Array<OchreProperty>;
985
1001
  };
@@ -1042,7 +1058,8 @@ type OchreLink =
1042
1058
  | { tree: OchreLinkItem | Array<OchreLinkItem> }
1043
1059
  | { person: OchreLinkItem | Array<OchreLinkItem> }
1044
1060
  | { epigraphicUnit: OchreLinkItem | Array<OchreLinkItem> }
1045
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
1061
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
1062
+ | { propertyValue: OchreLinkItem | Array<OchreLinkItem> };
1046
1063
 
1047
1064
  /**
1048
1065
  * Raw image structure corresponding to the parsed Image type
@@ -1263,6 +1280,19 @@ type OchreInterpretation = {
1263
1280
  properties?: { property: OchreProperty | Array<OchreProperty> };
1264
1281
  };
1265
1282
 
1283
+ /**
1284
+ * Raw property value structure corresponding to the parsed PropertyValue type
1285
+ */
1286
+ type OchrePropertyValue = {
1287
+ uuid: string;
1288
+ n: number;
1289
+ publicationDateTime?: string; // YYYY-MM-DDThh:mm:ss
1290
+ identification: OchreIdentification;
1291
+ description: OchreStringContent | FakeString;
1292
+ notes?: { note: OchreNote | Array<OchreNote> };
1293
+ links?: OchreLink | Array<OchreLink>;
1294
+ };
1295
+
1266
1296
  /**
1267
1297
  * Fetches raw OCHRE data by UUID from the OCHRE API
1268
1298
  *
@@ -1734,6 +1764,20 @@ declare function parseBibliography(bibliography: OchreBibliography): Bibliograph
1734
1764
  * @returns Array of parsed Bibliography objects
1735
1765
  */
1736
1766
  declare function parseBibliographies(bibliographies: Array<OchreBibliography>): Array<Bibliography>;
1767
+ /**
1768
+ * Parses raw property value data into a standardized PropertyValue structure
1769
+ *
1770
+ * @param propertyValue - Raw property value data in OCHRE format
1771
+ * @returns Parsed PropertyValue object
1772
+ */
1773
+ declare function parsePropertyValue(propertyValue: OchrePropertyValue): PropertyValue;
1774
+ /**
1775
+ * Parses an array of raw property values into standardized PropertyValue objects
1776
+ *
1777
+ * @param propertyValues - Array of raw property values in OCHRE format
1778
+ * @returns Array of parsed PropertyValue objects
1779
+ */
1780
+ declare function parsePropertyValues(propertyValues: Array<OchrePropertyValue>): Array<PropertyValue>;
1737
1781
  /**
1738
1782
  * Parses a raw tree structure into a standardized Tree object
1739
1783
  *
@@ -1847,4 +1891,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1847
1891
  */
1848
1892
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1849
1893
 
1850
- export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
1894
+ export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ type Data = {
11
11
  };
12
12
  publicationDateTime: Date;
13
13
  metadata: Metadata;
14
- item: Tree | Set | Resource | SpatialUnit | Concept | Period | Bibliography | Person;
14
+ item: Tree | Set | Resource | SpatialUnit | Concept | Period | Bibliography | Person | PropertyValue;
15
15
  };
16
16
  /**
17
17
  * Basic identification information used across multiple types
@@ -112,7 +112,7 @@ type Link = {
112
112
  uuid: string;
113
113
  publicationDateTime: Date | null;
114
114
  type: string | null;
115
- category: "resource" | "spatialUnit" | "concept" | "set" | "tree" | "person" | "bibliography" | "epigraphicUnit" | null;
115
+ category: "resource" | "spatialUnit" | "concept" | "set" | "tree" | "person" | "bibliography" | "epigraphicUnit" | "propertyValue" | null;
116
116
  identification: Identification | null;
117
117
  content: string | null;
118
118
  href: string | null;
@@ -295,6 +295,7 @@ type Set = {
295
295
  periods: Array<Period>;
296
296
  bibliographies: Array<Bibliography>;
297
297
  persons: Array<Person>;
298
+ propertyValues: Array<PropertyValue>;
298
299
  };
299
300
  };
300
301
  /**
@@ -343,15 +344,24 @@ type Period = {
343
344
  description: string | null;
344
345
  };
345
346
  /**
346
- * Valid types for property values
347
+ * Represents a property value with type information
347
348
  */
348
- type PropertyValueType = "string" | "number" | "integer" | "boolean" | "date" | "dateTime" | "time" | "IDREF";
349
+ type PropertyValue = {
350
+ uuid: string;
351
+ category: "propertyValue";
352
+ n: number;
353
+ publicationDateTime: Date | null;
354
+ identification: Identification;
355
+ description: string;
356
+ notes: Array<Note>;
357
+ links: Array<Link>;
358
+ };
349
359
  /**
350
360
  * Represents a property value with type information
351
361
  */
352
- type PropertyValue = {
362
+ type PropertyValueContent = {
353
363
  content: string;
354
- type: PropertyValueType;
364
+ type: "string" | "number" | "integer" | "boolean" | "date" | "dateTime" | "time" | "IDREF";
355
365
  category: string | null;
356
366
  uuid: string | null;
357
367
  publicationDateTime: Date | null;
@@ -361,7 +371,7 @@ type PropertyValue = {
361
371
  */
362
372
  type Property = {
363
373
  label: string;
364
- values: Array<PropertyValue>;
374
+ values: Array<PropertyValueContent>;
365
375
  comment: string | null;
366
376
  properties: Array<Property>;
367
377
  };
@@ -385,6 +395,7 @@ type Tree = {
385
395
  periods: Array<Period>;
386
396
  bibliographies: Array<Bibliography>;
387
397
  persons: Array<Person>;
398
+ propertyValues: Array<PropertyValue>;
388
399
  };
389
400
  properties: Array<Property>;
390
401
  };
@@ -539,10 +550,6 @@ type WebElementComponent = {
539
550
  component: "image-gallery";
540
551
  galleryId: string;
541
552
  isSearchable: boolean;
542
- } | {
543
- component: "item-gallery";
544
- galleryId: string;
545
- isSearchable: boolean;
546
553
  } | {
547
554
  component: "n-columns";
548
555
  columns: Array<WebElement>;
@@ -551,6 +558,9 @@ type WebElementComponent = {
551
558
  rows: Array<WebElement>;
552
559
  } | {
553
560
  component: "network-graph";
561
+ } | {
562
+ component: "search-bar";
563
+ variant: "default" | "full";
554
564
  } | {
555
565
  component: "table";
556
566
  tableId: string;
@@ -800,6 +810,7 @@ type OchreData = {
800
810
  | { period: OchrePeriod }
801
811
  | { bibliography: OchreBibliography }
802
812
  | { person: OchrePerson }
813
+ | { propertyValue: OchrePropertyValue }
803
814
  );
804
815
  };
805
816
 
@@ -844,7 +855,8 @@ type OchreTree = {
844
855
  | { concept: OchreConcept | Array<OchreConcept> }
845
856
  | { period: OchrePeriod | Array<OchrePeriod> }
846
857
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
847
- | { person: OchrePerson | Array<OchrePerson> };
858
+ | { person: OchrePerson | Array<OchrePerson> }
859
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
848
860
  properties?: { property: OchreProperty | Array<OchreProperty> };
849
861
  };
850
862
 
@@ -869,7 +881,8 @@ type OchreSet = {
869
881
  | { concept: OchreConcept | Array<OchreConcept> }
870
882
  | { period: OchrePeriod | Array<OchrePeriod> }
871
883
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
872
- | { person: OchrePerson | Array<OchrePerson> };
884
+ | { person: OchrePerson | Array<OchrePerson> }
885
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
873
886
  };
874
887
 
875
888
  /**
@@ -966,7 +979,7 @@ type OchreNestedConcept = Omit<OchreConcept, "context" | "availability">;
966
979
  /**
967
980
  * Raw property value structure corresponding to the parsed PropertyValue type
968
981
  */
969
- type OchrePropertyValue = OchreStringContent & {
982
+ type OchrePropertyValueContent = OchreStringContent & {
970
983
  uuid?: string;
971
984
  publicationDateTime?: string; // YYYY-MM-DDThh:mm:ssZ
972
985
  type: string;
@@ -979,7 +992,10 @@ type OchrePropertyValue = OchreStringContent & {
979
992
  */
980
993
  type OchreProperty = {
981
994
  label: OchreStringContent & { uuid: string };
982
- value?: OchrePropertyValue | Array<OchrePropertyValue> | FakeString;
995
+ value?:
996
+ | OchrePropertyValueContent
997
+ | Array<OchrePropertyValueContent>
998
+ | FakeString;
983
999
  comment?: FakeString;
984
1000
  property?: OchreProperty | Array<OchreProperty>;
985
1001
  };
@@ -1042,7 +1058,8 @@ type OchreLink =
1042
1058
  | { tree: OchreLinkItem | Array<OchreLinkItem> }
1043
1059
  | { person: OchreLinkItem | Array<OchreLinkItem> }
1044
1060
  | { epigraphicUnit: OchreLinkItem | Array<OchreLinkItem> }
1045
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
1061
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
1062
+ | { propertyValue: OchreLinkItem | Array<OchreLinkItem> };
1046
1063
 
1047
1064
  /**
1048
1065
  * Raw image structure corresponding to the parsed Image type
@@ -1263,6 +1280,19 @@ type OchreInterpretation = {
1263
1280
  properties?: { property: OchreProperty | Array<OchreProperty> };
1264
1281
  };
1265
1282
 
1283
+ /**
1284
+ * Raw property value structure corresponding to the parsed PropertyValue type
1285
+ */
1286
+ type OchrePropertyValue = {
1287
+ uuid: string;
1288
+ n: number;
1289
+ publicationDateTime?: string; // YYYY-MM-DDThh:mm:ss
1290
+ identification: OchreIdentification;
1291
+ description: OchreStringContent | FakeString;
1292
+ notes?: { note: OchreNote | Array<OchreNote> };
1293
+ links?: OchreLink | Array<OchreLink>;
1294
+ };
1295
+
1266
1296
  /**
1267
1297
  * Fetches raw OCHRE data by UUID from the OCHRE API
1268
1298
  *
@@ -1734,6 +1764,20 @@ declare function parseBibliography(bibliography: OchreBibliography): Bibliograph
1734
1764
  * @returns Array of parsed Bibliography objects
1735
1765
  */
1736
1766
  declare function parseBibliographies(bibliographies: Array<OchreBibliography>): Array<Bibliography>;
1767
+ /**
1768
+ * Parses raw property value data into a standardized PropertyValue structure
1769
+ *
1770
+ * @param propertyValue - Raw property value data in OCHRE format
1771
+ * @returns Parsed PropertyValue object
1772
+ */
1773
+ declare function parsePropertyValue(propertyValue: OchrePropertyValue): PropertyValue;
1774
+ /**
1775
+ * Parses an array of raw property values into standardized PropertyValue objects
1776
+ *
1777
+ * @param propertyValues - Array of raw property values in OCHRE format
1778
+ * @returns Array of parsed PropertyValue objects
1779
+ */
1780
+ declare function parsePropertyValues(propertyValues: Array<OchrePropertyValue>): Array<PropertyValue>;
1737
1781
  /**
1738
1782
  * Parses a raw tree structure into a standardized Tree object
1739
1783
  *
@@ -1847,4 +1891,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1847
1891
  */
1848
1892
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1849
1893
 
1850
- export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
1894
+ export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueContent, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebBlock, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmail, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parsePropertyValue, parsePropertyValues, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
package/dist/index.js CHANGED
@@ -494,10 +494,10 @@ var componentSchema = z3.enum(
494
494
  "iiif-viewer",
495
495
  "image",
496
496
  "image-gallery",
497
- "item-gallery",
498
497
  "n-columns",
499
498
  "n-rows",
500
499
  "network-graph",
500
+ "search-bar",
501
501
  "table",
502
502
  "text",
503
503
  "timeline",
@@ -636,7 +636,7 @@ function parsePersons(persons) {
636
636
  return returnPersons;
637
637
  }
638
638
  function parseLink(linkRaw) {
639
- const links = "resource" in linkRaw ? linkRaw.resource : "spatialUnit" in linkRaw ? linkRaw.spatialUnit : "concept" in linkRaw ? linkRaw.concept : "set" in linkRaw ? linkRaw.set : "tree" in linkRaw ? linkRaw.tree : "person" in linkRaw ? linkRaw.person : "bibliography" in linkRaw ? linkRaw.bibliography : "epigraphicUnit" in linkRaw ? linkRaw.epigraphicUnit : null;
639
+ const links = "resource" in linkRaw ? linkRaw.resource : "spatialUnit" in linkRaw ? linkRaw.spatialUnit : "concept" in linkRaw ? linkRaw.concept : "set" in linkRaw ? linkRaw.set : "tree" in linkRaw ? linkRaw.tree : "person" in linkRaw ? linkRaw.person : "bibliography" in linkRaw ? linkRaw.bibliography : "epigraphicUnit" in linkRaw ? linkRaw.epigraphicUnit : "propertyValue" in linkRaw ? linkRaw.propertyValue : null;
640
640
  if (!links) {
641
641
  throw new Error(
642
642
  `Invalid link provided: ${JSON.stringify(linkRaw, null, 2)}`
@@ -646,7 +646,7 @@ function parseLink(linkRaw) {
646
646
  const returnLinks = [];
647
647
  for (const link of linksToParse) {
648
648
  const returnLink = {
649
- category: "resource" in linkRaw ? "resource" : "spatialUnit" in linkRaw ? "spatialUnit" : "concept" in linkRaw ? "concept" : "set" in linkRaw ? "set" : "person" in linkRaw ? "person" : "tree" in linkRaw ? "tree" : "bibliography" in linkRaw ? "bibliography" : "epigraphicUnit" in linkRaw ? "epigraphicUnit" : null,
649
+ category: "resource" in linkRaw ? "resource" : "spatialUnit" in linkRaw ? "spatialUnit" : "concept" in linkRaw ? "concept" : "set" in linkRaw ? "set" : "person" in linkRaw ? "person" : "tree" in linkRaw ? "tree" : "bibliography" in linkRaw ? "bibliography" : "epigraphicUnit" in linkRaw ? "epigraphicUnit" : "propertyValue" in linkRaw ? "propertyValue" : null,
650
650
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
651
651
  href: "href" in link && link.href != null ? link.href : null,
652
652
  uuid: link.uuid,
@@ -941,6 +941,31 @@ function parseBibliographies(bibliographies) {
941
941
  }
942
942
  return returnBibliographies;
943
943
  }
944
+ function parsePropertyValue(propertyValue) {
945
+ return {
946
+ uuid: propertyValue.uuid,
947
+ category: "propertyValue",
948
+ n: propertyValue.n,
949
+ publicationDateTime: propertyValue.publicationDateTime ? new Date(propertyValue.publicationDateTime) : null,
950
+ identification: parseIdentification(propertyValue.identification),
951
+ description: ["string", "number", "boolean"].includes(
952
+ typeof propertyValue.description
953
+ ) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description),
954
+ notes: propertyValue.notes ? parseNotes(
955
+ Array.isArray(propertyValue.notes.note) ? propertyValue.notes.note : [propertyValue.notes.note]
956
+ ) : [],
957
+ links: propertyValue.links ? parseLinks(
958
+ Array.isArray(propertyValue.links) ? propertyValue.links : [propertyValue.links]
959
+ ) : []
960
+ };
961
+ }
962
+ function parsePropertyValues(propertyValues) {
963
+ const returnPropertyValues = [];
964
+ for (const propertyValue of propertyValues) {
965
+ returnPropertyValues.push(parsePropertyValue(propertyValue));
966
+ }
967
+ return returnPropertyValues;
968
+ }
944
969
  function parseTree(tree) {
945
970
  let creators = [];
946
971
  if (tree.creators) {
@@ -958,6 +983,7 @@ function parseTree(tree) {
958
983
  let periods = [];
959
984
  let bibliographies = [];
960
985
  let persons = [];
986
+ let propertyValues = [];
961
987
  if (typeof tree.items !== "string" && "resource" in tree.items) {
962
988
  resources = parseResources(
963
989
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -988,6 +1014,11 @@ function parseTree(tree) {
988
1014
  Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
989
1015
  );
990
1016
  }
1017
+ if (typeof tree.items !== "string" && "propertyValue" in tree.items) {
1018
+ propertyValues = parsePropertyValues(
1019
+ Array.isArray(tree.items.propertyValue) ? tree.items.propertyValue : [tree.items.propertyValue]
1020
+ );
1021
+ }
991
1022
  const returnTree = {
992
1023
  uuid: tree.uuid,
993
1024
  category: "tree",
@@ -1004,7 +1035,8 @@ function parseTree(tree) {
1004
1035
  concepts,
1005
1036
  periods,
1006
1037
  bibliographies,
1007
- persons
1038
+ persons,
1039
+ propertyValues
1008
1040
  },
1009
1041
  properties: tree.properties ? parseProperties(
1010
1042
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1019,6 +1051,7 @@ function parseSet(set) {
1019
1051
  let periods = [];
1020
1052
  let bibliographies = [];
1021
1053
  let persons = [];
1054
+ let propertyValues = [];
1022
1055
  if (typeof set.items !== "string" && "resource" in set.items) {
1023
1056
  resources = parseResources(
1024
1057
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1052,6 +1085,11 @@ function parseSet(set) {
1052
1085
  Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1053
1086
  );
1054
1087
  }
1088
+ if (typeof set.items !== "string" && "propertyValue" in set.items) {
1089
+ propertyValues = parsePropertyValues(
1090
+ Array.isArray(set.items.propertyValue) ? set.items.propertyValue : [set.items.propertyValue]
1091
+ );
1092
+ }
1055
1093
  return {
1056
1094
  uuid: set.uuid,
1057
1095
  category: "set",
@@ -1072,7 +1110,8 @@ function parseSet(set) {
1072
1110
  concepts,
1073
1111
  periods,
1074
1112
  bibliographies,
1075
- persons
1113
+ persons,
1114
+ propertyValues
1076
1115
  }
1077
1116
  };
1078
1117
  }
@@ -1591,7 +1630,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1591
1630
  break;
1592
1631
  }
1593
1632
  case "image-gallery": {
1594
- const galleryLink = links.find((link) => link.category === "tree");
1633
+ const galleryLink = links.find(
1634
+ (link) => link.category === "tree" || link.category === "set"
1635
+ );
1595
1636
  if (!galleryLink) {
1596
1637
  throw new Error(
1597
1638
  `Image gallery link not found for the following component: \u201C${componentName}\u201D`
@@ -1605,21 +1646,6 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1605
1646
  properties.isSearchable = isSearchable;
1606
1647
  break;
1607
1648
  }
1608
- case "item-gallery": {
1609
- const galleryLink = links.find((link) => link.category === "tree");
1610
- if (!galleryLink) {
1611
- throw new Error(
1612
- `Item gallery link not found for the following component: \u201C${componentName}\u201D`
1613
- );
1614
- }
1615
- const isSearchable = getPropertyValueByLabel(
1616
- componentProperty.properties,
1617
- "is-searchable"
1618
- ) === "Yes";
1619
- properties.galleryId = galleryLink.uuid;
1620
- properties.isSearchable = isSearchable;
1621
- break;
1622
- }
1623
1649
  case "n-columns": {
1624
1650
  const subElements = elementResource.resource ? await parseWebpageResources(
1625
1651
  Array.isArray(elementResource.resource) ? elementResource.resource : [elementResource.resource],
@@ -1649,6 +1675,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1649
1675
  properties.tableId = tableLink.uuid;
1650
1676
  break;
1651
1677
  }
1678
+ case "search-bar": {
1679
+ let variant = getPropertyValueByLabel(
1680
+ componentProperty.properties,
1681
+ "variant"
1682
+ );
1683
+ variant ??= "default";
1684
+ properties.variant = variant;
1685
+ break;
1686
+ }
1652
1687
  case "text": {
1653
1688
  if (!document) {
1654
1689
  throw new Error(
@@ -2585,6 +2620,8 @@ export {
2585
2620
  parsePerson,
2586
2621
  parsePersons,
2587
2622
  parseProperties,
2623
+ parsePropertyValue,
2624
+ parsePropertyValues,
2588
2625
  parseResource,
2589
2626
  parseResources,
2590
2627
  parseSet,
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
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",
7
7
  "author": "Firat Ciftci <firatciftci@uchicago.edu> (https://digitalculture.uchicago.edu)",
8
- "homepage": "https://github.com/forumfordigitalculture/ochre-sdk",
8
+ "homepage": "https://github.com/uchicago-digitalculture-webdev/ochre-sdk",
9
9
  "bugs": {
10
- "url": "https://github.com/forumfordigitalculture/ochre-sdk/issues"
10
+ "url": "https://github.com/uchicago-digitalculture-webdev/ochre-sdk/issues"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/forumfordigitalculture/ochre-sdk.git"
14
+ "url": "git+https://github.com/uchicago-digitalculture-webdev/ochre-sdk.git"
15
15
  },
16
16
  "keywords": [
17
17
  "ochre",