ochre-sdk 1.3.25 → 1.3.27

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.
Files changed (97) hide show
  1. package/dist/categories.d.mts +56 -56
  2. package/dist/categories.mjs +39 -39
  3. package/dist/constants.d.mts +8 -8
  4. package/dist/constants.mjs +6 -6
  5. package/dist/errors.d.mts +12 -12
  6. package/dist/errors.mjs +22 -23
  7. package/dist/fetchers/container-items.d.mts +28 -28
  8. package/dist/fetchers/container-items.mjs +27 -27
  9. package/dist/fetchers/gallery.d.mts +13 -13
  10. package/dist/fetchers/gallery.mjs +2 -2
  11. package/dist/fetchers/item-children.d.mts +12 -12
  12. package/dist/fetchers/item-children.mjs +2 -2
  13. package/dist/fetchers/item-links.d.mts +10 -10
  14. package/dist/fetchers/item-links.mjs +6 -6
  15. package/dist/fetchers/item-locations.d.mts +20 -20
  16. package/dist/fetchers/item-locations.mjs +3 -3
  17. package/dist/fetchers/item-ocr-data.d.mts +23 -23
  18. package/dist/fetchers/item-ocr-data.mjs +44 -44
  19. package/dist/fetchers/item.d.mts +23 -18
  20. package/dist/fetchers/item.mjs +15 -15
  21. package/dist/fetchers/map-layers.d.mts +15 -15
  22. package/dist/fetchers/map-layers.mjs +12 -11
  23. package/dist/fetchers/request.d.mts +40 -40
  24. package/dist/fetchers/request.mjs +37 -37
  25. package/dist/fetchers/set/items.d.mts +15 -15
  26. package/dist/fetchers/set/items.mjs +1 -1
  27. package/dist/fetchers/set/property-values.d.mts +16 -16
  28. package/dist/fetchers/set/property-values.mjs +43 -43
  29. package/dist/fetchers/tree/items.d.mts +27 -27
  30. package/dist/fetchers/tree/items.mjs +1 -1
  31. package/dist/fetchers/website-metadata.d.mts +4 -4
  32. package/dist/fetchers/website-metadata.mjs +9 -9
  33. package/dist/fetchers/website.d.mts +10 -10
  34. package/dist/fetchers/website.mjs +12 -12
  35. package/dist/getters.d.mts +83 -83
  36. package/dist/getters.mjs +74 -74
  37. package/dist/helpers.d.mts +4 -4
  38. package/dist/helpers.mjs +7 -7
  39. package/dist/index.d.mts +3 -3
  40. package/dist/index.mjs +5 -5
  41. package/dist/languages.d.mts +58 -58
  42. package/dist/languages.mjs +21 -21
  43. package/dist/ocr.d.mts +27 -27
  44. package/dist/ocr.mjs +29 -29
  45. package/dist/parsers/helpers.d.mts +23 -23
  46. package/dist/parsers/helpers.mjs +8 -8
  47. package/dist/parsers/index.d.mts +2 -2
  48. package/dist/parsers/index.mjs +15 -15
  49. package/dist/parsers/languages.d.mts +49 -49
  50. package/dist/parsers/languages.mjs +49 -49
  51. package/dist/parsers/multilingual.d.mts +174 -174
  52. package/dist/parsers/multilingual.mjs +146 -146
  53. package/dist/parsers/partial-date.d.mts +12 -12
  54. package/dist/parsers/partial-date.mjs +11 -11
  55. package/dist/parsers/property-token.d.mts +20 -20
  56. package/dist/parsers/property-token.mjs +16 -16
  57. package/dist/parsers/string.d.mts +33 -33
  58. package/dist/parsers/string.mjs +62 -64
  59. package/dist/parsers/website/bounds.d.mts +6 -6
  60. package/dist/parsers/website/bounds.mjs +5 -5
  61. package/dist/parsers/website/components.d.mts +46 -31
  62. package/dist/parsers/website/components.mjs +84 -51
  63. package/dist/parsers/website/index.d.mts +2 -2
  64. package/dist/parsers/website/index.mjs +45 -48
  65. package/dist/parsers/website/links.d.mts +24 -24
  66. package/dist/parsers/website/links.mjs +18 -18
  67. package/dist/parsers/website/messages.d.mts +16 -16
  68. package/dist/parsers/website/messages.mjs +14 -14
  69. package/dist/parsers/website/options.d.mts +1 -1
  70. package/dist/parsers/website/properties.d.mts +17 -8
  71. package/dist/parsers/website/properties.mjs +31 -10
  72. package/dist/parsers/website/reader.d.mts +55 -47
  73. package/dist/parsers/website/reader.mjs +66 -51
  74. package/dist/parsers/website/slug.d.mts +50 -50
  75. package/dist/parsers/website/slug.mjs +36 -36
  76. package/dist/parsers/website/styles.d.mts +18 -18
  77. package/dist/parsers/website/styles.mjs +19 -19
  78. package/dist/parsers/website/walk.d.mts +46 -46
  79. package/dist/parsers/website/walk.mjs +34 -34
  80. package/dist/query.d.mts +63 -63
  81. package/dist/query.mjs +137 -140
  82. package/dist/reflection.d.mts +51 -51
  83. package/dist/reflection.mjs +45 -45
  84. package/dist/schemas.d.mts +44 -44
  85. package/dist/schemas.mjs +50 -50
  86. package/dist/types/index.d.mts +192 -192
  87. package/dist/types/utilities.d.mts +5 -5
  88. package/dist/types/website.d.mts +74 -62
  89. package/dist/xml/dates.d.mts +9 -9
  90. package/dist/xml/dates.mjs +9 -9
  91. package/dist/xml/metadata.d.mts +14 -14
  92. package/dist/xml/metadata.mjs +18 -18
  93. package/dist/xml/schemas.mjs +24 -24
  94. package/dist/xml/types.d.mts +9 -9
  95. package/dist/xquery.d.mts +49 -49
  96. package/dist/xquery.mjs +50 -50
  97. package/package.json +10 -10
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Flatten an intersection so editors show one object instead of `A & B`
3
- *
4
- * Deliberately not re-exported from the package root: it is a TypeScript
5
- * presentation detail, not part of the OCHRE model.
6
- */
2
+ Flatten an intersection so editors show one object instead of `A & B`
3
+
4
+ Deliberately not re-exported from the package root: it is a TypeScript
5
+ presentation detail, not part of the OCHRE model.
6
+ */
7
7
  export type Prettify<T> = { [K in keyof T]: T[K]; } & {};
@@ -1,16 +1,16 @@
1
1
  import { MultilingualString } from "../parsers/multilingual.mjs";
2
+ import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, QueryablePropertyValueDataType, SimplifiedProperty } from "./index.mjs";
2
3
  import { Prettify } from "./utilities.mjs";
3
- import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, QueryablePropertyValueDataType } from "./index.mjs";
4
4
  /**
5
- * Represents a context tree level item with a variable and value
6
- */
5
+ Represents a context tree level item with a variable and value
6
+ */
7
7
  export type ContextTreeLevelItem = {
8
8
  variableUuid: string;
9
9
  valueUuid: string | null;
10
10
  };
11
11
  /**
12
- * Represents a context tree level with a context item
13
- */
12
+ Represents a context tree level with a context item
13
+ */
14
14
  export type ContextTreeLevel<T extends LanguageCodes = LanguageCodes> = {
15
15
  context: Array<ContextTreeLevelItem>;
16
16
  identification: Identification<T>;
@@ -18,12 +18,12 @@ export type ContextTreeLevel<T extends LanguageCodes = LanguageCodes> = {
18
18
  type: string;
19
19
  };
20
20
  /**
21
- * Represents the input control a filter context level is rendered with
22
- */
21
+ Represents the input control a filter context level is rendered with
22
+ */
23
23
  export type ContextTreeFilterVariant = "checkbox" | "chip" | "range" | "tile" | "toggle";
24
24
  /**
25
- * Represents a filter context tree level with a context item
26
- */
25
+ Represents a filter context tree level with a context item
26
+ */
27
27
  export type ContextTreeFilterLevel<T extends LanguageCodes = LanguageCodes> = Prettify<ContextTreeLevel<T> & {
28
28
  filterType: "property" | "coordinates" | "bibliography" | "period";
29
29
  filterVariant: ContextTreeFilterVariant | null;
@@ -32,8 +32,8 @@ export type ContextTreeFilterLevel<T extends LanguageCodes = LanguageCodes> = Pr
32
32
  isSidebarOpen: boolean;
33
33
  }>;
34
34
  /**
35
- * Represents a context tree with levels grouped by behavior
36
- */
35
+ Represents a context tree with levels grouped by behavior
36
+ */
37
37
  export type ContextTree<T extends LanguageCodes = LanguageCodes> = {
38
38
  flatten: Array<ContextTreeLevel<T>>;
39
39
  suppress: Array<ContextTreeLevel<T>>;
@@ -45,17 +45,17 @@ export type ContextTree<T extends LanguageCodes = LanguageCodes> = {
45
45
  prominent: Array<ContextTreeLevel<T>>;
46
46
  };
47
47
  /**
48
- * Represents a scope with its UUID, type and identification
49
- */
48
+ Represents a scope with its UUID, type and identification
49
+ */
50
50
  export type Scope<T extends LanguageCodes = LanguageCodes> = {
51
51
  uuid: string;
52
52
  type: string;
53
53
  identification: Identification<T>;
54
54
  };
55
55
  /**
56
- * Represents the parsed OCHRE "options" block shared by the website itself and
57
- * by every web element component that supports it
58
- */
56
+ Represents the parsed OCHRE "options" block shared by the website itself and
57
+ by every web element component that supports it
58
+ */
59
59
  export type WebOptions<T extends LanguageCodes = LanguageCodes> = {
60
60
  scopes: Array<Scope<T>> | null;
61
61
  contextTree: ContextTree<T> | null;
@@ -64,43 +64,43 @@ export type WebOptions<T extends LanguageCodes = LanguageCodes> = {
64
64
  };
65
65
  };
66
66
  /**
67
- * The style overrides for each viewport a website presentation targets
68
- */
67
+ The style overrides for each viewport a website presentation targets
68
+ */
69
69
  export type ResponsiveStyles = {
70
70
  default: Array<Style>;
71
71
  tablet: Array<Style>;
72
72
  mobile: Array<Style>;
73
73
  };
74
74
  /**
75
- * Whether an item page section and its header are shown
76
- */
75
+ Whether an item page section and its header are shown
76
+ */
77
77
  export type WebSectionDisplay = {
78
78
  isDisplayed: boolean;
79
79
  isHeaderDisplayed: boolean;
80
80
  };
81
81
  /**
82
- * How a collection displays its items
83
- */
82
+ How a collection displays its items
83
+ */
84
84
  export type WebCollectionVariant = "slide" | "table" | "card" | "tile" | "showcase";
85
85
  /**
86
- * How a website indicates that content is loading
87
- */
86
+ How a website indicates that content is loading
87
+ */
88
88
  export type WebLoadingVariant = "spinner" | "skeleton" | "animation" | "none";
89
89
  /**
90
- * How an item page groups a repeated section
91
- */
90
+ How an item page groups a repeated section
91
+ */
92
92
  export type WebSectionVariant = "discrete" | "tabs-horizontal" | "tabs-vertical" | "tabular";
93
93
  /**
94
- * How a website displays an item's related items
95
- */
94
+ How a website displays an item's related items
95
+ */
96
96
  export type WebRelationVariant = "list" | "dropdown-list" | "grid" | "gallery" | "inline";
97
97
  /**
98
- * The IIIF viewer a website renders images with
99
- */
98
+ The IIIF viewer a website renders images with
99
+ */
100
100
  export type WebIiifViewer = "universal-viewer" | "clover";
101
101
  /**
102
- * How a website restricts access to its content
103
- */
102
+ How a website restricts access to its content
103
+ */
104
104
  export type WebsitePrivacy = "public" | "password" | "credentials-ochre";
105
105
  export type StylesheetItem<T extends LanguageCodes = LanguageCodes> = {
106
106
  uuid: string;
@@ -129,12 +129,12 @@ export type WebsitePropertyQuery<T extends LanguageCodes = LanguageCodes> = Webs
129
129
  or: Array<WebsitePropertyQuery<T>>;
130
130
  };
131
131
  /**
132
- * Represents the OCHRE website type
133
- */
132
+ Represents the OCHRE website type
133
+ */
134
134
  export type WebsiteType = "traditional" | "digital-collection" | "plum" | "cedar" | "elm" | "maple" | "oak" | "palm";
135
135
  /**
136
- * Represents a sidebar with its title, items, layout and responsive styles
137
- */
136
+ Represents a sidebar with its title, items, layout and responsive styles
137
+ */
138
138
  export type WebSidebar<T extends LanguageCodes = LanguageCodes> = {
139
139
  isDisplayed: boolean;
140
140
  items: Array<WebElement<T> | WebBlock<T>>;
@@ -144,8 +144,8 @@ export type WebSidebar<T extends LanguageCodes = LanguageCodes> = {
144
144
  cssStyles: ResponsiveStyles;
145
145
  };
146
146
  /**
147
- * Represents a website with its properties and items
148
- */
147
+ Represents a website with its properties and items
148
+ */
149
149
  export type Website<T extends LanguageCodes = LanguageCodes> = {
150
150
  uuid: string;
151
151
  type: "website" | "segment";
@@ -192,6 +192,18 @@ export type Website<T extends LanguageCodes = LanguageCodes> = {
192
192
  items: Array<WebElement<T> | WebBlock<T>> | null;
193
193
  };
194
194
  sidebar: WebSidebar<T> | null;
195
+ /**
196
+ The settings every page of the website starts from, which a page
197
+ overrides by setting the property itself, each null when the website
198
+ leaves it unset
199
+ */
200
+ page: { [K in "width" | "variant" | "isBreadcrumbsDisplayed" | "isSidebarDisplayed" | "isNavbarSearchBarDisplayed"]: Webpage<T>["properties"][K] | null; };
201
+ /**
202
+ The settings every element of a component starts from, keyed by
203
+ component name: the "component" properties of this website, then of each
204
+ enclosing one, which an element overrides by setting the property itself
205
+ */
206
+ componentDefaults: Partial<Record<WebElementComponentName, Array<Array<SimplifiedProperty<T>>>>>;
195
207
  itemPage: {
196
208
  isMainContentDisplayed: boolean;
197
209
  description: WebSectionDisplay;
@@ -225,10 +237,10 @@ export type Website<T extends LanguageCodes = LanguageCodes> = {
225
237
  }>;
226
238
  };
227
239
  /**
228
- * The bare Map element of an OAK website, null for every other design. Its
229
- * bare Collection elements are in `items` as pages hidden from the navbar,
230
- * in tree order.
231
- */
240
+ The bare Map element of an OAK website, null for every other design. Its
241
+ bare Collection elements are in `items` as pages hidden from the navbar,
242
+ in tree order.
243
+ */
232
244
  oak: {
233
245
  map: WebElementOf<"map", T> | null;
234
246
  } | null;
@@ -237,8 +249,8 @@ export type WebsiteSegment<T extends LanguageCodes = LanguageCodes> = Website<T>
237
249
  type: "segment";
238
250
  };
239
251
  /**
240
- * Represents a webpage with its title, slug, properties, items and subpages
241
- */
252
+ Represents a webpage with its title, slug, properties, items and subpages
253
+ */
242
254
  export type Webpage<T extends LanguageCodes = LanguageCodes> = {
243
255
  uuid: string;
244
256
  type: "page";
@@ -274,8 +286,8 @@ export type Webpage<T extends LanguageCodes = LanguageCodes> = {
274
286
  webpages: Array<Webpage<T>>;
275
287
  };
276
288
  /**
277
- * Represents a title with its label and variant
278
- */
289
+ Represents a title with its label and variant
290
+ */
279
291
  export type WebTitle<T extends LanguageCodes = LanguageCodes> = {
280
292
  label: MultilingualString<T>;
281
293
  variant: "default" | "simple";
@@ -288,8 +300,8 @@ export type WebTitle<T extends LanguageCodes = LanguageCodes> = {
288
300
  };
289
301
  };
290
302
  /**
291
- * Base properties for web elements
292
- */
303
+ Base properties for web elements
304
+ */
293
305
  export type WebElement<T extends LanguageCodes = LanguageCodes> = {
294
306
  uuid: string;
295
307
  language: string | null;
@@ -298,8 +310,8 @@ export type WebElement<T extends LanguageCodes = LanguageCodes> = {
298
310
  cssStyles: ResponsiveStyles;
299
311
  } & WebElementComponent<T>;
300
312
  /**
301
- * Union type of all possible web element components
302
- */
313
+ Union type of all possible web element components
314
+ */
303
315
  export type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
304
316
  component: "3d-viewer";
305
317
  linkUuid: string;
@@ -519,8 +531,8 @@ export type WebElementOf<U extends WebElementComponentName, T extends LanguageCo
519
531
  component: U;
520
532
  }>;
521
533
  /**
522
- * Represents an image used in web elements
523
- */
534
+ Represents an image used in web elements
535
+ */
524
536
  export type WebImage<T extends LanguageCodes = LanguageCodes> = {
525
537
  uuid: string | null;
526
538
  label: MultilingualString<T> | null;
@@ -530,8 +542,8 @@ export type WebImage<T extends LanguageCodes = LanguageCodes> = {
530
542
  quality: "low" | "high";
531
543
  };
532
544
  /**
533
- * Represents a CSS style with label and value
534
- */
545
+ Represents a CSS style with label and value
546
+ */
535
547
  export type Style = {
536
548
  label: string;
537
549
  value: string;
@@ -545,8 +557,8 @@ export type WebAccordionItem<T extends LanguageCodes = LanguageCodes> = {
545
557
  items: Array<WebBlockItem<T>>;
546
558
  };
547
559
  /**
548
- * Represents a block of vertical or horizontal content alignment
549
- */
560
+ Represents a block of vertical or horizontal content alignment
561
+ */
550
562
  export type WebBlock<T extends LanguageCodes = LanguageCodes, U extends WebBlockLayout = WebBlockLayout> = {
551
563
  uuid: string;
552
564
  language: string | null;
@@ -558,12 +570,12 @@ export type WebBlock<T extends LanguageCodes = LanguageCodes, U extends WebBlock
558
570
  layout: U;
559
571
  wrap: "nowrap" | "wrap" | "wrap-reverse";
560
572
  /**
561
- * valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
562
- */
573
+ valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
574
+ */
563
575
  spacing: string | null;
564
576
  /**
565
- * `gap` CSS property value
566
- */
577
+ `gap` CSS property value
578
+ */
567
579
  gap: string | null;
568
580
  isAccordionEnabled: U extends "accordion" ? boolean : never;
569
581
  isAccordionExpandedByDefault: U extends "accordion" ? boolean : never;
@@ -601,6 +613,6 @@ export type ProtectedWebsite<T extends LanguageCodes = LanguageCodes> = {
601
613
  };
602
614
  export type AccordionWebBlock<T extends LanguageCodes = LanguageCodes> = WebBlock<T, "accordion">;
603
615
  /**
604
- * Represents a stylesheet item with its UUID and category
605
- */
616
+ Represents a stylesheet item with its UUID and category
617
+ */
606
618
  export type StylesheetCategory = Extract<ItemCategory, "propertyVariable" | "propertyValue">;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Parses ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
3
- * Like date-fns parseISO: strings without a timezone offset (including
4
- * date-only strings) are parsed as local time, not UTC. Returns an
5
- * Invalid Date for anything unparseable.
6
- *
7
- * @param value - The date/time string to parse.
8
- * @returns A Date object representing the parsed date/time, or an Invalid Date if parsing fails.
9
- * @internal
10
- */
2
+ Parses ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
3
+ Like date-fns parseISO: strings without a timezone offset (including
4
+ date-only strings) are parsed as local time, not UTC. Returns an
5
+ Invalid Date for anything unparseable.
6
+
7
+ @param value - The date/time string to parse.
8
+ @returns A Date object representing the parsed date/time, or an Invalid Date if parsing fails.
9
+ @internal
10
+ */
11
11
  export declare function parseDateTime(value: string): Date;
@@ -1,6 +1,6 @@
1
1
  // src/xml/dates.ts
2
2
  /**
3
- * Regular expression to match ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
3
+ Regular expression to match ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
4
4
  */
5
5
  const DATE_TIME_REGEX = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d+))?)?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/;
6
6
  function applyTimezoneOffset(date, timezone) {
@@ -11,14 +11,14 @@ function applyTimezoneOffset(date, timezone) {
11
11
  return new Date(date.getTime() + offsetSign * (offsetHours * 36e5 + offsetMinutes * 6e4));
12
12
  }
13
13
  /**
14
- * Parses ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
15
- * Like date-fns parseISO: strings without a timezone offset (including
16
- * date-only strings) are parsed as local time, not UTC. Returns an
17
- * Invalid Date for anything unparseable.
18
- *
19
- * @param value - The date/time string to parse.
20
- * @returns A Date object representing the parsed date/time, or an Invalid Date if parsing fails.
21
- * @internal
14
+ Parses ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
15
+ Like date-fns parseISO: strings without a timezone offset (including
16
+ date-only strings) are parsed as local time, not UTC. Returns an
17
+ Invalid Date for anything unparseable.
18
+
19
+ @param value - The date/time string to parse.
20
+ @returns A Date object representing the parsed date/time, or an Invalid Date if parsing fails.
21
+ @internal
22
22
  */
23
23
  function parseDateTime(value) {
24
24
  const match = DATE_TIME_REGEX.exec(value.replace(" ", "T"));
@@ -1,18 +1,18 @@
1
1
  /**
2
- * Read the offset a node started at in the source XML
3
- * @param value - The parsed node
4
- * @returns The offset, or null when the node carries no source metadata
5
- * @internal
6
- */
2
+ Read the offset a node started at in the source XML
3
+ @param value - The parsed node
4
+ @returns The offset, or null when the node carries no source metadata
5
+ @internal
6
+ */
7
7
  export declare function getXMLSourceIndex(value: unknown): number | null;
8
8
  /**
9
- * Re-attach the source metadata validation dropped
10
- *
11
- * `v.safeParse` returns a fresh object graph and does not carry over the
12
- * non-enumerable symbol `fast-xml-parser` records offsets under, so it is
13
- * grafted back on by walking the validated output alongside the raw input.
14
- * @param output - The validated output to graft onto
15
- * @param input - The raw parsed input to read metadata from
16
- * @internal
17
- */
9
+ Re-attach the source metadata validation dropped
10
+
11
+ `v.safeParse` returns a fresh object graph and does not carry over the
12
+ non-enumerable symbol `fast-xml-parser` records offsets under, so it is
13
+ grafted back on by walking the validated output alongside the raw input.
14
+ @param output - The validated output to graft onto
15
+ @param input - The raw parsed input to read metadata from
16
+ @internal
17
+ */
18
18
  export declare function restoreXMLMetadata(output: unknown, input: unknown): void;
@@ -3,35 +3,35 @@ import { XMLParser } from "fast-xml-parser";
3
3
  // src/xml/metadata.ts
4
4
  const XML_METADATA_SYMBOL = XMLParser.getMetaDataSymbol();
5
5
  /**
6
- * Read the source metadata `fast-xml-parser` attaches under a symbol key
7
- *
8
- * Returned as `unknown`: nothing here needs to know its shape, only whether it
9
- * is there, and {@link getXMLSourceIndex} narrows the one field it reads.
10
- * @param value - The value to read from
11
- * @returns The metadata, or undefined when there is none
6
+ Read the source metadata `fast-xml-parser` attaches under a symbol key
7
+
8
+ Returned as `unknown`: nothing here needs to know its shape, only whether it
9
+ is there, and {@link getXMLSourceIndex} narrows the one field it reads.
10
+ @param value - The value to read from
11
+ @returns The metadata, or undefined when there is none
12
12
  */
13
13
  function readXMLMetadata(value) {
14
14
  return readProperty(value, XML_METADATA_SYMBOL);
15
15
  }
16
16
  /**
17
- * Read the offset a node started at in the source XML
18
- * @param value - The parsed node
19
- * @returns The offset, or null when the node carries no source metadata
20
- * @internal
17
+ Read the offset a node started at in the source XML
18
+ @param value - The parsed node
19
+ @returns The offset, or null when the node carries no source metadata
20
+ @internal
21
21
  */
22
22
  function getXMLSourceIndex(value) {
23
23
  const startIndex = readProperty(readXMLMetadata(value), "startIndex");
24
24
  return typeof startIndex === "number" ? startIndex : null;
25
25
  }
26
26
  /**
27
- * Re-attach the source metadata validation dropped
28
- *
29
- * `v.safeParse` returns a fresh object graph and does not carry over the
30
- * non-enumerable symbol `fast-xml-parser` records offsets under, so it is
31
- * grafted back on by walking the validated output alongside the raw input.
32
- * @param output - The validated output to graft onto
33
- * @param input - The raw parsed input to read metadata from
34
- * @internal
27
+ Re-attach the source metadata validation dropped
28
+
29
+ `v.safeParse` returns a fresh object graph and does not carry over the
30
+ non-enumerable symbol `fast-xml-parser` records offsets under, so it is
31
+ grafted back on by walking the validated output alongside the raw input.
32
+ @param output - The validated output to graft onto
33
+ @param input - The raw parsed input to read metadata from
34
+ @internal
35
35
  */
36
36
  function restoreXMLMetadata(output, input) {
37
37
  if (!isObject(output) || !isObject(input)) return;
@@ -49,10 +49,10 @@ const XMLRichTextEnvelope = {
49
49
  annotation: v.optional(v.string("XMLRichTextEnvelope: annotation is string and optional"))
50
50
  };
51
51
  /**
52
- * The entries every string-like OCHRE element carries
53
- *
54
- * Spread rather than re-listed by the shapes that embed a string envelope, so
55
- * a shape cannot declare the envelope in its type and forget to validate it.
52
+ The entries every string-like OCHRE element carries
53
+
54
+ Spread rather than re-listed by the shapes that embed a string envelope, so
55
+ a shape cannot declare the envelope in its type and forget to validate it.
56
56
  */
57
57
  const XMLStringEntries = {
58
58
  payload: v.optional(v.string("XMLString: payload is string and optional")),
@@ -309,12 +309,12 @@ const XMLProperty = v.lazy(() => v.object({
309
309
  property: v.optional(v.array(XMLProperty, "XMLProperty: property is array of XMLProperty"))
310
310
  }, "XMLProperty: Shape error"));
311
311
  /**
312
- * The raw shape of a simplified property
313
- *
314
- * Identical to {@link XMLProperty}: OCHRE serves one shape, and the
315
- * "simplified" distinction is a parsing choice, not a wire-format one. The
316
- * parser decides whether a label becomes a multilingual string or a plain
317
- * string; nothing about the XML differs.
312
+ The raw shape of a simplified property
313
+
314
+ Identical to {@link XMLProperty}: OCHRE serves one shape, and the
315
+ "simplified" distinction is a parsing choice, not a wire-format one. The
316
+ parser decides whether a label becomes a multilingual string or a plain
317
+ string; nothing about the XML differs.
318
318
  */
319
319
  const XMLSimplifiedProperty = XMLProperty;
320
320
  const XMLBaseItem = v.object({
@@ -822,16 +822,16 @@ const XMLWebsiteSegment = v.lazy(() => v.object({
822
822
  publicationDateTime: v.optional(customDateTime("XMLWebsiteSegment: publicationDateTime is not a valid datetime"))
823
823
  }, "XMLWebsiteSegment: Shape error"));
824
824
  /**
825
- * A website resource item
826
- *
827
- * The member order is load-bearing, because a union returns its first match
828
- * and every member is an object schema, which drops the keys its own shape
829
- * does not name. {@link XMLWebsiteSegment} goes first: every entry on
830
- * {@link XMLWebsiteResource} other than `uuid` is optional, so a segment
831
- * wrapper satisfies that schema too and would come back without its
832
- * `segments`. {@link XMLWebsiteResourceGroup} goes last for the mirror
833
- * reason, since a resource holding children satisfies the group shape and
834
- * would lose its own slug and properties.
825
+ A website resource item
826
+
827
+ The member order is load-bearing, because a union returns its first match
828
+ and every member is an object schema, which drops the keys its own shape
829
+ does not name. {@link XMLWebsiteSegment} goes first: every entry on
830
+ {@link XMLWebsiteResource} other than `uuid` is optional, so a segment
831
+ wrapper satisfies that schema too and would come back without its
832
+ `segments`. {@link XMLWebsiteResourceGroup} goes last for the mirror
833
+ reason, since a resource holding children satisfies the group shape and
834
+ would lose its own slug and properties.
835
835
  */
836
836
  const XMLWebsiteResourceItem = v.lazy(() => v.union([
837
837
  XMLWebsiteSegment,
@@ -901,10 +901,10 @@ const XMLDataItem = v.union([
901
901
  v.object({ set: v.array(XMLSet) }, "XMLDataItem: set is array of XMLSet")
902
902
  ], "XMLDataItem: Shape error");
903
903
  /**
904
- * Whether any child of these items has children of its own
905
- *
906
- * Driven by the child element's name rather than an accessor, so the check does
907
- * not have to name a declared element type and cannot drift from one.
904
+ Whether any child of these items has children of its own
905
+
906
+ Driven by the child element's name rather than an accessor, so the check does
907
+ not have to name a declared element type and cannot drift from one.
908
908
  */
909
909
  function hasNestedRecursiveChildren(items, childKey) {
910
910
  for (const item of items) for (const child of readArrayProperty(item, childKey)) if (readArrayProperty(child, childKey).length > 0) return true;
@@ -1,10 +1,10 @@
1
1
  export type XMLItemCategory = "tree" | "bibliography" | "spatialUnit" | "concept" | "period" | "person" | "propertyVariable" | "variable" | "propertyValue" | "value" | "text" | "resource" | "set";
2
2
  export type XMLRecursiveItemCategory = Exclude<XMLItemCategory, "tree" | "person" | "propertyVariable" | "propertyValue" | "set">;
3
3
  /**
4
- * Rich text envelope shared by `<string>` and `<content>` nodes, carrying the
5
- * inline links, presentation properties and annotation identifier that turn a
6
- * span of text into an annotation.
7
- */
4
+ Rich text envelope shared by `<string>` and `<content>` nodes, carrying the
5
+ inline links, presentation properties and annotation identifier that turn a
6
+ span of text into an annotation.
7
+ */
8
8
  export type XMLRichTextEnvelope = {
9
9
  links?: XMLLink;
10
10
  properties?: {
@@ -244,11 +244,11 @@ export type XMLProperty = {
244
244
  property?: Array<XMLProperty>;
245
245
  };
246
246
  /**
247
- * The raw shape of a simplified property
248
- *
249
- * Identical to {@link XMLProperty}: the "simplified" distinction is a parsing
250
- * choice, not a wire-format one.
251
- */
247
+ The raw shape of a simplified property
248
+
249
+ Identical to {@link XMLProperty}: the "simplified" distinction is a parsing
250
+ choice, not a wire-format one.
251
+ */
252
252
  export type XMLSimplifiedProperty = XMLProperty;
253
253
  export type XMLBaseItem = {
254
254
  uuid: string;