@digitalculture/ochre-sdk 0.5.10 → 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,
@@ -574,6 +576,7 @@ var componentSchema = import_zod3.z.enum(
574
576
  "n-columns",
575
577
  "n-rows",
576
578
  "network-graph",
579
+ "search-bar",
577
580
  "table",
578
581
  "text",
579
582
  "timeline",
@@ -712,7 +715,7 @@ function parsePersons(persons) {
712
715
  return returnPersons;
713
716
  }
714
717
  function parseLink(linkRaw) {
715
- 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;
716
719
  if (!links) {
717
720
  throw new Error(
718
721
  `Invalid link provided: ${JSON.stringify(linkRaw, null, 2)}`
@@ -722,7 +725,7 @@ function parseLink(linkRaw) {
722
725
  const returnLinks = [];
723
726
  for (const link of linksToParse) {
724
727
  const returnLink = {
725
- 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,
726
729
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
727
730
  href: "href" in link && link.href != null ? link.href : null,
728
731
  uuid: link.uuid,
@@ -1017,6 +1020,31 @@ function parseBibliographies(bibliographies) {
1017
1020
  }
1018
1021
  return returnBibliographies;
1019
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
+ }
1020
1048
  function parseTree(tree) {
1021
1049
  let creators = [];
1022
1050
  if (tree.creators) {
@@ -1034,6 +1062,7 @@ function parseTree(tree) {
1034
1062
  let periods = [];
1035
1063
  let bibliographies = [];
1036
1064
  let persons = [];
1065
+ let propertyValues = [];
1037
1066
  if (typeof tree.items !== "string" && "resource" in tree.items) {
1038
1067
  resources = parseResources(
1039
1068
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -1064,6 +1093,11 @@ function parseTree(tree) {
1064
1093
  Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
1065
1094
  );
1066
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
+ }
1067
1101
  const returnTree = {
1068
1102
  uuid: tree.uuid,
1069
1103
  category: "tree",
@@ -1080,7 +1114,8 @@ function parseTree(tree) {
1080
1114
  concepts,
1081
1115
  periods,
1082
1116
  bibliographies,
1083
- persons
1117
+ persons,
1118
+ propertyValues
1084
1119
  },
1085
1120
  properties: tree.properties ? parseProperties(
1086
1121
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1095,6 +1130,7 @@ function parseSet(set) {
1095
1130
  let periods = [];
1096
1131
  let bibliographies = [];
1097
1132
  let persons = [];
1133
+ let propertyValues = [];
1098
1134
  if (typeof set.items !== "string" && "resource" in set.items) {
1099
1135
  resources = parseResources(
1100
1136
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1128,6 +1164,11 @@ function parseSet(set) {
1128
1164
  Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1129
1165
  );
1130
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
+ }
1131
1172
  return {
1132
1173
  uuid: set.uuid,
1133
1174
  category: "set",
@@ -1148,7 +1189,8 @@ function parseSet(set) {
1148
1189
  concepts,
1149
1190
  periods,
1150
1191
  bibliographies,
1151
- persons
1192
+ persons,
1193
+ propertyValues
1152
1194
  }
1153
1195
  };
1154
1196
  }
@@ -1712,6 +1754,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1712
1754
  properties.tableId = tableLink.uuid;
1713
1755
  break;
1714
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
+ }
1715
1766
  case "text": {
1716
1767
  if (!document) {
1717
1768
  throw new Error(
@@ -2649,6 +2700,8 @@ async function fetchWebsite(abbreviation) {
2649
2700
  parsePerson,
2650
2701
  parsePersons,
2651
2702
  parseProperties,
2703
+ parsePropertyValue,
2704
+ parsePropertyValues,
2652
2705
  parseResource,
2653
2706
  parseResources,
2654
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
  };
@@ -547,6 +558,9 @@ type WebElementComponent = {
547
558
  rows: Array<WebElement>;
548
559
  } | {
549
560
  component: "network-graph";
561
+ } | {
562
+ component: "search-bar";
563
+ variant: "default" | "full";
550
564
  } | {
551
565
  component: "table";
552
566
  tableId: string;
@@ -796,6 +810,7 @@ type OchreData = {
796
810
  | { period: OchrePeriod }
797
811
  | { bibliography: OchreBibliography }
798
812
  | { person: OchrePerson }
813
+ | { propertyValue: OchrePropertyValue }
799
814
  );
800
815
  };
801
816
 
@@ -840,7 +855,8 @@ type OchreTree = {
840
855
  | { concept: OchreConcept | Array<OchreConcept> }
841
856
  | { period: OchrePeriod | Array<OchrePeriod> }
842
857
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
843
- | { person: OchrePerson | Array<OchrePerson> };
858
+ | { person: OchrePerson | Array<OchrePerson> }
859
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
844
860
  properties?: { property: OchreProperty | Array<OchreProperty> };
845
861
  };
846
862
 
@@ -865,7 +881,8 @@ type OchreSet = {
865
881
  | { concept: OchreConcept | Array<OchreConcept> }
866
882
  | { period: OchrePeriod | Array<OchrePeriod> }
867
883
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
868
- | { person: OchrePerson | Array<OchrePerson> };
884
+ | { person: OchrePerson | Array<OchrePerson> }
885
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
869
886
  };
870
887
 
871
888
  /**
@@ -962,7 +979,7 @@ type OchreNestedConcept = Omit<OchreConcept, "context" | "availability">;
962
979
  /**
963
980
  * Raw property value structure corresponding to the parsed PropertyValue type
964
981
  */
965
- type OchrePropertyValue = OchreStringContent & {
982
+ type OchrePropertyValueContent = OchreStringContent & {
966
983
  uuid?: string;
967
984
  publicationDateTime?: string; // YYYY-MM-DDThh:mm:ssZ
968
985
  type: string;
@@ -975,7 +992,10 @@ type OchrePropertyValue = OchreStringContent & {
975
992
  */
976
993
  type OchreProperty = {
977
994
  label: OchreStringContent & { uuid: string };
978
- value?: OchrePropertyValue | Array<OchrePropertyValue> | FakeString;
995
+ value?:
996
+ | OchrePropertyValueContent
997
+ | Array<OchrePropertyValueContent>
998
+ | FakeString;
979
999
  comment?: FakeString;
980
1000
  property?: OchreProperty | Array<OchreProperty>;
981
1001
  };
@@ -1038,7 +1058,8 @@ type OchreLink =
1038
1058
  | { tree: OchreLinkItem | Array<OchreLinkItem> }
1039
1059
  | { person: OchreLinkItem | Array<OchreLinkItem> }
1040
1060
  | { epigraphicUnit: OchreLinkItem | Array<OchreLinkItem> }
1041
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
1061
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
1062
+ | { propertyValue: OchreLinkItem | Array<OchreLinkItem> };
1042
1063
 
1043
1064
  /**
1044
1065
  * Raw image structure corresponding to the parsed Image type
@@ -1259,6 +1280,19 @@ type OchreInterpretation = {
1259
1280
  properties?: { property: OchreProperty | Array<OchreProperty> };
1260
1281
  };
1261
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
+
1262
1296
  /**
1263
1297
  * Fetches raw OCHRE data by UUID from the OCHRE API
1264
1298
  *
@@ -1730,6 +1764,20 @@ declare function parseBibliography(bibliography: OchreBibliography): Bibliograph
1730
1764
  * @returns Array of parsed Bibliography objects
1731
1765
  */
1732
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>;
1733
1781
  /**
1734
1782
  * Parses a raw tree structure into a standardized Tree object
1735
1783
  *
@@ -1843,4 +1891,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1843
1891
  */
1844
1892
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1845
1893
 
1846
- 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
  };
@@ -547,6 +558,9 @@ type WebElementComponent = {
547
558
  rows: Array<WebElement>;
548
559
  } | {
549
560
  component: "network-graph";
561
+ } | {
562
+ component: "search-bar";
563
+ variant: "default" | "full";
550
564
  } | {
551
565
  component: "table";
552
566
  tableId: string;
@@ -796,6 +810,7 @@ type OchreData = {
796
810
  | { period: OchrePeriod }
797
811
  | { bibliography: OchreBibliography }
798
812
  | { person: OchrePerson }
813
+ | { propertyValue: OchrePropertyValue }
799
814
  );
800
815
  };
801
816
 
@@ -840,7 +855,8 @@ type OchreTree = {
840
855
  | { concept: OchreConcept | Array<OchreConcept> }
841
856
  | { period: OchrePeriod | Array<OchrePeriod> }
842
857
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
843
- | { person: OchrePerson | Array<OchrePerson> };
858
+ | { person: OchrePerson | Array<OchrePerson> }
859
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
844
860
  properties?: { property: OchreProperty | Array<OchreProperty> };
845
861
  };
846
862
 
@@ -865,7 +881,8 @@ type OchreSet = {
865
881
  | { concept: OchreConcept | Array<OchreConcept> }
866
882
  | { period: OchrePeriod | Array<OchrePeriod> }
867
883
  | { bibliography: OchreBibliography | Array<OchreBibliography> }
868
- | { person: OchrePerson | Array<OchrePerson> };
884
+ | { person: OchrePerson | Array<OchrePerson> }
885
+ | { propertyValue: OchrePropertyValue | Array<OchrePropertyValue> };
869
886
  };
870
887
 
871
888
  /**
@@ -962,7 +979,7 @@ type OchreNestedConcept = Omit<OchreConcept, "context" | "availability">;
962
979
  /**
963
980
  * Raw property value structure corresponding to the parsed PropertyValue type
964
981
  */
965
- type OchrePropertyValue = OchreStringContent & {
982
+ type OchrePropertyValueContent = OchreStringContent & {
966
983
  uuid?: string;
967
984
  publicationDateTime?: string; // YYYY-MM-DDThh:mm:ssZ
968
985
  type: string;
@@ -975,7 +992,10 @@ type OchrePropertyValue = OchreStringContent & {
975
992
  */
976
993
  type OchreProperty = {
977
994
  label: OchreStringContent & { uuid: string };
978
- value?: OchrePropertyValue | Array<OchrePropertyValue> | FakeString;
995
+ value?:
996
+ | OchrePropertyValueContent
997
+ | Array<OchrePropertyValueContent>
998
+ | FakeString;
979
999
  comment?: FakeString;
980
1000
  property?: OchreProperty | Array<OchreProperty>;
981
1001
  };
@@ -1038,7 +1058,8 @@ type OchreLink =
1038
1058
  | { tree: OchreLinkItem | Array<OchreLinkItem> }
1039
1059
  | { person: OchreLinkItem | Array<OchreLinkItem> }
1040
1060
  | { epigraphicUnit: OchreLinkItem | Array<OchreLinkItem> }
1041
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
1061
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
1062
+ | { propertyValue: OchreLinkItem | Array<OchreLinkItem> };
1042
1063
 
1043
1064
  /**
1044
1065
  * Raw image structure corresponding to the parsed Image type
@@ -1259,6 +1280,19 @@ type OchreInterpretation = {
1259
1280
  properties?: { property: OchreProperty | Array<OchreProperty> };
1260
1281
  };
1261
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
+
1262
1296
  /**
1263
1297
  * Fetches raw OCHRE data by UUID from the OCHRE API
1264
1298
  *
@@ -1730,6 +1764,20 @@ declare function parseBibliography(bibliography: OchreBibliography): Bibliograph
1730
1764
  * @returns Array of parsed Bibliography objects
1731
1765
  */
1732
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>;
1733
1781
  /**
1734
1782
  * Parses a raw tree structure into a standardized Tree object
1735
1783
  *
@@ -1843,4 +1891,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1843
1891
  */
1844
1892
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1845
1893
 
1846
- 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
@@ -497,6 +497,7 @@ var componentSchema = z3.enum(
497
497
  "n-columns",
498
498
  "n-rows",
499
499
  "network-graph",
500
+ "search-bar",
500
501
  "table",
501
502
  "text",
502
503
  "timeline",
@@ -635,7 +636,7 @@ function parsePersons(persons) {
635
636
  return returnPersons;
636
637
  }
637
638
  function parseLink(linkRaw) {
638
- 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;
639
640
  if (!links) {
640
641
  throw new Error(
641
642
  `Invalid link provided: ${JSON.stringify(linkRaw, null, 2)}`
@@ -645,7 +646,7 @@ function parseLink(linkRaw) {
645
646
  const returnLinks = [];
646
647
  for (const link of linksToParse) {
647
648
  const returnLink = {
648
- 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,
649
650
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
650
651
  href: "href" in link && link.href != null ? link.href : null,
651
652
  uuid: link.uuid,
@@ -940,6 +941,31 @@ function parseBibliographies(bibliographies) {
940
941
  }
941
942
  return returnBibliographies;
942
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
+ }
943
969
  function parseTree(tree) {
944
970
  let creators = [];
945
971
  if (tree.creators) {
@@ -957,6 +983,7 @@ function parseTree(tree) {
957
983
  let periods = [];
958
984
  let bibliographies = [];
959
985
  let persons = [];
986
+ let propertyValues = [];
960
987
  if (typeof tree.items !== "string" && "resource" in tree.items) {
961
988
  resources = parseResources(
962
989
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -987,6 +1014,11 @@ function parseTree(tree) {
987
1014
  Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
988
1015
  );
989
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
+ }
990
1022
  const returnTree = {
991
1023
  uuid: tree.uuid,
992
1024
  category: "tree",
@@ -1003,7 +1035,8 @@ function parseTree(tree) {
1003
1035
  concepts,
1004
1036
  periods,
1005
1037
  bibliographies,
1006
- persons
1038
+ persons,
1039
+ propertyValues
1007
1040
  },
1008
1041
  properties: tree.properties ? parseProperties(
1009
1042
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1018,6 +1051,7 @@ function parseSet(set) {
1018
1051
  let periods = [];
1019
1052
  let bibliographies = [];
1020
1053
  let persons = [];
1054
+ let propertyValues = [];
1021
1055
  if (typeof set.items !== "string" && "resource" in set.items) {
1022
1056
  resources = parseResources(
1023
1057
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1051,6 +1085,11 @@ function parseSet(set) {
1051
1085
  Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1052
1086
  );
1053
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
+ }
1054
1093
  return {
1055
1094
  uuid: set.uuid,
1056
1095
  category: "set",
@@ -1071,7 +1110,8 @@ function parseSet(set) {
1071
1110
  concepts,
1072
1111
  periods,
1073
1112
  bibliographies,
1074
- persons
1113
+ persons,
1114
+ propertyValues
1075
1115
  }
1076
1116
  };
1077
1117
  }
@@ -1635,6 +1675,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1635
1675
  properties.tableId = tableLink.uuid;
1636
1676
  break;
1637
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
+ }
1638
1687
  case "text": {
1639
1688
  if (!document) {
1640
1689
  throw new Error(
@@ -2571,6 +2620,8 @@ export {
2571
2620
  parsePerson,
2572
2621
  parsePersons,
2573
2622
  parseProperties,
2623
+ parsePropertyValue,
2624
+ parsePropertyValues,
2574
2625
  parseResource,
2575
2626
  parseResources,
2576
2627
  parseSet,
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.5.10",
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",