ochre-sdk 1.3.24 → 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 +23 -11
  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,6 +1,6 @@
1
1
  import { DEFAULT_LANGUAGES } from "../constants.mjs";
2
- import { readProperty } from "../reflection.mjs";
3
2
  import { serializeMDXText } from "./mdx.mjs";
3
+ import { readProperty } from "../reflection.mjs";
4
4
  // src/parsers/multilingual.ts
5
5
  const MULTILINGUAL_STRING_INTERNAL_INIT = Symbol("MultilingualString.internalInit");
6
6
  function normalizeInputText(text) {
@@ -19,16 +19,16 @@ function normalizeAliases(aliases) {
19
19
  return normalizedAliases;
20
20
  }
21
21
  /**
22
- * Apply the rule OCHRE publishes `zxx` content by
23
- *
24
- * `zxx` content beside a field's languages names the same thing again, so it
25
- * is aliases; `zxx` content with no language beside it is the text itself,
26
- * in no language. Normalizing every string through this keeps the two
27
- * readings from ever coexisting, whichever way a string was built or edited.
28
- * @param hasLanguages - Whether any language carries an entry
29
- * @param aliases - The aliases the string would carry
30
- * @param nonLinguistic - The non-linguistic entries the string would carry
31
- * @returns The aliases and non-linguistic entries to store
22
+ Apply the rule OCHRE publishes `zxx` content by
23
+
24
+ `zxx` content beside a field's languages names the same thing again, so it
25
+ is aliases; `zxx` content with no language beside it is the text itself,
26
+ in no language. Normalizing every string through this keeps the two
27
+ readings from ever coexisting, whichever way a string was built or edited.
28
+ @param hasLanguages - Whether any language carries an entry
29
+ @param aliases - The aliases the string would carry
30
+ @param nonLinguistic - The non-linguistic entries the string would carry
31
+ @returns The aliases and non-linguistic entries to store
32
32
  */
33
33
  function normalizeUntaggedText(hasLanguages, aliases, nonLinguistic) {
34
34
  if (hasLanguages) return {
@@ -80,30 +80,30 @@ function getImplicitLanguages(content, options) {
80
80
  return languages.length > 0 ? languages : [...DEFAULT_LANGUAGES];
81
81
  }
82
82
  /**
83
- * Pick the language reads should fall back to first
84
- * @param availableLanguages - The languages carrying content, in order
85
- * @param supportedLanguages - Every language the string was created for
86
- * @returns The default language
83
+ Pick the language reads should fall back to first
84
+ @param availableLanguages - The languages carrying content, in order
85
+ @param supportedLanguages - Every language the string was created for
86
+ @returns The default language
87
87
  */
88
88
  function resolveDefaultLanguageOption(availableLanguages, supportedLanguages) {
89
89
  return availableLanguages[0] ?? supportedLanguages[0] ?? DEFAULT_LANGUAGES[0];
90
90
  }
91
91
  /**
92
- * Whether a constructor argument is the module's own normalized init
93
- *
94
- * The assertion is earned by the brand rather than by inspecting the fields:
95
- * {@link MULTILINGUAL_STRING_INTERNAL_INIT} is a module-private symbol, so no
96
- * caller outside this file can produce a value carrying it, and the single
97
- * producer is `fromNormalized`. That is what makes the narrowing sound; a
98
- * field-by-field check would only re-state what the brand already guarantees.
99
- * @param value - The constructor argument
100
- * @returns True when the value carries the internal brand
92
+ Whether a constructor argument is the module's own normalized init
93
+
94
+ The assertion is earned by the brand rather than by inspecting the fields:
95
+ {@link MULTILINGUAL_STRING_INTERNAL_INIT} is a module-private symbol, so no
96
+ caller outside this file can produce a value carrying it, and the single
97
+ producer is `fromNormalized`. That is what makes the narrowing sound; a
98
+ field-by-field check would only re-state what the brand already guarantees.
99
+ @param value - The constructor argument
100
+ @returns True when the value carries the internal brand
101
101
  */
102
102
  function isInternalInit(value) {
103
103
  return readProperty(value, MULTILINGUAL_STRING_INTERNAL_INIT) === true;
104
104
  }
105
105
  /**
106
- * Multilingual string
106
+ Multilingual string
107
107
  */
108
108
  var MultilingualString = class MultilingualString {
109
109
  static fromNormalized(content, options, availableLanguages, nonLinguistic) {
@@ -198,13 +198,13 @@ var MultilingualString = class MultilingualString {
198
198
  this._nonLinguistic = parsed._nonLinguistic;
199
199
  }
200
200
  /**
201
- * Resolve the entries to read for a language
202
- *
203
- * The fallback order is requested language, then the dataset's default
204
- * language, then the first language that has any content. This is the only
205
- * place that order is written down; every reader below is a projection of it.
206
- * Non-linguistic text is the same in every language, so it answers every
207
- * read, exact ones included.
201
+ Resolve the entries to read for a language
202
+
203
+ The fallback order is requested language, then the dataset's default
204
+ language, then the first language that has any content. This is the only
205
+ place that order is written down; every reader below is a projection of it.
206
+ Non-linguistic text is the same in every language, so it answers every
207
+ read, exact ones included.
208
208
  */
209
209
  resolveEntries(language, isExact) {
210
210
  const candidateLanguages = isExact ? [language] : [
@@ -225,132 +225,132 @@ var MultilingualString = class MultilingualString {
225
225
  return entries[0] ?? null;
226
226
  }
227
227
  /**
228
- * Get text in a specific language, falling back when it has none
228
+ Get text in a specific language, falling back when it has none
229
229
  */
230
230
  getText(language) {
231
231
  return this.resolvePrimaryEntry(language, false)?.text ?? "";
232
232
  }
233
233
  /**
234
- * Get rich text in a specific language, falling back when it has none
234
+ Get rich text in a specific language, falling back when it has none
235
235
  */
236
236
  getRichText(language) {
237
237
  return this.resolvePrimaryEntry(language, false)?.richText ?? "";
238
238
  }
239
239
  /**
240
- * Get text in a specific language, with no fallback
240
+ Get text in a specific language, with no fallback
241
241
  */
242
242
  getExactText(language) {
243
243
  return this.resolvePrimaryEntry(language, true)?.text ?? "";
244
244
  }
245
245
  /**
246
- * Get rich text in a specific language, with no fallback
246
+ Get rich text in a specific language, with no fallback
247
247
  */
248
248
  getExactRichText(language) {
249
249
  return this.resolvePrimaryEntry(language, true)?.richText ?? "";
250
250
  }
251
251
  /**
252
- * Get every entry for a specific language, with no fallback
252
+ Get every entry for a specific language, with no fallback
253
253
  */
254
254
  getExactEntries(language) {
255
255
  return Array.from(this.resolveEntries(language, true), (entry) => ({ ...entry }));
256
256
  }
257
257
  /**
258
- * Get every entry for a language, falling back when it has none
259
- *
260
- * The multi-entry counterpart of {@link MultilingualString.getText}: OCHRE
261
- * can carry several entries for one language, and this returns all of them
262
- * rather than only the primary. Each entry carries both `text` and
263
- * `richText`, so a caller rendering a rich field reads them from here.
264
- * @param language - The language to read
265
- * @returns The entries, or an empty array when no language has any
258
+ Get every entry for a language, falling back when it has none
259
+
260
+ The multi-entry counterpart of {@link MultilingualString.getText}: OCHRE
261
+ can carry several entries for one language, and this returns all of them
262
+ rather than only the primary. Each entry carries both `text` and
263
+ `richText`, so a caller rendering a rich field reads them from here.
264
+ @param language - The language to read
265
+ @returns The entries, or an empty array when no language has any
266
266
  */
267
267
  getEntries(language) {
268
268
  return Array.from(this.resolveEntries(language, false), (entry) => ({ ...entry }));
269
269
  }
270
270
  /**
271
- * Get the text of every entry for a language, falling back when it has none
272
- * @param language - The language to read
273
- * @returns The texts, or an empty array when no language has any
271
+ Get the text of every entry for a language, falling back when it has none
272
+ @param language - The language to read
273
+ @returns The texts, or an empty array when no language has any
274
274
  */
275
275
  getTexts(language) {
276
276
  return Array.from(this.resolveEntries(language, false), (entry) => entry.text);
277
277
  }
278
278
  /**
279
- * Get the text of every entry for a language, with no fallback
280
- * @param language - The language to read
281
- * @returns The texts, or an empty array when that language has none
279
+ Get the text of every entry for a language, with no fallback
280
+ @param language - The language to read
281
+ @returns The texts, or an empty array when that language has none
282
282
  */
283
283
  getExactTexts(language) {
284
284
  return Array.from(this.resolveEntries(language, true), (entry) => entry.text);
285
285
  }
286
286
  /**
287
- * Get the alternative names OCHRE publishes as `zxx` content beside the
288
- * string's languages
289
- *
290
- * A non-linguistic string has none: its `zxx` content is the text itself.
287
+ Get the alternative names OCHRE publishes as `zxx` content beside the
288
+ string's languages
289
+
290
+ A non-linguistic string has none: its `zxx` content is the text itself.
291
291
  */
292
292
  getAliases() {
293
293
  return [...this._aliases];
294
294
  }
295
295
  /**
296
- * Get the languages that carry language-specific content
297
- *
298
- * A non-linguistic string has none, although every language reads its text;
299
- * {@link MultilingualString.isNonLinguistic} tells the two apart.
296
+ Get the languages that carry language-specific content
297
+
298
+ A non-linguistic string has none, although every language reads its text;
299
+ {@link MultilingualString.isNonLinguistic} tells the two apart.
300
300
  */
301
301
  getAvailableLanguages() {
302
302
  return [...this._availableLanguages];
303
303
  }
304
304
  /**
305
- * Get the language reads fall back to before trying the rest
305
+ Get the language reads fall back to before trying the rest
306
306
  */
307
307
  getDefaultLanguage() {
308
308
  return this._options.defaultLanguage;
309
309
  }
310
310
  /**
311
- * Get every language this string was built to hold
312
- *
313
- * The configured language list, which is not the same question as
314
- * {@link MultilingualString.getAvailableLanguages}: that one answers which
315
- * languages actually carry content, and is a subset of this.
316
- * @returns The supported languages
311
+ Get every language this string was built to hold
312
+
313
+ The configured language list, which is not the same question as
314
+ {@link MultilingualString.getAvailableLanguages}: that one answers which
315
+ languages actually carry content, and is a subset of this.
316
+ @returns The supported languages
317
317
  */
318
318
  getSupportedLanguages() {
319
319
  return [...this._options.availableLanguages];
320
320
  }
321
321
  /**
322
- * Whether any language carries an entry
323
- *
324
- * Answers the structural question. A language whose only entry is blank
325
- * still counts here; {@link MultilingualString.hasContent} is the question
326
- * about text. Non-linguistic text counts as an entry; aliases never stand
327
- * without one, since `zxx` content alone is read as non-linguistic text.
328
- * @returns True when no language carries an entry and there is no
329
- * non-linguistic text
322
+ Whether any language carries an entry
323
+
324
+ Answers the structural question. A language whose only entry is blank
325
+ still counts here; {@link MultilingualString.hasContent} is the question
326
+ about text. Non-linguistic text counts as an entry; aliases never stand
327
+ without one, since `zxx` content alone is read as non-linguistic text.
328
+ @returns True when no language carries an entry and there is no
329
+ non-linguistic text
330
330
  */
331
331
  isEmpty() {
332
332
  return this._availableLanguages.length === 0 && this._nonLinguistic.length === 0;
333
333
  }
334
334
  /**
335
- * Whether the string is text in no language, such as an identifier or a code
336
- *
337
- * OCHRE publishes this as `zxx` content with no other language beside it.
338
- * Its text answers every language, so a caller that needs to know whether
339
- * text was written in a language, to set an HTML `lang` attribute or to
340
- * leave it out of a translation check, asks this.
341
- * @returns True when the string holds non-linguistic text
335
+ Whether the string is text in no language, such as an identifier or a code
336
+
337
+ OCHRE publishes this as `zxx` content with no other language beside it.
338
+ Its text answers every language, so a caller that needs to know whether
339
+ text was written in a language, to set an HTML `lang` attribute or to
340
+ leave it out of a translation check, asks this.
341
+ @returns True when the string holds non-linguistic text
342
342
  */
343
343
  isNonLinguistic() {
344
344
  return this._nonLinguistic.length > 0;
345
345
  }
346
346
  /**
347
- * Whether any entry in any language carries text that is not whitespace
348
- *
349
- * Deliberately not the negation of {@link MultilingualString.isEmpty}, which
350
- * only asks whether entries exist. OCHRE does serve fields holding a single
351
- * whitespace entry, so a caller deciding whether to render something wants
352
- * this one, and it looks at every entry rather than only the primary.
353
- * @returns True when some entry has non-whitespace text
347
+ Whether any entry in any language carries text that is not whitespace
348
+
349
+ Deliberately not the negation of {@link MultilingualString.isEmpty}, which
350
+ only asks whether entries exist. OCHRE does serve fields holding a single
351
+ whitespace entry, so a caller deciding whether to render something wants
352
+ this one, and it looks at every entry rather than only the primary.
353
+ @returns True when some entry has non-whitespace text
354
354
  */
355
355
  hasContent() {
356
356
  for (const language of this._availableLanguages) {
@@ -361,30 +361,30 @@ var MultilingualString = class MultilingualString {
361
361
  return false;
362
362
  }
363
363
  /**
364
- * Whether a specific language reads an entry, with no fallback
365
- *
366
- * True for every language when the string is non-linguistic, matching the
367
- * exact readers, which return non-linguistic text for any language.
368
- * @param language - The language to test
369
- * @returns True when that language carries at least one entry
364
+ Whether a specific language reads an entry, with no fallback
365
+
366
+ True for every language when the string is non-linguistic, matching the
367
+ exact readers, which return non-linguistic text for any language.
368
+ @param language - The language to test
369
+ @returns True when that language carries at least one entry
370
370
  */
371
371
  hasLanguage(language) {
372
372
  return (this._content[language]?.length ?? 0) > 0 || this._nonLinguistic.length > 0;
373
373
  }
374
374
  /**
375
- * Whether OCHRE published any alternative names for this string
376
- * @returns True when there is at least one alias
375
+ Whether OCHRE published any alternative names for this string
376
+ @returns True when there is at least one alias
377
377
  */
378
378
  hasAliases() {
379
379
  return this._aliases.length > 0;
380
380
  }
381
381
  /**
382
- * Set the text for a language, or append another entry to it
383
- * @param language - The language to write
384
- * @param text - The text to write
385
- * @param options - Write options
386
- * @param options.shouldAppend - Append as an additional entry instead of replacing
387
- * @returns A new multilingual string
382
+ Set the text for a language, or append another entry to it
383
+ @param language - The language to write
384
+ @param text - The text to write
385
+ @param options - Write options
386
+ @param options.shouldAppend - Append as an additional entry instead of replacing
387
+ @returns A new multilingual string
388
388
  */
389
389
  with(language, text, options = {}) {
390
390
  const newContent = cloneContent(this._content);
@@ -395,12 +395,12 @@ var MultilingualString = class MultilingualString {
395
395
  return MultilingualString.fromNormalized(newContent, this._options, getLanguagesWithEntries(newContent, this._options.availableLanguages), this._nonLinguistic);
396
396
  }
397
397
  /**
398
- * Remove the content for a language
399
- *
400
- * When the removed language was the default, the default moves to the first
401
- * language that still has content, so reads keep resolving.
402
- * @param language - The language to remove
403
- * @returns A new multilingual string
398
+ Remove the content for a language
399
+
400
+ When the removed language was the default, the default moves to the first
401
+ language that still has content, so reads keep resolving.
402
+ @param language - The language to remove
403
+ @returns A new multilingual string
404
404
  */
405
405
  without(language) {
406
406
  const currentContent = cloneContent(this._content);
@@ -413,15 +413,15 @@ var MultilingualString = class MultilingualString {
413
413
  }, newAvailableLanguages, this._nonLinguistic);
414
414
  }
415
415
  /**
416
- * Replace the alias values
417
- *
418
- * Aliases are the `zxx` content OCHRE publishes beside a field's languages,
419
- * so they are set as a whole rather than per language. Empty strings are
420
- * dropped, matching how they are read from a payload, and on a string with
421
- * no language they become its non-linguistic text, as the same content
422
- * would be read.
423
- * @param aliases - The aliases to carry
424
- * @returns A new multilingual string
416
+ Replace the alias values
417
+
418
+ Aliases are the `zxx` content OCHRE publishes beside a field's languages,
419
+ so they are set as a whole rather than per language. Empty strings are
420
+ dropped, matching how they are read from a payload, and on a string with
421
+ no language they become its non-linguistic text, as the same content
422
+ would be read.
423
+ @param aliases - The aliases to carry
424
+ @returns A new multilingual string
425
425
  */
426
426
  withAliases(aliases) {
427
427
  return MultilingualString.fromNormalized(cloneContent(this._content), {
@@ -430,20 +430,20 @@ var MultilingualString = class MultilingualString {
430
430
  }, this._availableLanguages, this._nonLinguistic);
431
431
  }
432
432
  /**
433
- * Transform the text of every entry in every language
434
- *
435
- * Replaces the old `map`, which corrupted rich text: it wrote the
436
- * transformed plain text and left the entry's `richText` to be re-derived,
437
- * so a transform such as uppercasing turned `<InternalLink uuid="abc">` into
438
- * markup OCHRE never wrote. The transform here runs against plain text only,
439
- * and the entry's rich text is rebuilt from the result, so the two can never
440
- * disagree.
441
- *
442
- * A transform that needs to keep or rewrite markup returns
443
- * `{ text, richText }` instead of a string, and both are used verbatim.
444
- * Non-linguistic text is transformed too, with `null` as its language.
445
- * @param transform - Produces the new text for one entry
446
- * @returns A new multilingual string
433
+ Transform the text of every entry in every language
434
+
435
+ Replaces the old `map`, which corrupted rich text: it wrote the
436
+ transformed plain text and left the entry's `richText` to be re-derived,
437
+ so a transform such as uppercasing turned `<InternalLink uuid="abc">` into
438
+ markup OCHRE never wrote. The transform here runs against plain text only,
439
+ and the entry's rich text is rebuilt from the result, so the two can never
440
+ disagree.
441
+
442
+ A transform that needs to keep or rewrite markup returns
443
+ `{ text, richText }` instead of a string, and both are used verbatim.
444
+ Non-linguistic text is transformed too, with `null` as its language.
445
+ @param transform - Produces the new text for one entry
446
+ @returns A new multilingual string
447
447
  */
448
448
  mapText(transform) {
449
449
  const newContent = {};
@@ -460,16 +460,16 @@ var MultilingualString = class MultilingualString {
460
460
  })));
461
461
  }
462
462
  /**
463
- * Keep only the entries a predicate accepts
464
- *
465
- * The callback receives the whole entry rather than just its text, so it
466
- * can also test `richText` and `isPrimary`. Dropping every entry of a
467
- * language removes that language, and when that was the default the default
468
- * moves to the first language that still has content, so reads keep
469
- * resolving. Non-linguistic entries are tested too, with `null` as their
470
- * language.
471
- * @param shouldKeep - Whether to keep one entry
472
- * @returns A new multilingual string
463
+ Keep only the entries a predicate accepts
464
+
465
+ The callback receives the whole entry rather than just its text, so it
466
+ can also test `richText` and `isPrimary`. Dropping every entry of a
467
+ language removes that language, and when that was the default the default
468
+ moves to the first language that still has content, so reads keep
469
+ resolving. Non-linguistic entries are tested too, with `null` as their
470
+ language.
471
+ @param shouldKeep - Whether to keep one entry
472
+ @returns A new multilingual string
473
473
  */
474
474
  filterEntries(shouldKeep) {
475
475
  const newContent = {};
@@ -486,11 +486,11 @@ var MultilingualString = class MultilingualString {
486
486
  }, newAvailableLanguages, this._nonLinguistic.filter((entry) => shouldKeep({ ...entry }, null)));
487
487
  }
488
488
  /**
489
- * Get the JSON representation
490
- *
491
- * Carries `defaultLanguage`, because it is not derivable from the content:
492
- * without it {@link MultilingualString.fromJSON} would fall back to the first
493
- * available language and `getText()` would resolve differently.
489
+ Get the JSON representation
490
+
491
+ Carries `defaultLanguage`, because it is not derivable from the content:
492
+ without it {@link MultilingualString.fromJSON} would fall back to the first
493
+ available language and `getText()` would resolve differently.
494
494
  */
495
495
  toJSON() {
496
496
  const content = {};
@@ -1,16 +1,16 @@
1
1
  import { PartialDate } from "../types/index.mjs";
2
2
  import { XMLPartialDates } from "../xml/types.mjs";
3
3
  /**
4
- * Parse the partial dates of an event
5
- *
6
- * Reads the year, month and day fields rather than the EDTF text OCHRE
7
- * writes alongside them, which leaves out every field that is not a plain
8
- * four-digit year. An end identical to the start is a single date. The EDTF
9
- * string is only set for what EDTF can express: no qualifier on a year with
10
- * unspecified digits or on a season, no season in a range, and no range
11
- * whose end begins before its start.
12
- * @param rawPartialDates - The raw partialDates element
13
- * @returns The parsed partial dates, or null when every field is empty
14
- * @internal
15
- */
4
+ Parse the partial dates of an event
5
+
6
+ Reads the year, month and day fields rather than the EDTF text OCHRE
7
+ writes alongside them, which leaves out every field that is not a plain
8
+ four-digit year. An end identical to the start is a single date. The EDTF
9
+ string is only set for what EDTF can express: no qualifier on a year with
10
+ unspecified digits or on a season, no season in a range, and no range
11
+ whose end begins before its start.
12
+ @param rawPartialDates - The raw partialDates element
13
+ @returns The parsed partial dates, or null when every field is empty
14
+ @internal
15
+ */
16
16
  export declare function parsePartialDate(rawPartialDates: XMLPartialDates | undefined): PartialDate | null;
@@ -202,17 +202,17 @@ function formatEdtf(start, end) {
202
202
  return startEdtf == null || endEdtf == null ? null : `${startEdtf}/${endEdtf}`;
203
203
  }
204
204
  /**
205
- * Parse the partial dates of an event
206
- *
207
- * Reads the year, month and day fields rather than the EDTF text OCHRE
208
- * writes alongside them, which leaves out every field that is not a plain
209
- * four-digit year. An end identical to the start is a single date. The EDTF
210
- * string is only set for what EDTF can express: no qualifier on a year with
211
- * unspecified digits or on a season, no season in a range, and no range
212
- * whose end begins before its start.
213
- * @param rawPartialDates - The raw partialDates element
214
- * @returns The parsed partial dates, or null when every field is empty
215
- * @internal
205
+ Parse the partial dates of an event
206
+
207
+ Reads the year, month and day fields rather than the EDTF text OCHRE
208
+ writes alongside them, which leaves out every field that is not a plain
209
+ four-digit year. An end identical to the start is a single date. The EDTF
210
+ string is only set for what EDTF can express: no qualifier on a year with
211
+ unspecified digits or on a season, no season in a range, and no range
212
+ whose end begins before its start.
213
+ @param rawPartialDates - The raw partialDates element
214
+ @returns The parsed partial dates, or null when every field is empty
215
+ @internal
216
216
  */
217
217
  function parsePartialDate(rawPartialDates) {
218
218
  if (rawPartialDates == null) return null;
@@ -1,32 +1,32 @@
1
1
  /**
2
- * The attributes a property value can carry its text in
3
- */
2
+ The attributes a property value can carry its text in
3
+ */
4
4
  type PropertyValueTextSource = {
5
5
  rawValue?: string;
6
6
  payload?: string;
7
7
  slug?: string;
8
8
  };
9
9
  /**
10
- * The text a property value stands for
11
- *
12
- * OCHRE spreads that text over four places, so which one wins is real domain
13
- * knowledge and this is the only place it is written down. The content step is
14
- * injected because the two callers reach it differently: the item parser builds
15
- * a full multilingual string, while the rich-text parser needs one language's
16
- * plain text. Reading the sources in a different order is what let the two
17
- * disagree for a value carrying both a `slug` and `content`.
18
- * @param value - The raw property value
19
- * @param readContentText - Reads the value's `content` as plain text, or null when it has none
20
- * @returns The text, or an empty string when the value carries none
21
- * @internal
22
- */
10
+ The text a property value stands for
11
+
12
+ OCHRE spreads that text over four places, so which one wins is real domain
13
+ knowledge and this is the only place it is written down. The content step is
14
+ injected because the two callers reach it differently: the item parser builds
15
+ a full multilingual string, while the rich-text parser needs one language's
16
+ plain text. Reading the sources in a different order is what let the two
17
+ disagree for a value carrying both a `slug` and `content`.
18
+ @param value - The raw property value
19
+ @param readContentText - Reads the value's `content` as plain text, or null when it has none
20
+ @returns The text, or an empty string when the value carries none
21
+ @internal
22
+ */
23
23
  export declare function readPropertyValueText(value: PropertyValueTextSource, readContentText: () => string | null): string;
24
24
  /**
25
- * The UUID a property value points at, treating an empty attribute as absent
26
- * @param value - The raw property value
27
- * @returns The UUID, or null when there is none
28
- * @internal
29
- */
25
+ The UUID a property value points at, treating an empty attribute as absent
26
+ @param value - The raw property value
27
+ @returns The UUID, or null when there is none
28
+ @internal
29
+ */
30
30
  export declare function readPropertyValueUuid(value: {
31
31
  uuid?: string;
32
32
  } | undefined): string | null;
@@ -1,26 +1,26 @@
1
1
  // src/parsers/property-token.ts
2
2
  /**
3
- * The text a property value stands for
4
- *
5
- * OCHRE spreads that text over four places, so which one wins is real domain
6
- * knowledge and this is the only place it is written down. The content step is
7
- * injected because the two callers reach it differently: the item parser builds
8
- * a full multilingual string, while the rich-text parser needs one language's
9
- * plain text. Reading the sources in a different order is what let the two
10
- * disagree for a value carrying both a `slug` and `content`.
11
- * @param value - The raw property value
12
- * @param readContentText - Reads the value's `content` as plain text, or null when it has none
13
- * @returns The text, or an empty string when the value carries none
14
- * @internal
3
+ The text a property value stands for
4
+
5
+ OCHRE spreads that text over four places, so which one wins is real domain
6
+ knowledge and this is the only place it is written down. The content step is
7
+ injected because the two callers reach it differently: the item parser builds
8
+ a full multilingual string, while the rich-text parser needs one language's
9
+ plain text. Reading the sources in a different order is what let the two
10
+ disagree for a value carrying both a `slug` and `content`.
11
+ @param value - The raw property value
12
+ @param readContentText - Reads the value's `content` as plain text, or null when it has none
13
+ @returns The text, or an empty string when the value carries none
14
+ @internal
15
15
  */
16
16
  function readPropertyValueText(value, readContentText) {
17
17
  return value.rawValue ?? value.payload ?? readContentText() ?? value.slug ?? "";
18
18
  }
19
19
  /**
20
- * The UUID a property value points at, treating an empty attribute as absent
21
- * @param value - The raw property value
22
- * @returns The UUID, or null when there is none
23
- * @internal
20
+ The UUID a property value points at, treating an empty attribute as absent
21
+ @param value - The raw property value
22
+ @returns The UUID, or null when there is none
23
+ @internal
24
24
  */
25
25
  function readPropertyValueUuid(value) {
26
26
  return value?.uuid == null || value.uuid === "" ? null : value.uuid;