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,64 +1,64 @@
1
1
  /**
2
- * What an OCHRE language code tags
3
- *
4
- * - `language`: text in a natural language
5
- * - `transliteration`: a language written in another script (`ota-xlt`)
6
- * - `vocabulary`: codes or notation that are not a language (`rel`)
7
- * - `non-linguistic`: `zxx`, which OCHRE publishes for aliases and for
8
- * labels that are not in any language
9
- */
2
+ What an OCHRE language code tags
3
+
4
+ - `language`: text in a natural language
5
+ - `transliteration`: a language written in another script (`ota-xlt`)
6
+ - `vocabulary`: codes or notation that are not a language (`rel`)
7
+ - `non-linguistic`: `zxx`, which OCHRE publishes for aliases and for
8
+ labels that are not in any language
9
+ */
10
10
  export type OchreLanguageKind = "language" | "transliteration" | "vocabulary" | "non-linguistic";
11
11
  /**
12
- * The standard an OCHRE language code is taken from
13
- *
14
- * - `iso639-2b`: the bibliographic ISO 639-2 code, which is OCHRE's rule
15
- * - `iso639-2t`: the terminology ISO 639-2 code, which OCHRE uses for Dutch
16
- * - `iso639-3`: the ISO 639-3 identifier, for languages ISO 639-2 has no
17
- * code for
18
- * - `ochre`: a code of OCHRE's own, which may collide with an unrelated
19
- * ISO 639-3 language (`rel` is OCHRE's relator vocabulary, ISO's Rendille)
20
- */
12
+ The standard an OCHRE language code is taken from
13
+
14
+ - `iso639-2b`: the bibliographic ISO 639-2 code, which is OCHRE's rule
15
+ - `iso639-2t`: the terminology ISO 639-2 code, which OCHRE uses for Dutch
16
+ - `iso639-3`: the ISO 639-3 identifier, for languages ISO 639-2 has no
17
+ code for
18
+ - `ochre`: a code of OCHRE's own, which may collide with an unrelated
19
+ ISO 639-3 language (`rel` is OCHRE's relator vocabulary, ISO's Rendille)
20
+ */
21
21
  export type OchreLanguageStandard = "iso639-2b" | "iso639-2t" | "iso639-3" | "ochre";
22
22
  /**
23
- * A language code OCHRE publishes, with the standard codes it stands for
24
- */
23
+ A language code OCHRE publishes, with the standard codes it stands for
24
+ */
25
25
  export type OchreLanguage = {
26
26
  /**
27
- * The English name of the language
28
- */
27
+ The English name of the language
28
+ */
29
29
  name: string;
30
30
  /**
31
- * What the code tags
32
- */
31
+ What the code tags
32
+ */
33
33
  kind: OchreLanguageKind;
34
34
  /**
35
- * The standard the OCHRE code itself is taken from
36
- */
35
+ The standard the OCHRE code itself is taken from
36
+ */
37
37
  standard: OchreLanguageStandard;
38
38
  /**
39
- * The ISO 639-3 identifier of the language, or null when the code tags
40
- * no language, or a language ISO 639-3 does not code
41
- */
39
+ The ISO 639-3 identifier of the language, or null when the code tags
40
+ no language, or a language ISO 639-3 does not code
41
+ */
42
42
  iso639_3: string | null;
43
43
  /**
44
- * The BCP 47 tag to hand to `Intl` and HTML `lang` attributes, or null
45
- * when no standard tag fits
46
- */
44
+ The BCP 47 tag to hand to `Intl` and HTML `lang` attributes, or null
45
+ when no standard tag fits
46
+ */
47
47
  bcp47: string | null;
48
48
  };
49
49
  /**
50
- * Every language code OCHRE publishes, mapped to the ISO 639-3 and BCP 47
51
- * codes it stands for
52
- *
53
- * OCHRE publishes ISO 639-2 codes in their bibliographic (B) form, the
54
- * Library of Congress MARC convention (`per`, not ISO 639-3 `fas`), with
55
- * three exceptions: the ISO 639-3 identifier where ISO 639-2 has no code
56
- * (`yua`), the terminology (T) form for Dutch (`nld`, not `dut`), and codes
57
- * of its own for transliterations and vocabularies (`ota-xlt`, `rel`), some
58
- * of which collide with unrelated ISO 639-3 languages. Key everything by
59
- * these codes, because they are what OCHRE serves, and convert through this
60
- * table when a standard code is needed.
61
- */
50
+ Every language code OCHRE publishes, mapped to the ISO 639-3 and BCP 47
51
+ codes it stands for
52
+
53
+ OCHRE publishes ISO 639-2 codes in their bibliographic (B) form, the
54
+ Library of Congress MARC convention (`per`, not ISO 639-3 `fas`), with
55
+ three exceptions: the ISO 639-3 identifier where ISO 639-2 has no code
56
+ (`yua`), the terminology (T) form for Dutch (`nld`, not `dut`), and codes
57
+ of its own for transliterations and vocabularies (`ota-xlt`, `rel`), some
58
+ of which collide with unrelated ISO 639-3 languages. Key everything by
59
+ these codes, because they are what OCHRE serves, and convert through this
60
+ table when a standard code is needed.
61
+ */
62
62
  export declare const OCHRE_LANGUAGES: {
63
63
  readonly akk: {
64
64
  readonly name: "Akkadian";
@@ -650,25 +650,25 @@ export declare const OCHRE_LANGUAGES: {
650
650
  };
651
651
  };
652
652
  /**
653
- * A language code OCHRE publishes
654
- */
653
+ A language code OCHRE publishes
654
+ */
655
655
  export type OchreLanguageCode = keyof typeof OCHRE_LANGUAGES;
656
656
  /**
657
- * Check whether a string is a language code OCHRE publishes
658
- * @param code - The code to check
659
- * @returns Whether OCHRE publishes the code
660
- */
657
+ Check whether a string is a language code OCHRE publishes
658
+ @param code - The code to check
659
+ @returns Whether OCHRE publishes the code
660
+ */
661
661
  export declare function isOchreLanguageCode(code: string): code is OchreLanguageCode;
662
662
  /**
663
- * Look up a language OCHRE publishes by its OCHRE code
664
- * @param code - The OCHRE language code
665
- * @returns The language, or null when OCHRE does not publish the code
666
- */
663
+ Look up a language OCHRE publishes by its OCHRE code
664
+ @param code - The OCHRE language code
665
+ @returns The language, or null when OCHRE does not publish the code
666
+ */
667
667
  export declare function getOchreLanguage(code: string): OchreLanguage | null;
668
668
  /**
669
- * Find the OCHRE code of a language from its ISO 639-3 identifier
670
- * @param iso639_3 - The ISO 639-3 identifier
671
- * @returns The OCHRE code of the language itself, not of a transliteration,
672
- * or null when OCHRE publishes no code for it
673
- */
669
+ Find the OCHRE code of a language from its ISO 639-3 identifier
670
+ @param iso639_3 - The ISO 639-3 identifier
671
+ @returns The OCHRE code of the language itself, not of a transliteration,
672
+ or null when OCHRE publishes no code for it
673
+ */
674
674
  export declare function getOchreLanguageCode(iso639_3: string): OchreLanguageCode | null;
@@ -1,16 +1,16 @@
1
1
  // src/languages.ts
2
2
  /**
3
- * Every language code OCHRE publishes, mapped to the ISO 639-3 and BCP 47
4
- * codes it stands for
5
- *
6
- * OCHRE publishes ISO 639-2 codes in their bibliographic (B) form, the
7
- * Library of Congress MARC convention (`per`, not ISO 639-3 `fas`), with
8
- * three exceptions: the ISO 639-3 identifier where ISO 639-2 has no code
9
- * (`yua`), the terminology (T) form for Dutch (`nld`, not `dut`), and codes
10
- * of its own for transliterations and vocabularies (`ota-xlt`, `rel`), some
11
- * of which collide with unrelated ISO 639-3 languages. Key everything by
12
- * these codes, because they are what OCHRE serves, and convert through this
13
- * table when a standard code is needed.
3
+ Every language code OCHRE publishes, mapped to the ISO 639-3 and BCP 47
4
+ codes it stands for
5
+
6
+ OCHRE publishes ISO 639-2 codes in their bibliographic (B) form, the
7
+ Library of Congress MARC convention (`per`, not ISO 639-3 `fas`), with
8
+ three exceptions: the ISO 639-3 identifier where ISO 639-2 has no code
9
+ (`yua`), the terminology (T) form for Dutch (`nld`, not `dut`), and codes
10
+ of its own for transliterations and vocabularies (`ota-xlt`, `rel`), some
11
+ of which collide with unrelated ISO 639-3 languages. Key everything by
12
+ these codes, because they are what OCHRE serves, and convert through this
13
+ table when a standard code is needed.
14
14
  */
15
15
  const OCHRE_LANGUAGES = {
16
16
  akk: {
@@ -603,26 +603,26 @@ const OCHRE_LANGUAGES = {
603
603
  }
604
604
  };
605
605
  /**
606
- * Check whether a string is a language code OCHRE publishes
607
- * @param code - The code to check
608
- * @returns Whether OCHRE publishes the code
606
+ Check whether a string is a language code OCHRE publishes
607
+ @param code - The code to check
608
+ @returns Whether OCHRE publishes the code
609
609
  */
610
610
  function isOchreLanguageCode(code) {
611
611
  return Object.hasOwn(OCHRE_LANGUAGES, code);
612
612
  }
613
613
  /**
614
- * Look up a language OCHRE publishes by its OCHRE code
615
- * @param code - The OCHRE language code
616
- * @returns The language, or null when OCHRE does not publish the code
614
+ Look up a language OCHRE publishes by its OCHRE code
615
+ @param code - The OCHRE language code
616
+ @returns The language, or null when OCHRE does not publish the code
617
617
  */
618
618
  function getOchreLanguage(code) {
619
619
  return isOchreLanguageCode(code) ? OCHRE_LANGUAGES[code] : null;
620
620
  }
621
621
  /**
622
- * Find the OCHRE code of a language from its ISO 639-3 identifier
623
- * @param iso639_3 - The ISO 639-3 identifier
624
- * @returns The OCHRE code of the language itself, not of a transliteration,
625
- * or null when OCHRE publishes no code for it
622
+ Find the OCHRE code of a language from its ISO 639-3 identifier
623
+ @param iso639_3 - The ISO 639-3 identifier
624
+ @returns The OCHRE code of the language itself, not of a transliteration,
625
+ or null when OCHRE publishes no code for it
626
626
  */
627
627
  function getOchreLanguageCode(iso639_3) {
628
628
  if (isOchreLanguageCode(iso639_3) && OCHRE_LANGUAGES[iso639_3].iso639_3 === iso639_3) return iso639_3;
package/dist/ocr.d.mts CHANGED
@@ -1,35 +1,35 @@
1
1
  /**
2
- * The name of the element wrapping an OCR layer inside an OCHRE document
3
- * @internal
4
- */
2
+ The name of the element wrapping an OCR layer inside an OCHRE document
3
+ @internal
4
+ */
5
5
  export declare const OCR_LAYER_ELEMENT_NAME = "ocr";
6
6
  /**
7
- * The attribute an OCR word element holds its word in
8
- *
9
- * The word is in the attribute rather than in the element's text content.
10
- * @internal
11
- */
7
+ The attribute an OCR word element holds its word in
8
+
9
+ The word is in the attribute rather than in the element's text content.
10
+ @internal
11
+ */
12
12
  export declare const OCR_WORD_CONTENT_ATTRIBUTE = "CONTENT";
13
13
  /**
14
- * An XQuery sequence of every QName an OCR word element can carry
15
- *
16
- * Use with the `cts:element-*` query constructors, which need concrete QNames
17
- * and cannot match on a case-folded local name the way {@link buildOcrWordPath}
18
- * does. This has to stay in agreement with that path: a word element the
19
- * narrowing misses is a document the search silently drops.
20
- * @internal
21
- */
14
+ An XQuery sequence of every QName an OCR word element can carry
15
+
16
+ Use with the `cts:element-*` query constructors, which need concrete QNames
17
+ and cannot match on a case-folded local name the way {@link buildOcrWordPath}
18
+ does. This has to stay in agreement with that path: a word element the
19
+ narrowing misses is a document the search silently drops.
20
+ @internal
21
+ */
22
22
  export declare const OCR_WORD_QNAMES: string;
23
23
  /**
24
- * Build an XQuery path selecting every OCR word element beneath a node
25
- *
26
- * Matches the layer and the word elements on a case-folded `local-name()`
27
- * rather than a name test, because a name test silently matches nothing when
28
- * OCHRE varies the casing or serves the elements in a namespace. Word elements
29
- * are selected at any depth, because the hierarchy between the layer and its
30
- * words is irregular and is not parsed.
31
- * @param rootExpression - The XQuery expression to select from
32
- * @returns The XQuery path
33
- * @internal
34
- */
24
+ Build an XQuery path selecting every OCR word element beneath a node
25
+
26
+ Matches the layer and the word elements on a case-folded `local-name()`
27
+ rather than a name test, because a name test silently matches nothing when
28
+ OCHRE varies the casing or serves the elements in a namespace. Word elements
29
+ are selected at any depth, because the hierarchy between the layer and its
30
+ words is irregular and is not parsed.
31
+ @param rootExpression - The XQuery expression to select from
32
+ @returns The XQuery path
33
+ @internal
34
+ */
35
35
  export declare function buildOcrWordPath(rootExpression: string): string;
package/dist/ocr.mjs CHANGED
@@ -2,48 +2,48 @@ import { stringLiteral } from "./xquery.mjs";
2
2
  // src/ocr.ts
3
3
  const ALTO_NAMESPACE = "http://www.loc.gov/standards/alto/ns-v2#";
4
4
  /**
5
- * The local names OCHRE serves OCR word elements under
6
- *
7
- * OCHRE varies the casing, and serves the elements both in the ALTO namespace
8
- * and in no namespace at all. Every selector over the layer has to accept all
9
- * of them: an `xs:QName("String")` narrowing matches 2 of the 18,446 documents
10
- * carrying an OCR layer, while the ALTO-namespaced `String` matches 14,650.
5
+ The local names OCHRE serves OCR word elements under
6
+
7
+ OCHRE varies the casing, and serves the elements both in the ALTO namespace
8
+ and in no namespace at all. Every selector over the layer has to accept all
9
+ of them: an `xs:QName("String")` narrowing matches 2 of the 18,446 documents
10
+ carrying an OCR layer, while the ALTO-namespaced `String` matches 14,650.
11
11
  */
12
12
  const OCR_WORD_LOCAL_NAMES = ["String", "string"];
13
13
  const OCR_WORD_CASE_FOLDED_LOCAL_NAME = "string";
14
14
  /**
15
- * The name of the element wrapping an OCR layer inside an OCHRE document
16
- * @internal
15
+ The name of the element wrapping an OCR layer inside an OCHRE document
16
+ @internal
17
17
  */
18
18
  const OCR_LAYER_ELEMENT_NAME = "ocr";
19
19
  /**
20
- * The attribute an OCR word element holds its word in
21
- *
22
- * The word is in the attribute rather than in the element's text content.
23
- * @internal
20
+ The attribute an OCR word element holds its word in
21
+
22
+ The word is in the attribute rather than in the element's text content.
23
+ @internal
24
24
  */
25
25
  const OCR_WORD_CONTENT_ATTRIBUTE = "CONTENT";
26
26
  /**
27
- * An XQuery sequence of every QName an OCR word element can carry
28
- *
29
- * Use with the `cts:element-*` query constructors, which need concrete QNames
30
- * and cannot match on a case-folded local name the way {@link buildOcrWordPath}
31
- * does. This has to stay in agreement with that path: a word element the
32
- * narrowing misses is a document the search silently drops.
33
- * @internal
27
+ An XQuery sequence of every QName an OCR word element can carry
28
+
29
+ Use with the `cts:element-*` query constructors, which need concrete QNames
30
+ and cannot match on a case-folded local name the way {@link buildOcrWordPath}
31
+ does. This has to stay in agreement with that path: a word element the
32
+ narrowing misses is a document the search silently drops.
33
+ @internal
34
34
  */
35
35
  const OCR_WORD_QNAMES = `(${[...OCR_WORD_LOCAL_NAMES.map((localName) => `fn:QName(${stringLiteral(ALTO_NAMESPACE)}, ${stringLiteral(localName)})`), ...OCR_WORD_LOCAL_NAMES.map((localName) => `xs:QName(${stringLiteral(localName)})`)].join(", ")})`;
36
36
  /**
37
- * Build an XQuery path selecting every OCR word element beneath a node
38
- *
39
- * Matches the layer and the word elements on a case-folded `local-name()`
40
- * rather than a name test, because a name test silently matches nothing when
41
- * OCHRE varies the casing or serves the elements in a namespace. Word elements
42
- * are selected at any depth, because the hierarchy between the layer and its
43
- * words is irregular and is not parsed.
44
- * @param rootExpression - The XQuery expression to select from
45
- * @returns The XQuery path
46
- * @internal
37
+ Build an XQuery path selecting every OCR word element beneath a node
38
+
39
+ Matches the layer and the word elements on a case-folded `local-name()`
40
+ rather than a name test, because a name test silently matches nothing when
41
+ OCHRE varies the casing or serves the elements in a namespace. Word elements
42
+ are selected at any depth, because the hierarchy between the layer and its
43
+ words is irregular and is not parsed.
44
+ @param rootExpression - The XQuery expression to select from
45
+ @returns The XQuery path
46
+ @internal
47
47
  */
48
48
  function buildOcrWordPath(rootExpression) {
49
49
  return `${rootExpression}//*[lower-case(local-name(.)) = ${stringLiteral("ocr")}]//*[lower-case(local-name(.)) = ${stringLiteral(OCR_WORD_CASE_FOLDED_LOCAL_NAME)}][@${OCR_WORD_CONTENT_ATTRIBUTE}]`;
@@ -1,19 +1,19 @@
1
- import { MultilingualString } from "./multilingual.mjs";
2
1
  import { License } from "../types/index.mjs";
3
2
  import { XMLContent, XMLString } from "../xml/types.mjs";
3
+ import { MultilingualString } from "./multilingual.mjs";
4
4
  export type FetchFunction = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
5
5
  export type FetchBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
6
6
  languages?: TLanguages;
7
7
  /**
8
- * Fetch only this language of every multilingual field, instead of every
9
- * language OCHRE holds. A field without it keeps its `fallbackLanguage`
10
- * content, else its content in any language; aliases are always kept.
11
- */
8
+ Fetch only this language of every multilingual field, instead of every
9
+ language OCHRE holds. A field without it keeps its `fallbackLanguage`
10
+ content, else its content in any language; aliases are always kept.
11
+ */
12
12
  language?: string;
13
13
  /**
14
- * The language shown for fields that have no `language` content, typically
15
- * the website's default language (defaults to `"eng"`)
16
- */
14
+ The language shown for fields that have no `language` content, typically
15
+ the website's default language (defaults to `"eng"`)
16
+ */
17
17
  fallbackLanguage?: string;
18
18
  fetch?: FetchFunction;
19
19
  signal?: AbortSignal;
@@ -24,25 +24,25 @@ export type FetchLanguages<TLanguages extends ReadonlyArray<string> | undefined>
24
24
  export type ParserOptions<T extends ReadonlyArray<string>> = {
25
25
  languages: T;
26
26
  /**
27
- * The language the dataset declares as its default
28
- *
29
- * Threaded into every {@link MultilingualString} so a read with no language
30
- * resolves to the dataset's default rather than whichever language happens to
31
- * come first in the payload.
32
- */
27
+ The language the dataset declares as its default
28
+
29
+ Threaded into every {@link MultilingualString} so a read with no language
30
+ resolves to the dataset's default rather than whichever language happens to
31
+ come first in the payload.
32
+ */
33
33
  defaultLanguage?: T[number];
34
34
  };
35
35
  export declare function getParserOptions<T extends ReadonlyArray<string>>(options: ParserOptions<T>): ParserOptions<T>;
36
36
  /**
37
- * Drop the keys whose value is undefined
38
- *
39
- * Constrained to `object` rather than `Record<string, unknown>`, which an
40
- * interface never satisfies for want of an index signature. `Object.entries`
41
- * cannot be typed precisely, so the one cast that costs is here rather than at
42
- * the call site.
43
- * @param object - The object to clean
44
- * @returns A copy carrying only the defined keys
45
- */
37
+ Drop the keys whose value is undefined
38
+
39
+ Constrained to `object` rather than `Record<string, unknown>`, which an
40
+ interface never satisfies for want of an index signature. `Object.entries`
41
+ cannot be typed precisely, so the one cast that costs is here rather than at
42
+ the call site.
43
+ @param object - The object to clean
44
+ @returns A copy carrying only the defined keys
45
+ */
46
46
  export declare function cleanObject<T extends object>(object: T): Partial<T>;
47
47
  export declare function parseLicense(availability: {
48
48
  license: XMLString & {
@@ -10,14 +10,14 @@ function getParserOptions(options) {
10
10
  };
11
11
  }
12
12
  /**
13
- * Drop the keys whose value is undefined
14
- *
15
- * Constrained to `object` rather than `Record<string, unknown>`, which an
16
- * interface never satisfies for want of an index signature. `Object.entries`
17
- * cannot be typed precisely, so the one cast that costs is here rather than at
18
- * the call site.
19
- * @param object - The object to clean
20
- * @returns A copy carrying only the defined keys
13
+ Drop the keys whose value is undefined
14
+
15
+ Constrained to `object` rather than `Record<string, unknown>`, which an
16
+ interface never satisfies for want of an index signature. `Object.entries`
17
+ cannot be typed precisely, so the one cast that costs is here rather than at
18
+ the call site.
19
+ @param object - The object to clean
20
+ @returns A copy carrying only the defined keys
21
21
  */
22
22
  function cleanObject(object) {
23
23
  const entries = Object.entries(object);
@@ -1,7 +1,7 @@
1
- import { Webpage } from "../types/website.mjs";
1
+ import { ParserOptions, getParserOptions, parseStringLike } from "./helpers.mjs";
2
2
  import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Coordinates, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty, SpatialUnit } from "../types/index.mjs";
3
+ import { Webpage } from "../types/website.mjs";
3
4
  import { XMLBibliography, XMLCoordinates, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty, XMLSpatialUnit } from "../xml/types.mjs";
4
- import { ParserOptions, getParserOptions, parseStringLike } from "./helpers.mjs";
5
5
  export type RawOchre = XMLData["result"]["ochre"];
6
6
  type ResourceViewParser<T extends ReadonlyArray<string>> = (view: XMLResource["view"], context: Pick<Resource<T, "topLevel">, "belongsTo" | "metadata">) => Webpage<T> | null;
7
7
  type SetItemCategoryFromCategories<T extends ReadonlyArray<SetItemCategory> | undefined> = T extends ReadonlyArray<infer U> ? Extract<U, SetItemCategory> : SetItemCategory;
@@ -1,12 +1,12 @@
1
1
  import { CONTEXT_CATEGORY_ALIASES, ITEM_CATEGORY_BY_ALIAS, ITEM_CATEGORY_FACTS, SET_ITEM_CATEGORIES, isHeadingItemCategory, normalizeItemCategory } from "../categories.mjs";
2
- import { readEntries, readProperty } from "../reflection.mjs";
3
- import { getXMLSourceIndex } from "../xml/metadata.mjs";
4
- import { MultilingualString } from "./multilingual.mjs";
5
- import { readPropertyValueText } from "./property-token.mjs";
6
- import { parseXMLString, transformPermanentIdentificationUrl } from "./string.mjs";
7
2
  import { getParserOptions, multilingualFromText, parseContentLike, parseContentLikeText, parseLicense, parseRequiredContentLike, parseStringLike } from "./helpers.mjs";
8
3
  import { parseMetadataLanguages, resolveDefaultLanguage, resolveLanguages } from "./languages.mjs";
4
+ import { MultilingualString } from "./multilingual.mjs";
9
5
  import { parsePartialDate } from "./partial-date.mjs";
6
+ import { readPropertyValueText } from "./property-token.mjs";
7
+ import { parseXMLString, transformPermanentIdentificationUrl } from "./string.mjs";
8
+ import { readEntries, readProperty } from "../reflection.mjs";
9
+ import { getXMLSourceIndex } from "../xml/metadata.mjs";
10
10
  import * as v from "valibot";
11
11
  // src/parsers/index.ts
12
12
  function isXMLContextGroup(context) {
@@ -231,12 +231,12 @@ function getHierarchyEntryCategory(key) {
231
231
  return ITEM_CATEGORY_BY_ALIAS.get(key) ?? null;
232
232
  }
233
233
  /**
234
- * A group element wrapping child resources rather than being one itself
235
- *
236
- * A schema rather than a hand-written predicate: `v.is` narrows to exactly what
237
- * it checked, and a wrapper is distinguished from a resource by carrying no
238
- * `uuid`, which the `undefined` entry states rather than leaving to a
239
- * `!("uuid" in value)` test whose false branch means nothing in particular.
234
+ A group element wrapping child resources rather than being one itself
235
+
236
+ A schema rather than a hand-written predicate: `v.is` narrows to exactly what
237
+ it checked, and a wrapper is distinguished from a resource by carrying no
238
+ `uuid`, which the `undefined` entry states rather than leaving to a
239
+ `!("uuid" in value)` test whose false branch means nothing in particular.
240
240
  */
241
241
  const resourceWrapperSchema = v.looseObject({
242
242
  uuid: v.undefined(),
@@ -409,7 +409,7 @@ function parseImageMapArea(area) {
409
409
  type: area.type,
410
410
  title: area.title,
411
411
  slug: area.slug ?? null,
412
- items: shape === "rectangle" ? [{
412
+ items: [shape === "rectangle" ? {
413
413
  shape,
414
414
  coords: [
415
415
  coords[0] ?? 0,
@@ -417,20 +417,20 @@ function parseImageMapArea(area) {
417
417
  coords[2] ?? 0,
418
418
  coords[3] ?? 0
419
419
  ]
420
- }] : shape === "circle" ? [{
420
+ } : shape === "circle" ? {
421
421
  shape,
422
422
  center: {
423
423
  x: coords[0] ?? 0,
424
424
  y: coords[1] ?? 0
425
425
  },
426
426
  radius: coords[2] ?? 0
427
- }] : shape === "point" ? [{
427
+ } : shape === "point" ? {
428
428
  shape,
429
429
  point: {
430
430
  x: coords[0] ?? 0,
431
431
  y: coords[1] ?? 0
432
432
  }
433
- }] : [{
433
+ } : {
434
434
  shape,
435
435
  coords
436
436
  }]
@@ -1,68 +1,68 @@
1
1
  import { XMLMetadata } from "../xml/types.mjs";
2
2
  /**
3
- * Validate language codes while preserving literal tuple inference
4
- * @param languages - The language codes to validate
5
- * @returns The same tuple, with its literal types intact
6
- * @internal
7
- */
3
+ Validate language codes while preserving literal tuple inference
4
+ @param languages - The language codes to validate
5
+ @returns The same tuple, with its literal types intact
6
+ @internal
7
+ */
8
8
  export declare function parseLanguages<const T extends ReadonlyArray<string>>(languages: T): T;
9
9
  /**
10
- * Define a reusable languages tuple with validation and literal type inference
11
- *
12
- * Inline arrays can be passed directly to a fetcher
13
- * (`fetchItem(uuid, { languages: ["eng", "spa"] })`); use this when the
14
- * language set is stored separately.
15
- * @param languages - The language codes to validate
16
- * @returns The same tuple, with its literal types intact
17
- */
10
+ Define a reusable languages tuple with validation and literal type inference
11
+
12
+ Inline arrays can be passed directly to a fetcher
13
+ (`fetchItem(uuid, { languages: ["eng", "spa"] })`); use this when the
14
+ language set is stored separately.
15
+ @param languages - The language codes to validate
16
+ @returns The same tuple, with its literal types intact
17
+ */
18
18
  export declare function defineLanguages<const TLanguages extends ReadonlyArray<string>>(...languages: TLanguages): TLanguages;
19
19
  /**
20
- * Validate an optional caller-supplied language tuple
21
- * @param languages - The language codes to validate, or undefined
22
- * @returns The validated codes, or an empty array when none were requested
23
- * @internal
24
- */
20
+ Validate an optional caller-supplied language tuple
21
+ @param languages - The language codes to validate, or undefined
22
+ @returns The validated codes, or an empty array when none were requested
23
+ @internal
24
+ */
25
25
  export declare function parseRequestedLanguages(languages: ReadonlyArray<string> | undefined): ReadonlyArray<string>;
26
26
  /**
27
- * Resolve which languages to parse from the content of a payload
28
- *
29
- * Requested languages win. Otherwise every `content/@xml:lang` found anywhere
30
- * beneath the node is used, falling back to {@link DEFAULT_LANGUAGES} when the
31
- * payload carries no tagged content at all.
32
- * @param node - The payload node to walk
33
- * @param requestedLanguages - The languages the caller asked for
34
- * @returns The languages to parse
35
- * @internal
36
- */
27
+ Resolve which languages to parse from the content of a payload
28
+
29
+ Requested languages win. Otherwise every `content/@xml:lang` found anywhere
30
+ beneath the node is used, falling back to {@link DEFAULT_LANGUAGES} when the
31
+ payload carries no tagged content at all.
32
+ @param node - The payload node to walk
33
+ @param requestedLanguages - The languages the caller asked for
34
+ @returns The languages to parse
35
+ @internal
36
+ */
37
37
  export declare function resolveContentLanguages(node: unknown, requestedLanguages: ReadonlyArray<string>): ReadonlyArray<string>;
38
38
  /**
39
- * Read the languages a dataset declares in its metadata
40
- * @param rawOchre - The raw OCHRE payload root
41
- * @param rawOchre.metadata - The payload metadata declaring the languages
42
- * @returns The declared languages, falling back to {@link DEFAULT_LANGUAGES}
43
- * @internal
44
- */
39
+ Read the languages a dataset declares in its metadata
40
+ @param rawOchre - The raw OCHRE payload root
41
+ @param rawOchre.metadata - The payload metadata declaring the languages
42
+ @returns The declared languages, falling back to {@link DEFAULT_LANGUAGES}
43
+ @internal
44
+ */
45
45
  export declare function parseMetadataLanguages(rawOchre: {
46
46
  metadata: XMLMetadata;
47
47
  }): Array<string>;
48
48
  /**
49
- * Reconcile requested languages against the ones a dataset declares
50
- * @param requestedLanguages - The languages the caller asked for
51
- * @param metadataLanguages - The languages the dataset declares
52
- * @returns The languages to parse
53
- * @throws When a requested language is not offered by the dataset
54
- * @internal
55
- */
49
+ Reconcile requested languages against the ones a dataset declares
50
+ @param requestedLanguages - The languages the caller asked for
51
+ @param metadataLanguages - The languages the dataset declares
52
+ @returns The languages to parse
53
+ @throws When a requested language is not offered by the dataset
54
+ @internal
55
+ */
56
56
  export declare function resolveLanguages<T extends ReadonlyArray<string>>(requestedLanguages: T | undefined, metadataLanguages: Array<string>): T;
57
57
  /**
58
- * Pick the language a dataset treats as its default
59
- * @param rawOchre - The raw OCHRE payload root
60
- * @param rawOchre.metadata - The payload metadata declaring the default
61
- * @param languages - The languages being parsed
62
- * @returns The default language
63
- * @throws When `languages` is empty
64
- * @internal
65
- */
58
+ Pick the language a dataset treats as its default
59
+ @param rawOchre - The raw OCHRE payload root
60
+ @param rawOchre.metadata - The payload metadata declaring the default
61
+ @param languages - The languages being parsed
62
+ @returns The default language
63
+ @throws When `languages` is empty
64
+ @internal
65
+ */
66
66
  export declare function resolveDefaultLanguage<T extends ReadonlyArray<string>>(rawOchre: {
67
67
  metadata: XMLMetadata;
68
68
  }, languages: T): T[number];