@docsearch/react 4.7.0 → 5.0.0-beta.1
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/README.md +0 -2
- package/dist/esm/AskAiScreenState-CRHicWbN.d.ts +106 -0
- package/dist/esm/DocSearch-HJsNvtZr.d.ts +295 -0
- package/dist/esm/DocSearchAskAiModal-B7vpLudE.d.ts +48 -0
- package/dist/esm/DocSearchAskAiModal-KaA6fBV4.js +954 -0
- package/dist/esm/DocSearchAskAiModal-KaA6fBV4.js.map +1 -0
- package/dist/esm/DocSearchButton-CZM_jACU.d.ts +18 -0
- package/dist/esm/DocSearchButton-CaxxOzQU.js +71 -0
- package/dist/esm/DocSearchButton-CaxxOzQU.js.map +1 -0
- package/dist/esm/DocSearchModal-CpvDjo1O.js +250 -0
- package/dist/esm/DocSearchModal-CpvDjo1O.js.map +1 -0
- package/dist/esm/DocSearchTheme-DvL4mf0D.d.ts +5 -0
- package/dist/esm/askaiModal.d.ts +2 -0
- package/dist/esm/askaiModal.js +3 -0
- package/dist/esm/button.d.ts +2 -0
- package/dist/esm/button.js +3 -0
- package/dist/esm/docsearchAi.d.ts +220 -0
- package/dist/esm/docsearchAi.js +34 -0
- package/dist/esm/docsearchAi.js.map +1 -0
- package/dist/esm/index-Bqqv4HmN.d.ts +233 -0
- package/dist/esm/index.d.ts +9 -657
- package/dist/esm/index.js +35 -3
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/keyboard-BkSdCzTU.js +9 -0
- package/dist/esm/keyboard-BkSdCzTU.js.map +1 -0
- package/dist/esm/keyboardShortcuts-C-lx6Xt7.js +25 -0
- package/dist/esm/keyboardShortcuts-C-lx6Xt7.js.map +1 -0
- package/dist/esm/modal.d.ts +2 -0
- package/dist/esm/modal.js +3 -0
- package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js +1240 -0
- package/dist/esm/normalizeDocSearchIndexes-DAzlMybx.js.map +1 -0
- package/dist/esm/objectSpread2-BNmiQYyW.js +67 -0
- package/dist/esm/objectWithoutProperties-phqYxDS0.js +53 -0
- package/dist/esm/objectWithoutProperties-phqYxDS0.js.map +1 -0
- package/dist/esm/sidepanel.d.ts +395 -0
- package/dist/esm/sidepanel.js +773 -0
- package/dist/esm/sidepanel.js.map +1 -0
- package/dist/esm/useDocSearchKeyboardEvents-u23fFhR9.d.ts +43 -0
- package/dist/esm/useDocSearchKeyboardEvents.d.ts +2 -41
- package/dist/esm/useDocSearchKeyboardEvents.js +43 -1
- package/dist/esm/useDocSearchKeyboardEvents.js.map +1 -0
- package/dist/esm/useSearchClient-mIHVB6ga.js +433 -0
- package/dist/esm/useSearchClient-mIHVB6ga.js.map +1 -0
- package/dist/esm/useSuggestedQuestions-CG2H3qm4.js +1116 -0
- package/dist/esm/useSuggestedQuestions-CG2H3qm4.js.map +1 -0
- package/dist/esm/useTheme.d.ts +7 -6
- package/dist/esm/useTheme.js +21 -1
- package/dist/esm/useTheme.js.map +1 -0
- package/dist/esm/version.d.ts +4 -2
- package/dist/esm/version.js +6 -1
- package/dist/esm/version.js.map +1 -0
- package/dist/umd/index.js +175 -5
- package/dist/umd/index.js.map +1 -1
- package/package.json +31 -34
- package/style/askai.js +1 -0
- package/button.js +0 -1
- package/dist/esm/DocSearchButton.d.ts +0 -18
- package/dist/esm/DocSearchButton.js +0 -1
- package/dist/esm/DocSearchModal.d.ts +0 -446
- package/dist/esm/DocSearchModal.js +0 -3
- package/dist/esm/Sidepanel.d.ts +0 -371
- package/dist/esm/Sidepanel.js +0 -3
- package/dist/umd/DocSearchModal.js +0 -5
- package/dist/umd/DocSearchModal.js.map +0 -1
- package/dist/umd/DocsearchButton.js +0 -3
- package/dist/umd/DocsearchButton.js.map +0 -1
- package/dist/umd/Sidepanel.js +0 -5
- package/dist/umd/Sidepanel.js.map +0 -1
- package/dist/umd/useDocSearchKeyboardEvents.js +0 -3
- package/dist/umd/useDocSearchKeyboardEvents.js.map +0 -1
- package/dist/umd/useTheme.js +0 -3
- package/dist/umd/useTheme.js.map +0 -1
- package/dist/umd/version.js +0 -3
- package/dist/umd/version.js.map +0 -1
- package/modal.js +0 -1
- package/sidepanel.js +0 -1
- package/useDocSearchKeyboardEvents.js +0 -1
- package/useTheme.js +0 -1
- package/version.js +0 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,657 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
interface DocSearchHitAttributeHighlightResult {
|
|
11
|
-
value: string;
|
|
12
|
-
matchLevel: 'full' | 'none' | 'partial';
|
|
13
|
-
matchedWords: string[];
|
|
14
|
-
fullyHighlighted?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface DocSearchHitHighlightResultHierarchy {
|
|
17
|
-
lvl0: DocSearchHitAttributeHighlightResult;
|
|
18
|
-
lvl1: DocSearchHitAttributeHighlightResult;
|
|
19
|
-
lvl2: DocSearchHitAttributeHighlightResult;
|
|
20
|
-
lvl3: DocSearchHitAttributeHighlightResult;
|
|
21
|
-
lvl4: DocSearchHitAttributeHighlightResult;
|
|
22
|
-
lvl5: DocSearchHitAttributeHighlightResult;
|
|
23
|
-
lvl6: DocSearchHitAttributeHighlightResult;
|
|
24
|
-
}
|
|
25
|
-
interface DocSearchHitHighlightResult {
|
|
26
|
-
content: DocSearchHitAttributeHighlightResult;
|
|
27
|
-
hierarchy: DocSearchHitHighlightResultHierarchy;
|
|
28
|
-
hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
|
|
29
|
-
}
|
|
30
|
-
interface DocSearchHitAttributeSnippetResult {
|
|
31
|
-
value: string;
|
|
32
|
-
matchLevel: 'full' | 'none' | 'partial';
|
|
33
|
-
}
|
|
34
|
-
interface DocSearchHitSnippetResult {
|
|
35
|
-
content: DocSearchHitAttributeSnippetResult;
|
|
36
|
-
hierarchy: DocSearchHitHighlightResultHierarchy;
|
|
37
|
-
hierarchy_camel: DocSearchHitHighlightResultHierarchy[];
|
|
38
|
-
}
|
|
39
|
-
declare type DocSearchHit = {
|
|
40
|
-
objectID: string;
|
|
41
|
-
content: string | null;
|
|
42
|
-
query?: string;
|
|
43
|
-
url: string;
|
|
44
|
-
url_without_anchor: string;
|
|
45
|
-
type: ContentType;
|
|
46
|
-
anchor: string | null;
|
|
47
|
-
hierarchy: {
|
|
48
|
-
lvl0: string;
|
|
49
|
-
lvl1: string;
|
|
50
|
-
lvl2: string | null;
|
|
51
|
-
lvl3: string | null;
|
|
52
|
-
lvl4: string | null;
|
|
53
|
-
lvl5: string | null;
|
|
54
|
-
lvl6: string | null;
|
|
55
|
-
};
|
|
56
|
-
_highlightResult: DocSearchHitHighlightResult;
|
|
57
|
-
_snippetResult: DocSearchHitSnippetResult;
|
|
58
|
-
_rankingInfo?: {
|
|
59
|
-
promoted: boolean;
|
|
60
|
-
nbTypos: number;
|
|
61
|
-
firstMatchedWord: number;
|
|
62
|
-
proximityDistance?: number;
|
|
63
|
-
geoDistance: number;
|
|
64
|
-
geoPrecision?: number;
|
|
65
|
-
nbExactWords: number;
|
|
66
|
-
words: number;
|
|
67
|
-
filters: number;
|
|
68
|
-
userScore: number;
|
|
69
|
-
matchedGeoLocation?: {
|
|
70
|
-
lat: number;
|
|
71
|
-
lng: number;
|
|
72
|
-
distance: number;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
_distinctSeqID?: number;
|
|
76
|
-
__autocomplete_indexName?: string;
|
|
77
|
-
__autocomplete_queryID?: string;
|
|
78
|
-
__autocomplete_algoliaCredentials?: {
|
|
79
|
-
appId: string;
|
|
80
|
-
apiKey: string;
|
|
81
|
-
};
|
|
82
|
-
__autocomplete_id?: number;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
interface DocSearchContext extends AutocompleteContext {
|
|
86
|
-
algoliaInsightsPlugin?: {
|
|
87
|
-
insights: AutocompleteInsightsApi;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
interface DocSearchState<TItem extends BaseItem> extends AutocompleteState<TItem> {
|
|
91
|
-
context: DocSearchContext;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type DocSearchTheme = 'dark' | 'light';
|
|
95
|
-
|
|
96
|
-
type InternalDocSearchHit = DocSearchHit & {
|
|
97
|
-
__docsearch_parent: InternalDocSearchHit | null;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
interface KeyboardShortcuts {
|
|
101
|
-
/**
|
|
102
|
-
* Enable/disable the Ctrl/Cmd+K shortcut to toggle the search modal.
|
|
103
|
-
*
|
|
104
|
-
* @default true
|
|
105
|
-
*/
|
|
106
|
-
'Ctrl/Cmd+K'?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Enable/disable the / shortcut to open the search modal.
|
|
109
|
-
*
|
|
110
|
-
* @default true
|
|
111
|
-
*/
|
|
112
|
-
'/'?: boolean;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
interface SearchIndexTool {
|
|
116
|
-
input: {
|
|
117
|
-
query: string;
|
|
118
|
-
};
|
|
119
|
-
output: {
|
|
120
|
-
query?: string;
|
|
121
|
-
hits?: any[];
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
interface AgentStudioSearchTool {
|
|
125
|
-
input: {
|
|
126
|
-
index: string;
|
|
127
|
-
query: string;
|
|
128
|
-
number_of_results: number;
|
|
129
|
-
facet_filters: any | null;
|
|
130
|
-
};
|
|
131
|
-
output: {
|
|
132
|
-
hits?: any[];
|
|
133
|
-
nbHits?: number;
|
|
134
|
-
queryID?: string;
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
interface AlgoliaMCPSearchTool {
|
|
138
|
-
input: {
|
|
139
|
-
query: string;
|
|
140
|
-
};
|
|
141
|
-
output: {
|
|
142
|
-
hits?: any[];
|
|
143
|
-
nbHits?: number;
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
type Tools = {
|
|
147
|
-
[K in `algolia_search_index_${string}`]: AlgoliaMCPSearchTool;
|
|
148
|
-
} & {
|
|
149
|
-
searchIndex: SearchIndexTool;
|
|
150
|
-
algolia_search_index: AgentStudioSearchTool;
|
|
151
|
-
};
|
|
152
|
-
type AIMessage = UIMessage<{
|
|
153
|
-
stopped?: boolean;
|
|
154
|
-
}, UIDataTypes, Tools>;
|
|
155
|
-
|
|
156
|
-
type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
|
|
157
|
-
type StoredAskAiMessage = AIMessage & {
|
|
158
|
-
/** Optional user feedback on this assistant message. */
|
|
159
|
-
feedback?: 'dislike' | 'like';
|
|
160
|
-
};
|
|
161
|
-
type StoredAskAiState = StoredDocSearchHit & {
|
|
162
|
-
stopped?: boolean;
|
|
163
|
-
messages?: StoredAskAiMessage[];
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
type SuggestedQuestion = {
|
|
167
|
-
appId: string;
|
|
168
|
-
assistantId: string;
|
|
169
|
-
question: string;
|
|
170
|
-
locale?: string;
|
|
171
|
-
state: 'published';
|
|
172
|
-
source: string;
|
|
173
|
-
order: number;
|
|
174
|
-
};
|
|
175
|
-
type SuggestedQuestionHit = Hit<SuggestedQuestion>;
|
|
176
|
-
|
|
177
|
-
type ExchangeWithOptionalAssistant = {
|
|
178
|
-
assistantMessage: AIMessage | null;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Pass-through: keep all exchanges when thread depth fails so the last user message stays visible
|
|
182
|
-
* (there is often no assistant reply for that turn).
|
|
183
|
-
*/
|
|
184
|
-
declare function filterExchangesForThreadDepthError<T extends ExchangeWithOptionalAssistant>(exchanges: T[], _hasThreadDepthError: boolean): T[];
|
|
185
|
-
/**
|
|
186
|
-
* Whether the error is conversation depth exceeded (AI-217), including JSON-shaped Agent Studio payloads.
|
|
187
|
-
*/
|
|
188
|
-
declare function isThreadDepthError(error?: Error): boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Whether further prompts should be blocked: thread depth (all backends) or Agent Studio cost controls.
|
|
191
|
-
*/
|
|
192
|
-
declare function isAskAiPromptBlockingError(error: Error | undefined, agentStudio: boolean): boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Agent Studio stream hit the completion token ceiling (`TokenOutputLimitError`).
|
|
195
|
-
* This case uses a message-only banner (no “Start a new conversation” row).
|
|
196
|
-
*/
|
|
197
|
-
declare function isAgentStudioTokenOutputLimitError(error?: Error): boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Whether the blocking banner should include “Start a new conversation … to continue”.
|
|
200
|
-
* Thread depth and most Agent Studio limits keep it; token output limit and “request blocked for this domain” omit it.
|
|
201
|
-
*/
|
|
202
|
-
declare function showAskAiBlockingBannerNewConversationLink(error: Error | undefined, agentStudio: boolean): boolean;
|
|
203
|
-
/**
|
|
204
|
-
* Pulls `message` or `error` from Agent Studio JSON payloads, including double-encoded JSON
|
|
205
|
-
* and objects serialized with escaped quotes (`{\"error\": \"...\"}`).
|
|
206
|
-
*/
|
|
207
|
-
declare function extractAgentStudioErrorFieldMessage(raw: string): string | undefined;
|
|
208
|
-
/**
|
|
209
|
-
* Prefer the API `message` when the body was JSON; otherwise the thrown message (without a trailing `(AI-xxx)` suffix).
|
|
210
|
-
* Only meaningful when {@link isAskAiPromptBlockingError} would return true for this error.
|
|
211
|
-
*/
|
|
212
|
-
declare function getAskAiPromptBlockingUserFacingMessage(error?: Error): string | undefined;
|
|
213
|
-
/**
|
|
214
|
-
* Message shown in the top blocking banner (parsed API text, never raw JSON when avoidable).
|
|
215
|
-
*/
|
|
216
|
-
declare function getAskAiBlockingBannerMessage(error?: Error): string | undefined;
|
|
217
|
-
/**
|
|
218
|
-
* Prefer the API `message` field when the error body is JSON; otherwise the thrown message string.
|
|
219
|
-
* Only meaningful when {@link isThreadDepthError} is true.
|
|
220
|
-
*/
|
|
221
|
-
declare function getThreadDepthErrorUserFacingMessage(error?: Error): string | undefined;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Registry of Agent Studio prompt-blocking matchers (cost controls, access, limits).
|
|
225
|
-
* Add cases here instead of scattering regex across call sites.
|
|
226
|
-
* Set `showNewConversationLink` to false to omit the “Start a new conversation … to continue” row when starting over does not fix the issue (for example, domain allowlisting).
|
|
227
|
-
*/
|
|
228
|
-
type AgentStudioBlockingMatchContext = {
|
|
229
|
-
message: string;
|
|
230
|
-
messageLower: string;
|
|
231
|
-
parsedJson: Record<string, unknown> | null;
|
|
232
|
-
extractedCodeUpper: string | undefined;
|
|
233
|
-
};
|
|
234
|
-
type AgentStudioPromptBlockingMatcher = {
|
|
235
|
-
matches: (ctx: AgentStudioBlockingMatchContext) => boolean;
|
|
236
|
-
showNewConversationLink?: boolean;
|
|
237
|
-
};
|
|
238
|
-
/** Agent Studio cost / access control codes that block further input. */
|
|
239
|
-
declare const AGENT_STUDIO_PROMPT_BLOCKING_CODES: Set<string>;
|
|
240
|
-
declare function readAgentStudioJsonStringField(o: Record<string, unknown>, key: string): string | undefined;
|
|
241
|
-
declare function extractAiErrorCodeFromMessage(message: string): string | undefined;
|
|
242
|
-
/** Plain-text / stringified JSON heuristic; JSON-shaped payloads still use `isThreadDepthError` in `ai.ts`. */
|
|
243
|
-
declare function matchesThreadDepthLimitError(normalizedMessage: string): boolean;
|
|
244
|
-
/** API copy for domain allowlisting — starting a new conversation does not resolve it. */
|
|
245
|
-
declare function matchesRequestBlockedForThisDomainMessage(normalizedMessage: string): boolean;
|
|
246
|
-
declare function matchesAgentStudioMaxStepsMessage(normalizedMessage: string): boolean;
|
|
247
|
-
declare function matchesAgentStudioRateLimitMessage(normalizedMessage: string): boolean;
|
|
248
|
-
declare function matchesAgentStudioTokenOutputLimitPlainMessage(message: string): boolean;
|
|
249
|
-
declare function matchesAgentStudioWhitelistOrNotAllowedDomainPlainMessage(normalizedMessage: string): boolean;
|
|
250
|
-
declare function matchesAgentStudioContextOrTokenLimitsPlainMessage(normalizedMessage: string): boolean;
|
|
251
|
-
/**
|
|
252
|
-
* Ordered registry: first match does not win alone — `resolveAgentStudioPromptBlocking`
|
|
253
|
-
* OR-combines blocking and AND-combines “show new conversation” (any `false` hides the row).
|
|
254
|
-
*/
|
|
255
|
-
declare const agentStudioPromptBlockingMatchers: AgentStudioPromptBlockingMatcher[];
|
|
256
|
-
declare function resolveAgentStudioPromptBlocking(error: Error): {
|
|
257
|
-
blocking: boolean;
|
|
258
|
-
showNewConversationLink: boolean;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Plain-text matchers over `Error.message.toLowerCase()` (callers pass `error.message.toLowerCase()`).
|
|
262
|
-
* Conversation depth / AI-217: first entry mirrors common plain cases; JSON-shaped payloads still need `isThreadDepthError` in `ai.ts`.
|
|
263
|
-
*
|
|
264
|
-
* Blocking UX and “Start new conversation” visibility are driven by `agentStudioPromptBlockingMatchers`.
|
|
265
|
-
*/
|
|
266
|
-
type NewConversationErrorMatcher = (normalizedMessage: string) => boolean;
|
|
267
|
-
declare const newConversationErrorMatchers: NewConversationErrorMatcher[];
|
|
268
|
-
|
|
269
|
-
type DocSearchTranslations = Partial<{
|
|
270
|
-
button: ButtonTranslations;
|
|
271
|
-
modal: ModalTranslations;
|
|
272
|
-
}>;
|
|
273
|
-
type DocSearchTransformClient = {
|
|
274
|
-
search: LiteClient['search'];
|
|
275
|
-
addAlgoliaAgent: LiteClient['addAlgoliaAgent'];
|
|
276
|
-
transporter: Pick<LiteClient['transporter'], 'algoliaAgent'>;
|
|
277
|
-
};
|
|
278
|
-
type AskAiSearchParameters = {
|
|
279
|
-
facetFilters?: string[];
|
|
280
|
-
filters?: string;
|
|
281
|
-
attributesToRetrieve?: string[];
|
|
282
|
-
restrictSearchableAttributes?: string[];
|
|
283
|
-
distinct?: boolean | number | string;
|
|
284
|
-
};
|
|
285
|
-
type AgentStudioSearchParameters = Record<string, Omit<AskAiSearchParameters, 'facetFilters'>>;
|
|
286
|
-
type DocSearchAskAi = {
|
|
287
|
-
/**
|
|
288
|
-
* The index name to use for the ask AI feature. Your assistant will search this index for relevant documents.
|
|
289
|
-
* If not provided, the index name will be used.
|
|
290
|
-
*/
|
|
291
|
-
indexName?: string;
|
|
292
|
-
/**
|
|
293
|
-
* The API key to use for the ask AI feature. Your assistant will use this API key to search the index.
|
|
294
|
-
* If not provided, the API key will be used.
|
|
295
|
-
*/
|
|
296
|
-
apiKey?: string;
|
|
297
|
-
/**
|
|
298
|
-
* The app ID to use for the ask AI feature. Your assistant will use this app ID to search the index.
|
|
299
|
-
* If not provided, the app ID will be used.
|
|
300
|
-
*/
|
|
301
|
-
appId?: string;
|
|
302
|
-
/**
|
|
303
|
-
* The assistant ID to use for the ask AI feature.
|
|
304
|
-
*/
|
|
305
|
-
assistantId: string;
|
|
306
|
-
/**
|
|
307
|
-
* Enables displaying suggested questions on Ask AI's new conversation screen.
|
|
308
|
-
*
|
|
309
|
-
* @default false
|
|
310
|
-
*/
|
|
311
|
-
suggestedQuestions?: boolean;
|
|
312
|
-
useStagingEnv?: boolean;
|
|
313
|
-
} & ({
|
|
314
|
-
/**
|
|
315
|
-
* **Experimental:** Whether to use Agent Studio as the chat backend.
|
|
316
|
-
*
|
|
317
|
-
* This is an experimental feature and its API may change without notice in future releases.
|
|
318
|
-
* Use with caution in production environments.
|
|
319
|
-
*
|
|
320
|
-
* @default false
|
|
321
|
-
*/
|
|
322
|
-
agentStudio?: never;
|
|
323
|
-
/**
|
|
324
|
-
* The search parameters to use for the ask AI feature.
|
|
325
|
-
*
|
|
326
|
-
* **NOTE**: If using `agentStudio = true`, the `searchParameters` object is
|
|
327
|
-
* keyed by the index name.
|
|
328
|
-
*/
|
|
329
|
-
searchParameters?: AskAiSearchParameters;
|
|
330
|
-
} | {
|
|
331
|
-
agentStudio: false;
|
|
332
|
-
searchParameters?: AskAiSearchParameters;
|
|
333
|
-
} | {
|
|
334
|
-
agentStudio: true;
|
|
335
|
-
/**
|
|
336
|
-
* The search parameters to use for the ask AI feature.
|
|
337
|
-
* Keyed by the index name.
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* {
|
|
341
|
-
* "INDEX_NAME": { distinct: false }
|
|
342
|
-
* }
|
|
343
|
-
*/
|
|
344
|
-
searchParameters?: AgentStudioSearchParameters;
|
|
345
|
-
});
|
|
346
|
-
interface DocSearchIndex {
|
|
347
|
-
name: string;
|
|
348
|
-
searchParameters?: SearchParamsObject;
|
|
349
|
-
}
|
|
350
|
-
interface DocSearchProps {
|
|
351
|
-
/**
|
|
352
|
-
* Algolia application id used by the search client.
|
|
353
|
-
*/
|
|
354
|
-
appId: string;
|
|
355
|
-
/**
|
|
356
|
-
* Public api key with search permissions for the index.
|
|
357
|
-
*/
|
|
358
|
-
apiKey: string;
|
|
359
|
-
/**
|
|
360
|
-
* Name of the algolia index to query.
|
|
361
|
-
*
|
|
362
|
-
* @deprecated `indexName` will be removed in a future version. Please use `indices` property going forward.
|
|
363
|
-
*/
|
|
364
|
-
indexName?: string;
|
|
365
|
-
/**
|
|
366
|
-
* List of indices and _optional_ searchParameters to be used for search.
|
|
367
|
-
*
|
|
368
|
-
* @see {@link https://docsearch.algolia.com/docs/api#indices}
|
|
369
|
-
*/
|
|
370
|
-
indices?: Array<DocSearchIndex | string>;
|
|
371
|
-
/**
|
|
372
|
-
* Configuration or assistant id to enable ask ai mode. Pass a string assistant id or a full config object.
|
|
373
|
-
*
|
|
374
|
-
* @deprecated Ask AI is being migrated from a standalone DocSearch feature into Algolia's Agent Studio. The `askAi` prop will be removed in DocSearch v5.
|
|
375
|
-
*/
|
|
376
|
-
askAi?: DocSearchAskAi | string;
|
|
377
|
-
/**
|
|
378
|
-
* Intercept Ask AI requests (e.g. Submitting a prompt or selecting a suggested question).
|
|
379
|
-
*
|
|
380
|
-
* Return `true` to prevent the default modal Ask AI flow (no toggle, no sendMessage).
|
|
381
|
-
* Useful to route Ask AI into a different UI (e.g. `@docsearch/sidepanel-js`) without flicker.
|
|
382
|
-
*/
|
|
383
|
-
interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
|
|
384
|
-
/**
|
|
385
|
-
* Theme overrides applied to the modal and related components.
|
|
386
|
-
*/
|
|
387
|
-
theme?: DocSearchTheme;
|
|
388
|
-
/**
|
|
389
|
-
* Placeholder text for the search input.
|
|
390
|
-
*/
|
|
391
|
-
placeholder?: string;
|
|
392
|
-
/**
|
|
393
|
-
* Additional algolia search parameters to merge into each query.
|
|
394
|
-
*
|
|
395
|
-
* @deprecated `searchParameters` will be removed in a future version. Please use `indices` property going forward.
|
|
396
|
-
*/
|
|
397
|
-
searchParameters?: SearchParamsObject;
|
|
398
|
-
/**
|
|
399
|
-
* Maximum number of hits to display per source/group.
|
|
400
|
-
*/
|
|
401
|
-
maxResultsPerGroup?: number;
|
|
402
|
-
/**
|
|
403
|
-
* Hook to post-process hits before rendering.
|
|
404
|
-
*/
|
|
405
|
-
transformItems?: (items: DocSearchHit[]) => DocSearchHit[];
|
|
406
|
-
/**
|
|
407
|
-
* Custom component to render an individual hit.
|
|
408
|
-
* Supports template patterns:
|
|
409
|
-
* - HTML strings with html helper: (props, { html }) => html`<div>...</div>`
|
|
410
|
-
* - JSX templates: (props) => <div>...</div>
|
|
411
|
-
* - Function-based templates: (props) => string | JSX.Element | Function.
|
|
412
|
-
*/
|
|
413
|
-
hitComponent?: (props: {
|
|
414
|
-
hit: InternalDocSearchHit | StoredDocSearchHit;
|
|
415
|
-
children: React.ReactNode;
|
|
416
|
-
}, helpers?: {
|
|
417
|
-
html: (template: TemplateStringsArray, ...values: any[]) => any;
|
|
418
|
-
}) => JSX.Element;
|
|
419
|
-
/**
|
|
420
|
-
* Custom component rendered at the bottom of the results panel.
|
|
421
|
-
* Supports template patterns:
|
|
422
|
-
* - HTML strings with html helper: (props, { html }) => html`<div>...</div>`
|
|
423
|
-
* - JSX templates: (props) => <div>...</div>
|
|
424
|
-
* - Function-based templates: (props) => string | JSX.Element | Function.
|
|
425
|
-
*/
|
|
426
|
-
resultsFooterComponent?: (props: {
|
|
427
|
-
state: AutocompleteState<InternalDocSearchHit>;
|
|
428
|
-
}, helpers?: {
|
|
429
|
-
html: (template: TemplateStringsArray, ...values: any[]) => any;
|
|
430
|
-
}) => JSX.Element | null;
|
|
431
|
-
/**
|
|
432
|
-
* Hook to wrap or modify the algolia search client.
|
|
433
|
-
*/
|
|
434
|
-
transformSearchClient?: (searchClient: DocSearchTransformClient) => DocSearchTransformClient;
|
|
435
|
-
/**
|
|
436
|
-
* Disable storage and usage of recent and favorite searches.
|
|
437
|
-
*/
|
|
438
|
-
disableUserPersonalization?: boolean;
|
|
439
|
-
/**
|
|
440
|
-
* Query string to prefill when opening the modal.
|
|
441
|
-
*/
|
|
442
|
-
initialQuery?: string;
|
|
443
|
-
/**
|
|
444
|
-
* Custom navigator for controlling link navigation.
|
|
445
|
-
*/
|
|
446
|
-
navigator?: AutocompleteOptions<InternalDocSearchHit>['navigator'];
|
|
447
|
-
/**
|
|
448
|
-
* Localized strings for the button and modal ui.
|
|
449
|
-
*/
|
|
450
|
-
translations?: DocSearchTranslations;
|
|
451
|
-
/**
|
|
452
|
-
* Builds a url to report missing results for a given query.
|
|
453
|
-
*/
|
|
454
|
-
getMissingResultsUrl?: ({ query }: {
|
|
455
|
-
query: string;
|
|
456
|
-
}) => string;
|
|
457
|
-
/**
|
|
458
|
-
* Insights client integration options to send analytics events.
|
|
459
|
-
*/
|
|
460
|
-
insights?: AutocompleteOptions<InternalDocSearchHit>['insights'];
|
|
461
|
-
/**
|
|
462
|
-
* The container element where the modal should be portaled to. Defaults to document.body.
|
|
463
|
-
*/
|
|
464
|
-
portalContainer?: DocumentFragment | Element;
|
|
465
|
-
/**
|
|
466
|
-
* Limit of how many recent searches should be saved/displayed..
|
|
467
|
-
*
|
|
468
|
-
* @default 7
|
|
469
|
-
*/
|
|
470
|
-
recentSearchesLimit?: number;
|
|
471
|
-
/**
|
|
472
|
-
* Limit of how many recent searches should be saved/displayed when there are favorited searches..
|
|
473
|
-
*
|
|
474
|
-
* @default 4
|
|
475
|
-
*/
|
|
476
|
-
recentSearchesWithFavoritesLimit?: number;
|
|
477
|
-
/**
|
|
478
|
-
* Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.
|
|
479
|
-
*
|
|
480
|
-
* @default `{ 'Ctrl/Cmd+K': true, '/': true }`
|
|
481
|
-
*/
|
|
482
|
-
keyboardShortcuts?: DocSearchModalShortcuts;
|
|
483
|
-
}
|
|
484
|
-
declare const DocSearch: React.ForwardRefExoticComponent<DocSearchProps & React.RefAttributes<DocSearchRef>>;
|
|
485
|
-
declare function DocSearchInner(props: DocSearchProps): JSX.Element;
|
|
486
|
-
|
|
487
|
-
type ButtonTranslations = Partial<{
|
|
488
|
-
buttonText: string;
|
|
489
|
-
buttonAriaLabel: string;
|
|
490
|
-
}>;
|
|
491
|
-
type DocSearchButtonProps = React.ComponentProps<'button'> & {
|
|
492
|
-
theme?: DocSearchTheme;
|
|
493
|
-
translations?: ButtonTranslations;
|
|
494
|
-
keyboardShortcuts?: DocSearchModalShortcuts;
|
|
495
|
-
};
|
|
496
|
-
declare const DocSearchButton: React.ForwardRefExoticComponent<Omit<DocSearchButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
497
|
-
|
|
498
|
-
type FooterTranslations = Partial<{
|
|
499
|
-
selectText: string;
|
|
500
|
-
submitQuestionText: string;
|
|
501
|
-
selectKeyAriaLabel: string;
|
|
502
|
-
navigateText: string;
|
|
503
|
-
navigateUpKeyAriaLabel: string;
|
|
504
|
-
navigateDownKeyAriaLabel: string;
|
|
505
|
-
closeText: string;
|
|
506
|
-
backToSearchText: string;
|
|
507
|
-
closeKeyAriaLabel: string;
|
|
508
|
-
poweredByText: string;
|
|
509
|
-
}>;
|
|
510
|
-
|
|
511
|
-
type NewConversationTranslations = Partial<{
|
|
512
|
-
newConversationTitle: string;
|
|
513
|
-
newConversationDescription: string;
|
|
514
|
-
}>;
|
|
515
|
-
|
|
516
|
-
type AskAiScreenTranslations = Partial<{
|
|
517
|
-
disclaimerText: string;
|
|
518
|
-
relatedSourcesText: string;
|
|
519
|
-
thinkingText: string;
|
|
520
|
-
copyButtonText: string;
|
|
521
|
-
copyButtonCopiedText: string;
|
|
522
|
-
copyButtonTitle: string;
|
|
523
|
-
likeButtonTitle: string;
|
|
524
|
-
dislikeButtonTitle: string;
|
|
525
|
-
thanksForFeedbackText: string;
|
|
526
|
-
preToolCallText: string;
|
|
527
|
-
duringToolCallText: string;
|
|
528
|
-
afterToolCallText: string;
|
|
529
|
-
/**
|
|
530
|
-
* Build the full jsx element for the aggregated search block.
|
|
531
|
-
* If provided, completely overrides the default english renderer.
|
|
532
|
-
*/
|
|
533
|
-
aggregatedToolCallNode?: (queries: string[], onSearchQueryClick: (query: string) => void) => React.ReactNode;
|
|
534
|
-
/**
|
|
535
|
-
* Generate the list connective parts only (backwards compatibility).
|
|
536
|
-
* Receives full list of queries and should return translation parts for before/after/separators.
|
|
537
|
-
* Example: (qs) => ({ before: 'searched for ', separator: ', ', lastSeparator: ' and ', after: '' }).
|
|
538
|
-
*/
|
|
539
|
-
aggregatedToolCallText?: (queries: string[]) => {
|
|
540
|
-
before?: string;
|
|
541
|
-
separator?: string;
|
|
542
|
-
lastSeparator?: string;
|
|
543
|
-
after?: string;
|
|
544
|
-
};
|
|
545
|
-
/**
|
|
546
|
-
* Message that's shown when user has stopped the streaming of a message.
|
|
547
|
-
*/
|
|
548
|
-
stoppedStreamingText: string;
|
|
549
|
-
/**
|
|
550
|
-
* Error title shown if there is an error while chatting.
|
|
551
|
-
*/
|
|
552
|
-
errorTitleText: string;
|
|
553
|
-
/**
|
|
554
|
-
* Button text for starting a new conversation after a blocking Ask AI error.
|
|
555
|
-
*/
|
|
556
|
-
startNewConversationButtonText: string;
|
|
557
|
-
}>;
|
|
558
|
-
|
|
559
|
-
type ErrorScreenTranslations = Partial<{
|
|
560
|
-
titleText: string;
|
|
561
|
-
helpText: string;
|
|
562
|
-
}>;
|
|
563
|
-
|
|
564
|
-
type NoResultsScreenTranslations = Partial<{
|
|
565
|
-
noResultsText: string;
|
|
566
|
-
suggestedQueryText: string;
|
|
567
|
-
reportMissingResultsText: string;
|
|
568
|
-
reportMissingResultsLinkText: string;
|
|
569
|
-
}>;
|
|
570
|
-
|
|
571
|
-
type ResultsScreenTranslations = Partial<{
|
|
572
|
-
askAiPlaceholder: string;
|
|
573
|
-
noResultsAskAiPlaceholder: string;
|
|
574
|
-
}>;
|
|
575
|
-
|
|
576
|
-
type StartScreenTranslations = Partial<{
|
|
577
|
-
recentSearchesTitle: string;
|
|
578
|
-
noRecentSearchesText: string;
|
|
579
|
-
saveRecentSearchButtonTitle: string;
|
|
580
|
-
removeRecentSearchButtonTitle: string;
|
|
581
|
-
favoriteSearchesTitle: string;
|
|
582
|
-
removeFavoriteSearchButtonTitle: string;
|
|
583
|
-
recentConversationsTitle: string;
|
|
584
|
-
removeRecentConversationButtonTitle: string;
|
|
585
|
-
}>;
|
|
586
|
-
|
|
587
|
-
type ScreenStateTranslations = Partial<{
|
|
588
|
-
errorScreen: ErrorScreenTranslations;
|
|
589
|
-
startScreen: StartScreenTranslations;
|
|
590
|
-
noResultsScreen: NoResultsScreenTranslations;
|
|
591
|
-
resultsScreen: ResultsScreenTranslations;
|
|
592
|
-
askAiScreen: AskAiScreenTranslations;
|
|
593
|
-
newConversation: NewConversationTranslations;
|
|
594
|
-
}>;
|
|
595
|
-
|
|
596
|
-
type SearchBoxTranslations = Partial<{
|
|
597
|
-
clearButtonTitle: string;
|
|
598
|
-
clearButtonAriaLabel: string;
|
|
599
|
-
closeButtonText: string;
|
|
600
|
-
closeButtonAriaLabel: string;
|
|
601
|
-
placeholderText: string;
|
|
602
|
-
placeholderTextAskAi: string;
|
|
603
|
-
placeholderTextAskAiStreaming: string;
|
|
604
|
-
enterKeyHint: string;
|
|
605
|
-
enterKeyHintAskAi: string;
|
|
606
|
-
searchInputLabel: string;
|
|
607
|
-
backToKeywordSearchButtonText: string;
|
|
608
|
-
backToKeywordSearchButtonAriaLabel: string;
|
|
609
|
-
newConversationPlaceholder: string;
|
|
610
|
-
conversationHistoryTitle: string;
|
|
611
|
-
startNewConversationText: string;
|
|
612
|
-
viewConversationHistoryText: string;
|
|
613
|
-
threadDepthErrorPlaceholder: string;
|
|
614
|
-
}>;
|
|
615
|
-
|
|
616
|
-
type ModalTranslations = Partial<{
|
|
617
|
-
searchBox: SearchBoxTranslations;
|
|
618
|
-
newConversation: NewConversationTranslations;
|
|
619
|
-
footer: FooterTranslations;
|
|
620
|
-
}> & ScreenStateTranslations;
|
|
621
|
-
type DocSearchModalProps = DocSearchProps & {
|
|
622
|
-
initialScrollY: number;
|
|
623
|
-
onAskAiToggle: OnAskAiToggle;
|
|
624
|
-
interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
|
|
625
|
-
onClose?: () => void;
|
|
626
|
-
isAskAiActive?: boolean;
|
|
627
|
-
translations?: ModalTranslations;
|
|
628
|
-
isHybridModeSupported?: boolean;
|
|
629
|
-
};
|
|
630
|
-
declare function DocSearchModal({ appId, apiKey, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, interceptAskAiEvent, isAskAiActive, recentSearchesLimit, recentSearchesWithFavoritesLimit, indices, indexName, searchParameters, isHybridModeSupported, ...props }: DocSearchModalProps): JSX.Element;
|
|
631
|
-
|
|
632
|
-
interface UseDocSearchKeyboardEventsProps {
|
|
633
|
-
isOpen: boolean;
|
|
634
|
-
onOpen: () => void;
|
|
635
|
-
onClose: () => void;
|
|
636
|
-
/**
|
|
637
|
-
* Deprecated: Still here for backwards compat.
|
|
638
|
-
*
|
|
639
|
-
* @deprecated
|
|
640
|
-
*/
|
|
641
|
-
onInput?: (event: KeyboardEvent) => void;
|
|
642
|
-
/**
|
|
643
|
-
* Deprecated: Still here for backwards compat.
|
|
644
|
-
*
|
|
645
|
-
* @deprecated
|
|
646
|
-
*/
|
|
647
|
-
searchButtonRef?: React.RefObject<HTMLButtonElement | null>;
|
|
648
|
-
isAskAiActive: boolean;
|
|
649
|
-
onAskAiToggle: (toggle: boolean) => void;
|
|
650
|
-
keyboardShortcuts?: KeyboardShortcuts;
|
|
651
|
-
}
|
|
652
|
-
declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, isAskAiActive, onAskAiToggle, keyboardShortcuts, }: UseDocSearchKeyboardEventsProps): void;
|
|
653
|
-
|
|
654
|
-
declare const version = "4.7.0";
|
|
655
|
-
|
|
656
|
-
export { AGENT_STUDIO_PROMPT_BLOCKING_CODES, DocSearch, DocSearchButton, DocSearchInner, DocSearchModal, agentStudioPromptBlockingMatchers, extractAgentStudioErrorFieldMessage, extractAiErrorCodeFromMessage, filterExchangesForThreadDepthError, getAskAiBlockingBannerMessage, getAskAiPromptBlockingUserFacingMessage, getThreadDepthErrorUserFacingMessage, isAgentStudioTokenOutputLimitError, isAskAiPromptBlockingError, isThreadDepthError, matchesAgentStudioContextOrTokenLimitsPlainMessage, matchesAgentStudioMaxStepsMessage, matchesAgentStudioRateLimitMessage, matchesAgentStudioTokenOutputLimitPlainMessage, matchesAgentStudioWhitelistOrNotAllowedDomainPlainMessage, matchesRequestBlockedForThisDomainMessage, matchesThreadDepthLimitError, newConversationErrorMatchers, readAgentStudioJsonStringField, resolveAgentStudioPromptBlocking, showAskAiBlockingBannerNewConversationLink, useDocSearchKeyboardEvents, version };
|
|
657
|
-
export type { AgentStudioBlockingMatchContext, AgentStudioPromptBlockingMatcher, AgentStudioSearchParameters, AskAiSearchParameters, ButtonTranslations, DocSearchAskAi, DocSearchButtonProps, DocSearchHit, DocSearchIndex, DocSearchModalProps, DocSearchProps, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, ModalTranslations, NewConversationErrorMatcher, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, UseDocSearchKeyboardEventsProps };
|
|
1
|
+
import { a as StoredDocSearchHit, c as AskAiFeedbackReason, d as DocSearchHit, i as StoredAskAiState, l as OnAskAiFeedback, n as SuggestedQuestionHit, o as ToolCalls, r as StoredAskAiMessage, s as AskAiFeedbackPayload, t as SuggestedQuestion, u as DocSearchState } from "./index-Bqqv4HmN.js";
|
|
2
|
+
import { t as DocSearchTheme } from "./DocSearchTheme-DvL4mf0D.js";
|
|
3
|
+
import { a as DocSearchProps, c as DocSearchTranslations, d as ModalTranslations, i as DocSearchInner, l as DocSearchModal, n as DocSearchFacet, o as DocSearchRef, r as DocSearchIndex, s as DocSearchTransformClient, t as DocSearch, u as DocSearchModalProps, v as InternalDocSearchHit } from "./DocSearch-HJsNvtZr.js";
|
|
4
|
+
import { n as useDocSearchKeyboardEvents, r as KeyboardShortcuts, t as UseDocSearchKeyboardEventsProps } from "./useDocSearchKeyboardEvents-u23fFhR9.js";
|
|
5
|
+
import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-CZM_jACU.js";
|
|
6
|
+
import { AgentStudioIndices, AgentStudioSearchControls, AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions } from "./docsearchAi.js";
|
|
7
|
+
import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-B7vpLudE.js";
|
|
8
|
+
import { version } from "./version.js";
|
|
9
|
+
export { AgentStudioIndices, AgentStudioSearchControls, AgentStudioSearchParameters, AskAiFeedbackPayload, AskAiFeedbackReason, AskAiSearchParameters, ButtonTranslations, DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations, DocSearchButton, DocSearchButtonProps, DocSearchFacet, DocSearchHit, DocSearchIndex, DocSearchInner, DocSearchModal, DocSearchModalProps, DocSearchProps, type DocSearchRef, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, Memory, ModalTranslations, OnAskAiFeedback, PromptSuggestions, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, type ToolCalls, UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };
|