ochre-sdk 1.0.53 → 1.0.54

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/getters.mjs CHANGED
@@ -21,15 +21,15 @@ function findPropertyByVariableLabel(properties, variableLabel) {
21
21
  function getPropertyVariableLabel(property) {
22
22
  return typeof property.variable.label === "string" ? property.variable.label : property.variable.label.getText();
23
23
  }
24
- function propertyHasValue(property, value) {
24
+ function hasPropertyValue(property, value) {
25
25
  for (const candidateValue of property.values) if (deepEqual(candidateValue, value)) return true;
26
26
  return false;
27
27
  }
28
- function propertyHasValueContent(property, valueContent) {
28
+ function hasPropertyValueContent(property, valueContent) {
29
29
  for (const value of property.values) if (deepEqual(value.content, valueContent)) return true;
30
30
  return false;
31
31
  }
32
- function propertyValueContentsEqual(property, valueContents) {
32
+ function hasEqualPropertyValueContents(property, valueContents) {
33
33
  if (property.values.length !== valueContents.length) return false;
34
34
  for (const [index, value] of property.values.entries()) if (!deepEqual(value.content, valueContents[index])) return false;
35
35
  return true;
@@ -47,9 +47,9 @@ function searchPropertyResult(properties, options, findDirectResult, transformNe
47
47
  }
48
48
  return null;
49
49
  }
50
- function getPropertyValuesResult(values, limitToLeafPropertyValues, copyValuesWhenUnfiltered) {
51
- if (limitToLeafPropertyValues) return getLeafPropertyValues(values);
52
- if (copyValuesWhenUnfiltered) return clonePropertyValues(values);
50
+ function getPropertyValuesResult(values, shouldLimitToLeafPropertyValues, shouldCopyValuesWhenUnfiltered) {
51
+ if (shouldLimitToLeafPropertyValues) return getLeafPropertyValues(values);
52
+ if (shouldCopyValuesWhenUnfiltered) return clonePropertyValues(values);
53
53
  return [...values];
54
54
  }
55
55
  function clonePropertyValues(values) {
@@ -82,26 +82,26 @@ function clonePropertyValues(values) {
82
82
  }
83
83
  return clonedValues;
84
84
  }
85
- function getNormalizedProperty(property, limitToLeafPropertyValues, transformValues) {
86
- if (!limitToLeafPropertyValues) return property;
85
+ function getNormalizedProperty(property, shouldLimitToLeafPropertyValues, transformValues) {
86
+ if (!shouldLimitToLeafPropertyValues) return property;
87
87
  const values = getLeafPropertyValues(property.values);
88
88
  return {
89
89
  ...property,
90
90
  values: transformValues != null ? transformValues(values) : values
91
91
  };
92
92
  }
93
- function getFirstPropertyValueResult(values, limitToLeafPropertyValues) {
94
- if (limitToLeafPropertyValues) return getLeafPropertyValues(values)[0] ?? null;
93
+ function getFirstPropertyValueResult(values, shouldLimitToLeafPropertyValues) {
94
+ if (shouldLimitToLeafPropertyValues) return getLeafPropertyValues(values)[0] ?? null;
95
95
  return values[0] ?? null;
96
96
  }
97
- function getFirstPropertyValueContentResult(values, limitToLeafPropertyValues) {
98
- if (limitToLeafPropertyValues) return getLeafPropertyValues(values)[0]?.content ?? null;
97
+ function getFirstPropertyValueContentResult(values, shouldLimitToLeafPropertyValues) {
98
+ if (shouldLimitToLeafPropertyValues) return getLeafPropertyValues(values)[0]?.content ?? null;
99
99
  return values[0]?.content ?? null;
100
100
  }
101
- function visitProperties(properties, includeNestedProperties, visit) {
101
+ function visitProperties(properties, shouldIncludeNestedProperties, visit) {
102
102
  for (const property of properties) {
103
103
  visit(property);
104
- if (includeNestedProperties && "properties" in property) visitProperties(property.properties, includeNestedProperties, visit);
104
+ if (shouldIncludeNestedProperties && "properties" in property) visitProperties(property.properties, shouldIncludeNestedProperties, visit);
105
105
  }
106
106
  }
107
107
  function getPropertyByVariableUuid(properties, variableUuid, options = DEFAULT_OPTIONS) {
@@ -137,9 +137,7 @@ function getPropertyValueContentsByVariableUuid(properties, variableUuid, option
137
137
  return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
138
138
  const property = findPropertyByVariableUuid(currentProperties, variableUuid);
139
139
  if (property == null) return null;
140
- const valueContents = [];
141
- for (const value of getPropertyValuesResult(property.values, limitToLeafPropertyValues, false)) valueContents.push(value.content);
142
- return valueContents;
140
+ return Array.from(getPropertyValuesResult(property.values, limitToLeafPropertyValues, false), (value) => value.content);
143
141
  });
144
142
  }
145
143
  /**
@@ -194,21 +192,21 @@ function getPropertyByVariableLabelAndValues(properties, variableLabel, values,
194
192
  function getPropertyByVariableLabelAndValueContents(properties, variableLabel, valueContents, options = DEFAULT_OPTIONS) {
195
193
  const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
196
194
  return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
197
- for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && propertyValueContentsEqual(property, valueContents)) return getNormalizedProperty(property, limitToLeafPropertyValues, clonePropertyValues);
195
+ for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && hasEqualPropertyValueContents(property, valueContents)) return getNormalizedProperty(property, limitToLeafPropertyValues, clonePropertyValues);
198
196
  return null;
199
197
  }, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
200
198
  }
201
199
  function getPropertyByVariableLabelAndValue(properties, variableLabel, value, options = DEFAULT_OPTIONS) {
202
200
  const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
203
201
  return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
204
- for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && propertyHasValue(property, value)) return getNormalizedProperty(property, limitToLeafPropertyValues);
202
+ for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && hasPropertyValue(property, value)) return getNormalizedProperty(property, limitToLeafPropertyValues);
205
203
  return null;
206
204
  }, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
207
205
  }
208
206
  function getPropertyByVariableLabelAndValueContent(properties, variableLabel, valueContent, options = DEFAULT_OPTIONS) {
209
207
  const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
210
208
  return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
211
- for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && propertyHasValueContent(property, valueContent)) return getNormalizedProperty(property, limitToLeafPropertyValues);
209
+ for (const property of currentProperties) if (getPropertyVariableLabel(property) === variableLabel && hasPropertyValueContent(property, valueContent)) return getNormalizedProperty(property, limitToLeafPropertyValues);
212
210
  return null;
213
211
  }, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
214
212
  }
@@ -273,11 +271,7 @@ function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
273
271
  for (const uniqueProperty of uniqueProperties) if (uniqueProperty.variable.uuid === property.variable.uuid) return;
274
272
  uniqueProperties.push(property);
275
273
  });
276
- if (limitToLeafPropertyValues) {
277
- const normalizedProperties = [];
278
- for (const property of uniqueProperties) normalizedProperties.push(getNormalizedProperty(property, limitToLeafPropertyValues));
279
- return normalizedProperties;
280
- }
274
+ if (limitToLeafPropertyValues) return Array.from(uniqueProperties, (property) => getNormalizedProperty(property, limitToLeafPropertyValues));
281
275
  return uniqueProperties;
282
276
  }
283
277
  /**
@@ -308,7 +302,7 @@ function getLeafPropertyValues(propertyValues) {
308
302
  for (const value of propertyValues) if (value.hierarchy.isLeaf) leafPropertyValues.push(value);
309
303
  return leafPropertyValues;
310
304
  }
311
- function contentMatchesFilter(content, filterContent) {
305
+ function isContentMatchingFilter(content, filterContent) {
312
306
  if (typeof content === "string") return typeof filterContent === "string" && content.toLocaleLowerCase("en-US").includes(filterContent.toLocaleLowerCase("en-US"));
313
307
  if (typeof content === "number") return typeof filterContent === "number" && content === filterContent;
314
308
  return typeof filterContent === "boolean" && content === filterContent;
@@ -327,7 +321,7 @@ function filterProperties(property, filter, options = DEFAULT_OPTIONS) {
327
321
  const { includeNestedProperties, limitToLeafPropertyValues } = withDefaultOptions(options);
328
322
  if (filter.variableLabel.toLocaleLowerCase("en-US") === "all fields" || getPropertyVariableLabel(property).toLocaleLowerCase("en-US") === filter.variableLabel.toLocaleLowerCase("en-US")) {
329
323
  const values = getPropertyValuesResult(property.values, limitToLeafPropertyValues, false);
330
- for (const value of values) if (contentMatchesFilter(value.content, filter.value.content)) return true;
324
+ for (const value of values) if (isContentMatchingFilter(value.content, filter.value.content)) return true;
331
325
  }
332
326
  if (includeNestedProperties && "properties" in property) {
333
327
  for (const nestedProperty of property.properties) if (filterProperties(nestedProperty, filter, {
package/dist/helpers.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { flattenProperties } from "./utils.mjs";
1
+ import { flattenProperties } from "./utilities.mjs";
2
2
  //#region src/helpers.ts
3
3
  /**
4
4
  * The default page size to use for fetching paginated items
@@ -14,7 +14,7 @@ type ParserOptions<T extends ReadonlyArray<string>> = {
14
14
  languages: T;
15
15
  };
16
16
  declare function getParserOptions<T extends ReadonlyArray<string>>(options: ParserOptions<T>): ParserOptions<T>;
17
- declare function cleanObject<T extends Record<string, unknown>>(obj: T): Partial<T>;
17
+ declare function cleanObject<T extends Record<string, unknown>>(object: T): Partial<T>;
18
18
  declare function parseLicense(availability: {
19
19
  license: XMLString & {
20
20
  target?: string;
@@ -6,9 +6,9 @@ const FALLBACK_PARSER_OPTIONS = { languages: DEFAULT_LANGUAGES };
6
6
  function getParserOptions(options) {
7
7
  return { languages: options.languages };
8
8
  }
9
- function cleanObject(obj) {
9
+ function cleanObject(object) {
10
10
  const cleaned = {};
11
- for (const [key, value] of Object.entries(obj)) if (value !== void 0) cleaned[key] = value;
11
+ for (const [key, value] of Object.entries(object)) if (value !== void 0) cleaned[key] = value;
12
12
  return cleaned;
13
13
  }
14
14
  function parseLicense(availability) {
@@ -125,7 +125,7 @@ function parseContext(rawContext) {
125
125
  let displayPath = "";
126
126
  for (const rawContextOuterItem of rawContext) {
127
127
  if (!isXMLContextGroup(rawContextOuterItem)) continue;
128
- displayPath = displayPath || rawContextOuterItem.displayPath;
128
+ displayPath ||= rawContextOuterItem.displayPath;
129
129
  for (const rawContextItem of rawContextOuterItem.context) {
130
130
  if (!isXMLContextItem(rawContextItem)) continue;
131
131
  const node = {
@@ -134,7 +134,8 @@ function parseContext(rawContext) {
134
134
  heading: []
135
135
  };
136
136
  const rawContextValues = rawContextItem;
137
- for (const heading of rawContextValues.heading ?? []) node.heading.push(parseContextItem(heading));
137
+ const headings = rawContextValues.heading ?? [];
138
+ for (const heading of headings) node.heading.push(parseContextItem(heading));
138
139
  for (const { raw, parsed } of CONTEXT_CATEGORY_MAPPINGS) {
139
140
  const contextValues = rawContextValues[raw] ?? [];
140
141
  for (const contextValue of contextValues) {
@@ -179,10 +180,8 @@ function parseEvent(rawEvent, options) {
179
180
  };
180
181
  }
181
182
  function parseBaseItem(category, rawItem, options) {
182
- const events = [];
183
- for (const event of rawItem.events?.event ?? []) events.push(parseEvent(event, options));
184
- const creators = [];
185
- for (const creator of rawItem.creators?.creator ?? []) creators.push(parsePerson(creator, options));
183
+ const events = Array.from(rawItem.events?.event ?? [], (event) => parseEvent(event, options));
184
+ const creators = Array.from(rawItem.creators?.creator ?? [], (creator) => parsePerson(creator, options));
186
185
  return {
187
186
  uuid: rawItem.uuid ?? "",
188
187
  category,
@@ -250,10 +249,9 @@ function collectHierarchyEntries(hierarchy, categories) {
250
249
  const entries = [];
251
250
  if (hierarchy == null) return entries;
252
251
  let fallbackIndex = 0;
253
- for (const key of Object.keys(hierarchy)) {
252
+ for (const [key, values] of Object.entries(hierarchy)) {
254
253
  const category = getHierarchyEntryCategory(key);
255
254
  if (category == null || !(categories == null || categories.includes(category))) continue;
256
- const values = hierarchy[key];
257
255
  if (!Array.isArray(values)) continue;
258
256
  for (const value of values) {
259
257
  if (category === "resource" && isResourceWrapper(value)) {
@@ -382,9 +380,7 @@ function parseCoordinate(coordinate, options) {
382
380
  }
383
381
  }
384
382
  function parseCoordinates(rawCoordinates, options) {
385
- const coordinates = [];
386
- for (const coordinate of rawCoordinates?.coord ?? []) coordinates.push(parseCoordinate(coordinate, options));
387
- return coordinates;
383
+ return Array.from(rawCoordinates?.coord ?? [], (coordinate) => parseCoordinate(coordinate, options));
388
384
  }
389
385
  function parseImageMapArea(area) {
390
386
  const coords = [];
@@ -428,17 +424,14 @@ function parseImageMapArea(area) {
428
424
  }
429
425
  function parseImageMap(rawImageMap) {
430
426
  if (rawImageMap == null) return null;
431
- const areas = [];
432
- for (const area of rawImageMap.area) areas.push(parseImageMapArea(area));
433
427
  return {
434
- areas,
428
+ areas: Array.from(rawImageMap.area, (area) => parseImageMapArea(area)),
435
429
  width: rawImageMap.width,
436
430
  height: rawImageMap.height
437
431
  };
438
432
  }
439
433
  function parseNote(rawNote, options) {
440
- const authors = [];
441
- for (const author of rawNote.authors?.author ?? []) authors.push(parsePerson(author, options));
434
+ const authors = Array.from(rawNote.authors?.author ?? [], (author) => parsePerson(author, options));
442
435
  const content = rawNote.content == null ? multilingualFromText(parseXMLString(rawNote), options) : parseRequiredContentLike(rawNote, options);
443
436
  return {
444
437
  number: rawNote.noteNo ?? 0,
@@ -450,18 +443,17 @@ function parseNote(rawNote, options) {
450
443
  function parseNoteTitle(rawNote, options) {
451
444
  if (rawNote.title != null) return multilingualFromText(rawNote.title, options);
452
445
  const titleContent = {};
453
- for (const content of rawNote.content ?? []) {
446
+ const noteContents = rawNote.content ?? [];
447
+ for (const content of noteContents) {
454
448
  if (!options.languages.includes(content.lang) || content.title == null) continue;
455
449
  titleContent[content.lang] = content.title;
456
450
  }
457
451
  if (Object.keys(titleContent).length > 0) return MultilingualString.fromObject(titleContent, options.languages);
458
- for (const content of rawNote.content ?? []) if (content.lang !== "zxx" && content.title != null) return multilingualFromText(content.title, options);
452
+ for (const content of noteContents) if (content.lang !== "zxx" && content.title != null) return multilingualFromText(content.title, options);
459
453
  return null;
460
454
  }
461
455
  function parseNotes(rawNotes, options) {
462
- const notes = [];
463
- for (const note of rawNotes?.note ?? []) notes.push(parseNote(note, options));
464
- return notes;
456
+ return Array.from(rawNotes?.note ?? [], (note) => parseNote(note, options));
465
457
  }
466
458
  function parsePropertyDataType(dataType) {
467
459
  if (dataType == null || dataType === "") return "string";
@@ -520,10 +512,8 @@ function parsePropertyValueContent(value, options) {
520
512
  }
521
513
  }
522
514
  function parseProperty(rawProperty, options) {
523
- const values = [];
524
- for (const value of rawProperty.value ?? []) values.push(parsePropertyValueContent(value, options));
525
- const properties = [];
526
- for (const property of rawProperty.property ?? []) properties.push(parseProperty(property, options));
515
+ const values = Array.from(rawProperty.value ?? [], (value) => parsePropertyValueContent(value, options));
516
+ const properties = Array.from(rawProperty.property ?? [], (property) => parseProperty(property, options));
527
517
  return {
528
518
  variable: {
529
519
  uuid: rawProperty.label.uuid,
@@ -537,15 +527,11 @@ function parseProperty(rawProperty, options) {
537
527
  };
538
528
  }
539
529
  function parseProperties(rawProperties, options) {
540
- const properties = [];
541
- for (const property of rawProperties?.property ?? []) properties.push(parseProperty(property, options));
542
- return properties;
530
+ return Array.from(rawProperties?.property ?? [], (property) => parseProperty(property, options));
543
531
  }
544
532
  function parseSimplifiedProperty(rawProperty, options) {
545
- const values = [];
546
- for (const value of rawProperty.value ?? []) values.push(parsePropertyValueContent(value, options));
547
- const properties = [];
548
- for (const property of rawProperty.property ?? []) properties.push(parseSimplifiedProperty(property, options));
533
+ const values = Array.from(rawProperty.value ?? [], (value) => parsePropertyValueContent(value, options));
534
+ const properties = Array.from(rawProperty.property ?? [], (property) => parseSimplifiedProperty(property, options));
549
535
  return {
550
536
  variable: {
551
537
  uuid: rawProperty.label.uuid,
@@ -559,9 +545,7 @@ function parseSimplifiedProperty(rawProperty, options) {
559
545
  };
560
546
  }
561
547
  function parseSimplifiedProperties(rawProperties, options) {
562
- const properties = [];
563
- for (const property of rawProperties?.property ?? []) properties.push(parseSimplifiedProperty(property, options));
564
- return properties;
548
+ return Array.from(rawProperties?.property ?? [], (property) => parseSimplifiedProperty(property, options));
565
549
  }
566
550
  function parseSetItemProperty(rawProperty, options) {
567
551
  const property = parseProperty(rawProperty, options);
@@ -572,9 +556,7 @@ function parseSetItemProperty(rawProperty, options) {
572
556
  };
573
557
  }
574
558
  function parseSetItemProperties(rawProperties, options) {
575
- const properties = [];
576
- for (const property of rawProperties?.property ?? []) properties.push(parseSetItemProperty(property, options));
577
- return properties;
559
+ return Array.from(rawProperties?.property ?? [], (property) => parseSetItemProperty(property, options));
578
560
  }
579
561
  function withSetItemProperties(item, rawProperties, options) {
580
562
  return {
@@ -705,18 +687,13 @@ function parseBibliographyEntryInfo(entryInfo) {
705
687
  };
706
688
  }
707
689
  function firstItemLink(rawLinks, options) {
708
- const link = parseLinks(rawLinks, options)[0];
709
- return link == null ? null : link;
690
+ return parseLinks(rawLinks, options)[0] ?? null;
710
691
  }
711
692
  function parsePersonItemLinks(rawPersons, options) {
712
- const people = [];
713
- for (const person of rawPersons ?? []) people.push(parsePersonItemLink(person, options));
714
- return people;
693
+ return Array.from(rawPersons ?? [], (person) => parsePersonItemLink(person, options));
715
694
  }
716
695
  function parsePeriodItemLinks(rawPeriods, options) {
717
- const periods = [];
718
- for (const period of rawPeriods ?? []) periods.push(parsePeriodItemLink(period, options));
719
- return periods;
696
+ return Array.from(rawPeriods ?? [], (period) => parsePeriodItemLink(period, options));
720
697
  }
721
698
  function parseTreeItemLink(rawTree, options) {
722
699
  return {
@@ -875,27 +852,22 @@ function parseReverseLinks(rawLinks, options) {
875
852
  return links;
876
853
  }
877
854
  function parsePeriodList(rawPeriods, options) {
878
- const periods = [];
879
- for (const period of rawPeriods?.period ?? []) periods.push(parsePeriod(period, options));
880
- return periods;
855
+ return Array.from(rawPeriods?.period ?? [], (period) => parsePeriod(period, options));
881
856
  }
882
857
  function parseBibliographyList(rawBibliographies, options) {
883
- const bibliographies = [];
884
- for (const bibliography of rawBibliographies?.bibliography ?? []) bibliographies.push(parseBibliography(bibliography, options));
885
- return bibliographies;
858
+ return Array.from(rawBibliographies?.bibliography ?? [], (bibliography) => parseBibliography(bibliography, options));
886
859
  }
887
860
  function parsePersonList(rawPersons, options) {
888
- const persons = [];
889
- for (const person of rawPersons ?? []) persons.push(parsePerson(person, options));
890
- return persons;
861
+ return Array.from(rawPersons ?? [], (person) => parsePerson(person, options));
891
862
  }
892
863
  function parseInterpretation(rawInterpretation, options) {
893
864
  return {
894
865
  number: rawInterpretation.interpretationNo,
895
866
  date: rawInterpretation.date ?? null,
896
- observers: parsePersonList(rawInterpretation.observers?.observer, options),
867
+ interpreters: parsePersonList(rawInterpretation.interpreters?.interpreter, options),
897
868
  periods: parsePeriodList(rawInterpretation.periods, options),
898
869
  links: parseLinks(rawInterpretation.links, options),
870
+ reverseLinks: parseReverseLinks(rawInterpretation.reverseLinks, options),
899
871
  notes: parseNotes(rawInterpretation.notes, options),
900
872
  properties: parseProperties(rawInterpretation.properties, options),
901
873
  bibliographies: parseBibliographyList(rawInterpretation.bibliographies, options)
@@ -908,6 +880,7 @@ function parseObservation(rawObservation, options) {
908
880
  observers: parsePersonList(rawObservation.observers?.observer, options),
909
881
  periods: parsePeriodList(rawObservation.periods, options),
910
882
  links: parseLinks(rawObservation.links, options),
883
+ reverseLinks: parseReverseLinks(rawObservation.reverseLinks, options),
911
884
  notes: parseNotes(rawObservation.notes, options),
912
885
  properties: parseProperties(rawObservation.properties, options),
913
886
  bibliographies: parseBibliographyList(rawObservation.bibliographies, options)
@@ -924,13 +897,14 @@ function parseSection(rawSection, options) {
924
897
  function parseSections(rawSections, options) {
925
898
  const sections = [];
926
899
  if (rawSections == null || !("translation" in rawSections) && !("phonemic" in rawSections)) return sections;
927
- for (const translation of rawSections.translation ?? []) for (const section of translation.section) sections.push(parseSection(section, options));
928
- for (const phonemic of rawSections.phonemic ?? []) for (const section of phonemic.section) sections.push(parseSection(section, options));
900
+ const translations = rawSections.translation ?? [];
901
+ for (const translation of translations) for (const section of translation.section) sections.push(parseSection(section, options));
902
+ const phonemics = rawSections.phonemic ?? [];
903
+ for (const phonemic of phonemics) for (const section of phonemic.section) sections.push(parseSection(section, options));
929
904
  return sections;
930
905
  }
931
906
  function parseHeading(rawHeading, containedItemCategory, options) {
932
- const headings = [];
933
- for (const heading of rawHeading.heading ?? []) headings.push(parseHeading(heading, containedItemCategory, options));
907
+ const headings = Array.from(rawHeading.heading ?? [], (heading) => parseHeading(heading, containedItemCategory, options));
934
908
  return {
935
909
  name: rawHeading.name,
936
910
  headings,
@@ -959,6 +933,7 @@ function parseTree(rawTree, options) {
959
933
  type: rawTree.type ?? null,
960
934
  containedItemCategory,
961
935
  links: parseLinks(rawTree.links, childOptions),
936
+ reverseLinks: parseReverseLinks(rawTree.reverseLinks, childOptions),
962
937
  notes: parseNotes(rawTree.notes, childOptions),
963
938
  properties: parseProperties(rawTree.properties, childOptions),
964
939
  bibliographies: parseBibliographyList(rawTree.bibliographies, childOptions),
@@ -974,6 +949,7 @@ function parseSet(rawSet, options) {
974
949
  isTabularStructure: rawSet.tabularStructure ?? false,
975
950
  isSuppressingBlanks: rawSet.suppressBlanks ?? false,
976
951
  links: parseLinks(rawSet.links, childOptions),
952
+ reverseLinks: parseReverseLinks(rawSet.reverseLinks, childOptions),
977
953
  notes: parseNotes(rawSet.notes, childOptions),
978
954
  properties: parseProperties(rawSet.properties, childOptions),
979
955
  items: parseSetItemHierarchy(rawSet.items, childOptions, containedItemCategories)
@@ -986,6 +962,7 @@ function parseSetConcept(rawConcept, options) {
986
962
  return {
987
963
  ...parseBaseItem("concept", rawConcept, options),
988
964
  image: parseImage(rawConcept.image, options),
965
+ interpretations: Array.from(rawConcept.interpretations?.interpretation ?? rawConcept.interpretation ?? [], (interpretation) => parseInterpretation(interpretation, options)),
989
966
  coordinates: parseCoordinates(rawConcept.coordinates, options),
990
967
  properties: parseSetItemProperties(rawConcept.properties, options)
991
968
  };
@@ -1003,6 +980,7 @@ function parseSetSpatialUnit(rawSpatialUnit, options) {
1003
980
  image: parseImage(rawSpatialUnit.image, options),
1004
981
  coordinates: parseCoordinates(rawSpatialUnit.coordinates, options),
1005
982
  mapData: parseSpatialUnitMapData(rawSpatialUnit.mapData),
983
+ observations: Array.from(rawSpatialUnit.observations?.observation ?? rawSpatialUnit.observation ?? [], (observation) => parseObservation(observation, options)),
1006
984
  properties: parseSetItemProperties(rawSpatialUnit.properties, options),
1007
985
  bibliographies: parseBibliographyList(rawSpatialUnit.bibliographies, options)
1008
986
  };
@@ -1022,8 +1000,7 @@ function parseSetSet(rawSet, options) {
1022
1000
  function parseBibliography(rawBibliography, options) {
1023
1001
  const sourceItems = rawBibliography.source == null ? [] : parseLinks(rawBibliography.source, options);
1024
1002
  const bibliographies = parseBibliographyList(rawBibliography.bibliographies, options);
1025
- const items = [];
1026
- for (const bibliography of rawBibliography.bibliography ?? []) items.push(parseBibliography(bibliography, options));
1003
+ const items = Array.from(rawBibliography.bibliography ?? [], (bibliography) => parseBibliography(bibliography, options));
1027
1004
  const baseBibliography = {
1028
1005
  ...parseBaseItem("bibliography", rawBibliography, options),
1029
1006
  citationDetails: rawBibliography.citationDetails ?? null,
@@ -1037,10 +1014,11 @@ function parseBibliography(rawBibliography, options) {
1037
1014
  startDate: parseBibliographyStartDate(rawBibliography.publicationInfo.startDate)
1038
1015
  },
1039
1016
  entryInfo: parseBibliographyEntryInfo(rawBibliography.entryInfo),
1040
- source: sourceItems[0] == null ? null : sourceItems[0],
1017
+ source: sourceItems[0] ?? null,
1041
1018
  authors: parsePersonList(rawBibliography.authors?.person, options),
1042
1019
  periods: parsePeriodList(rawBibliography.periods, options),
1043
1020
  links: parseLinks(rawBibliography.links, options),
1021
+ reverseLinks: parseReverseLinks(rawBibliography.reverseLinks, options),
1044
1022
  notes: parseNotes(rawBibliography.notes, options),
1045
1023
  properties: parseProperties(rawBibliography.properties, options),
1046
1024
  bibliographies,
@@ -1057,10 +1035,8 @@ function parseBibliography(rawBibliography, options) {
1057
1035
  };
1058
1036
  }
1059
1037
  function parseConcept(rawConcept, options) {
1060
- const interpretations = [];
1061
- for (const interpretation of rawConcept.interpretations?.interpretation ?? []) interpretations.push(parseInterpretation(interpretation, options));
1062
- const items = [];
1063
- for (const concept of rawConcept.concept ?? []) items.push(parseConcept(concept, options));
1038
+ const interpretations = Array.from(rawConcept.interpretations?.interpretation ?? rawConcept.interpretation ?? [], (interpretation) => parseInterpretation(interpretation, options));
1039
+ const items = Array.from(rawConcept.concept ?? [], (concept) => parseConcept(concept, options));
1064
1040
  return {
1065
1041
  ...parseBaseItem("concept", rawConcept, options),
1066
1042
  image: parseImage(rawConcept.image, options),
@@ -1070,10 +1046,8 @@ function parseConcept(rawConcept, options) {
1070
1046
  };
1071
1047
  }
1072
1048
  function parseSpatialUnit(rawSpatialUnit, options) {
1073
- const observations = [];
1074
- for (const observation of rawSpatialUnit.observations?.observation ?? []) observations.push(parseObservation(observation, options));
1075
- const items = [];
1076
- for (const spatialUnit of rawSpatialUnit.spatialUnit ?? []) items.push(parseSpatialUnit(spatialUnit, options));
1049
+ const observations = Array.from(rawSpatialUnit.observations?.observation ?? rawSpatialUnit.observation ?? [], (observation) => parseObservation(observation, options));
1050
+ const items = Array.from(rawSpatialUnit.spatialUnit ?? [], (spatialUnit) => parseSpatialUnit(spatialUnit, options));
1077
1051
  return {
1078
1052
  ...parseBaseItem("spatialUnit", rawSpatialUnit, options),
1079
1053
  image: parseImage(rawSpatialUnit.image, options),
@@ -1085,13 +1059,13 @@ function parseSpatialUnit(rawSpatialUnit, options) {
1085
1059
  };
1086
1060
  }
1087
1061
  function parsePeriod(rawPeriod, options) {
1088
- const items = [];
1089
- for (const period of rawPeriod.period ?? []) items.push(parsePeriod(period, options));
1062
+ const items = Array.from(rawPeriod.period ?? [], (period) => parsePeriod(period, options));
1090
1063
  return {
1091
1064
  ...parseBaseItem("period", rawPeriod, options),
1092
1065
  type: rawPeriod.type ?? null,
1093
1066
  coordinates: parseCoordinates(rawPeriod.coordinates, options),
1094
1067
  links: parseLinks(rawPeriod.links, options),
1068
+ reverseLinks: parseReverseLinks(rawPeriod.reverseLinks, options),
1095
1069
  notes: parseNotes(rawPeriod.notes, options),
1096
1070
  properties: parseProperties(rawPeriod.properties, options),
1097
1071
  bibliographies: parseBibliographyList(rawPeriod.bibliographies, options),
@@ -1113,6 +1087,7 @@ function parsePerson(rawPerson, options) {
1113
1087
  content: rawPerson.content == null ? null : parseRequiredContentLike(rawPerson, options),
1114
1088
  periods: parsePeriodList(rawPerson.periods, options),
1115
1089
  links: parseLinks(rawPerson.links, options),
1090
+ reverseLinks: parseReverseLinks(rawPerson.reverseLinks, options),
1116
1091
  notes: parseNotes(rawPerson.notes, options),
1117
1092
  properties: parseProperties(rawPerson.properties, options),
1118
1093
  bibliographies: parseBibliographyList(rawPerson.bibliographies, options)
@@ -1124,6 +1099,7 @@ function parsePropertyVariable(rawPropertyVariable, options) {
1124
1099
  type: rawPropertyVariable.type ?? null,
1125
1100
  coordinates: parseCoordinates(rawPropertyVariable.coordinates, options),
1126
1101
  links: parseLinks(rawPropertyVariable.links, options),
1102
+ reverseLinks: parseReverseLinks(rawPropertyVariable.reverseLinks, options),
1127
1103
  notes: parseNotes(rawPropertyVariable.notes, options),
1128
1104
  bibliographies: parseBibliographyList(rawPropertyVariable.bibliographies, options)
1129
1105
  };
@@ -1133,14 +1109,14 @@ function parsePropertyValue(rawPropertyValue, options) {
1133
1109
  ...parseBaseItem("propertyValue", rawPropertyValue, options),
1134
1110
  coordinates: parseCoordinates(rawPropertyValue.coordinates, options),
1135
1111
  links: parseLinks(rawPropertyValue.links, options),
1112
+ reverseLinks: parseReverseLinks(rawPropertyValue.reverseLinks, options),
1136
1113
  notes: parseNotes(rawPropertyValue.notes, options),
1137
1114
  properties: parseProperties(rawPropertyValue.properties, options),
1138
1115
  bibliographies: parseBibliographyList(rawPropertyValue.bibliographies, options)
1139
1116
  };
1140
1117
  }
1141
1118
  function parseResource(rawResource, options) {
1142
- const items = [];
1143
- for (const resource of rawResource.resource ?? []) items.push(parseResource(resource, options));
1119
+ const items = Array.from(rawResource.resource ?? [], (resource) => parseResource(resource, options));
1144
1120
  return {
1145
1121
  ...parseBaseItem("resource", rawResource, options),
1146
1122
  language: rawResource.lang ?? null,
@@ -1165,10 +1141,11 @@ function parseResource(rawResource, options) {
1165
1141
  };
1166
1142
  }
1167
1143
  function parseText(rawText, options) {
1168
- const editions = [];
1169
- for (const edition of rawText.editions?.edition ?? []) editions.push(parsePerson(edition, options));
1170
- for (const editor of rawText.editions?.editor ?? []) editions.push(parsePerson(editor, options));
1171
- for (const publisher of rawText.editions?.publisher ?? []) editions.push(parsePerson(publisher, options));
1144
+ const editions = Array.from(rawText.editions?.edition ?? [], (edition) => parsePerson(edition, options));
1145
+ const editors = rawText.editions?.editor ?? [];
1146
+ for (const editor of editors) editions.push(parsePerson(editor, options));
1147
+ const publishers = rawText.editions?.publisher ?? [];
1148
+ for (const publisher of publishers) editions.push(parsePerson(publisher, options));
1172
1149
  return {
1173
1150
  ...parseBaseItem("text", rawText, options),
1174
1151
  type: rawText.type ?? "",
@@ -1187,7 +1164,8 @@ function parseText(rawText, options) {
1187
1164
  }
1188
1165
  function parseMetadataLanguages(rawOchre) {
1189
1166
  const languages = [];
1190
- for (const language of rawOchre.metadata.language ?? []) {
1167
+ const metadataLanguages = rawOchre.metadata.language ?? [];
1168
+ for (const language of metadataLanguages) {
1191
1169
  const parsedLanguage = parseStringLike(language);
1192
1170
  if (parsedLanguage != null) languages.push(parsedLanguage);
1193
1171
  }
@@ -1205,7 +1183,8 @@ function resolveLanguages(requestedLanguages, metadataLanguages) {
1205
1183
  return requestedLanguages;
1206
1184
  }
1207
1185
  function resolveDefaultLanguage(rawOchre, languages) {
1208
- for (const language of rawOchre.metadata.language ?? []) {
1186
+ const metadataLanguages = rawOchre.metadata.language ?? [];
1187
+ for (const language of metadataLanguages) {
1209
1188
  const parsedLanguage = parseStringLike(language);
1210
1189
  if (parsedLanguage != null && language.default === "true" && languages.includes(parsedLanguage)) return parsedLanguage;
1211
1190
  }
@@ -1253,7 +1232,7 @@ function parseMetadata(rawOchre, options, defaultLanguage) {
1253
1232
  };
1254
1233
  }
1255
1234
  function inferTopLevelCategory(rawOchre) {
1256
- for (const category of SET_ITEM_CATEGORIES) if (category in rawOchre) return category;
1235
+ for (const category of SET_ITEM_CATEGORIES) if (Object.hasOwn(rawOchre, category)) return category;
1257
1236
  if ("variable" in rawOchre) return "propertyVariable";
1258
1237
  if ("value" in rawOchre) return "propertyValue";
1259
1238
  throw new Error("Could not infer OCHRE item category", { cause: rawOchre });
@@ -1298,8 +1277,7 @@ function parseSetItems(rawItems, options) {
1298
1277
  }
1299
1278
  function parseGallery(rawData, options) {
1300
1279
  const gallery = rawData.result.ochre.gallery;
1301
- const resources = [];
1302
- for (const resource of gallery.resource ?? []) resources.push(parseResource(resource, options));
1280
+ const resources = Array.from(gallery.resource ?? [], (resource) => parseResource(resource, options));
1303
1281
  return {
1304
1282
  identification: parseIdentification(gallery.item.identification, options),
1305
1283
  projectIdentification: parseIdentification(gallery.project.identification, options),
@@ -42,17 +42,6 @@ type MultilingualStringInternalInit<T extends ReadonlyArray<string>> = {
42
42
  * Multilingual string
43
43
  */
44
44
  declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray<string>> {
45
- private readonly _content;
46
- private readonly _options;
47
- private readonly _availableLanguages;
48
- private readonly _aliases;
49
- /**
50
- * Create a new multilingual string from an object of language codes to text.
51
- */
52
- /** @internal */
53
- constructor(init: MultilingualStringInternalInit<T>);
54
- constructor(content: MultilingualStringObject<T>, languages: T, options?: MultilingualOptions);
55
- constructor(content?: Partial<Record<string, MultilingualStringInput>>, languages?: undefined, options?: MultilingualOptions);
56
45
  private static fromNormalized;
57
46
  /**
58
47
  * Create a new multilingual string from an object of language codes to text
@@ -79,6 +68,17 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
79
68
  */
80
69
  static fromJSON<U extends ReadonlyArray<string>>(json: MultilingualStringJSON<U>, languages: U, options?: Omit<MultilingualOptions, "aliases">): MultilingualString<U>;
81
70
  static fromJSON(json: MultilingualStringJSON, languages?: undefined, options?: Omit<MultilingualOptions, "aliases">): MultilingualString<ReadonlyArray<string>>;
71
+ private readonly _content;
72
+ private readonly _options;
73
+ private readonly _availableLanguages;
74
+ private readonly _aliases;
75
+ /**
76
+ * Create a new multilingual string from an object of language codes to text.
77
+ */
78
+ /** @internal */
79
+ constructor(init: MultilingualStringInternalInit<T>);
80
+ constructor(content: MultilingualStringObject<T>, languages: T, options?: MultilingualOptions);
81
+ constructor(content?: Partial<Record<string, MultilingualStringInput>>, languages?: undefined, options?: MultilingualOptions);
82
82
  private getPrimaryEntry;
83
83
  /**
84
84
  * Get text in a specific language with automatic fallback
@@ -171,11 +171,11 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
171
171
  /**
172
172
  * Transform all language versions (returns new instance)
173
173
  */
174
- map(fn: (text: string, language: T[number]) => string): MultilingualString<T>;
174
+ map(function_: (text: string, language: T[number]) => string): MultilingualString<T>;
175
175
  /**
176
176
  * Filter languages based on predicate (returns new instance)
177
177
  */
178
- filter(predicate: (text: string, language: T[number]) => boolean): MultilingualString<T>;
178
+ filter(shouldInclude: (text: string, language: T[number]) => boolean): MultilingualString<T>;
179
179
  /**
180
180
  * Get the string representation (uses default language)
181
181
  */