ochre-sdk 1.0.0-beta.2 → 1.0.0-beta.4

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,13 @@
5
5
  */
6
6
  type MultilingualStringEntry = {
7
7
  text: string;
8
+ richText: string;
8
9
  isPrimary: boolean;
9
10
  };
11
+ type MultilingualStringInput = string | {
12
+ text: string;
13
+ richText?: string;
14
+ };
10
15
  type MultilingualStringJSON<T extends ReadonlyArray<string> = ReadonlyArray<string>> = {
11
16
  content: Partial<Record<T[number], Array<MultilingualStringEntry>>>;
12
17
  aliases: Array<string>;
@@ -15,13 +20,12 @@ type MultilingualStringJSON<T extends ReadonlyArray<string> = ReadonlyArray<stri
15
20
  * Options for creating and working with multilingual strings
16
21
  */
17
22
  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 */
23
+ /** Default language to use for fallbacks */defaultLanguage?: string; /** Available languages for this string */
20
24
  availableLanguages?: ReadonlyArray<string>; /** Alias values carried by OCHRE as zxx content */
21
25
  aliases?: ReadonlyArray<string>;
22
26
  };
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>>>;
27
+ type MultilingualInputContent<T extends ReadonlyArray<string>> = Partial<Record<T[number], MultilingualStringInput>>;
28
+ type MultilingualEntriesInput<T extends ReadonlyArray<string>> = Partial<Record<T[number], ReadonlyArray<MultilingualStringInput>>>;
25
29
  /**
26
30
  * Multilingual string
27
31
  */
@@ -35,17 +39,17 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
35
39
  * Create a new multilingual string from an object of language codes to text
36
40
  */
37
41
  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>>;
42
+ static fromObject(content: Partial<Record<string, MultilingualStringInput>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
39
43
  /**
40
44
  * Create a new multilingual string from language entries.
41
45
  */
42
46
  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>>;
47
+ static fromEntries(content: Partial<Record<string, ReadonlyArray<MultilingualStringInput>>>, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
44
48
  /**
45
49
  * Create a new multilingual string for a single language
46
50
  */
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>>;
51
+ static create<U extends ReadonlyArray<string>>(language: U[number], text: MultilingualStringInput, languages: U, options?: MultilingualOptions): MultilingualString<U>;
52
+ static create(language: string, text: MultilingualStringInput, languages?: undefined, options?: MultilingualOptions): MultilingualString<ReadonlyArray<string>>;
49
53
  /**
50
54
  * Create an empty multilingual string
51
55
  */
@@ -56,18 +60,34 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
56
60
  * Get text in a specific language with automatic fallback
57
61
  */
58
62
  getText(language?: T[number]): string;
63
+ /**
64
+ * Get rich text in a specific language with automatic fallback
65
+ */
66
+ getRichText(language?: T[number]): string;
59
67
  /**
60
68
  * Get primary text in a specific language without fallback
61
69
  */
62
70
  getExactText(language: T[number]): string | null;
71
+ /**
72
+ * Get primary rich text in a specific language without fallback
73
+ */
74
+ getExactRichText(language: T[number]): string | null;
63
75
  /**
64
76
  * Get all text entries in a specific language without fallback
65
77
  */
66
78
  getExactTexts(language: T[number]): Array<string>;
79
+ /**
80
+ * Get all rich text entries in a specific language without fallback
81
+ */
82
+ getExactRichTexts(language: T[number]): Array<string>;
67
83
  /**
68
84
  * Get all text entries in a specific language with fallback
69
85
  */
70
86
  getTexts(language?: T[number]): Array<string>;
87
+ /**
88
+ * Get all rich text entries in a specific language with fallback
89
+ */
90
+ getRichTexts(language?: T[number]): Array<string>;
71
91
  /**
72
92
  * Get all entries in a specific language without fallback
73
93
  */
@@ -108,18 +128,14 @@ declare class MultilingualString<T extends ReadonlyArray<string> = ReadonlyArray
108
128
  * Get the default language
109
129
  */
110
130
  getDefaultLanguage(): T[number];
111
- /**
112
- * Check if this string contains rich text
113
- */
114
- isRichText(): boolean;
115
131
  /**
116
132
  * Add or update the primary text for a language (returns new instance)
117
133
  */
118
- withText(language: T[number], text: string): MultilingualString<T>;
134
+ withText(language: T[number], text: MultilingualStringInput): MultilingualString<T>;
119
135
  /**
120
136
  * Add another text entry for a language (returns new instance)
121
137
  */
122
- withEntry(language: T[number], text: string): MultilingualString<T>;
138
+ withEntry(language: T[number], text: MultilingualStringInput): MultilingualString<T>;
123
139
  /**
124
140
  * Replace aliases (returns new instance)
125
141
  */
@@ -925,7 +941,6 @@ type Query = QueryLeaf | QueryGroup;
925
941
  type FetchFunction$4 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
926
942
  type FetchGalleryBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
927
943
  languages?: TLanguages;
928
- isRichText?: boolean;
929
944
  fetch?: FetchFunction$4;
930
945
  };
931
946
  type FetchGalleryLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -939,7 +954,6 @@ type FetchGalleryLanguages<TLanguages extends ReadonlyArray<string> | undefined>
939
954
  * @param params.perPage - The number of items per page
940
955
  * @param options - The options for the fetch
941
956
  * @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
957
  * @param options.fetch - The fetch function to use
944
958
  * @returns The parsed gallery or an error message if the fetch/parse fails
945
959
  */
@@ -960,7 +974,6 @@ declare function fetchGallery<const TLanguages extends ReadonlyArray<string> | u
960
974
  type FetchFunction$3 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
961
975
  type FetchItemLinksBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
962
976
  languages?: TLanguages;
963
- isRichText?: boolean;
964
977
  fetch?: FetchFunction$3;
965
978
  };
966
979
  type FetchItemLinksLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -971,7 +984,6 @@ type FetchItemLinksLanguages<TLanguages extends ReadonlyArray<string> | undefine
971
984
  * @param options - Fetch and parser options
972
985
  * @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
986
  * @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
987
  * @param options.fetch - Custom fetch function to use instead of the default fetch
976
988
  * @returns An object containing parsed linked items
977
989
  */
@@ -989,7 +1001,6 @@ declare function fetchItemLinks<const TItemCategory extends HierarchyItemCategor
989
1001
  type FetchFunction$2 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
990
1002
  type FetchItemBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
991
1003
  languages?: TLanguages;
992
- isRichText?: boolean;
993
1004
  fetch?: FetchFunction$2;
994
1005
  };
995
1006
  type FetchItemLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -1016,7 +1027,6 @@ declare function withLanguages<const TLanguages extends ReadonlyArray<string>>(l
1016
1027
  * @param options.category - The category of the OCHRE item to fetch
1017
1028
  * @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
1029
  * @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
1030
  * @param options.fetch - Custom fetch function to use instead of the default fetch
1021
1031
  * @returns An object containing the parsed item
1022
1032
  */
@@ -1055,7 +1065,6 @@ declare function fetchItem<const TCategory extends DataCategory, const TLanguage
1055
1065
  type FetchFunction$1 = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
1056
1066
  type FetchSetItemsBaseOptions<TLanguages extends ReadonlyArray<string> | undefined = undefined> = {
1057
1067
  languages?: TLanguages;
1058
- isRichText?: boolean;
1059
1068
  fetch?: FetchFunction$1;
1060
1069
  };
1061
1070
  type FetchSetItemsLanguages<TLanguages extends ReadonlyArray<string> | undefined> = TLanguages extends readonly [] ? ReadonlyArray<string> : TLanguages extends ReadonlyArray<string> ? TLanguages : ReadonlyArray<string>;
@@ -1650,7 +1659,6 @@ type FetchFunction = (input: string | URL | globalThis.Request, init?: RequestIn
1650
1659
  declare function fetchWebsite<const T extends ReadonlyArray<string> = ReadonlyArray<string>>(abbreviation: string, options?: {
1651
1660
  fetch?: FetchFunction;
1652
1661
  languages?: T;
1653
- isRichText?: boolean;
1654
1662
  }): Promise<{
1655
1663
  website: Website<T>;
1656
1664
  error: null;