@delali/narsil 0.3.1-next.70 → 0.3.1-next.71

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/react.d.ts CHANGED
@@ -3,338 +3,433 @@ export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as Error
3
3
  import { e as TaskRecord, d as TaskProgress, b as ImportResult, c as TaskListQuery, T as TaskListPage } from './tasks-BZt_zes6.js';
4
4
  export { I as ImportError, f as TaskStatus, g as TaskType } from './tasks-BZt_zes6.js';
5
5
  import { ReactNode, ReactElement } from 'react';
6
+ import { a as Narsil } from './engine-igk0aMpQ.js';
6
7
  import { N as NarsilClient, I as ImportSource } from './client-COek5GXK.js';
7
8
  import { A as AnyDocument } from './schema-Bgzr4g7b.js';
8
9
  import './adapters-79OIa4xm.js';
9
10
 
10
11
  /**
11
- * These are the settings {@link NarsilProvider} takes.
12
+ * These settings apply to {@link NarsilProvider} whether it holds a client or
13
+ * an engine.
12
14
  *
13
15
  * @public
14
16
  */
15
- interface NarsilProviderProps {
16
- /** Every hook under the provider sends through this client. Build it once,
17
- * outside the component tree, because a client built during a render would
18
- * throw away everything the hooks under it hold. */
19
- client: NarsilClient;
20
- /** The hooks keep an answer for this many milliseconds after the last
21
- * component reading it has gone, and 2000 unless you say otherwise. The wait
22
- * covers the gap between React unmounting a component and mounting it again,
23
- * so a quick navigation back shows what it showed before and sends no second
24
- * request. */
17
+ interface NarsilProviderSettings {
18
+ /** The provider keeps each answer for this many milliseconds after the last
19
+ * component that reads the answer unmounts, which is 2000 unless you set
20
+ * another value. That wait spans the gap between React unmounting a component
21
+ * and mounting it again, so a quick navigation back can show the earlier
22
+ * answer without sending a second request. */
25
23
  keepAliveMs?: number;
26
- /** These are the components the provider covers. */
24
+ /** Under an engine, the hooks that read a written index search again once
25
+ * this many milliseconds pass without another write to that index, so each
26
+ * mounted hook searches once for a whole burst of writes. `useIndexes`
27
+ * searches again once that many milliseconds pass without a write to any
28
+ * index. The wait lasts 200 milliseconds unless you set another value. Under
29
+ * a client, the setting has no effect,
30
+ * because a server sends the client no write events. */
31
+ refreshAfterWriteMs?: number;
32
+ /** React renders these components under the provider. */
27
33
  children?: ReactNode;
28
34
  }
29
35
  /**
30
- * Gives every hook below it the client to send through, and the shared state
31
- * they read.
36
+ * These props give {@link NarsilProvider} a client, so that every hook under
37
+ * the provider sends its requests to a server.
32
38
  *
33
- * Two components asking for the same thing under one provider send one request
34
- * and read one answer. The provider drops that state once it unmounts, and it
35
- * stops whatever is still in flight.
39
+ * @public
40
+ */
41
+ interface NarsilClientProviderProps extends NarsilProviderSettings {
42
+ /** Every hook under the provider sends its requests through this client.
43
+ * Build the client once, outside the component tree, because a render that
44
+ * builds a client builds a new one each time, so every hook under the
45
+ * provider starts again. */
46
+ client: NarsilClient;
47
+ /** Leave this unset, because a provider holds either a client or an engine. */
48
+ engine?: undefined;
49
+ }
50
+ /**
51
+ * These props give {@link NarsilProvider} an engine in the same page, so that
52
+ * every read hook under the provider calls that engine and searches again after
53
+ * each burst of writes to an index that the hook reads.
36
54
  *
37
- * @param props - These name the client and the components the provider covers.
38
- * @returns The provider renders its children unchanged.
55
+ * @public
56
+ */
57
+ interface NarsilEngineProviderProps extends NarsilProviderSettings {
58
+ /** Every read hook under the provider calls this engine. Create the engine
59
+ * once, outside the component tree, because a render that creates an engine
60
+ * creates a new one each time, so every hook under the provider starts
61
+ * again. */
62
+ engine: Narsil;
63
+ /** Leave this unset, because a provider holds either a client or an engine. */
64
+ client?: undefined;
65
+ }
66
+ /**
67
+ * These are the props of {@link NarsilProvider}, which hold either a client of
68
+ * a server or an engine in the same page, together with the settings that both
69
+ * cases share.
70
+ *
71
+ * @public
72
+ */
73
+ type NarsilProviderProps = NarsilClientProviderProps | NarsilEngineProviderProps;
74
+ /**
75
+ * This component gives every hook under it the client or the engine to call,
76
+ * together with one store of answers that those hooks share.
77
+ *
78
+ * Every read hook calls the method of the same name on the client or on the
79
+ * engine. When two components under one provider ask for the same thing, they
80
+ * send one request and receive one answer. Under an engine, the provider
81
+ * registers a listener for the engine's `write` event, so every mounted hook
82
+ * that reads the written index searches again once per burst of writes. Once
83
+ * the provider unmounts and `keepAliveMs` passes, the provider drops the shared
84
+ * answers and stops waiting for the requests that are still in flight.
85
+ *
86
+ * @param props - These props set the client or the engine, the settings, and
87
+ * the components that render under the provider.
88
+ * @returns The element renders the children unchanged.
89
+ * @throws A `NarsilError` with `CONFIG_INVALID` during the render, when the
90
+ * props set both a client and an engine, or neither.
39
91
  *
40
92
  * @public
41
93
  */
42
94
  declare function NarsilProvider(props: NarsilProviderProps): ReactElement;
43
95
  /**
44
- * Reads the client the nearest {@link NarsilProvider} holds, which is what any
45
- * call the hooks leave out goes through.
96
+ * This hook returns the client that the nearest {@link NarsilProvider} holds,
97
+ * which serves every call that has no hook of its own, such as a write.
46
98
  *
47
- * @returns This is the client the provider was given.
48
- * @throws A `NarsilError` with `CONFIG_INVALID` when no provider stands above
49
- * the component.
99
+ * @returns This is the client that the provider holds.
100
+ * @throws A `NarsilError` with `CONFIG_INVALID` when no provider wraps the
101
+ * component, and also when the provider holds an engine, which the component
102
+ * can import directly.
50
103
  *
51
104
  * @public
52
105
  */
53
106
  declare function useNarsilClient(): NarsilClient;
54
107
 
55
108
  /**
56
- * What every hook sends with each request it makes.
109
+ * A hook sends these settings with each request that it makes through a
110
+ * client.
57
111
  *
58
- * A hook owns the lifetime of its own request, so it takes no signal. The store
59
- * behind it stops a request the moment nothing reads the answer.
112
+ * These settings include no signal, because each hook controls the lifetime of
113
+ * its own request. The provider stops waiting for a request once `keepAliveMs`
114
+ * passes with no component reading the answer. Under an engine, the hooks pass
115
+ * neither setting to the engine, because the engine computes its results in the
116
+ * same page.
60
117
  *
61
118
  * @public
62
119
  */
63
120
  interface NarsilRequestSettings {
64
- /** The hook sends these headers with its request. */
121
+ /** Under a client, the hook sends these headers with its request. */
65
122
  headers?: Record<string, string>;
66
- /** The hook gives the server this many milliseconds to answer, and 0 waits
67
- * for as long as the server takes. */
123
+ /** Under a client, the hook gives the server this many milliseconds to
124
+ * respond, while 0 sets no deadline. */
68
125
  timeoutMs?: number;
69
126
  }
70
127
  /**
71
- * These settings change what a read hook does, and every read hook takes them
72
- * as its last argument.
128
+ * These settings, which form the last argument of every read hook, change what
129
+ * the hook does.
73
130
  *
74
131
  * @public
75
132
  */
76
133
  interface NarsilReadOptions extends NarsilRequestSettings {
77
- /** The hook sends nothing while this is false, and it reports no data and no
78
- * failure, which is how a search waits for a term. */
134
+ /** While this is false, the hook sends no request and reports neither data
135
+ * nor a failure, so keep it false until a search has a term. */
79
136
  enabled?: boolean;
80
- /** The hook keeps showing the last answer while the next one loads, which
81
- * holds a result list steady as somebody types. */
137
+ /** The hook keeps showing the last answer while the next request is in
138
+ * flight, which keeps a result list in place as somebody types. */
82
139
  keepPreviousData?: boolean;
83
- /** The hook asks again this often, in milliseconds, and it pauses while the
84
- * page is hidden. It asks once and stops unless you set this. */
140
+ /** The hook sends the request again at this interval in milliseconds,
141
+ * pausing while the page is hidden. Without this setting, the hook sends the
142
+ * request once, then again after each burst of writes when the provider holds
143
+ * an engine. */
85
144
  refreshIntervalMs?: number;
86
145
  }
87
146
  /**
88
- * What a read hook reports.
147
+ * These fields report where the request of a read hook stands.
89
148
  *
90
- * `isLoading` covers the wait for the first answer, so a spinner branches on
91
- * it, while `isFetching` covers every request including a refresh, so a quieter
92
- * indicator branches on that one.
149
+ * `isLoading` covers the wait for the first answer, so show a spinner while it
150
+ * is true. `isFetching` covers every request, including a refresh, so show a
151
+ * quieter indicator while that one is true.
93
152
  *
94
- * @typeParam T - This is what the underlying client method answers with.
153
+ * @typeParam T - This is the type that the method behind the hook returns.
95
154
  *
96
155
  * @public
97
156
  */
98
157
  interface NarsilReadState<T> {
99
- /** This is the answer, and it stays undefined until the first one arrives. */
158
+ /** This is the answer, which stays undefined until the first request
159
+ * succeeds. */
100
160
  data: T | undefined;
101
- /** This is the failure the last request ended on, and the next success clears it. */
161
+ /** This is the failure that ended the last request, until the next success
162
+ * clears it. */
102
163
  error: NarsilError | undefined;
103
- /** This is true while the hook waits for an answer and has none to show. */
164
+ /** This is true while the hook has no answer to show and a request is in
165
+ * flight. */
104
166
  isLoading: boolean;
105
167
  /** This is true while a request is in flight, including a refresh. */
106
168
  isFetching: boolean;
107
- /** Calling this asks the server again, keeping the answer already on screen
108
- * until the new one arrives. */
169
+ /** Calling this sends the request again, while the answer already on screen
170
+ * stays until the new answer replaces it. */
109
171
  refresh: () => void;
110
172
  }
111
173
 
112
174
  /**
113
- * Reads one stored document, and reads it again whenever the id changes.
114
- *
115
- * A document the index does not hold comes back as `data: undefined` with no
116
- * failure, so read `isLoading` to tell an empty answer from one still on its
117
- * way. Passing no id switches the hook off, which is what a detail panel does
118
- * until somebody picks a row.
119
- *
120
- * @param indexName - This names the index holding the document.
121
- * @param docId - This names the document to read, and a nullish or empty id
122
- * switches the hook off.
123
- * @param options - These switch the hook off, keep the last document on screen,
124
- * and set the refresh interval, the headers, and the deadline.
125
- * @returns The state holds the document, the failure, the loading flags, and
126
- * the way to read it again.
175
+ * This hook fetches one stored document, then fetches it again whenever the id
176
+ * changes and, under an engine, after each burst of writes to the index.
177
+ *
178
+ * For a document that the index does not hold, the hook reports
179
+ * `data: undefined` with no failure, so check `isLoading` to tell an empty
180
+ * answer from one that is still in flight. A missing id switches the hook off,
181
+ * which suits a detail panel until somebody picks a row.
182
+ *
183
+ * @param indexName - This is the name of the index that holds the document.
184
+ * @param docId - This is the id of the document to fetch, where a nullish or
185
+ * empty id switches the hook off.
186
+ * @param options - These settings can switch the hook off, keep the last
187
+ * document on screen, and set the refresh interval, the headers, and the
188
+ * deadline.
189
+ * @returns The state holds the document, the failure, the two loading flags,
190
+ * and the `refresh` function.
127
191
  *
128
192
  * @public
129
193
  */
130
194
  declare function useDocument(indexName: string, docId: string | null | undefined, options?: NarsilReadOptions): NarsilReadState<AnyDocument | undefined>;
131
195
  /**
132
- * Pages through the stored documents without searching, which is what a table
133
- * of everything an index holds reads.
196
+ * This hook pages through the stored documents of an index without searching,
197
+ * which suits a table of everything that the index holds. Under an engine, the
198
+ * hook fetches the page again after each burst of writes to the index.
134
199
  *
135
- * @typeParam T - This is the shape of the stored documents.
136
- * @param indexName - This names the index to page through.
200
+ * @typeParam T - This is the type of the stored documents.
201
+ * @param indexName - This is the name of the index to page through.
137
202
  * @param params - These set the page size, the cursor, and any filter, sort, or
138
203
  * projection.
139
- * @param options - These switch the hook off, keep the last page on screen, and
140
- * set the refresh interval, the headers, and the deadline.
141
- * @returns The state holds the page and the cursor that reaches the next one.
204
+ * @param options - These settings can switch the hook off, keep the last page
205
+ * on screen, and set the refresh interval, the headers, and the deadline.
206
+ * @returns The state holds the page and the cursor for the next page.
142
207
  *
143
208
  * @public
144
209
  */
145
210
  declare function useDocuments<T = AnyDocument>(indexName: string, params?: ListParams, options?: NarsilReadOptions): NarsilReadState<ListResult<T>>;
146
211
 
147
212
  /**
148
- * These settings say how {@link useImport} runs a load and follows it.
213
+ * These settings control how {@link useImport} starts a load and polls its
214
+ * progress.
149
215
  *
150
216
  * @public
151
217
  */
152
218
  interface NarsilImportOptions extends NarsilRequestSettings {
153
- /** The hook asks the server how far the load has gone this often, and every
154
- * 250 ms unless you say otherwise, which is how often the server writes the
155
- * figures. It leaves five seconds between attempts while the server is
156
- * failing. */
219
+ /** The hook asks the server for the progress of the load at this interval in
220
+ * milliseconds, which is 250 unless you set another value. That default
221
+ * matches the interval at which the server updates the figures. While the
222
+ * server is failing, the hook waits five seconds between attempts. */
157
223
  pollIntervalMs?: number;
158
- /** The hook calls this once the load reaches a final status, whichever status
159
- * that is. */
224
+ /** The hook calls this function once the load reaches a final status,
225
+ * whatever that status is. */
160
226
  onSettled?: (record: TaskRecord) => void;
161
227
  }
162
228
  /**
163
- * What {@link useImport} reports, and what it offers to call.
229
+ * These fields report where a load from {@link useImport} stands, together with
230
+ * the functions that control the load.
164
231
  *
165
232
  * @public
166
233
  */
167
234
  interface NarsilImportState {
168
235
  /**
169
- * Sends a corpus and returns once the server has read the body and taken the
170
- * work on. The server loads the documents afterwards, and this hook follows
171
- * that work.
236
+ * This function sends a corpus, then returns once the server has received the
237
+ * body and started the task. The server loads the documents after that, while
238
+ * the hook polls the task.
172
239
  *
173
- * @param source - These are the documents, or the NDJSON you already hold.
174
- * @returns The record is the task the server started.
175
- * @throws A `NarsilError` under the code the server sent, and with
176
- * `NOT_FOUND` where the server predates the asynchronous import.
240
+ * @param source - These are the documents, or the NDJSON text that you
241
+ * already hold.
242
+ * @returns This is the record of the task that the server started.
243
+ * @throws A `NarsilError` under the code that the server sent, or with
244
+ * `NOT_FOUND` when the server is older than the asynchronous import.
177
245
  */
178
246
  start: (source: ImportSource) => Promise<TaskRecord>;
179
- /** Asks the running load to stop. Calling it while the corpus is still going
180
- * up stops the upload, and calling it afterwards asks the server to stop the
181
- * task, which stops between batches, so whatever it had already written stays
182
- * written. */
247
+ /** This function asks the load in progress to stop. While the browser is
248
+ * still sending the corpus, a call aborts the upload; after that, a call asks
249
+ * the server to stop the task. The server stops between batches, so the
250
+ * documents that it has already written stay in the index. */
183
251
  cancel: () => void;
184
- /** Clears the record and the failure, ready for another load. */
252
+ /** This function clears the record and the failure, so that the hook is
253
+ * ready for another load. */
185
254
  reset: () => void;
186
- /** This is the task, from the moment the server takes the load on. */
255
+ /** This is the record of the task, from the moment that the server starts
256
+ * it. */
187
257
  task: TaskRecord | undefined;
188
- /** This is how far the load has gone, which a progress bar reads. */
258
+ /** This is the progress of the load, which suits a progress bar. */
189
259
  progress: TaskProgress | undefined;
190
- /** This counts what the server accepted and refused, and it arrives once the
191
- * load finishes. */
260
+ /** This counts the documents that the server indexed and refused, which the
261
+ * hook sets once the load finishes. */
192
262
  result: ImportResult | undefined;
193
- /** This is the failure that stopped the load, or the one the last poll ended
194
- * on. */
263
+ /** This is the failure that stopped the load, or the failure that ended the
264
+ * last poll. */
195
265
  error: NarsilError | undefined;
196
- /** This is true from the moment you call `start` until the load reaches a
197
- * final status. */
266
+ /** This is true from the call to `start` until the load reaches a final
267
+ * status. */
198
268
  isImporting: boolean;
199
269
  }
200
270
  /**
201
- * Loads a corpus into an index and reports how far the load has gone.
271
+ * This hook loads a corpus into an index on a server and reports the progress
272
+ * of the load.
202
273
  *
203
274
  * The hook starts the load as a task, so the request returns as soon as the
204
- * server has read the body. A corpus that would outlast a proxy's response
205
- * timeout therefore still loads. The hook then polls the task, pausing while
206
- * the page is hidden, until the load succeeds, fails, or is cancelled.
275
+ * server has received the body. A corpus can therefore load even when the load
276
+ * takes longer than the response timeout of a proxy. The hook then polls the
277
+ * task until the load succeeds, fails, or ends in a cancellation, pausing
278
+ * whenever the page is hidden.
207
279
  *
208
280
  * Unmounting the component stops the polling alone, because the server finishes
209
- * the load either way. Follow it again with {@link useTask}, under the id of the
210
- * record `start` returned.
281
+ * the load either way. Follow the load again with {@link useTask}, under the id
282
+ * of the record that `start` returns.
211
283
  *
212
- * @param indexName - This names the index that receives the corpus.
213
- * @param options - These set the poll interval, the callback for the final
214
- * record, the headers, and the deadline.
215
- * @returns The state holds the task, the progress, the result, the failure, and
216
- * the three methods that drive a load.
284
+ * @param indexName - This is the name of the index that receives the corpus.
285
+ * @param options - These settings can set the poll interval, the callback for
286
+ * the final record, the headers, and the deadline.
287
+ * @returns The state holds the task, the progress, the result, the failure,
288
+ * and the three functions that control a load.
289
+ * @throws A `NarsilError` with `CONFIG_INVALID` during the render under a
290
+ * provider that holds an engine, because only a server handles imports.
217
291
  *
218
292
  * @public
219
293
  */
220
294
  declare function useImport(indexName: string, options?: NarsilImportOptions): NarsilImportState;
221
295
 
222
296
  /**
223
- * Lists every index the server holds, with its size and its language.
297
+ * This hook lists every index that the server or the engine holds, with the
298
+ * size and the language of each one. Under an engine, the hook fetches the list
299
+ * again after each burst of writes to any index.
224
300
  *
225
- * @param options - These switch the hook off, keep the last list on screen, and
226
- * set the refresh interval, the headers, and the deadline.
227
- * @returns The state holds the indexes in creation order.
301
+ * @param options - These settings can switch the hook off, keep the last list
302
+ * on screen, and set the refresh interval, the headers, and the deadline.
303
+ * @returns The state holds the indexes in the order of their creation.
228
304
  *
229
305
  * @public
230
306
  */
231
307
  declare function useIndexes(options?: NarsilReadOptions): NarsilReadState<IndexInfo[]>;
232
308
  /**
233
- * Reads one index's document count, partition count, memory estimate, language,
234
- * and schema.
309
+ * This hook fetches the document count, the partition count, the memory
310
+ * estimate, the language, and the schema of one index.
235
311
  *
236
- * Set `refreshIntervalMs` to watch the figures move while a load runs.
312
+ * Set `refreshIntervalMs` to watch the figures change while a load is in
313
+ * progress. Under an engine, the hook fetches the figures again after each
314
+ * burst of writes to the index.
237
315
  *
238
- * @param indexName - This names the index to describe.
239
- * @param options - These switch the hook off, keep the last figures on screen,
240
- * and set the refresh interval, the headers, and the deadline.
241
- * @returns The state holds the figures as they stood when the server answered.
316
+ * @param indexName - This is the name of the index to describe.
317
+ * @param options - These settings can switch the hook off, keep the last
318
+ * figures on screen, and set the refresh interval, the headers, and the
319
+ * deadline.
320
+ * @returns The state holds the figures as they stood when the server or the
321
+ * engine returned them.
242
322
  *
243
323
  * @public
244
324
  */
245
325
  declare function useStats(indexName: string, options?: NarsilReadOptions): NarsilReadState<IndexStats>;
246
326
 
247
327
  /**
248
- * Searches an index and re-runs the search whenever the parameters change.
249
- *
250
- * The parameters are the ones {@link SearchOperations.query} takes, and the
251
- * answer is the same `QueryResult`. Set `keepPreviousData` for a
252
- * search-as-you-type box, so that the hits already on screen stay there while
253
- * the next answer loads.
254
- *
255
- * @typeParam T - This is the shape of the stored documents, which flows through
256
- * to each hit's `document`.
257
- * @param indexName - This names the index to search.
258
- * @param params - These carry the text, the filters, the sort, and everything
259
- * else the search asks for.
260
- * @param options - These switch the hook off, keep the last answer on screen,
261
- * and set the refresh interval, the headers, and the deadline.
262
- * @returns The state holds the result, the failure, the loading flags, and the
263
- * way to search again.
328
+ * This hook searches an index, then searches it again whenever the parameters
329
+ * change and, under an engine, after each burst of writes to the index.
330
+ *
331
+ * Its parameters and its result match those of {@link SearchOperations.query}.
332
+ * Set `keepPreviousData` for a search-as-you-type box, so that the hits
333
+ * already on screen stay there while the next request is in flight.
334
+ *
335
+ * @typeParam T - This is the type of the stored documents, which also types the
336
+ * `document` field of each hit.
337
+ * @param indexName - This is the name of the index to search.
338
+ * @param params - These set the text, the filters, the sort, and every other
339
+ * part of the search.
340
+ * @param options - These settings can switch the hook off, keep the last answer
341
+ * on screen, and set the refresh interval, the headers, and the deadline.
342
+ * @returns The state holds the result, the failure, the two loading flags, and
343
+ * the `refresh` function.
264
344
  *
265
345
  * @public
266
346
  */
267
347
  declare function useQuery<T = AnyDocument>(indexName: string, params: QueryParams, options?: NarsilReadOptions): NarsilReadState<QueryResult<T>>;
268
348
  /**
269
- * Counts what a search would match, without building or ranking a single hit,
270
- * which is what a result count beside a filter reads.
349
+ * This hook counts the documents that a search matches without building or
350
+ * ranking a single hit, which suits a result count beside a filter. Under an
351
+ * engine, it counts again after each burst of writes to the index.
271
352
  *
272
- * @param indexName - This names the index to count in.
273
- * @param params - These are the parameters {@link useQuery} takes.
274
- * @param options - These switch the hook off, keep the last answer, and set the
275
- * refresh interval, the headers, and the deadline.
276
- * @returns The state holds the match count and how long the count took.
353
+ * @param indexName - This is the name of the index to count in.
354
+ * @param params - These have the same form as the parameters of
355
+ * {@link useQuery}.
356
+ * @param options - These settings can switch the hook off, keep the last count
357
+ * on screen, and set the refresh interval, the headers, and the deadline.
358
+ * @returns The state holds the match count and the time that the count took.
277
359
  *
278
360
  * @public
279
361
  */
280
362
  declare function usePreflight(indexName: string, params: QueryParams, options?: NarsilReadOptions): NarsilReadState<PreflightResult>;
281
363
  /**
282
- * Completes a prefix from the terms an index holds, ready to offer under a
283
- * search box.
284
- *
285
- * @param indexName - This names the index to complete from.
286
- * @param params - These set the prefix and how many completions come back.
287
- * @param options - These switch the hook off, keep the last completions on
288
- * screen, and set the refresh interval, the headers, and the deadline.
289
- * @returns The state holds the completions, most widely used first.
364
+ * This hook completes a prefix from the terms that an index holds, so that a
365
+ * search box can offer the completions as somebody types. Under an engine, it
366
+ * completes the prefix again after each burst of writes to the index.
367
+ *
368
+ * @param indexName - This is the name of the index whose terms complete the
369
+ * prefix.
370
+ * @param params - These set the prefix and the number of completions to
371
+ * return.
372
+ * @param options - These settings can switch the hook off, keep the last
373
+ * completions on screen, and set the refresh interval, the headers, and the
374
+ * deadline.
375
+ * @returns The state holds the completions, with the most widely used term
376
+ * first.
290
377
  *
291
378
  * @public
292
379
  */
293
380
  declare function useSuggest(indexName: string, params: SuggestParams, options?: NarsilReadOptions): NarsilReadState<SuggestResult>;
294
381
 
295
382
  /**
296
- * These settings say how a task hook follows the work.
383
+ * These settings control how often a task hook polls its task.
297
384
  *
298
385
  * @public
299
386
  */
300
387
  interface NarsilTaskOptions extends Omit<NarsilReadOptions, 'refreshIntervalMs'> {
301
- /** The hook asks again this often while the task runs, and every 250 ms
302
- * unless you say otherwise, which is how often a running import writes its
303
- * progress. It stops once the task reaches a final status. */
388
+ /** The hook polls the task at this interval in milliseconds while the task
389
+ * is in progress, which is 250 unless you set another value. That default
390
+ * matches the interval at which the server updates the figures of an import.
391
+ * The hook stops polling once the task reaches a final status. */
304
392
  pollIntervalMs?: number;
305
393
  }
306
394
  /**
307
- * Follows one long-running operation, and stops asking once it finishes.
308
- *
309
- * The hook polls while the task runs, pauses while the page is hidden, and
310
- * reads the figures once more as soon as the page comes back. A failed task
311
- * arrives as a record carrying its `error`, because a part-finished import
312
- * still reports what it indexed, so read the status you get.
313
- *
314
- * @param taskId - This names the task to follow, and a nullish or empty id
315
- * switches the hook off.
316
- * @param options - These set the poll interval, switch the hook off, and carry
317
- * the headers and the deadline.
318
- * @returns The state holds the record, and `data: null` says the server no
319
- * longer holds it.
395
+ * This hook polls one long-running task on a server until the task reaches a
396
+ * final status.
397
+ *
398
+ * The hook pauses polling while the page is hidden, then fetches the figures
399
+ * once more as soon as the page is visible again. A failed task comes back as
400
+ * a record with its `error` field set, because the record of a part-finished
401
+ * import still counts the documents that it indexed. Check the `status` field
402
+ * to tell the outcomes apart.
403
+ *
404
+ * @param taskId - This is the id of the task to poll, where a nullish or empty
405
+ * id switches the hook off.
406
+ * @param options - These settings can set the poll interval, switch the hook
407
+ * off, and set the headers and the deadline.
408
+ * @returns The state holds the record, while `data: null` means that the
409
+ * server no longer holds the task.
410
+ * @throws A `NarsilError` with `CONFIG_INVALID` during the render under a
411
+ * provider that holds an engine, because only a server handles tasks.
320
412
  *
321
413
  * @public
322
414
  */
323
415
  declare function useTask(taskId: string | null | undefined, options?: NarsilTaskOptions): NarsilReadState<TaskRecord | null>;
324
416
  /**
325
- * Lists the task records the server still holds, newest first.
417
+ * This hook lists the task records that the server holds, with the newest
418
+ * record first.
326
419
  *
327
- * Set `refreshIntervalMs` to keep a table of running work up to date.
420
+ * Set `refreshIntervalMs` to keep a table of the work in progress up to date.
328
421
  *
329
- * @param query - This says which records to keep and where the page starts.
330
- * Omit it for the newest 20 records.
331
- * @param options - These switch the hook off, keep the last page on screen, and
332
- * set the refresh interval, the headers, and the deadline.
333
- * @returns The state holds the records, the total the filters matched, and the
334
- * offset the next page starts at.
422
+ * @param query - This selects the records and sets where the page starts.
423
+ * Without it, the hook lists the newest 20 records.
424
+ * @param options - These settings can switch the hook off, keep the last page
425
+ * on screen, and set the refresh interval, the headers, and the deadline.
426
+ * @returns The state holds the records, the total that the filters matched,
427
+ * and the offset where the next page starts.
428
+ * @throws A `NarsilError` with `CONFIG_INVALID` during the render under a
429
+ * provider that holds an engine, because only a server handles tasks.
335
430
  *
336
431
  * @public
337
432
  */
338
433
  declare function useTasks(query?: TaskListQuery, options?: NarsilReadOptions): NarsilReadState<TaskListPage>;
339
434
 
340
- export { ImportResult, NarsilError, type NarsilImportOptions, type NarsilImportState, NarsilProvider, type NarsilProviderProps, type NarsilReadOptions, type NarsilReadState, type NarsilRequestSettings, type NarsilTaskOptions, TaskListPage, TaskListQuery, TaskProgress, TaskRecord, useDocument, useDocuments, useImport, useIndexes, useNarsilClient, usePreflight, useQuery, useStats, useSuggest, useTask, useTasks };
435
+ export { ImportResult, type NarsilClientProviderProps, type NarsilEngineProviderProps, NarsilError, type NarsilImportOptions, type NarsilImportState, NarsilProvider, type NarsilProviderProps, type NarsilProviderSettings, type NarsilReadOptions, type NarsilReadState, type NarsilRequestSettings, type NarsilTaskOptions, TaskListPage, TaskListQuery, TaskProgress, TaskRecord, useDocument, useDocuments, useImport, useIndexes, useNarsilClient, usePreflight, useQuery, useStats, useSuggest, useTask, useTasks };