@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/{chunk-VNMTB3KC.mjs → chunk-IOR2K26O.mjs} +48 -22
- package/dist/distribution.d.ts +1 -1
- package/dist/distribution.mjs +1 -1
- package/dist/{engine-CXKfmK7I.d.ts → engine-igk0aMpQ.d.ts} +102 -60
- package/dist/index.browser.mjs +48 -22
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +1 -1
- package/dist/react.d.ts +271 -176
- package/dist/react.mjs +189 -45
- package/dist/server.d.ts +1 -1
- package/package.json +7 -7
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
|
|
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
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
* @
|
|
38
|
-
|
|
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
|
-
*
|
|
45
|
-
* call
|
|
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
|
|
48
|
-
* @throws A `NarsilError` with `CONFIG_INVALID` when no provider
|
|
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
|
-
*
|
|
109
|
+
* A hook sends these settings with each request that it makes through a
|
|
110
|
+
* client.
|
|
57
111
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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
|
-
/**
|
|
121
|
+
/** Under a client, the hook sends these headers with its request. */
|
|
65
122
|
headers?: Record<string, string>;
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
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
|
|
72
|
-
*
|
|
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
|
-
/**
|
|
78
|
-
* failure,
|
|
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
|
|
81
|
-
*
|
|
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
|
|
84
|
-
* page is hidden.
|
|
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
|
-
*
|
|
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
|
|
91
|
-
*
|
|
92
|
-
* indicator
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
108
|
-
* until the new
|
|
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
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* @param
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
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
|
-
*
|
|
133
|
-
* of everything
|
|
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
|
|
136
|
-
* @param indexName - This
|
|
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
|
|
140
|
-
* set the refresh interval, the headers, and the deadline.
|
|
141
|
-
* @returns The state holds the page and the cursor
|
|
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
|
|
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
|
|
154
|
-
*
|
|
155
|
-
*
|
|
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,
|
|
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
|
-
*
|
|
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
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
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
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
* `
|
|
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
|
-
/**
|
|
180
|
-
*
|
|
181
|
-
* task
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
258
|
+
/** This is the progress of the load, which suits a progress bar. */
|
|
189
259
|
progress: TaskProgress | undefined;
|
|
190
|
-
/** This counts
|
|
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
|
|
194
|
-
*
|
|
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
|
|
197
|
-
*
|
|
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
|
-
*
|
|
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
|
|
205
|
-
* timeout
|
|
206
|
-
*
|
|
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
|
|
210
|
-
* record `start`
|
|
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
|
|
213
|
-
* @param options - These set the poll interval, the callback for
|
|
214
|
-
* record, the headers, and the deadline.
|
|
215
|
-
* @returns The state holds the task, the progress, the result, the failure,
|
|
216
|
-
* the three
|
|
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
|
-
*
|
|
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
|
|
226
|
-
* set the refresh interval, the headers, and the deadline.
|
|
227
|
-
* @returns The state holds the indexes in
|
|
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
|
-
*
|
|
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
|
|
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
|
|
239
|
-
* @param options - These switch the hook off, keep the last
|
|
240
|
-
* and set the refresh interval, the headers, and the
|
|
241
|
-
*
|
|
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
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* search-as-you-type box, so that the hits
|
|
253
|
-
* the next
|
|
254
|
-
*
|
|
255
|
-
* @typeParam T - This is the
|
|
256
|
-
*
|
|
257
|
-
* @param indexName - This
|
|
258
|
-
* @param params - These
|
|
259
|
-
*
|
|
260
|
-
* @param options - These switch the hook off, keep the last answer
|
|
261
|
-
* and set the refresh interval, the headers, and the deadline.
|
|
262
|
-
* @returns The state holds the result, the failure, the loading flags, and
|
|
263
|
-
*
|
|
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
|
-
*
|
|
270
|
-
* which
|
|
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
|
|
273
|
-
* @param params - These
|
|
274
|
-
* @
|
|
275
|
-
*
|
|
276
|
-
*
|
|
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
|
-
*
|
|
283
|
-
* search box.
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* @param
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
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
|
|
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
|
|
302
|
-
*
|
|
303
|
-
*
|
|
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
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* @param
|
|
317
|
-
*
|
|
318
|
-
* @
|
|
319
|
-
*
|
|
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
|
-
*
|
|
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
|
|
420
|
+
* Set `refreshIntervalMs` to keep a table of the work in progress up to date.
|
|
328
421
|
*
|
|
329
|
-
* @param query - This
|
|
330
|
-
*
|
|
331
|
-
* @param options - These switch the hook off, keep the last page
|
|
332
|
-
* set the refresh interval, the headers, and the deadline.
|
|
333
|
-
* @returns The state holds the records, the total the filters matched,
|
|
334
|
-
* offset the next page starts
|
|
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 };
|