@digitalculture/ochre-sdk 0.18.16 → 0.18.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -15,11 +15,11 @@ type Data<T extends DataCategory = DataCategory, U extends DataCategory | Array<
15
15
  /**
16
16
  * Represents the category of the data
17
17
  */
18
- type DataCategory = "resource" | "spatialUnit" | "concept" | "period" | "bibliography" | "person" | "propertyValue" | "text" | "tree" | "set";
18
+ type DataCategory = "resource" | "spatialUnit" | "concept" | "period" | "bibliography" | "person" | "propertyVariable" | "propertyValue" | "text" | "tree" | "set";
19
19
  /**
20
20
  * Represents the item of the data, with proper type narrowing based on category
21
21
  */
22
- type Item<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)> = T extends "resource" ? Resource : T extends "spatialUnit" ? SpatialUnit : T extends "concept" ? Concept : T extends "period" ? Period : T extends "bibliography" ? Bibliography : T extends "person" ? Person : T extends "propertyValue" ? PropertyValue : T extends "text" ? Text : T extends "tree" ? Tree<U extends Array<DataCategory> ? Exclude<U[number], "tree"> : Exclude<U, "tree">> : T extends "set" ? Set<U extends Array<DataCategory> ? U : Array<U>> : Resource | SpatialUnit | Concept | Period | Bibliography | Person | PropertyValue | Tree<U extends Array<DataCategory> ? Exclude<U[number], "tree"> : Exclude<U, "tree">> | Set<U extends Array<DataCategory> ? U : Array<U>>;
22
+ type Item<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)> = T extends "resource" ? Resource : T extends "spatialUnit" ? SpatialUnit : T extends "concept" ? Concept : T extends "period" ? Period : T extends "bibliography" ? Bibliography : T extends "person" ? Person : T extends "propertyVariable" ? PropertyVariable : T extends "propertyValue" ? PropertyValue : T extends "text" ? Text : T extends "tree" ? Tree<U extends Array<DataCategory> ? Exclude<U[number], "tree"> : Exclude<U, "tree">> : T extends "set" ? Set<U extends Array<DataCategory> ? U : Array<U>> : Resource | SpatialUnit | Concept | Period | Bibliography | Person | PropertyVariable | PropertyValue | Tree<U extends Array<DataCategory> ? Exclude<U[number], "tree"> : Exclude<U, "tree">> | Set<U extends Array<DataCategory> ? U : Array<U>>;
23
23
  /**
24
24
  * Basic identification information used across multiple types
25
25
  */
@@ -36,6 +36,7 @@ type Metadata = {
36
36
  identification: Identification & {
37
37
  website: string | null;
38
38
  };
39
+ dateFormat: string | null;
39
40
  } | null;
40
41
  collection: {
41
42
  identification: Identification;
@@ -260,8 +261,7 @@ type Observation = {
260
261
  * Represents an event with date, label and optional agent
261
262
  */
262
263
  type Event = {
263
- dateTime: Date | null;
264
- date: string | null;
264
+ dateTime: string | null;
265
265
  label: string;
266
266
  agent: {
267
267
  uuid: string;
@@ -406,7 +406,7 @@ type Set<U extends Array<DataCategory> = Array<DataCategory>> = {
406
406
  isSuppressingBlanks: boolean;
407
407
  description: string;
408
408
  creators: Array<Person>;
409
- items: [DataCategory] extends [U] ? Array<Item> : U extends "resource" ? Array<Resource> : U extends "spatialUnit" ? Array<SpatialUnit> : U extends "concept" ? Array<Concept> : U extends "period" ? Array<Period> : U extends "bibliography" ? Array<Bibliography> : U extends "person" ? Array<Person> : U extends "propertyValue" ? Array<PropertyValue> : U extends "tree" ? Array<Tree<Exclude<DataCategory, "tree">>> : U extends "set" ? Array<Set<Array<DataCategory>>> : Array<Item>;
409
+ items: [DataCategory] extends [U] ? Array<Item> : U extends "resource" ? Array<Resource> : U extends "spatialUnit" ? Array<SpatialUnit> : U extends "concept" ? Array<Concept> : U extends "period" ? Array<Period> : U extends "bibliography" ? Array<Bibliography> : U extends "person" ? Array<Person> : U extends "propertyVariable" ? Array<PropertyVariable> : U extends "propertyValue" ? Array<PropertyValue> : U extends "tree" ? Array<Tree<Exclude<DataCategory, "tree">>> : U extends "set" ? Array<Set<Array<DataCategory>>> : Array<Item>;
410
410
  };
411
411
  /**
412
412
  * Represents a bibliography entry with citation and publication information
@@ -468,6 +468,25 @@ type Period = {
468
468
  coordinates: Array<Coordinate>;
469
469
  description: string | null;
470
470
  };
471
+ /**
472
+ * Represents a property variable
473
+ */
474
+ type PropertyVariable = {
475
+ uuid: string;
476
+ category: "propertyVariable";
477
+ belongsTo: {
478
+ uuid: string;
479
+ abbreviation: string;
480
+ } | null;
481
+ metadata: Metadata | null;
482
+ persistentUrl: string | null;
483
+ type: string;
484
+ number: number;
485
+ publicationDateTime: Date | null;
486
+ context: Context | null;
487
+ availability: License | null;
488
+ identification: Identification;
489
+ };
471
490
  /**
472
491
  * Represents a property value with type information
473
492
  */
@@ -590,7 +609,7 @@ type Tree<U extends Exclude<DataCategory, "tree"> = Exclude<DataCategory, "tree"
590
609
  identification: Identification;
591
610
  creators: Array<Person>;
592
611
  properties: Array<Property>;
593
- items: [Exclude<DataCategory, "tree">] extends [U] ? Array<Item> : U extends "resource" ? Array<Resource> : U extends "spatialUnit" ? Array<SpatialUnit> : U extends "concept" ? Array<Concept> : U extends "period" ? Array<Period> : U extends "bibliography" ? Array<Bibliography> : U extends "person" ? Array<Person> : U extends "propertyValue" ? Array<PropertyValue> : U extends "text" ? Array<Text> : U extends "set" ? Array<Set<U extends Array<DataCategory> ? U : Array<U>>> : Array<Item>;
612
+ items: [Exclude<DataCategory, "tree">] extends [U] ? Array<Item> : U extends "resource" ? Array<Resource> : U extends "spatialUnit" ? Array<SpatialUnit> : U extends "concept" ? Array<Concept> : U extends "period" ? Array<Period> : U extends "bibliography" ? Array<Bibliography> : U extends "person" ? Array<Person> : U extends "propertyVariable" ? Array<PropertyVariable> : U extends "propertyValue" ? Array<PropertyValue> : U extends "text" ? Array<Text> : U extends "set" ? Array<Set<U extends Array<DataCategory> ? U : Array<U>>> : Array<Item>;
594
613
  };
595
614
  /**
596
615
  * Represents a gallery with its identification, project identification, resources and max length
@@ -1031,24 +1050,7 @@ type WebBlock<T extends WebBlockLayout = WebBlockLayout> = {
1031
1050
  * @param options - The options for the fetch
1032
1051
  * @param options.fetch - The fetch function to use
1033
1052
  * @param options.version - The version of the OCHRE API to use
1034
- * @returns The parsed gallery or null if the fetch/parse fails
1035
- *
1036
- * @example
1037
- * ```ts
1038
- * const gallery = await fetchGallery("9c4da06b-f15e-40af-a747-0933eaf3587e", "1978", 1, 12);
1039
- * if (gallery === null) {
1040
- * console.error("Failed to fetch gallery");
1041
- * return;
1042
- * }
1043
- * console.log(`Fetched gallery: ${gallery.identification.label}`);
1044
- * console.log(`Contains ${gallery.resources.length.toLocaleString()} resources`);
1045
- * ```
1046
- *
1047
- * @remarks
1048
- * The returned gallery includes:
1049
- * - Gallery metadata and identification
1050
- * - Project identification
1051
- * - Resources (gallery items)
1053
+ * @returns The parsed gallery or an error message if the fetch/parse fails
1052
1054
  */
1053
1055
  declare function fetchGallery(uuid: string, filter: string, page: number, pageSize: number, options?: {
1054
1056
  fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
@@ -1066,34 +1068,7 @@ declare function fetchGallery(uuid: string, filter: string, page: number, pageSi
1066
1068
  * Fetches and parses an OCHRE item from the OCHRE API
1067
1069
  *
1068
1070
  * @param uuid - The UUID of the OCHRE item to fetch
1069
- * @returns Object containing the parsed OCHRE item and its metadata, or null if the fetch/parse fails
1070
- *
1071
- * @example
1072
- * ```ts
1073
- * const result = await fetchItem("123e4567-e89b-12d3-a456-426614174000");
1074
- * if (result === null) {
1075
- * console.error("Failed to fetch OCHRE item");
1076
- * return;
1077
- * }
1078
- * const { metadata, belongsTo, item, category } = result;
1079
- * console.log(`Fetched OCHRE item: ${item.identification.label} with category ${category}`);
1080
- * ```
1081
- *
1082
- * Or, if you want to fetch a specific category, you can do so by passing the category as an argument:
1083
- * ```ts
1084
- * const result = await fetchItem("123e4567-e89b-12d3-a456-426614174000", "resource");
1085
- * const { metadata, belongsTo, item, category } = result;
1086
- * console.log(item.category); // "resource"
1087
- * ```
1088
- *
1089
- * @remarks
1090
- * The returned OCHRE item includes:
1091
- * - Item metadata
1092
- * - Item belongsTo information
1093
- * - Item content
1094
- * - Item category
1095
- *
1096
- * If the fetch/parse fails, the returned object will have an `error` property.
1071
+ * @returns Object containing the parsed OCHRE item, or an error message if the fetch/parse fails
1097
1072
  */
1098
1073
  declare function fetchItem<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(uuid: string, category?: T, itemCategories?: U, options?: {
1099
1074
  fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
@@ -1101,13 +1076,9 @@ declare function fetchItem<T extends DataCategory = DataCategory, U extends Data
1101
1076
  }): Promise<{
1102
1077
  error: null;
1103
1078
  item: Item<T, U>;
1104
- category: T;
1105
- itemCategories: U;
1106
1079
  } | {
1107
1080
  error: string;
1108
- item: never;
1109
- category: never;
1110
- itemCategories: never;
1081
+ item: null;
1111
1082
  }>;
1112
1083
  //#endregion
1113
1084
  //#region src/utils/fetchers/items-by-property-values.d.ts
@@ -1235,29 +1206,6 @@ declare function fetchPropertyValuesByPropertyVariables(params: {
1235
1206
  *
1236
1207
  * @param abbreviation - The abbreviation identifier for the website
1237
1208
  * @returns The parsed website configuration or null if the fetch/parse fails
1238
- *
1239
- * @example
1240
- * ```ts
1241
- * const website = await fetchWebsite("guerrilla-television");
1242
- * if (website === null) {
1243
- * console.error("Failed to fetch website");
1244
- * return;
1245
- * }
1246
- * console.log(`Fetched website: ${website.identification.label}`);
1247
- * console.log(`Contains ${website.pages.length.toLocaleString()} pages`);
1248
- * ```
1249
- *
1250
- * @remarks
1251
- * The returned website configuration includes:
1252
- * - Website metadata and identification
1253
- * - Page structure and content
1254
- * - Layout and styling properties
1255
- * - Navigation configuration
1256
- * - Sidebar elements
1257
- * - Project information
1258
- * - Creator details
1259
- *
1260
- * The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
1261
1209
  */
1262
1210
  declare function fetchWebsite(abbreviation: string, options?: {
1263
1211
  fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
@@ -1278,14 +1226,6 @@ type PropertyOptions = {
1278
1226
  * @param uuid - The UUID to search for
1279
1227
  * @param options - Search options, including whether to include nested properties
1280
1228
  * @returns The matching Property object, or null if not found
1281
- *
1282
- * @example
1283
- * ```ts
1284
- * const property = getPropertyByUuid(properties, "123e4567-e89b-12d3-a456-426614174000", { includeNestedProperties: true });
1285
- * if (property) {
1286
- * console.log(property.values);
1287
- * }
1288
- * ```
1289
1229
  */
1290
1230
  declare function getPropertyByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Property | null;
1291
1231
  /**
@@ -1295,16 +1235,6 @@ declare function getPropertyByUuid(properties: Array<Property>, uuid: string, op
1295
1235
  * @param uuid - The UUID to search for
1296
1236
  * @param options - Search options, including whether to include nested properties
1297
1237
  * @returns Array of property values as strings, or null if property not found
1298
- *
1299
- * @example
1300
- * ```ts
1301
- * const values = getPropertyValuesByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
1302
- * if (values) {
1303
- * for (const value of values) {
1304
- * console.log(value);
1305
- * }
1306
- * }
1307
- * ```
1308
1238
  */
1309
1239
  declare function getPropertyValuesByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): Array<string | number | boolean | Date | null> | null;
1310
1240
  /**
@@ -1314,14 +1244,6 @@ declare function getPropertyValuesByUuid(properties: Array<Property>, uuid: stri
1314
1244
  * @param uuid - The UUID to search for
1315
1245
  * @param options - Search options, including whether to include nested properties
1316
1246
  * @returns The first property value as string, or null if property not found
1317
- *
1318
- * @example
1319
- * ```ts
1320
- * const title = getPropertyValueByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
1321
- * if (title) {
1322
- * console.log(`Document title: ${title}`);
1323
- * }
1324
- * ```
1325
1247
  */
1326
1248
  declare function getPropertyValueByUuid(properties: Array<Property>, uuid: string, options?: PropertyOptions): string | number | boolean | Date | null;
1327
1249
  /**
@@ -1331,14 +1253,6 @@ declare function getPropertyValueByUuid(properties: Array<Property>, uuid: strin
1331
1253
  * @param label - The label to search for
1332
1254
  * @param options - Search options, including whether to include nested properties
1333
1255
  * @returns The matching Property object, or null if not found
1334
- *
1335
- * @example
1336
- * ```ts
1337
- * const property = getPropertyByLabel(properties, "author", { includeNestedProperties: true });
1338
- * if (property) {
1339
- * console.log(property.values);
1340
- * }
1341
- * ```
1342
1256
  */
1343
1257
  declare function getPropertyByLabel(properties: Array<Property>, label: string, options?: PropertyOptions): Property | null;
1344
1258
  /**
@@ -1348,16 +1262,6 @@ declare function getPropertyByLabel(properties: Array<Property>, label: string,
1348
1262
  * @param label - The label to search for
1349
1263
  * @param options - Search options, including whether to include nested properties
1350
1264
  * @returns Array of property values as strings, or null if property not found
1351
- *
1352
- * @example
1353
- * ```ts
1354
- * const values = getPropertyValuesByLabel(properties, "keywords");
1355
- * if (values) {
1356
- * for (const value of values) {
1357
- * console.log(value);
1358
- * }
1359
- * }
1360
- * ```
1361
1265
  */
1362
1266
  declare function getPropertyValuesByLabel(properties: Array<Property>, label: string, options?: PropertyOptions): Array<string | number | boolean | Date | null> | null;
1363
1267
  /**
@@ -1367,14 +1271,6 @@ declare function getPropertyValuesByLabel(properties: Array<Property>, label: st
1367
1271
  * @param label - The label to search for
1368
1272
  * @param options - Search options, including whether to include nested properties
1369
1273
  * @returns The first property value as string, or null if property not found
1370
- *
1371
- * @example
1372
- * ```ts
1373
- * const title = getPropertyValueByLabel(properties, "title");
1374
- * if (title) {
1375
- * console.log(`Document title: ${title}`);
1376
- * }
1377
- * ```
1378
1274
  */
1379
1275
  declare function getPropertyValueByLabel(properties: Array<Property>, label: string, options?: PropertyOptions): string | number | boolean | Date | null;
1380
1276
  /**
@@ -1383,12 +1279,6 @@ declare function getPropertyValueByLabel(properties: Array<Property>, label: str
1383
1279
  * @param properties - Array of properties to get unique properties from
1384
1280
  * @param options - Search options, including whether to include nested properties
1385
1281
  * @returns Array of unique properties
1386
- *
1387
- * @example
1388
- * ```ts
1389
- * const properties = getAllUniqueProperties(properties, { includeNestedProperties: true });
1390
- * console.log(`Available properties: ${properties.map((p) => p.label).join(", ")}`);
1391
- * ```
1392
1282
  */
1393
1283
  declare function getUniqueProperties(properties: Array<Property>, options?: PropertyOptions): Array<Property>;
1394
1284
  /**
@@ -1397,12 +1287,6 @@ declare function getUniqueProperties(properties: Array<Property>, options?: Prop
1397
1287
  * @param properties - Array of properties to get unique property labels from
1398
1288
  * @param options - Search options, including whether to include nested properties
1399
1289
  * @returns Array of unique property labels
1400
- *
1401
- * @example
1402
- * ```ts
1403
- * const properties = getAllUniquePropertyLabels(properties, { includeNestedProperties: true });
1404
- * console.log(`Available properties: ${properties.join(", ")}`);
1405
- * ```
1406
1290
  */
1407
1291
  declare function getUniquePropertyLabels(properties: Array<Property>, options?: PropertyOptions): Array<string>;
1408
1292
  /**
@@ -1414,17 +1298,6 @@ declare function getUniquePropertyLabels(properties: Array<Property>, options?:
1414
1298
  * @param filter.value - The value to filter by
1415
1299
  * @param options - Search options, including whether to include nested properties
1416
1300
  * @returns True if the property matches the filter criteria, false otherwise
1417
- *
1418
- * @example
1419
- * ```ts
1420
- * const matches = filterProperties(property, {
1421
- * label: "category",
1422
- * value: "book"
1423
- * });
1424
- * if (matches) {
1425
- * console.log("Property matches filter criteria");
1426
- * }
1427
- * ```
1428
1301
  */
1429
1302
  declare function filterProperties(property: Property, filter: {
1430
1303
  label: string;
@@ -1460,4 +1333,4 @@ declare function flattenItemProperties<T extends DataCategory = DataCategory, U
1460
1333
  */
1461
1334
  declare function getLeafPropertyValues<T extends PropertyValueContentType = PropertyValueContentType>(propertyValues: Array<PropertyValueContent<T>>): Array<PropertyValueContent<T>>;
1462
1335
  //#endregion
1463
- export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, Resource, Scope, Section, Set, SpatialUnit, Style, Text, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, Website, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchItemsByUuidsAndLinks, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
1336
+ export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Resource, Scope, Section, Set, SpatialUnit, Style, Text, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, Website, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchItemsByUuidsAndLinks, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
package/dist/index.mjs CHANGED
@@ -187,6 +187,7 @@ const categorySchema = z.enum([
187
187
  "period",
188
188
  "bibliography",
189
189
  "person",
190
+ "propertyVariable",
190
191
  "propertyValue",
191
192
  "text",
192
193
  "tree",
@@ -277,14 +278,6 @@ const DEFAULT_OPTIONS = { includeNestedProperties: false };
277
278
  * @param uuid - The UUID to search for
278
279
  * @param options - Search options, including whether to include nested properties
279
280
  * @returns The matching Property object, or null if not found
280
- *
281
- * @example
282
- * ```ts
283
- * const property = getPropertyByUuid(properties, "123e4567-e89b-12d3-a456-426614174000", { includeNestedProperties: true });
284
- * if (property) {
285
- * console.log(property.values);
286
- * }
287
- * ```
288
281
  */
289
282
  function getPropertyByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
290
283
  const { includeNestedProperties } = options;
@@ -305,16 +298,6 @@ function getPropertyByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
305
298
  * @param uuid - The UUID to search for
306
299
  * @param options - Search options, including whether to include nested properties
307
300
  * @returns Array of property values as strings, or null if property not found
308
- *
309
- * @example
310
- * ```ts
311
- * const values = getPropertyValuesByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
312
- * if (values) {
313
- * for (const value of values) {
314
- * console.log(value);
315
- * }
316
- * }
317
- * ```
318
301
  */
319
302
  function getPropertyValuesByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
320
303
  const { includeNestedProperties } = options;
@@ -335,14 +318,6 @@ function getPropertyValuesByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
335
318
  * @param uuid - The UUID to search for
336
319
  * @param options - Search options, including whether to include nested properties
337
320
  * @returns The first property value as string, or null if property not found
338
- *
339
- * @example
340
- * ```ts
341
- * const title = getPropertyValueByUuid(properties, "123e4567-e89b-12d3-a456-426614174000");
342
- * if (title) {
343
- * console.log(`Document title: ${title}`);
344
- * }
345
- * ```
346
321
  */
347
322
  function getPropertyValueByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
348
323
  const { includeNestedProperties } = options;
@@ -363,14 +338,6 @@ function getPropertyValueByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
363
338
  * @param label - The label to search for
364
339
  * @param options - Search options, including whether to include nested properties
365
340
  * @returns The matching Property object, or null if not found
366
- *
367
- * @example
368
- * ```ts
369
- * const property = getPropertyByLabel(properties, "author", { includeNestedProperties: true });
370
- * if (property) {
371
- * console.log(property.values);
372
- * }
373
- * ```
374
341
  */
375
342
  function getPropertyByLabel(properties, label, options = DEFAULT_OPTIONS) {
376
343
  const { includeNestedProperties } = options;
@@ -391,16 +358,6 @@ function getPropertyByLabel(properties, label, options = DEFAULT_OPTIONS) {
391
358
  * @param label - The label to search for
392
359
  * @param options - Search options, including whether to include nested properties
393
360
  * @returns Array of property values as strings, or null if property not found
394
- *
395
- * @example
396
- * ```ts
397
- * const values = getPropertyValuesByLabel(properties, "keywords");
398
- * if (values) {
399
- * for (const value of values) {
400
- * console.log(value);
401
- * }
402
- * }
403
- * ```
404
361
  */
405
362
  function getPropertyValuesByLabel(properties, label, options = DEFAULT_OPTIONS) {
406
363
  const { includeNestedProperties } = options;
@@ -421,14 +378,6 @@ function getPropertyValuesByLabel(properties, label, options = DEFAULT_OPTIONS)
421
378
  * @param label - The label to search for
422
379
  * @param options - Search options, including whether to include nested properties
423
380
  * @returns The first property value as string, or null if property not found
424
- *
425
- * @example
426
- * ```ts
427
- * const title = getPropertyValueByLabel(properties, "title");
428
- * if (title) {
429
- * console.log(`Document title: ${title}`);
430
- * }
431
- * ```
432
381
  */
433
382
  function getPropertyValueByLabel(properties, label, options = DEFAULT_OPTIONS) {
434
383
  const { includeNestedProperties } = options;
@@ -448,12 +397,6 @@ function getPropertyValueByLabel(properties, label, options = DEFAULT_OPTIONS) {
448
397
  * @param properties - Array of properties to get unique properties from
449
398
  * @param options - Search options, including whether to include nested properties
450
399
  * @returns Array of unique properties
451
- *
452
- * @example
453
- * ```ts
454
- * const properties = getAllUniqueProperties(properties, { includeNestedProperties: true });
455
- * console.log(`Available properties: ${properties.map((p) => p.label).join(", ")}`);
456
- * ```
457
400
  */
458
401
  function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
459
402
  const { includeNestedProperties } = options;
@@ -477,12 +420,6 @@ function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
477
420
  * @param properties - Array of properties to get unique property labels from
478
421
  * @param options - Search options, including whether to include nested properties
479
422
  * @returns Array of unique property labels
480
- *
481
- * @example
482
- * ```ts
483
- * const properties = getAllUniquePropertyLabels(properties, { includeNestedProperties: true });
484
- * console.log(`Available properties: ${properties.join(", ")}`);
485
- * ```
486
423
  */
487
424
  function getUniquePropertyLabels(properties, options = DEFAULT_OPTIONS) {
488
425
  const { includeNestedProperties } = options;
@@ -509,17 +446,6 @@ function getUniquePropertyLabels(properties, options = DEFAULT_OPTIONS) {
509
446
  * @param filter.value - The value to filter by
510
447
  * @param options - Search options, including whether to include nested properties
511
448
  * @returns True if the property matches the filter criteria, false otherwise
512
- *
513
- * @example
514
- * ```ts
515
- * const matches = filterProperties(property, {
516
- * label: "category",
517
- * value: "book"
518
- * });
519
- * if (matches) {
520
- * console.log("Property matches filter criteria");
521
- * }
522
- * ```
523
449
  */
524
450
  function filterProperties(property, filter, options = DEFAULT_OPTIONS) {
525
451
  const { includeNestedProperties } = options;
@@ -548,7 +474,7 @@ function filterProperties(property, filter, options = DEFAULT_OPTIONS) {
548
474
 
549
475
  //#endregion
550
476
  //#region src/constants.ts
551
- const BELONG_TO_COLLECTION_UUID = "30054cb2-909a-4f34-8db9-8fe7369d691d";
477
+ const BELONGS_TO_COLLECTION_UUID = "30054cb2-909a-4f34-8db9-8fe7369d691d";
552
478
  const PRESENTATION_ITEM_UUID = "f1c131b6-1498-48a4-95bf-a9edae9fd518";
553
479
  const TEXT_ANNOTATION_UUID = "b9ca2732-78f4-416e-b77f-dae7647e68a9";
554
480
  const TEXT_ANNOTATION_HOVER_CARD_UUID = "c7f6a08a-f07b-49b6-bcb1-af485da3c58f";
@@ -576,12 +502,6 @@ function getStringItemByLanguage(content, language) {
576
502
  *
577
503
  * @param string - Input string to parse
578
504
  * @returns String with emails converted to HTML links
579
- *
580
- * @example
581
- * ```ts
582
- * const parsed = parseEmail("Contact us at info@example.com");
583
- * // Returns: "Contact us at <ExternalLink href="mailto:info@example.com">info@example.com</ExternalLink>"
584
- * ```
585
505
  */
586
506
  function parseEmail(string) {
587
507
  const splitString = string.split(" ");
@@ -661,13 +581,6 @@ function parseWhitespace(contentString, whitespace) {
661
581
  *
662
582
  * @param string - FakeString value to convert
663
583
  * @returns Converted string value
664
- *
665
- * @example
666
- * ```ts
667
- * parseFakeString(true); // Returns "Yes"
668
- * parseFakeString(123); // Returns "123"
669
- * parseFakeString("test"); // Returns "test"
670
- * ```
671
584
  */
672
585
  function parseFakeString(string) {
673
586
  return String(string).replaceAll("&#39;", "'").replaceAll("{", String.raw`\{`).replaceAll("}", String.raw`\}`);
@@ -1106,7 +1019,10 @@ function parseMetadata(metadata) {
1106
1019
  let collectionIdentification = null;
1107
1020
  if (metadata.collection) collectionIdentification = parseIdentification(metadata.collection.identification);
1108
1021
  return {
1109
- project: projectIdentification ? { identification: projectIdentification } : null,
1022
+ project: projectIdentification ? {
1023
+ identification: projectIdentification,
1024
+ dateFormat: metadata.project?.dateFormat ?? null
1025
+ } : null,
1110
1026
  collection: collectionIdentification ? { identification: collectionIdentification } : null,
1111
1027
  item: metadata.item ? {
1112
1028
  identification,
@@ -1225,13 +1141,13 @@ function parsePersons(persons) {
1225
1141
  * @returns Parsed Link object
1226
1142
  */
1227
1143
  function parseLink(linkRaw) {
1228
- 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 : "propertyValue" in linkRaw ? linkRaw.propertyValue : null;
1144
+ 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 : "propertyVariable" in linkRaw ? linkRaw.propertyVariable : "propertyValue" in linkRaw ? linkRaw.propertyValue : null;
1229
1145
  if (!links) throw new Error(`Invalid link provided: ${JSON.stringify(linkRaw, null, 2)}`);
1230
1146
  const linksToParse = Array.isArray(links) ? links : [links];
1231
1147
  const returnLinks = [];
1232
1148
  for (const link of linksToParse) {
1233
1149
  const returnLink = {
1234
- 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" : "propertyValue" in linkRaw ? "propertyValue" : null,
1150
+ 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" : "propertyVariable" in linkRaw ? "propertyVariable" : "propertyValue" in linkRaw ? "propertyValue" : null,
1235
1151
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
1236
1152
  href: "href" in link && link.href != null ? link.href : null,
1237
1153
  fileFormat: "fileFormat" in link && link.fileFormat != null ? link.fileFormat : null,
@@ -1438,8 +1354,7 @@ function parseObservations(observations) {
1438
1354
  function parseEvents(events) {
1439
1355
  const returnEvents = [];
1440
1356
  for (const event of events) returnEvents.push({
1441
- dateTime: event.dateTime != null ? parseISO(event.dateTime) : null,
1442
- date: event.partialDates?.year != null ? `${event.partialDates.year}-01-01/${event.partialDates.endYear ?? event.partialDates.year}-12-31` : null,
1357
+ dateTime: event.endDateTime != null ? `${event.dateTime}/${event.endDateTime}` : event.dateTime ?? null,
1443
1358
  label: parseStringContent(event.label),
1444
1359
  location: event.location ? {
1445
1360
  uuid: event.location.uuid,
@@ -1577,7 +1492,7 @@ function parseProperties(properties, language = "eng") {
1577
1492
  function parseInterpretations(interpretations) {
1578
1493
  const returnInterpretations = [];
1579
1494
  for (const interpretation of interpretations) returnInterpretations.push({
1580
- date: interpretation.date,
1495
+ date: interpretation.date ?? null,
1581
1496
  number: interpretation.interpretationNo,
1582
1497
  links: interpretation.links ? parseLinks(Array.isArray(interpretation.links) ? interpretation.links : [interpretation.links]) : [],
1583
1498
  properties: interpretation.properties ? parseProperties(Array.isArray(interpretation.properties.property) ? interpretation.properties.property : [interpretation.properties.property]) : [],
@@ -1713,6 +1628,38 @@ function parseBibliography(bibliography, metadata, persistentUrl, belongsTo) {
1713
1628
  };
1714
1629
  }
1715
1630
  /**
1631
+ * Parses raw property variable data into a standardized PropertyVariable structure
1632
+ *
1633
+ * @param propertyVariable - Raw property variable data in OCHRE format
1634
+ * @returns Parsed PropertyVariable object
1635
+ */
1636
+ function parsePropertyVariable(propertyVariable, metadata, persistentUrl, belongsTo) {
1637
+ return {
1638
+ uuid: propertyVariable.uuid,
1639
+ category: "propertyVariable",
1640
+ belongsTo: belongsTo ?? null,
1641
+ metadata: metadata ?? null,
1642
+ persistentUrl: persistentUrl ?? null,
1643
+ type: propertyVariable.type,
1644
+ number: propertyVariable.n,
1645
+ publicationDateTime: propertyVariable.publicationDateTime ? parseISO(propertyVariable.publicationDateTime) : null,
1646
+ context: propertyVariable.context ? parseContext(propertyVariable.context) : null,
1647
+ availability: propertyVariable.availability ? parseLicense(propertyVariable.availability) : null,
1648
+ identification: parseIdentification(propertyVariable.identification)
1649
+ };
1650
+ }
1651
+ /**
1652
+ * Parses an array of raw property variables into standardized PropertyVariable objects
1653
+ *
1654
+ * @param propertyVariables - Array of raw property variables in OCHRE format
1655
+ * @returns Array of parsed PropertyVariable objects
1656
+ */
1657
+ function parsePropertyVariables(propertyVariables) {
1658
+ const returnPropertyVariables = [];
1659
+ for (const propertyVariable of propertyVariables) returnPropertyVariables.push(parsePropertyVariable(propertyVariable));
1660
+ return returnPropertyVariables;
1661
+ }
1662
+ /**
1716
1663
  * Parses an array of raw bibliographies into standardized Bibliography objects
1717
1664
  *
1718
1665
  * @param bibliographies - Array of raw bibliographies in OCHRE format
@@ -1879,6 +1826,10 @@ function parseTree(tree, itemCategories, metadata, persistentUrl, belongsTo) {
1879
1826
  if (!("person" in tree.items)) throw new Error("Invalid OCHRE data: Tree has no persons");
1880
1827
  items = parsePersons(Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]);
1881
1828
  break;
1829
+ case "propertyVariable":
1830
+ if (!("propertyVariable" in tree.items)) throw new Error("Invalid OCHRE data: Tree has no property variables");
1831
+ items = parsePropertyVariables(Array.isArray(tree.items.propertyVariable) ? tree.items.propertyVariable : [tree.items.propertyVariable]);
1832
+ break;
1882
1833
  case "propertyValue":
1883
1834
  if (!("propertyValue" in tree.items)) throw new Error("Invalid OCHRE data: Tree has no property values");
1884
1835
  items = parsePropertyValues(Array.isArray(tree.items.propertyValue) ? tree.items.propertyValue : [tree.items.propertyValue]);
@@ -1959,6 +1910,10 @@ function parseSet(set, itemCategories, metadata, persistentUrl, belongsTo) {
1959
1910
  if (!("person" in set.items) || set.items.person == null) throw new Error("Invalid OCHRE data: Set has no persons");
1960
1911
  items.push(...parsePersons(Array.isArray(set.items.person) ? set.items.person : [set.items.person]));
1961
1912
  break;
1913
+ case "propertyVariable":
1914
+ if (!("propertyVariable" in set.items) || set.items.propertyVariable == null) throw new Error("Invalid OCHRE data: Set has no property variables");
1915
+ items.push(...parsePropertyVariables(Array.isArray(set.items.propertyVariable) ? set.items.propertyVariable : [set.items.propertyVariable]));
1916
+ break;
1962
1917
  case "propertyValue":
1963
1918
  if (!("propertyValue" in set.items) || set.items.propertyValue == null) throw new Error("Invalid OCHRE data: Set has no property values");
1964
1919
  items.push(...parsePropertyValues(Array.isArray(set.items.propertyValue) ? set.items.propertyValue : [set.items.propertyValue]));
@@ -3357,24 +3312,7 @@ function parseWebsite(websiteTree, metadata, belongsTo, { version = DEFAULT_API_
3357
3312
  * @param options - The options for the fetch
3358
3313
  * @param options.fetch - The fetch function to use
3359
3314
  * @param options.version - The version of the OCHRE API to use
3360
- * @returns The parsed gallery or null if the fetch/parse fails
3361
- *
3362
- * @example
3363
- * ```ts
3364
- * const gallery = await fetchGallery("9c4da06b-f15e-40af-a747-0933eaf3587e", "1978", 1, 12);
3365
- * if (gallery === null) {
3366
- * console.error("Failed to fetch gallery");
3367
- * return;
3368
- * }
3369
- * console.log(`Fetched gallery: ${gallery.identification.label}`);
3370
- * console.log(`Contains ${gallery.resources.length.toLocaleString()} resources`);
3371
- * ```
3372
- *
3373
- * @remarks
3374
- * The returned gallery includes:
3375
- * - Gallery metadata and identification
3376
- * - Project identification
3377
- * - Resources (gallery items)
3315
+ * @returns The parsed gallery or an error message if the fetch/parse fails
3378
3316
  */
3379
3317
  async function fetchGallery(uuid, filter, page, pageSize, options) {
3380
3318
  try {
@@ -3422,17 +3360,6 @@ async function fetchGallery(uuid, filter, page, pageSize, options) {
3422
3360
  *
3423
3361
  * @param uuid - The UUID of the OCHRE item to fetch
3424
3362
  * @returns A tuple containing either [null, OchreData] on success or [error message, null] on failure
3425
- *
3426
- * @example
3427
- * ```ts
3428
- * const [error, data] = await fetchByUuid("123e4567-e89b-12d3-a456-426614174000");
3429
- * if (error !== null) {
3430
- * console.error(`Failed to fetch: ${error}`);
3431
- * return;
3432
- * }
3433
- * // Process data...
3434
- * ```
3435
- *
3436
3363
  * @internal
3437
3364
  */
3438
3365
  async function fetchByUuid(uuid, options) {
@@ -3455,34 +3382,7 @@ async function fetchByUuid(uuid, options) {
3455
3382
  * Fetches and parses an OCHRE item from the OCHRE API
3456
3383
  *
3457
3384
  * @param uuid - The UUID of the OCHRE item to fetch
3458
- * @returns Object containing the parsed OCHRE item and its metadata, or null if the fetch/parse fails
3459
- *
3460
- * @example
3461
- * ```ts
3462
- * const result = await fetchItem("123e4567-e89b-12d3-a456-426614174000");
3463
- * if (result === null) {
3464
- * console.error("Failed to fetch OCHRE item");
3465
- * return;
3466
- * }
3467
- * const { metadata, belongsTo, item, category } = result;
3468
- * console.log(`Fetched OCHRE item: ${item.identification.label} with category ${category}`);
3469
- * ```
3470
- *
3471
- * Or, if you want to fetch a specific category, you can do so by passing the category as an argument:
3472
- * ```ts
3473
- * const result = await fetchItem("123e4567-e89b-12d3-a456-426614174000", "resource");
3474
- * const { metadata, belongsTo, item, category } = result;
3475
- * console.log(item.category); // "resource"
3476
- * ```
3477
- *
3478
- * @remarks
3479
- * The returned OCHRE item includes:
3480
- * - Item metadata
3481
- * - Item belongsTo information
3482
- * - Item content
3483
- * - Item category
3484
- *
3485
- * If the fetch/parse fails, the returned object will have an `error` property.
3385
+ * @returns Object containing the parsed OCHRE item, or an error message if the fetch/parse fails
3486
3386
  */
3487
3387
  async function fetchItem(uuid, category, itemCategories, options) {
3488
3388
  try {
@@ -3492,7 +3392,7 @@ async function fetchItem(uuid, category, itemCategories, options) {
3492
3392
  version
3493
3393
  });
3494
3394
  if (error !== null) throw new Error(error);
3495
- const categoryKey = getItemCategory(Object.keys(data.ochre));
3395
+ const categoryKey = category ?? getItemCategory(Object.keys(data.ochre));
3496
3396
  const belongsTo = {
3497
3397
  uuid: data.ochre.uuidBelongsTo,
3498
3398
  abbreviation: parseFakeString(data.ochre.belongsTo)
@@ -3527,6 +3427,10 @@ async function fetchItem(uuid, category, itemCategories, options) {
3527
3427
  if (!("person" in data.ochre)) throw new Error("Invalid OCHRE data: API response missing 'person' key");
3528
3428
  item = parsePerson(data.ochre.person, metadata, data.ochre.persistentUrl, belongsTo);
3529
3429
  break;
3430
+ case "propertyVariable":
3431
+ if (!("propertyVariable" in data.ochre)) throw new Error("Invalid OCHRE data: API response missing 'propertyVariable' key");
3432
+ item = parsePropertyVariable(data.ochre.propertyVariable, metadata, data.ochre.persistentUrl, belongsTo);
3433
+ break;
3530
3434
  case "propertyValue":
3531
3435
  if (!("propertyValue" in data.ochre)) throw new Error("Invalid OCHRE data: API response missing 'propertyValue' key");
3532
3436
  item = parsePropertyValue(data.ochre.propertyValue, metadata, data.ochre.persistentUrl, belongsTo);
@@ -3547,16 +3451,12 @@ async function fetchItem(uuid, category, itemCategories, options) {
3547
3451
  }
3548
3452
  return {
3549
3453
  error: null,
3550
- item,
3551
- category,
3552
- itemCategories
3454
+ item
3553
3455
  };
3554
3456
  } catch (error) {
3555
3457
  return {
3556
3458
  error: error instanceof Error ? error.message : "Unknown error",
3557
- item: void 0,
3558
- category: void 0,
3559
- itemCategories: void 0
3459
+ item: null
3560
3460
  };
3561
3461
  }
3562
3462
  }
@@ -3584,7 +3484,7 @@ function buildXQuery$2(params, options) {
3584
3484
  const startPos = (page - 1) * pageSize + 1;
3585
3485
  const endPos = page * pageSize;
3586
3486
  let belongsToCollectionScopeFilter = "";
3587
- if (belongsToCollectionScopeUuids.length > 0) belongsToCollectionScopeFilter = `[.//properties[property[label/@uuid="${BELONG_TO_COLLECTION_UUID}" and value/(${belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]]`;
3487
+ if (belongsToCollectionScopeUuids.length > 0) belongsToCollectionScopeFilter = `[.//properties[property[label/@uuid="${BELONGS_TO_COLLECTION_UUID}" and value/(${belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]]`;
3588
3488
  const propertyVariables = propertyVariableUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ");
3589
3489
  const propertyValuesFilters = propertyValues.map(({ dataType, value }) => {
3590
3490
  if (dataType === "IDREF") return `value[@uuid="${value}"]`;
@@ -3680,6 +3580,10 @@ async function fetchItemsByPropertyValues(params, categoryParams, options) {
3680
3580
  const persons = parsePersons(Array.isArray(data.result.ochre.items.person) ? data.result.ochre.items.person : [data.result.ochre.items.person]);
3681
3581
  items.push(...persons);
3682
3582
  }
3583
+ if ("propertyVariable" in data.result.ochre.items && data.result.ochre.items.propertyVariable != null) {
3584
+ const propertyVariables = parsePropertyVariables(Array.isArray(data.result.ochre.items.propertyVariable) ? data.result.ochre.items.propertyVariable : [data.result.ochre.items.propertyVariable]);
3585
+ items.push(...propertyVariables);
3586
+ }
3683
3587
  if ("propertyValue" in data.result.ochre.items && data.result.ochre.items.propertyValue != null) {
3684
3588
  const propertyValues = parsePropertyValues(Array.isArray(data.result.ochre.items.propertyValue) ? data.result.ochre.items.propertyValue : [data.result.ochre.items.propertyValue]);
3685
3589
  items.push(...propertyValues);
@@ -3733,7 +3637,7 @@ function buildXQuery$1(params, options) {
3733
3637
  const version = options?.version ?? DEFAULT_API_VERSION;
3734
3638
  const { projectScopeUuid, belongsToCollectionScopeUuids, itemCategory, itemUuids, linkUuids } = params;
3735
3639
  let belongsToCollectionScopeFilter = "";
3736
- if (belongsToCollectionScopeUuids.length > 0) belongsToCollectionScopeFilter = `properties/property[label/@uuid="${BELONG_TO_COLLECTION_UUID}"][value[${belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")}]]`;
3640
+ if (belongsToCollectionScopeUuids.length > 0) belongsToCollectionScopeFilter = `properties/property[label/@uuid="${BELONGS_TO_COLLECTION_UUID}"][value[${belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")}]]`;
3737
3641
  let itemCategoryFilter = "";
3738
3642
  const filterParts = [];
3739
3643
  if (itemUuids.length > 0) filterParts.push(itemUuids.map((uuid) => `@uuid="${uuid}"`).join(" or "));
@@ -3812,6 +3716,10 @@ async function fetchItemsByUuidsAndLinks(params, categoryParams, options) {
3812
3716
  const persons = parsePersons(Array.isArray(data.result.ochre.person) ? data.result.ochre.person : [data.result.ochre.person]);
3813
3717
  items.push(...persons);
3814
3718
  }
3719
+ if ("propertyVariable" in data.result.ochre && data.result.ochre.propertyVariable != null && itemCategory === null) {
3720
+ const propertyVariables = parsePropertyVariables(Array.isArray(data.result.ochre.propertyVariable) ? data.result.ochre.propertyVariable : [data.result.ochre.propertyVariable]);
3721
+ items.push(...propertyVariables);
3722
+ }
3815
3723
  if ("propertyValue" in data.result.ochre && data.result.ochre.propertyValue != null && itemCategory === null) {
3816
3724
  const propertyValues = parsePropertyValues(Array.isArray(data.result.ochre.propertyValue) ? data.result.ochre.propertyValue : [data.result.ochre.propertyValue]);
3817
3725
  items.push(...propertyValues);
@@ -3848,6 +3756,7 @@ async function fetchItemsByUuidsAndLinks(params, categoryParams, options) {
3848
3756
  */
3849
3757
  const propertyValueQueryItemSchema = z.object({
3850
3758
  uuid: z.string(),
3759
+ itemUuid: z.string().optional(),
3851
3760
  dataType: z.string(),
3852
3761
  rawValue: z.union([
3853
3762
  z.string(),
@@ -3863,6 +3772,7 @@ const propertyValueQueryItemSchema = z.object({
3863
3772
  ]).optional()
3864
3773
  }).transform((val) => {
3865
3774
  const returnValue = {
3775
+ itemUuid: val.itemUuid != null && val.itemUuid !== "" ? val.itemUuid : null,
3866
3776
  dataType: val.dataType,
3867
3777
  content: null,
3868
3778
  label: null
@@ -3907,16 +3817,17 @@ function buildXQuery(params, options) {
3907
3817
  const version = options?.version ?? DEFAULT_API_VERSION;
3908
3818
  const { projectScopeUuid, belongsToCollectionScopeUuids, propertyVariableUuids } = params;
3909
3819
  let collectionScopeFilter = "";
3910
- if (belongsToCollectionScopeUuids.length > 0) collectionScopeFilter = `//properties[property[label/@uuid="${BELONG_TO_COLLECTION_UUID}" and value/(${belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]]`;
3820
+ if (belongsToCollectionScopeUuids.length > 0) collectionScopeFilter = `//properties[property[label/@uuid="${BELONGS_TO_COLLECTION_UUID}" and value/(${belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]]`;
3911
3821
  const propertyVariableFilters = propertyVariableUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ");
3912
3822
  return `<ochre>{${`let $matching-props := ${version === 2 ? "doc()" : "input()"}/ochre[@uuidBelongsTo="${projectScopeUuid}"]
3913
3823
  ${collectionScopeFilter}
3914
3824
  //property[label/(${propertyVariableFilters})]
3915
3825
 
3916
3826
  for $v in $matching-props/value
3917
- return <propertyValue uuid="{$v/@uuid}" rawValue="{$v/@rawValue}" dataType="{$v/@dataType}">{
3918
- if ($v/content) then $v/content else $v/text()
3919
- }</propertyValue>`}}</ochre>`;
3827
+ let $item-uuid := $v/ancestor::*[parent::ochre]/@uuid
3828
+ return <propertyValue uuid="{$v/@uuid}" rawValue="{$v/@rawValue}" dataType="{$v/@dataType}" itemUuid="{$item-uuid}">{
3829
+ if ($v/content) then $v/content else $v/text()
3830
+ }</propertyValue>`}}</ochre>`;
3920
3831
  }
3921
3832
  /**
3922
3833
  * Fetches and parses property values by property variables from the OCHRE API
@@ -3945,15 +3856,24 @@ async function fetchPropertyValuesByPropertyVariables(params, options) {
3945
3856
  const parsedResultRaw = responseSchema.parse(data);
3946
3857
  if (Array.isArray(parsedResultRaw.result)) throw new TypeError("No items found");
3947
3858
  const parsedItems = Array.isArray(parsedResultRaw.result.ochre.propertyValue) ? parsedResultRaw.result.ochre.propertyValue : [parsedResultRaw.result.ochre.propertyValue];
3948
- const groupedItems = [];
3859
+ const groupedItemsMap = /* @__PURE__ */ new Map();
3949
3860
  for (const item of parsedItems) {
3950
- const existingItem = groupedItems.find((i) => i.content === item.content);
3951
- if (existingItem == null) groupedItems.push({
3952
- count: 1,
3953
- ...item
3861
+ const existing = groupedItemsMap.get(item.content);
3862
+ if (existing == null) groupedItemsMap.set(item.content, {
3863
+ dataType: item.dataType,
3864
+ content: item.content,
3865
+ label: item.label,
3866
+ itemUuids: new Set([item.itemUuid])
3954
3867
  });
3955
- else existingItem.count++;
3868
+ else existing.itemUuids.add(item.itemUuid);
3956
3869
  }
3870
+ const groupedItems = [];
3871
+ for (const group of groupedItemsMap.values()) groupedItems.push({
3872
+ count: group.itemUuids.size,
3873
+ dataType: group.dataType,
3874
+ content: group.content,
3875
+ label: group.label
3876
+ });
3957
3877
  return {
3958
3878
  items: groupedItems.toSorted((a, b) => {
3959
3879
  if (a.count !== b.count) return b.count - a.count;
@@ -3996,29 +3916,6 @@ function parseApiVersionSuffix(abbreviation) {
3996
3916
  *
3997
3917
  * @param abbreviation - The abbreviation identifier for the website
3998
3918
  * @returns The parsed website configuration or null if the fetch/parse fails
3999
- *
4000
- * @example
4001
- * ```ts
4002
- * const website = await fetchWebsite("guerrilla-television");
4003
- * if (website === null) {
4004
- * console.error("Failed to fetch website");
4005
- * return;
4006
- * }
4007
- * console.log(`Fetched website: ${website.identification.label}`);
4008
- * console.log(`Contains ${website.pages.length.toLocaleString()} pages`);
4009
- * ```
4010
- *
4011
- * @remarks
4012
- * The returned website configuration includes:
4013
- * - Website metadata and identification
4014
- * - Page structure and content
4015
- * - Layout and styling properties
4016
- * - Navigation configuration
4017
- * - Sidebar elements
4018
- * - Project information
4019
- * - Creator details
4020
- *
4021
- * The abbreviation is case-insensitive and should match the website's configured abbreviation in OCHRE.
4022
3919
  */
4023
3920
  async function fetchWebsite(abbreviation, options) {
4024
3921
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.18.16",
3
+ "version": "0.18.18",
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",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@antfu/eslint-config": "^7.2.0",
49
- "@types/node": "^24.10.10",
50
- "bumpp": "^10.4.0",
49
+ "@types/node": "^24.10.11",
50
+ "bumpp": "^10.4.1",
51
51
  "eslint": "^9.39.2",
52
52
  "prettier": "^3.8.1",
53
- "tsdown": "^0.20.1",
53
+ "tsdown": "^0.20.3",
54
54
  "typescript": "^5.9.3",
55
55
  "vitest": "^4.0.18"
56
56
  },