@digitalculture/ochre-sdk 0.5.10 → 0.5.12

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
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  fetchConcept: () => fetchConcept,
26
26
  fetchGallery: () => fetchGallery,
27
27
  fetchPeriod: () => fetchPeriod,
28
+ fetchPropertyValue: () => fetchPropertyValue,
28
29
  fetchResource: () => fetchResource,
29
30
  fetchSet: () => fetchSet,
30
31
  fetchSpatialUnit: () => fetchSpatialUnit,
@@ -62,6 +63,8 @@ __export(index_exports, {
62
63
  parsePerson: () => parsePerson,
63
64
  parsePersons: () => parsePersons,
64
65
  parseProperties: () => parseProperties,
66
+ parsePropertyValue: () => parsePropertyValue,
67
+ parsePropertyValues: () => parsePropertyValues,
65
68
  parseResource: () => parseResource,
66
69
  parseResources: () => parseResources,
67
70
  parseSet: () => parseSet,
@@ -574,6 +577,7 @@ var componentSchema = import_zod3.z.enum(
574
577
  "n-columns",
575
578
  "n-rows",
576
579
  "network-graph",
580
+ "search-bar",
577
581
  "table",
578
582
  "text",
579
583
  "timeline",
@@ -712,7 +716,7 @@ function parsePersons(persons) {
712
716
  return returnPersons;
713
717
  }
714
718
  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;
719
+ 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
720
  if (!links) {
717
721
  throw new Error(
718
722
  `Invalid link provided: ${JSON.stringify(linkRaw, null, 2)}`
@@ -722,7 +726,7 @@ function parseLink(linkRaw) {
722
726
  const returnLinks = [];
723
727
  for (const link of linksToParse) {
724
728
  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,
729
+ 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
730
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
727
731
  href: "href" in link && link.href != null ? link.href : null,
728
732
  uuid: link.uuid,
@@ -1017,6 +1021,31 @@ function parseBibliographies(bibliographies) {
1017
1021
  }
1018
1022
  return returnBibliographies;
1019
1023
  }
1024
+ function parsePropertyValue(propertyValue) {
1025
+ return {
1026
+ uuid: propertyValue.uuid,
1027
+ category: "propertyValue",
1028
+ n: propertyValue.n,
1029
+ publicationDateTime: propertyValue.publicationDateTime ? new Date(propertyValue.publicationDateTime) : null,
1030
+ identification: parseIdentification(propertyValue.identification),
1031
+ description: ["string", "number", "boolean"].includes(
1032
+ typeof propertyValue.description
1033
+ ) ? parseFakeString(propertyValue.description) : parseStringContent(propertyValue.description),
1034
+ notes: propertyValue.notes ? parseNotes(
1035
+ Array.isArray(propertyValue.notes.note) ? propertyValue.notes.note : [propertyValue.notes.note]
1036
+ ) : [],
1037
+ links: propertyValue.links ? parseLinks(
1038
+ Array.isArray(propertyValue.links) ? propertyValue.links : [propertyValue.links]
1039
+ ) : []
1040
+ };
1041
+ }
1042
+ function parsePropertyValues(propertyValues) {
1043
+ const returnPropertyValues = [];
1044
+ for (const propertyValue of propertyValues) {
1045
+ returnPropertyValues.push(parsePropertyValue(propertyValue));
1046
+ }
1047
+ return returnPropertyValues;
1048
+ }
1020
1049
  function parseTree(tree) {
1021
1050
  let creators = [];
1022
1051
  if (tree.creators) {
@@ -1034,6 +1063,7 @@ function parseTree(tree) {
1034
1063
  let periods = [];
1035
1064
  let bibliographies = [];
1036
1065
  let persons = [];
1066
+ let propertyValues = [];
1037
1067
  if (typeof tree.items !== "string" && "resource" in tree.items) {
1038
1068
  resources = parseResources(
1039
1069
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -1064,6 +1094,11 @@ function parseTree(tree) {
1064
1094
  Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
1065
1095
  );
1066
1096
  }
1097
+ if (typeof tree.items !== "string" && "propertyValue" in tree.items) {
1098
+ propertyValues = parsePropertyValues(
1099
+ Array.isArray(tree.items.propertyValue) ? tree.items.propertyValue : [tree.items.propertyValue]
1100
+ );
1101
+ }
1067
1102
  const returnTree = {
1068
1103
  uuid: tree.uuid,
1069
1104
  category: "tree",
@@ -1080,7 +1115,8 @@ function parseTree(tree) {
1080
1115
  concepts,
1081
1116
  periods,
1082
1117
  bibliographies,
1083
- persons
1118
+ persons,
1119
+ propertyValues
1084
1120
  },
1085
1121
  properties: tree.properties ? parseProperties(
1086
1122
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1095,6 +1131,7 @@ function parseSet(set) {
1095
1131
  let periods = [];
1096
1132
  let bibliographies = [];
1097
1133
  let persons = [];
1134
+ let propertyValues = [];
1098
1135
  if (typeof set.items !== "string" && "resource" in set.items) {
1099
1136
  resources = parseResources(
1100
1137
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1128,6 +1165,11 @@ function parseSet(set) {
1128
1165
  Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1129
1166
  );
1130
1167
  }
1168
+ if (typeof set.items !== "string" && "propertyValue" in set.items) {
1169
+ propertyValues = parsePropertyValues(
1170
+ Array.isArray(set.items.propertyValue) ? set.items.propertyValue : [set.items.propertyValue]
1171
+ );
1172
+ }
1131
1173
  return {
1132
1174
  uuid: set.uuid,
1133
1175
  category: "set",
@@ -1148,7 +1190,8 @@ function parseSet(set) {
1148
1190
  concepts,
1149
1191
  periods,
1150
1192
  bibliographies,
1151
- persons
1193
+ persons,
1194
+ propertyValues
1152
1195
  }
1153
1196
  };
1154
1197
  }
@@ -1712,6 +1755,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1712
1755
  properties.tableId = tableLink.uuid;
1713
1756
  break;
1714
1757
  }
1758
+ case "search-bar": {
1759
+ let variant = getPropertyValueByLabel(
1760
+ componentProperty.properties,
1761
+ "variant"
1762
+ );
1763
+ variant ??= "default";
1764
+ properties.variant = variant;
1765
+ break;
1766
+ }
1715
1767
  case "text": {
1716
1768
  if (!document) {
1717
1769
  throw new Error(
@@ -2491,6 +2543,36 @@ async function fetchPeriod(uuid) {
2491
2543
  }
2492
2544
  }
2493
2545
 
2546
+ // src/utils/fetchers/property-value.ts
2547
+ async function fetchPropertyValue(uuid) {
2548
+ try {
2549
+ const [error, dataRaw] = await fetchByUuid(uuid);
2550
+ if (error !== null) {
2551
+ throw new Error(error);
2552
+ }
2553
+ if (!("propertyValue" in dataRaw.ochre)) {
2554
+ throw new Error(
2555
+ "Invalid OCHRE data: API response missing 'propertyValue' key"
2556
+ );
2557
+ }
2558
+ const propertyValueItem = parsePropertyValue(dataRaw.ochre.propertyValue);
2559
+ const data = {
2560
+ uuid: parseFakeString(dataRaw.ochre.uuid),
2561
+ publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
2562
+ belongsTo: {
2563
+ uuid: dataRaw.ochre.uuidBelongsTo,
2564
+ abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
2565
+ },
2566
+ metadata: parseMetadata(dataRaw.ochre.metadata),
2567
+ item: propertyValueItem
2568
+ };
2569
+ return { metadata: data.metadata, propertyValue: data.item };
2570
+ } catch (error) {
2571
+ console.error(error);
2572
+ return null;
2573
+ }
2574
+ }
2575
+
2494
2576
  // src/utils/fetchers/set.ts
2495
2577
  async function fetchSet(uuid) {
2496
2578
  try {
@@ -2612,6 +2694,7 @@ async function fetchWebsite(abbreviation) {
2612
2694
  fetchConcept,
2613
2695
  fetchGallery,
2614
2696
  fetchPeriod,
2697
+ fetchPropertyValue,
2615
2698
  fetchResource,
2616
2699
  fetchSet,
2617
2700
  fetchSpatialUnit,
@@ -2649,6 +2732,8 @@ async function fetchWebsite(abbreviation) {
2649
2732
  parsePerson,
2650
2733
  parsePersons,
2651
2734
  parseProperties,
2735
+ parsePropertyValue,
2736
+ parsePropertyValues,
2652
2737
  parseResource,
2653
2738
  parseResources,
2654
2739
  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
  *
@@ -1308,6 +1342,35 @@ declare function fetchPeriod(uuid: string): Promise<{
1308
1342
  period: Period;
1309
1343
  } | null>;
1310
1344
 
1345
+ /**
1346
+ * Fetches and parses a property value from the OCHRE API
1347
+ *
1348
+ * @param uuid - The UUID of the property value to fetch
1349
+ * @returns Object containing the parsed property value and its metadata, or null if the fetch/parse fails
1350
+ *
1351
+ * @example
1352
+ * ```ts
1353
+ * const result = await fetchPropertyValue("123e4567-e89b-12d3-a456-426614174000");
1354
+ * if (result === null) {
1355
+ * console.error("Failed to fetch property value");
1356
+ * return;
1357
+ * }
1358
+ * const { metadata, item } = result;
1359
+ * console.log(`Fetched property value: ${item.identification.label}`);
1360
+ * ```
1361
+ *
1362
+ * @remarks
1363
+ * The returned property value includes:
1364
+ * - Identification
1365
+ * - Description
1366
+ * - Notes
1367
+ * - Links
1368
+ */
1369
+ declare function fetchPropertyValue(uuid: string): Promise<{
1370
+ metadata: Metadata;
1371
+ propertyValue: PropertyValue;
1372
+ } | null>;
1373
+
1311
1374
  /**
1312
1375
  * Fetches and parses a resource from the OCHRE API
1313
1376
  *
@@ -1730,6 +1793,20 @@ declare function parseBibliography(bibliography: OchreBibliography): Bibliograph
1730
1793
  * @returns Array of parsed Bibliography objects
1731
1794
  */
1732
1795
  declare function parseBibliographies(bibliographies: Array<OchreBibliography>): Array<Bibliography>;
1796
+ /**
1797
+ * Parses raw property value data into a standardized PropertyValue structure
1798
+ *
1799
+ * @param propertyValue - Raw property value data in OCHRE format
1800
+ * @returns Parsed PropertyValue object
1801
+ */
1802
+ declare function parsePropertyValue(propertyValue: OchrePropertyValue): PropertyValue;
1803
+ /**
1804
+ * Parses an array of raw property values into standardized PropertyValue objects
1805
+ *
1806
+ * @param propertyValues - Array of raw property values in OCHRE format
1807
+ * @returns Array of parsed PropertyValue objects
1808
+ */
1809
+ declare function parsePropertyValues(propertyValues: Array<OchrePropertyValue>): Array<PropertyValue>;
1733
1810
  /**
1734
1811
  * Parses a raw tree structure into a standardized Tree object
1735
1812
  *
@@ -1843,4 +1920,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1843
1920
  */
1844
1921
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1845
1922
 
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 };
1923
+ 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, fetchPropertyValue, 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
  *
@@ -1308,6 +1342,35 @@ declare function fetchPeriod(uuid: string): Promise<{
1308
1342
  period: Period;
1309
1343
  } | null>;
1310
1344
 
1345
+ /**
1346
+ * Fetches and parses a property value from the OCHRE API
1347
+ *
1348
+ * @param uuid - The UUID of the property value to fetch
1349
+ * @returns Object containing the parsed property value and its metadata, or null if the fetch/parse fails
1350
+ *
1351
+ * @example
1352
+ * ```ts
1353
+ * const result = await fetchPropertyValue("123e4567-e89b-12d3-a456-426614174000");
1354
+ * if (result === null) {
1355
+ * console.error("Failed to fetch property value");
1356
+ * return;
1357
+ * }
1358
+ * const { metadata, item } = result;
1359
+ * console.log(`Fetched property value: ${item.identification.label}`);
1360
+ * ```
1361
+ *
1362
+ * @remarks
1363
+ * The returned property value includes:
1364
+ * - Identification
1365
+ * - Description
1366
+ * - Notes
1367
+ * - Links
1368
+ */
1369
+ declare function fetchPropertyValue(uuid: string): Promise<{
1370
+ metadata: Metadata;
1371
+ propertyValue: PropertyValue;
1372
+ } | null>;
1373
+
1311
1374
  /**
1312
1375
  * Fetches and parses a resource from the OCHRE API
1313
1376
  *
@@ -1730,6 +1793,20 @@ declare function parseBibliography(bibliography: OchreBibliography): Bibliograph
1730
1793
  * @returns Array of parsed Bibliography objects
1731
1794
  */
1732
1795
  declare function parseBibliographies(bibliographies: Array<OchreBibliography>): Array<Bibliography>;
1796
+ /**
1797
+ * Parses raw property value data into a standardized PropertyValue structure
1798
+ *
1799
+ * @param propertyValue - Raw property value data in OCHRE format
1800
+ * @returns Parsed PropertyValue object
1801
+ */
1802
+ declare function parsePropertyValue(propertyValue: OchrePropertyValue): PropertyValue;
1803
+ /**
1804
+ * Parses an array of raw property values into standardized PropertyValue objects
1805
+ *
1806
+ * @param propertyValues - Array of raw property values in OCHRE format
1807
+ * @returns Array of parsed PropertyValue objects
1808
+ */
1809
+ declare function parsePropertyValues(propertyValues: Array<OchrePropertyValue>): Array<PropertyValue>;
1733
1810
  /**
1734
1811
  * Parses a raw tree structure into a standardized Tree object
1735
1812
  *
@@ -1843,4 +1920,4 @@ declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnote
1843
1920
  */
1844
1921
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1845
1922
 
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 };
1923
+ 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, fetchPropertyValue, 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(
@@ -2414,6 +2463,36 @@ async function fetchPeriod(uuid) {
2414
2463
  }
2415
2464
  }
2416
2465
 
2466
+ // src/utils/fetchers/property-value.ts
2467
+ async function fetchPropertyValue(uuid) {
2468
+ try {
2469
+ const [error, dataRaw] = await fetchByUuid(uuid);
2470
+ if (error !== null) {
2471
+ throw new Error(error);
2472
+ }
2473
+ if (!("propertyValue" in dataRaw.ochre)) {
2474
+ throw new Error(
2475
+ "Invalid OCHRE data: API response missing 'propertyValue' key"
2476
+ );
2477
+ }
2478
+ const propertyValueItem = parsePropertyValue(dataRaw.ochre.propertyValue);
2479
+ const data = {
2480
+ uuid: parseFakeString(dataRaw.ochre.uuid),
2481
+ publicationDateTime: new Date(dataRaw.ochre.publicationDateTime),
2482
+ belongsTo: {
2483
+ uuid: dataRaw.ochre.uuidBelongsTo,
2484
+ abbreviation: parseFakeString(dataRaw.ochre.belongsTo)
2485
+ },
2486
+ metadata: parseMetadata(dataRaw.ochre.metadata),
2487
+ item: propertyValueItem
2488
+ };
2489
+ return { metadata: data.metadata, propertyValue: data.item };
2490
+ } catch (error) {
2491
+ console.error(error);
2492
+ return null;
2493
+ }
2494
+ }
2495
+
2417
2496
  // src/utils/fetchers/set.ts
2418
2497
  async function fetchSet(uuid) {
2419
2498
  try {
@@ -2534,6 +2613,7 @@ export {
2534
2613
  fetchConcept,
2535
2614
  fetchGallery,
2536
2615
  fetchPeriod,
2616
+ fetchPropertyValue,
2537
2617
  fetchResource,
2538
2618
  fetchSet,
2539
2619
  fetchSpatialUnit,
@@ -2571,6 +2651,8 @@ export {
2571
2651
  parsePerson,
2572
2652
  parsePersons,
2573
2653
  parseProperties,
2654
+ parsePropertyValue,
2655
+ parsePropertyValues,
2574
2656
  parseResource,
2575
2657
  parseResources,
2576
2658
  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.12",
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",