ochre-sdk 1.0.0-beta.3 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -5,8 +5,17 @@
5
5
  */
6
6
  type MultilingualStringEntry = {
7
7
  text: string;
8
+ richText: string;
8
9
  isPrimary: boolean;
9
10
  };
11
+ type MultilingualStringText = {
12
+ text: string;
13
+ richText: string;
14
+ };
15
+ type MultilingualStringInput = string | {
16
+ text: string;
17
+ richText?: string;
18
+ };
10
19
  type MultilingualStringJSON<T extends ReadonlyArray<string> = ReadonlyArray<string>> = {
11
20
  content: Partial<Record<T[number], Array<MultilingualStringEntry>>>;
12
21
  aliases: Array<string>;
@@ -15,13 +24,12 @@ type MultilingualStringJSON<T extends ReadonlyArray<string> = ReadonlyArray<stri
15
24
  * Options for creating and working with multilingual strings
16
25
  */
17
26
  type MultilingualOptions = {
18
- /** Whether this string contains rich text/HTML content */isRichText?: boolean; /** Default language to use for fallbacks */
19
- defaultLanguage?: string; /** Available languages for this string */
27
+ /** Default language to use for fallbacks */defaultLanguage?: string; /** Available languages for this string */
20
28
  availableLanguages?: ReadonlyArray<string>; /** Alias values carried by OCHRE as zxx content */
21
29
  aliases?: ReadonlyArray<string>;
22
30
  };
23
- type MultilingualInputContent<T extends ReadonlyArray<string>> = Partial<Record<T[number], string>>;
24
- type MultilingualEntriesInput<T extends ReadonlyArray<string>> = Partial<Record<T[number], ReadonlyArray<string>>>;
31
+ type MultilingualInputContent<T extends ReadonlyArray<string>> = Partial<Record<T[number], MultilingualStringInput>>;
32
+ type MultilingualEntriesInput<T extends ReadonlyArray<string>> = Partial<Record<T[number], ReadonlyArray<MultilingualStringInput>>>;
25
33
  /**
26
34
  * Multilingual string
27
35
  */
@@ -35,17 +43,17 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
35
43
  * Create a new multilingual string from an object of language codes to text
36
44
  */
37
45
  static fromObject<U extends ReadonlyArray<string>>(content: MultilingualInputContent<U>, languages: U, options?: MultilingualOptions): MultilingualString<U>;
38
- static fromObject(content: Partial<Record<string, string>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
46
+ static fromObject(content: Partial<Record<string, MultilingualStringInput>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
39
47
  /**
40
48
  * Create a new multilingual string from language entries.
41
49
  */
42
50
  static fromEntries<U extends ReadonlyArray<string>>(content: MultilingualEntriesInput<U>, languages: U, options?: MultilingualOptions): MultilingualString<U>;
43
- static fromEntries(content: Partial<Record<string, ReadonlyArray<string>>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
51
+ static fromEntries(content: Partial<Record<string, ReadonlyArray<MultilingualStringInput>>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
44
52
  /**
45
53
  * Create a new multilingual string for a single language
46
54
  */
47
- static create<U extends ReadonlyArray<string>>(language: U[number], text: string, languages: U, options?: MultilingualOptions): MultilingualString<U>;
48
- static create(language: string, text: string, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
55
+ static create<U extends ReadonlyArray<string>>(language: U[number], text: MultilingualStringInput, languages: U, options?: MultilingualOptions): MultilingualString<U>;
56
+ static create(language: string, text: MultilingualStringInput, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
49
57
  /**
50
58
  * Create an empty multilingual string
51
59
  */
@@ -56,18 +64,34 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
56
64
  * Get text in a specific language with automatic fallback
57
65
  */
58
66
  getText(language?: T[number]): string;
67
+ /**
68
+ * Get rich text in a specific language with automatic fallback
69
+ */
70
+ getRichText(language?: T[number]): string;
59
71
  /**
60
72
  * Get primary text in a specific language without fallback
61
73
  */
62
74
  getExactText(language: T[number]): string | null;
75
+ /**
76
+ * Get primary rich text in a specific language without fallback
77
+ */
78
+ getExactRichText(language: T[number]): string | null;
63
79
  /**
64
80
  * Get all text entries in a specific language without fallback
65
81
  */
66
82
  getExactTexts(language: T[number]): Array<string>;
83
+ /**
84
+ * Get all rich text entries in a specific language without fallback
85
+ */
86
+ getExactRichTexts(language: T[number]): Array<string>;
67
87
  /**
68
88
  * Get all text entries in a specific language with fallback
69
89
  */
70
90
  getTexts(language?: T[number]): Array<string>;
91
+ /**
92
+ * Get all rich text entries in a specific language with fallback
93
+ */
94
+ getRichTexts(language?: T[number]): Array<string>;
71
95
  /**
72
96
  * Get all entries in a specific language without fallback
73
97
  */
@@ -108,18 +132,14 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
108
132
  * Get the default language
109
133
  */
110
134
  getDefaultLanguage(): T[number];
111
- /**
112
- * Check if this string contains rich text
113
- */
114
- isRichText(): boolean;
115
135
  /**
116
136
  * Add or update the primary text for a language (returns new instance)
117
137
  */
118
- withText(language: T[number], text: string): MultilingualString<T>;
138
+ withText(language: T[number], text: MultilingualStringInput): MultilingualString<T>;
119
139
  /**
120
140
  * Add another text entry for a language (returns new instance)
121
141
  */
122
- withEntry(language: T[number], text: string): MultilingualString<T>;
142
+ withEntry(language: T[number], text: MultilingualStringInput): MultilingualString<T>;
123
143
  /**
124
144
  * Replace aliases (returns new instance)
125
145
  */
@@ -925,7 +945,6 @@ type Query = QueryLeaf | QueryGroup;
925
945
  type FetchFunction$4 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
926
946
  type FetchGalleryBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
927
947
  languages?: TLanguages;
928
- isRichText?: boolean;
929
948
  fetch?: FetchFunction$4;
930
949
  };
931
950
  type FetchGalleryLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -939,7 +958,6 @@ type FetchGalleryLanguages<TLanguages extends ReadonlyArray<string> | undefined>
939
958
  * @param params.perPage - The number of items per page
940
959
  * @param options - The options for the fetch
941
960
  * @param options.languages - Language codes to parse. Inline arrays preserve literal types automatically.
942
- * @param options.isRichText - Whether to parse rich text fields as HTML strings
943
961
  * @param options.fetch - The fetch function to use
944
962
  * @returns The parsed gallery or an error message if the fetch/parse fails
945
963
  */
@@ -960,7 +978,6 @@ declare function fetchGallery<const TLanguages extends ReadonlyArray<string> | u
960
978
  type FetchFunction$3 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
961
979
  type FetchItemLinksBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
962
980
  languages?: TLanguages;
963
- isRichText?: boolean;
964
981
  fetch?: FetchFunction$3;
965
982
  };
966
983
  type FetchItemLinksLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -971,7 +988,6 @@ type FetchItemLinksLanguages<TLanguages extends ReadonlyArray<string> | undefine
971
988
  * @param options - Fetch and parser options
972
989
  * @param options.itemCategory - The category of items inside linked Trees/Sets to parse. Tree accepts one category; Set accepts one category or an array.
973
990
  * @param options.languages - Language codes to parse. Inline arrays preserve literal types automatically.
974
- * @param options.isRichText - Whether to parse the text as rich text
975
991
  * @param options.fetch - Custom fetch function to use instead of the default fetch
976
992
  * @returns An object containing parsed linked items
977
993
  */
@@ -989,7 +1005,6 @@ declare function fetchItemLinks<const TItemCategory extends HierarchyItemCategor
989
1005
  type FetchFunction$2 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
990
1006
  type FetchItemBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
991
1007
  languages?: TLanguages;
992
- isRichText?: boolean;
993
1008
  fetch?: FetchFunction$2;
994
1009
  };
995
1010
  type FetchItemLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -1016,7 +1031,6 @@ declare function withLanguages<const TLanguages extends ReadonlyArray<string>>(l
1016
1031
  * @param options.category - The category of the OCHRE item to fetch
1017
1032
  * @param options.itemCategory - The category of items inside the OCHRE item to fetch. Only valid for Trees and Sets. Tree accepts one category; Set accepts one category or an array.
1018
1033
  * @param options.languages - Language codes to parse. Inline arrays preserve literal types automatically.
1019
- * @param options.isRichText - Whether to parse the text as rich text
1020
1034
  * @param options.fetch - Custom fetch function to use instead of the default fetch
1021
1035
  * @returns An object containing the parsed item
1022
1036
  */
@@ -1055,7 +1069,6 @@ declare function fetchItem<const TCategory extends DataCategory, const TLanguage
1055
1069
  type FetchFunction$1 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
1056
1070
  type FetchSetItemsBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
1057
1071
  languages?: TLanguages;
1058
- isRichText?: boolean;
1059
1072
  fetch?: FetchFunction$1;
1060
1073
  };
1061
1074
  type FetchSetItemsLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -1650,7 +1663,6 @@ type FetchFunction = (input: string | URL | globalThis.Request, init?: RequestIn
1650
1663
  declare function fetchWebsite<const T extends ReadonlyArray<string> = ReadonlyArray<string>>(abbreviation: string, options?: {
1651
1664
  fetch?: FetchFunction;
1652
1665
  languages?: T;
1653
- isRichText?: boolean;
1654
1666
  }): Promise<{
1655
1667
  website: Website<T>;
1656
1668
  error: null;
@@ -1842,4 +1854,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
1842
1854
  */
1843
1855
  declare function flattenItemProperties<U extends DataCategory = DataCategory, V extends HierarchyItemDataCategory<U> = HierarchyItemDataCategory<U>, T extends ReadonlyArray<string> = ReadonlyArray<string>, W extends ItemLocation = "topLevel">(item: Item<U, V, T, W>): FlattenedItem<Item<U, V, T, W>, T>;
1844
1856
  //#endregion
1845
- export { BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, Context, ContextDataCategory, ContextItem, ContextNode, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Coordinates, CoordinatesSource, DEFAULT_PAGE_SIZE, DataCategory, DictionaryUnitItemLink, Event, Gallery, Heading, HeadingDataCategory, HierarchyDataCategory, HierarchyItemCategoryFromOption, HierarchyItemCategoryOption, HierarchyItemDataCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemLink, ItemLinkCategory, ItemLinks, ItemLocation, ItemsDataCategory, License, Metadata, Note, Observation, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyOptions, PropertyValue, PropertyValueContent, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, RecursiveDataCategory, Resource, ResourceItemLink, Scope, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemDataCategory, SetItemLink, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SingleHierarchyProperty, SpatialUnit, SpatialUnitItemLink, Style, StylesheetCategory, StylesheetItem, Text, TextItemLink, Tree, TreeItemLink, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabelName, getPropertyByLabelNameAndValue, getPropertyByLabelNameAndValueContent, getPropertyByLabelNameAndValueContents, getPropertyByLabelNameAndValues, getPropertyByLabelUuid, getPropertyValueByLabelName, getPropertyValueByLabelUuid, getPropertyValueContentByLabelName, getPropertyValueContentByLabelUuid, getPropertyValueContentsByLabelUuid, getPropertyValuesByLabelName, getPropertyValuesByLabelUuid, getUniqueProperties, getUniquePropertyLabelNames, withLanguages };
1857
+ export { BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, Context, ContextDataCategory, ContextItem, ContextNode, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Coordinates, CoordinatesSource, DEFAULT_PAGE_SIZE, DataCategory, DictionaryUnitItemLink, Event, Gallery, Heading, HeadingDataCategory, HierarchyDataCategory, HierarchyItemCategoryFromOption, HierarchyItemCategoryOption, HierarchyItemDataCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemLink, ItemLinkCategory, ItemLinks, ItemLocation, ItemsDataCategory, License, Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringText, Note, Observation, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyOptions, PropertyValue, PropertyValueContent, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, RecursiveDataCategory, Resource, ResourceItemLink, Scope, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemDataCategory, SetItemLink, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SingleHierarchyProperty, SpatialUnit, SpatialUnitItemLink, Style, StylesheetCategory, StylesheetItem, Text, TextItemLink, Tree, TreeItemLink, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabelName, getPropertyByLabelNameAndValue, getPropertyByLabelNameAndValueContent, getPropertyByLabelNameAndValueContents, getPropertyByLabelNameAndValues, getPropertyByLabelUuid, getPropertyValueByLabelName, getPropertyValueByLabelUuid, getPropertyValueContentByLabelName, getPropertyValueContentByLabelUuid, getPropertyValueContentsByLabelUuid, getPropertyValuesByLabelName, getPropertyValuesByLabelUuid, getUniqueProperties, getUniquePropertyLabelNames, withLanguages };