ochre-sdk 1.3.25 → 1.3.26

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 +14 -14
  20. package/dist/fetchers/item.mjs +14 -14
  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 +50 -31
  62. package/dist/parsers/website/components.mjs +79 -51
  63. package/dist/parsers/website/index.d.mts +1 -1
  64. package/dist/parsers/website/index.mjs +43 -47
  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 +22 -10
  72. package/dist/parsers/website/reader.d.mts +55 -46
  73. package/dist/parsers/website/reader.mjs +64 -46
  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 +67 -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,19 +1,19 @@
1
1
  import { DEFAULT_LANGUAGES } from "../constants.mjs";
2
+ import { parseStringLike } from "./helpers.mjs";
2
3
  import { readArrayProperty, readEntries } from "../reflection.mjs";
3
4
  import { ochreLanguageCodeSchema } from "../schemas.mjs";
4
- import { parseStringLike } from "./helpers.mjs";
5
5
  import * as v from "valibot";
6
6
  // src/parsers/languages.ts
7
7
  /**
8
- * A content entry carrying a language tag
9
- *
10
- * A schema rather than a hand-written predicate, because this is exactly a
11
- * shape check: `v.is` narrows only what it has verified, and an array or a
12
- * `Date` cannot pass because neither carries a string `lang`.
8
+ A content entry carrying a language tag
9
+
10
+ A schema rather than a hand-written predicate, because this is exactly a
11
+ shape check: `v.is` narrows only what it has verified, and an array or a
12
+ `Date` cannot pass because neither carries a string `lang`.
13
13
  */
14
14
  const languageTaggedContentSchema = v.looseObject({ lang: v.string() });
15
15
  /**
16
- * The language tag OCHRE uses for content that has no language
16
+ The language tag OCHRE uses for content that has no language
17
17
  */
18
18
  const UNTAGGED_LANGUAGE = "zxx";
19
19
  function collectContentLanguages(value, languages) {
@@ -25,46 +25,46 @@ function collectContentLanguages(value, languages) {
25
25
  for (const [, child] of readEntries(value)) collectContentLanguages(child, languages);
26
26
  }
27
27
  /**
28
- * Validate language codes while preserving literal tuple inference
29
- * @param languages - The language codes to validate
30
- * @returns The same tuple, with its literal types intact
31
- * @internal
28
+ Validate language codes while preserving literal tuple inference
29
+ @param languages - The language codes to validate
30
+ @returns The same tuple, with its literal types intact
31
+ @internal
32
32
  */
33
33
  function parseLanguages(languages) {
34
34
  for (const language of languages) v.parse(ochreLanguageCodeSchema, language);
35
35
  return languages;
36
36
  }
37
37
  /**
38
- * Define a reusable languages tuple with validation and literal type inference
39
- *
40
- * Inline arrays can be passed directly to a fetcher
41
- * (`fetchItem(uuid, { languages: ["eng", "spa"] })`); use this when the
42
- * language set is stored separately.
43
- * @param languages - The language codes to validate
44
- * @returns The same tuple, with its literal types intact
38
+ Define a reusable languages tuple with validation and literal type inference
39
+
40
+ Inline arrays can be passed directly to a fetcher
41
+ (`fetchItem(uuid, { languages: ["eng", "spa"] })`); use this when the
42
+ language set is stored separately.
43
+ @param languages - The language codes to validate
44
+ @returns The same tuple, with its literal types intact
45
45
  */
46
46
  function defineLanguages(...languages) {
47
47
  return parseLanguages(languages);
48
48
  }
49
49
  /**
50
- * Validate an optional caller-supplied language tuple
51
- * @param languages - The language codes to validate, or undefined
52
- * @returns The validated codes, or an empty array when none were requested
53
- * @internal
50
+ Validate an optional caller-supplied language tuple
51
+ @param languages - The language codes to validate, or undefined
52
+ @returns The validated codes, or an empty array when none were requested
53
+ @internal
54
54
  */
55
55
  function parseRequestedLanguages(languages) {
56
56
  return languages == null ? [] : parseLanguages(languages);
57
57
  }
58
58
  /**
59
- * Resolve which languages to parse from the content of a payload
60
- *
61
- * Requested languages win. Otherwise every `content/@xml:lang` found anywhere
62
- * beneath the node is used, falling back to {@link DEFAULT_LANGUAGES} when the
63
- * payload carries no tagged content at all.
64
- * @param node - The payload node to walk
65
- * @param requestedLanguages - The languages the caller asked for
66
- * @returns The languages to parse
67
- * @internal
59
+ Resolve which languages to parse from the content of a payload
60
+
61
+ Requested languages win. Otherwise every `content/@xml:lang` found anywhere
62
+ beneath the node is used, falling back to {@link DEFAULT_LANGUAGES} when the
63
+ payload carries no tagged content at all.
64
+ @param node - The payload node to walk
65
+ @param requestedLanguages - The languages the caller asked for
66
+ @returns The languages to parse
67
+ @internal
68
68
  */
69
69
  function resolveContentLanguages(node, requestedLanguages) {
70
70
  if (requestedLanguages.length > 0) return requestedLanguages;
@@ -73,11 +73,11 @@ function resolveContentLanguages(node, requestedLanguages) {
73
73
  return languages.size > 0 ? [...languages] : [...DEFAULT_LANGUAGES];
74
74
  }
75
75
  /**
76
- * Read the languages a dataset declares in its metadata
77
- * @param rawOchre - The raw OCHRE payload root
78
- * @param rawOchre.metadata - The payload metadata declaring the languages
79
- * @returns The declared languages, falling back to {@link DEFAULT_LANGUAGES}
80
- * @internal
76
+ Read the languages a dataset declares in its metadata
77
+ @param rawOchre - The raw OCHRE payload root
78
+ @param rawOchre.metadata - The payload metadata declaring the languages
79
+ @returns The declared languages, falling back to {@link DEFAULT_LANGUAGES}
80
+ @internal
81
81
  */
82
82
  function parseMetadataLanguages(rawOchre) {
83
83
  const languages = [];
@@ -89,12 +89,12 @@ function parseMetadataLanguages(rawOchre) {
89
89
  return languages.length > 0 ? languages : [...DEFAULT_LANGUAGES];
90
90
  }
91
91
  /**
92
- * Reconcile requested languages against the ones a dataset declares
93
- * @param requestedLanguages - The languages the caller asked for
94
- * @param metadataLanguages - The languages the dataset declares
95
- * @returns The languages to parse
96
- * @throws When a requested language is not offered by the dataset
97
- * @internal
92
+ Reconcile requested languages against the ones a dataset declares
93
+ @param requestedLanguages - The languages the caller asked for
94
+ @param metadataLanguages - The languages the dataset declares
95
+ @returns The languages to parse
96
+ @throws When a requested language is not offered by the dataset
97
+ @internal
98
98
  */
99
99
  function resolveLanguages(requestedLanguages, metadataLanguages) {
100
100
  if (requestedLanguages == null || requestedLanguages.length === 0) return metadataLanguages;
@@ -104,13 +104,13 @@ function resolveLanguages(requestedLanguages, metadataLanguages) {
104
104
  return requestedLanguages;
105
105
  }
106
106
  /**
107
- * Pick the language a dataset treats as its default
108
- * @param rawOchre - The raw OCHRE payload root
109
- * @param rawOchre.metadata - The payload metadata declaring the default
110
- * @param languages - The languages being parsed
111
- * @returns The default language
112
- * @throws When `languages` is empty
113
- * @internal
107
+ Pick the language a dataset treats as its default
108
+ @param rawOchre - The raw OCHRE payload root
109
+ @param rawOchre.metadata - The payload metadata declaring the default
110
+ @param languages - The languages being parsed
111
+ @returns The default language
112
+ @throws When `languages` is empty
113
+ @internal
114
114
  */
115
115
  function resolveDefaultLanguage(rawOchre, languages) {
116
116
  const metadataLanguages = rawOchre.metadata.language ?? [];
@@ -1,7 +1,7 @@
1
1
  /**
2
- * One text entry for a language. When OCHRE exposes multiple entries for the
3
- * same language, the first one is primary.
4
- */
2
+ One text entry for a language. When OCHRE exposes multiple entries for the
3
+ same language, the first one is primary.
4
+ */
5
5
  export type MultilingualStringEntry = {
6
6
  text: string;
7
7
  richText: string;
@@ -19,25 +19,25 @@ export type MultilingualStringJSON<T extends ReadonlyArray<string> = ReadonlyArr
19
19
  content: Partial<Record<T[number], Array<MultilingualStringEntry>>>;
20
20
  aliases: Array<string>;
21
21
  /**
22
- * Text in no language, read from `zxx` content that has no other language
23
- * beside it
24
- *
25
- * Optional so payloads written before it existed still parse.
26
- */
22
+ Text in no language, read from `zxx` content that has no other language
23
+ beside it
24
+
25
+ Optional so payloads written before it existed still parse.
26
+ */
27
27
  nonLinguistic?: Array<MultilingualStringEntry>;
28
28
  /**
29
- * The language reads fall back to first
30
- *
31
- * Optional so payloads written before it existed still parse; when absent the
32
- * first available language is used, which is what the old shape implied.
33
- */
29
+ The language reads fall back to first
30
+
31
+ Optional so payloads written before it existed still parse; when absent the
32
+ first available language is used, which is what the old shape implied.
33
+ */
34
34
  defaultLanguage?: string;
35
35
  };
36
36
  export type MultilingualStringObject<T extends ReadonlyArray<string> = ReadonlyArray<string>> = Partial<Record<T[number], MultilingualStringInput>>;
37
37
  export type MultilingualStringEntries<T extends ReadonlyArray<string> = ReadonlyArray<string>> = Partial<Record<T[number], ReadonlyArray<MultilingualStringInput>>>;
38
38
  /**
39
- * Options for creating and working with multilingual strings
40
- */
39
+ Options for creating and working with multilingual strings
40
+ */
41
41
  export type MultilingualOptions = {
42
42
  /**
43
43
  Default language to use for fallbacks
@@ -69,33 +69,33 @@ type MultilingualStringInternalInit<T extends ReadonlyArray<string>> = {
69
69
  nonLinguistic: ReadonlyArray<MultilingualStringEntry>;
70
70
  };
71
71
  /**
72
- * Multilingual string
73
- */
72
+ Multilingual string
73
+ */
74
74
  export declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray<string>> {
75
75
  private static fromNormalized;
76
76
  /**
77
- * Create a new multilingual string from an object of language codes to text
78
- */
77
+ Create a new multilingual string from an object of language codes to text
78
+ */
79
79
  static fromObject<U extends ReadonlyArray<string>>(content: MultilingualStringObject<U>, languages: U, options?: MultilingualOptions): MultilingualString<U>;
80
80
  static fromObject(content: Partial<Record<string, MultilingualStringInput>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
81
81
  /**
82
- * Create a new multilingual string from language entries.
83
- */
82
+ Create a new multilingual string from language entries.
83
+ */
84
84
  static fromEntries<U extends ReadonlyArray<string>>(content: MultilingualStringEntries<U>, languages: U, options?: MultilingualOptions): MultilingualString<U>;
85
85
  static fromEntries(content: Partial<Record<string, ReadonlyArray<MultilingualStringInput>>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
86
86
  /**
87
- * Create a new multilingual string for a single language
88
- */
87
+ Create a new multilingual string for a single language
88
+ */
89
89
  static create<U extends ReadonlyArray<string>>(language: U[number], text: MultilingualStringInput, languages: U, options?: MultilingualOptions): MultilingualString<U>;
90
90
  static create(language: string, text: MultilingualStringInput, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
91
91
  /**
92
- * Create an empty multilingual string
93
- */
92
+ Create an empty multilingual string
93
+ */
94
94
  static empty<U extends ReadonlyArray<string>>(languages: U, options?: MultilingualOptions): MultilingualString<U>;
95
95
  static empty(languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
96
96
  /**
97
- * Recreate a multilingual string from its JSON representation.
98
- */
97
+ Recreate a multilingual string from its JSON representation.
98
+ */
99
99
  static fromJSON<U extends ReadonlyArray<string>>(json: MultilingualStringJSON<U>, languages: U, options?: Omit<MultilingualOptions, "aliases" | "nonLinguistic">): MultilingualString<U>;
100
100
  static fromJSON(json: MultilingualStringJSON, languages?: undefined, options?: Omit<MultilingualOptions, "aliases" | "nonLinguistic">): MultilingualString<ReadonlyArray<string>>;
101
101
  private readonly _content;
@@ -104,8 +104,8 @@ export declare class MultilingualString<T extends ReadonlyArray<string> = Readon
104
104
  private readonly _aliases;
105
105
  private readonly _nonLinguistic;
106
106
  /**
107
- * Create a new multilingual string from an object of language codes to text.
108
- */
107
+ Create a new multilingual string from an object of language codes to text.
108
+ */
109
109
  /**
110
110
  @internal
111
111
  */
@@ -113,200 +113,200 @@ export declare class MultilingualString<T extends ReadonlyArray<string> = Readon
113
113
  constructor(content: MultilingualStringObject<T>, languages: T, options?: MultilingualOptions);
114
114
  constructor(content?: Partial<Record<string, MultilingualStringInput>>, languages?: undefined, options?: MultilingualOptions);
115
115
  /**
116
- * Resolve the entries to read for a language
117
- *
118
- * The fallback order is requested language, then the dataset's default
119
- * language, then the first language that has any content. This is the only
120
- * place that order is written down; every reader below is a projection of it.
121
- * Non-linguistic text is the same in every language, so it answers every
122
- * read, exact ones included.
123
- */
116
+ Resolve the entries to read for a language
117
+
118
+ The fallback order is requested language, then the dataset's default
119
+ language, then the first language that has any content. This is the only
120
+ place that order is written down; every reader below is a projection of it.
121
+ Non-linguistic text is the same in every language, so it answers every
122
+ read, exact ones included.
123
+ */
124
124
  private resolveEntries;
125
125
  private resolvePrimaryEntry;
126
126
  /**
127
- * Get text in a specific language, falling back when it has none
128
- */
127
+ Get text in a specific language, falling back when it has none
128
+ */
129
129
  getText(language: T[number]): string;
130
130
  /**
131
- * Get rich text in a specific language, falling back when it has none
132
- */
131
+ Get rich text in a specific language, falling back when it has none
132
+ */
133
133
  getRichText(language: T[number]): string;
134
134
  /**
135
- * Get text in a specific language, with no fallback
136
- */
135
+ Get text in a specific language, with no fallback
136
+ */
137
137
  getExactText(language: T[number]): string;
138
138
  /**
139
- * Get rich text in a specific language, with no fallback
140
- */
139
+ Get rich text in a specific language, with no fallback
140
+ */
141
141
  getExactRichText(language: T[number]): string;
142
142
  /**
143
- * Get every entry for a specific language, with no fallback
144
- */
143
+ Get every entry for a specific language, with no fallback
144
+ */
145
145
  getExactEntries(language: T[number]): Array<MultilingualStringEntry>;
146
146
  /**
147
- * Get every entry for a language, falling back when it has none
148
- *
149
- * The multi-entry counterpart of {@link MultilingualString.getText}: OCHRE
150
- * can carry several entries for one language, and this returns all of them
151
- * rather than only the primary. Each entry carries both `text` and
152
- * `richText`, so a caller rendering a rich field reads them from here.
153
- * @param language - The language to read
154
- * @returns The entries, or an empty array when no language has any
155
- */
147
+ Get every entry for a language, falling back when it has none
148
+
149
+ The multi-entry counterpart of {@link MultilingualString.getText}: OCHRE
150
+ can carry several entries for one language, and this returns all of them
151
+ rather than only the primary. Each entry carries both `text` and
152
+ `richText`, so a caller rendering a rich field reads them from here.
153
+ @param language - The language to read
154
+ @returns The entries, or an empty array when no language has any
155
+ */
156
156
  getEntries(language: T[number]): Array<MultilingualStringEntry>;
157
157
  /**
158
- * Get the text of every entry for a language, falling back when it has none
159
- * @param language - The language to read
160
- * @returns The texts, or an empty array when no language has any
161
- */
158
+ Get the text of every entry for a language, falling back when it has none
159
+ @param language - The language to read
160
+ @returns The texts, or an empty array when no language has any
161
+ */
162
162
  getTexts(language: T[number]): Array<string>;
163
163
  /**
164
- * Get the text of every entry for a language, with no fallback
165
- * @param language - The language to read
166
- * @returns The texts, or an empty array when that language has none
167
- */
164
+ Get the text of every entry for a language, with no fallback
165
+ @param language - The language to read
166
+ @returns The texts, or an empty array when that language has none
167
+ */
168
168
  getExactTexts(language: T[number]): Array<string>;
169
169
  /**
170
- * Get the alternative names OCHRE publishes as `zxx` content beside the
171
- * string's languages
172
- *
173
- * A non-linguistic string has none: its `zxx` content is the text itself.
174
- */
170
+ Get the alternative names OCHRE publishes as `zxx` content beside the
171
+ string's languages
172
+
173
+ A non-linguistic string has none: its `zxx` content is the text itself.
174
+ */
175
175
  getAliases(): Array<string>;
176
176
  /**
177
- * Get the languages that carry language-specific content
178
- *
179
- * A non-linguistic string has none, although every language reads its text;
180
- * {@link MultilingualString.isNonLinguistic} tells the two apart.
181
- */
177
+ Get the languages that carry language-specific content
178
+
179
+ A non-linguistic string has none, although every language reads its text;
180
+ {@link MultilingualString.isNonLinguistic} tells the two apart.
181
+ */
182
182
  getAvailableLanguages(): Array<T[number]>;
183
183
  /**
184
- * Get the language reads fall back to before trying the rest
185
- */
184
+ Get the language reads fall back to before trying the rest
185
+ */
186
186
  getDefaultLanguage(): T[number];
187
187
  /**
188
- * Get every language this string was built to hold
189
- *
190
- * The configured language list, which is not the same question as
191
- * {@link MultilingualString.getAvailableLanguages}: that one answers which
192
- * languages actually carry content, and is a subset of this.
193
- * @returns The supported languages
194
- */
188
+ Get every language this string was built to hold
189
+
190
+ The configured language list, which is not the same question as
191
+ {@link MultilingualString.getAvailableLanguages}: that one answers which
192
+ languages actually carry content, and is a subset of this.
193
+ @returns The supported languages
194
+ */
195
195
  getSupportedLanguages(): Array<T[number]>;
196
196
  /**
197
- * Whether any language carries an entry
198
- *
199
- * Answers the structural question. A language whose only entry is blank
200
- * still counts here; {@link MultilingualString.hasContent} is the question
201
- * about text. Non-linguistic text counts as an entry; aliases never stand
202
- * without one, since `zxx` content alone is read as non-linguistic text.
203
- * @returns True when no language carries an entry and there is no
204
- * non-linguistic text
205
- */
197
+ Whether any language carries an entry
198
+
199
+ Answers the structural question. A language whose only entry is blank
200
+ still counts here; {@link MultilingualString.hasContent} is the question
201
+ about text. Non-linguistic text counts as an entry; aliases never stand
202
+ without one, since `zxx` content alone is read as non-linguistic text.
203
+ @returns True when no language carries an entry and there is no
204
+ non-linguistic text
205
+ */
206
206
  isEmpty(): boolean;
207
207
  /**
208
- * Whether the string is text in no language, such as an identifier or a code
209
- *
210
- * OCHRE publishes this as `zxx` content with no other language beside it.
211
- * Its text answers every language, so a caller that needs to know whether
212
- * text was written in a language, to set an HTML `lang` attribute or to
213
- * leave it out of a translation check, asks this.
214
- * @returns True when the string holds non-linguistic text
215
- */
208
+ Whether the string is text in no language, such as an identifier or a code
209
+
210
+ OCHRE publishes this as `zxx` content with no other language beside it.
211
+ Its text answers every language, so a caller that needs to know whether
212
+ text was written in a language, to set an HTML `lang` attribute or to
213
+ leave it out of a translation check, asks this.
214
+ @returns True when the string holds non-linguistic text
215
+ */
216
216
  isNonLinguistic(): boolean;
217
217
  /**
218
- * Whether any entry in any language carries text that is not whitespace
219
- *
220
- * Deliberately not the negation of {@link MultilingualString.isEmpty}, which
221
- * only asks whether entries exist. OCHRE does serve fields holding a single
222
- * whitespace entry, so a caller deciding whether to render something wants
223
- * this one, and it looks at every entry rather than only the primary.
224
- * @returns True when some entry has non-whitespace text
225
- */
218
+ Whether any entry in any language carries text that is not whitespace
219
+
220
+ Deliberately not the negation of {@link MultilingualString.isEmpty}, which
221
+ only asks whether entries exist. OCHRE does serve fields holding a single
222
+ whitespace entry, so a caller deciding whether to render something wants
223
+ this one, and it looks at every entry rather than only the primary.
224
+ @returns True when some entry has non-whitespace text
225
+ */
226
226
  hasContent(): boolean;
227
227
  /**
228
- * Whether a specific language reads an entry, with no fallback
229
- *
230
- * True for every language when the string is non-linguistic, matching the
231
- * exact readers, which return non-linguistic text for any language.
232
- * @param language - The language to test
233
- * @returns True when that language carries at least one entry
234
- */
228
+ Whether a specific language reads an entry, with no fallback
229
+
230
+ True for every language when the string is non-linguistic, matching the
231
+ exact readers, which return non-linguistic text for any language.
232
+ @param language - The language to test
233
+ @returns True when that language carries at least one entry
234
+ */
235
235
  hasLanguage(language: T[number]): boolean;
236
236
  /**
237
- * Whether OCHRE published any alternative names for this string
238
- * @returns True when there is at least one alias
239
- */
237
+ Whether OCHRE published any alternative names for this string
238
+ @returns True when there is at least one alias
239
+ */
240
240
  hasAliases(): boolean;
241
241
  /**
242
- * Set the text for a language, or append another entry to it
243
- * @param language - The language to write
244
- * @param text - The text to write
245
- * @param options - Write options
246
- * @param options.shouldAppend - Append as an additional entry instead of replacing
247
- * @returns A new multilingual string
248
- */
242
+ Set the text for a language, or append another entry to it
243
+ @param language - The language to write
244
+ @param text - The text to write
245
+ @param options - Write options
246
+ @param options.shouldAppend - Append as an additional entry instead of replacing
247
+ @returns A new multilingual string
248
+ */
249
249
  with(language: T[number], text: MultilingualStringInput, options?: {
250
250
  shouldAppend?: boolean;
251
251
  }): MultilingualString<T>;
252
252
  /**
253
- * Remove the content for a language
254
- *
255
- * When the removed language was the default, the default moves to the first
256
- * language that still has content, so reads keep resolving.
257
- * @param language - The language to remove
258
- * @returns A new multilingual string
259
- */
253
+ Remove the content for a language
254
+
255
+ When the removed language was the default, the default moves to the first
256
+ language that still has content, so reads keep resolving.
257
+ @param language - The language to remove
258
+ @returns A new multilingual string
259
+ */
260
260
  without(language: T[number]): MultilingualString<T>;
261
261
  /**
262
- * Replace the alias values
263
- *
264
- * Aliases are the `zxx` content OCHRE publishes beside a field's languages,
265
- * so they are set as a whole rather than per language. Empty strings are
266
- * dropped, matching how they are read from a payload, and on a string with
267
- * no language they become its non-linguistic text, as the same content
268
- * would be read.
269
- * @param aliases - The aliases to carry
270
- * @returns A new multilingual string
271
- */
262
+ Replace the alias values
263
+
264
+ Aliases are the `zxx` content OCHRE publishes beside a field's languages,
265
+ so they are set as a whole rather than per language. Empty strings are
266
+ dropped, matching how they are read from a payload, and on a string with
267
+ no language they become its non-linguistic text, as the same content
268
+ would be read.
269
+ @param aliases - The aliases to carry
270
+ @returns A new multilingual string
271
+ */
272
272
  withAliases(aliases: ReadonlyArray<string>): MultilingualString<T>;
273
273
  /**
274
- * Transform the text of every entry in every language
275
- *
276
- * Replaces the old `map`, which corrupted rich text: it wrote the
277
- * transformed plain text and left the entry's `richText` to be re-derived,
278
- * so a transform such as uppercasing turned `<InternalLink uuid="abc">` into
279
- * markup OCHRE never wrote. The transform here runs against plain text only,
280
- * and the entry's rich text is rebuilt from the result, so the two can never
281
- * disagree.
282
- *
283
- * A transform that needs to keep or rewrite markup returns
284
- * `{ text, richText }` instead of a string, and both are used verbatim.
285
- * Non-linguistic text is transformed too, with `null` as its language.
286
- * @param transform - Produces the new text for one entry
287
- * @returns A new multilingual string
288
- */
274
+ Transform the text of every entry in every language
275
+
276
+ Replaces the old `map`, which corrupted rich text: it wrote the
277
+ transformed plain text and left the entry's `richText` to be re-derived,
278
+ so a transform such as uppercasing turned `<InternalLink uuid="abc">` into
279
+ markup OCHRE never wrote. The transform here runs against plain text only,
280
+ and the entry's rich text is rebuilt from the result, so the two can never
281
+ disagree.
282
+
283
+ A transform that needs to keep or rewrite markup returns
284
+ `{ text, richText }` instead of a string, and both are used verbatim.
285
+ Non-linguistic text is transformed too, with `null` as its language.
286
+ @param transform - Produces the new text for one entry
287
+ @returns A new multilingual string
288
+ */
289
289
  mapText(transform: (text: string, language: T[number] | null) => MultilingualStringInput): MultilingualString<T>;
290
290
  /**
291
- * Keep only the entries a predicate accepts
292
- *
293
- * The callback receives the whole entry rather than just its text, so it
294
- * can also test `richText` and `isPrimary`. Dropping every entry of a
295
- * language removes that language, and when that was the default the default
296
- * moves to the first language that still has content, so reads keep
297
- * resolving. Non-linguistic entries are tested too, with `null` as their
298
- * language.
299
- * @param shouldKeep - Whether to keep one entry
300
- * @returns A new multilingual string
301
- */
291
+ Keep only the entries a predicate accepts
292
+
293
+ The callback receives the whole entry rather than just its text, so it
294
+ can also test `richText` and `isPrimary`. Dropping every entry of a
295
+ language removes that language, and when that was the default the default
296
+ moves to the first language that still has content, so reads keep
297
+ resolving. Non-linguistic entries are tested too, with `null` as their
298
+ language.
299
+ @param shouldKeep - Whether to keep one entry
300
+ @returns A new multilingual string
301
+ */
302
302
  filterEntries(shouldKeep: (entry: MultilingualStringEntry, language: T[number] | null) => boolean): MultilingualString<T>;
303
303
  /**
304
- * Get the JSON representation
305
- *
306
- * Carries `defaultLanguage`, because it is not derivable from the content:
307
- * without it {@link MultilingualString.fromJSON} would fall back to the first
308
- * available language and `getText()` would resolve differently.
309
- */
304
+ Get the JSON representation
305
+
306
+ Carries `defaultLanguage`, because it is not derivable from the content:
307
+ without it {@link MultilingualString.fromJSON} would fall back to the first
308
+ available language and `getText()` would resolve differently.
309
+ */
310
310
  toJSON(): MultilingualStringJSON<T>;
311
311
  }
312
312
  export {};