@delali/narsil 0.2.2 → 0.2.3-next.32
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 +12 -9
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/{adapters-CVqI5NBt.d.ts → adapters-79OIa4xm.d.ts} +1 -1
- package/dist/brute-force-DbHYCTc3.d.ts +8 -0
- package/dist/chunk-BFIH7OV5.mjs +185 -0
- package/dist/chunk-C6VVLMRX.mjs +63 -0
- package/dist/{chunk-UNJZ7ZDB.mjs → chunk-EMI63EXP.mjs} +33 -2
- package/dist/chunk-MFFAJ2NR.mjs +135 -0
- package/dist/chunk-OBXS7OZM.mjs +376 -0
- package/dist/{chunk-ASI6AOW2.mjs → chunk-RO4EFWE6.mjs} +7833 -3524
- package/dist/{chunk-WLR5BFL3.mjs → chunk-TEAJO7CU.mjs} +3067 -2087
- package/dist/{chunk-S7RJJMHI.mjs → chunk-WDL632CN.mjs} +699 -222
- package/dist/{chunk-BKAI2WXI.mjs → chunk-WTONLDU3.mjs} +5 -0
- package/dist/client-DQHB_swQ.d.ts +793 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.mjs +843 -0
- package/dist/{config-DXypXAfN.d.ts → config-ChZ7lfqc.d.ts} +3 -3
- package/dist/direct-executor-YARCDMJF.mjs +8 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +471 -2
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/coordinator/in-memory.mjs +286 -1
- package/dist/distribution/transport/grpc.d.ts +45 -0
- package/dist/distribution/transport/grpc.mjs +586 -0
- package/dist/distribution/transport/in-memory.d.ts +118 -0
- package/dist/distribution/transport/in-memory.mjs +214 -0
- package/dist/distribution/transport/tcp.d.ts +27 -0
- package/dist/distribution/transport/tcp.mjs +595 -0
- package/dist/distribution.d.ts +241 -192
- package/dist/distribution.mjs +6620 -4795
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/{engine-CO9Wnfie.d.ts → engine-DScGlT2Z.d.ts} +30 -3
- package/dist/index.browser.mjs +10035 -3914
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +8 -5
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +3 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/options-BORJg5XB.d.ts +234 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +4 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +8 -5
- package/dist/react.d.ts +340 -0
- package/dist/react.mjs +687 -0
- package/dist/{schema-CE6S_aAr.d.ts → schema-emTQfEiX.d.ts} +21 -7
- package/dist/{search-DLBtiPdQ.d.ts → search-CQ-9bKxo.d.ts} +226 -14
- package/dist/server.d.ts +42 -356
- package/dist/server.mjs +493 -106
- package/dist/tasks-CnMLpfk-.d.ts +274 -0
- package/dist/types-BQDlIvfS.d.ts +34 -0
- package/dist/{types-BV3nAKTL.d.ts → types-Bfhhnh3G.d.ts} +23 -1
- package/dist/types-D5OwhtsQ.d.ts +97 -0
- package/dist/vector/hnsw-build-worker.d.ts +2 -7
- package/dist/vector/hnsw-build-worker.mjs +2 -1
- package/dist/vector/search-worker.d.ts +373 -0
- package/dist/vector/search-worker.mjs +279 -0
- package/dist/workers/entry.mjs +43 -25
- package/package.json +42 -2
- package/dist/chunk-FKK76OR7.mjs +0 -456
- package/dist/chunk-RQLXC2YS.mjs +0 -269
- package/dist/direct-executor-3W4QRA4E.mjs +0 -5
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
import { e as TaskRecord, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-CnMLpfk-.js';
|
|
2
|
+
import { P as PartitionConfig, A as AnyDocument, a as InsertOptions } from './schema-emTQfEiX.js';
|
|
3
|
+
import { V as VectorMaintenanceResult, M as MemoryStats, B as BatchResult, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, P as PartitionStatsResult, Q as QueryParams, e as QueryResult, h as PreflightResult, i as SuggestParams, j as SuggestResult } from './search-CQ-9bKxo.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is the `fetch` implementation the client sends every request through.
|
|
7
|
+
*
|
|
8
|
+
* It matches the global `fetch`, so pass one only to add a proxy agent, a retry
|
|
9
|
+
* wrapper, or a stub in a test.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
type FetchFunction = (input: string, init: RequestInit) => Promise<Response>;
|
|
14
|
+
/**
|
|
15
|
+
* These are the settings {@link createNarsilClient} accepts.
|
|
16
|
+
*
|
|
17
|
+
* Only `url` is required. A client built from the address alone sends no
|
|
18
|
+
* credentials, and it gives every request 30 seconds to answer.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
interface NarsilClientOptions {
|
|
23
|
+
/**
|
|
24
|
+
* The server answers at this address. Pass an absolute URL such as
|
|
25
|
+
* `https://search.example.com`, or a path such as `/search-api` when a
|
|
26
|
+
* browser reaches the server through its own origin.
|
|
27
|
+
*/
|
|
28
|
+
url: string;
|
|
29
|
+
/**
|
|
30
|
+
* The client sends this key as `authorization: Bearer <key>`, which a server
|
|
31
|
+
* reads in its `onRequest` hook. For any other scheme, set the header
|
|
32
|
+
* yourself through {@link NarsilClientOptions.headers}.
|
|
33
|
+
*/
|
|
34
|
+
apiKey?: string;
|
|
35
|
+
/** The client sends these headers with every request, and a per-call header of the same name replaces one. */
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* The client waits this many milliseconds for an answer before it fails with
|
|
39
|
+
* `CLIENT_REQUEST_TIMEOUT`, and it waits 30000 unless you say otherwise. Pass
|
|
40
|
+
* 0 so that it waits for as long as the server takes. Three routes carry a
|
|
41
|
+
* corpus or a whole index, so {@link BulkOperations.importDocuments},
|
|
42
|
+
* {@link AdminOperations.snapshot}, and {@link AdminOperations.restore} set no
|
|
43
|
+
* deadline of their own until this one arrives.
|
|
44
|
+
*/
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
/** The client sends every request through this instead of the global `fetch`. */
|
|
47
|
+
fetch?: FetchFunction;
|
|
48
|
+
/**
|
|
49
|
+
* The client stops reading an answer once it passes this many bytes, and
|
|
50
|
+
* fails with `CLIENT_INVALID_RESPONSE` rather than holding the rest. Set it
|
|
51
|
+
* where the client runs somewhere a runaway answer would matter, such as a
|
|
52
|
+
* browser tab, and leave it out to read whatever the server sends. A
|
|
53
|
+
* snapshot download reads the whole index, so give it its own ceiling
|
|
54
|
+
* through {@link RequestOptions.maxResponseBytes} or none at all.
|
|
55
|
+
*/
|
|
56
|
+
maxResponseBytes?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* These settings change the one request a method sends.
|
|
60
|
+
*
|
|
61
|
+
* Every client method takes them as its last argument.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
interface RequestOptions {
|
|
66
|
+
/** Aborting this stops the request, which then fails with `CLIENT_REQUEST_ABORTED`. */
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
/** The client waits this many milliseconds for this one answer, and 0 waits for as long as the server takes. */
|
|
69
|
+
timeoutMs?: number;
|
|
70
|
+
/** The client adds these headers to this request, and one of the same name replaces what it would otherwise send. */
|
|
71
|
+
headers?: Record<string, string>;
|
|
72
|
+
/** The client stops reading this one answer past this many bytes, and 0 reads whatever the server sends. */
|
|
73
|
+
maxResponseBytes?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* These methods run the operations that maintain an index: checkpoints,
|
|
78
|
+
* snapshots, vector maintenance, partitioning, and analysis rebuilds.
|
|
79
|
+
*
|
|
80
|
+
* Four of them can run for minutes, so each answers with a {@link TaskRecord}
|
|
81
|
+
* while the work carries on, and you follow it with
|
|
82
|
+
* {@link TaskOperations.waitForTask}. The {@link Narsil} methods they mirror
|
|
83
|
+
* return nothing and finish before they resolve, which is the one place this
|
|
84
|
+
* client parts from the engine.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
interface AdminOperations {
|
|
89
|
+
/**
|
|
90
|
+
* Writes everything an index holds to durable storage, so recovery starts
|
|
91
|
+
* from this point instead of replaying the log from the previous one.
|
|
92
|
+
*
|
|
93
|
+
* @param indexName - This names the index to checkpoint.
|
|
94
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
95
|
+
* this request.
|
|
96
|
+
*/
|
|
97
|
+
checkpoint(indexName: string, options?: RequestOptions): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Downloads one index as a portable `.nrsl` file, which any Narsil
|
|
100
|
+
* implementation can read back.
|
|
101
|
+
*
|
|
102
|
+
* The whole index crosses the network, so this call sets no deadline of its
|
|
103
|
+
* own and waits for as long as the download takes until
|
|
104
|
+
* {@link NarsilClientOptions.timeoutMs} or a per-call `timeoutMs` sets one.
|
|
105
|
+
*
|
|
106
|
+
* @param indexName - This names the index to serialise.
|
|
107
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
108
|
+
* this request.
|
|
109
|
+
* @returns The bytes make up the file.
|
|
110
|
+
*/
|
|
111
|
+
snapshot(indexName: string, options?: RequestOptions): Promise<Uint8Array>;
|
|
112
|
+
/**
|
|
113
|
+
* Replaces an index with the contents of a `.nrsl` file, dropping whatever
|
|
114
|
+
* the index held.
|
|
115
|
+
*
|
|
116
|
+
* The load runs as a task, so this resolves once the server has read the
|
|
117
|
+
* bytes, and the index comes back afterwards.
|
|
118
|
+
*
|
|
119
|
+
* @param indexName - This names the index to replace.
|
|
120
|
+
* @param data - These are the file's bytes.
|
|
121
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
122
|
+
* this request.
|
|
123
|
+
* @returns The record is the task to follow.
|
|
124
|
+
* @throws A `NarsilError` with `DOC_VALIDATION_FAILED` or an `ENVELOPE_`
|
|
125
|
+
* code, reported on the task, when the bytes hold no readable snapshot.
|
|
126
|
+
*/
|
|
127
|
+
restore(indexName: string, data: Uint8Array, options?: RequestOptions): Promise<TaskRecord>;
|
|
128
|
+
/**
|
|
129
|
+
* Reports the state of each vector field, and what maintenance would cost.
|
|
130
|
+
*
|
|
131
|
+
* @param indexName - This names the index to describe.
|
|
132
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
133
|
+
* this request.
|
|
134
|
+
* @returns Each vector field appears once.
|
|
135
|
+
*/
|
|
136
|
+
vectorMaintenanceStatus(indexName: string, options?: RequestOptions): Promise<VectorMaintenanceResult[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Reclaims the space removed vectors left behind, which a search would
|
|
139
|
+
* otherwise scan past.
|
|
140
|
+
*
|
|
141
|
+
* @param indexName - This names the index to compact.
|
|
142
|
+
* @param fieldName - This names one vector field, and omitting it covers
|
|
143
|
+
* every one.
|
|
144
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
145
|
+
* this request.
|
|
146
|
+
*/
|
|
147
|
+
compactVectors(indexName: string, fieldName?: string, options?: RequestOptions): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Rebuilds the vector graphs as a task, so searches run at full speed again.
|
|
150
|
+
*
|
|
151
|
+
* @param indexName - This names the index to optimise.
|
|
152
|
+
* @param fieldName - This names one vector field, and omitting it covers
|
|
153
|
+
* every one.
|
|
154
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
155
|
+
* this request.
|
|
156
|
+
* @returns The record is the task to follow.
|
|
157
|
+
*/
|
|
158
|
+
optimizeVectors(indexName: string, fieldName?: string, options?: RequestOptions): Promise<TaskRecord>;
|
|
159
|
+
/**
|
|
160
|
+
* Spreads an index across a different number of partitions, as a task.
|
|
161
|
+
*
|
|
162
|
+
* The server holds the writes that arrive while it runs and replays them in
|
|
163
|
+
* order, so an index stays writable throughout.
|
|
164
|
+
*
|
|
165
|
+
* @param indexName - This names the index to reshape.
|
|
166
|
+
* @param targetPartitionCount - The index ends up with this many partitions.
|
|
167
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
168
|
+
* this request.
|
|
169
|
+
* @returns The record is the task to follow.
|
|
170
|
+
*/
|
|
171
|
+
rebalance(indexName: string, targetPartitionCount: number, options?: RequestOptions): Promise<TaskRecord>;
|
|
172
|
+
/**
|
|
173
|
+
* Changes when an index splits into another partition, and how far it may
|
|
174
|
+
* grow.
|
|
175
|
+
*
|
|
176
|
+
* @param indexName - This names the index to reconfigure.
|
|
177
|
+
* @param partitionConfig - These are the settings to change, and the rest
|
|
178
|
+
* stay as they are.
|
|
179
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
180
|
+
* this request.
|
|
181
|
+
* @throws A `NarsilError` with `PARTITION_CAPACITY_EXCEEDED` when the new
|
|
182
|
+
* ceiling falls below what the index already holds.
|
|
183
|
+
*/
|
|
184
|
+
updatePartitionConfig(indexName: string, partitionConfig: Partial<PartitionConfig>, options?: RequestOptions): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Reanalyses every document in an index, as a task. An index analysed by an
|
|
187
|
+
* earlier revision of its language module must run this before its terms
|
|
188
|
+
* match again.
|
|
189
|
+
*
|
|
190
|
+
* A result with `analysisStale: true` says the index is due one.
|
|
191
|
+
*
|
|
192
|
+
* @param indexName - This names the index to reanalyse.
|
|
193
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
194
|
+
* this request.
|
|
195
|
+
* @returns The record is the task to follow.
|
|
196
|
+
*/
|
|
197
|
+
rebuildAnalysis(indexName: string, options?: RequestOptions): Promise<TaskRecord>;
|
|
198
|
+
/**
|
|
199
|
+
* Reports the server process's heap usage, its estimate of what the indexes
|
|
200
|
+
* hold, and each worker's heap.
|
|
201
|
+
*
|
|
202
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
203
|
+
* this request.
|
|
204
|
+
* @returns The figures are what you size a host from.
|
|
205
|
+
*/
|
|
206
|
+
getMemoryStats(options?: RequestOptions): Promise<MemoryStats>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* This is a corpus, in whichever form you already hold it.
|
|
211
|
+
*
|
|
212
|
+
* The client encodes documents as NDJSON. It sends a string or a byte array
|
|
213
|
+
* unchanged, so NDJSON read from a file needs no re-encoding.
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
type ImportSource = AnyDocument[] | string | Uint8Array;
|
|
218
|
+
/**
|
|
219
|
+
* These methods write and read many documents in one request.
|
|
220
|
+
*
|
|
221
|
+
* A batch reports every document's outcome, so one refusal leaves the rest
|
|
222
|
+
* written. An import streams a whole corpus instead, which the server writes in
|
|
223
|
+
* bounded batches.
|
|
224
|
+
*
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
interface BulkOperations {
|
|
228
|
+
/**
|
|
229
|
+
* Adds many documents in one request and reports each one's outcome.
|
|
230
|
+
*
|
|
231
|
+
* A document the server rejects appears in `failed` under the error that
|
|
232
|
+
* rejected it, while every other document is still written.
|
|
233
|
+
*
|
|
234
|
+
* @param indexName - This names the index that receives the documents.
|
|
235
|
+
* @param documents - Each document carries its own id, or leaves the server
|
|
236
|
+
* to generate one.
|
|
237
|
+
* @param insertOptions - These per-write settings reach the server, and apply
|
|
238
|
+
* to every document.
|
|
239
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
240
|
+
* this request.
|
|
241
|
+
* @returns The result lists the ids written, and each rejection with its
|
|
242
|
+
* error.
|
|
243
|
+
*/
|
|
244
|
+
insertBatch(indexName: string, documents: AnyDocument[], insertOptions?: InsertOptions, options?: RequestOptions): Promise<BatchResult>;
|
|
245
|
+
/**
|
|
246
|
+
* Replaces many documents in one request and reports each one's outcome.
|
|
247
|
+
*
|
|
248
|
+
* @param indexName - This names the index holding the documents.
|
|
249
|
+
* @param updates - Each entry names the document to replace and holds its
|
|
250
|
+
* replacement.
|
|
251
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
252
|
+
* this request.
|
|
253
|
+
* @returns The result lists the ids replaced, and each failure with its
|
|
254
|
+
* error.
|
|
255
|
+
*/
|
|
256
|
+
updateBatch(indexName: string, updates: Array<{
|
|
257
|
+
docId: string;
|
|
258
|
+
document: AnyDocument;
|
|
259
|
+
}>, options?: RequestOptions): Promise<BatchResult>;
|
|
260
|
+
/**
|
|
261
|
+
* Removes many documents in one request and reports each one's outcome.
|
|
262
|
+
*
|
|
263
|
+
* @param indexName - This names the index holding the documents.
|
|
264
|
+
* @param docIds - These name the documents to remove.
|
|
265
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
266
|
+
* this request.
|
|
267
|
+
* @returns The result lists the ids removed, and each failure with its error.
|
|
268
|
+
*/
|
|
269
|
+
removeBatch(indexName: string, docIds: string[], options?: RequestOptions): Promise<BatchResult>;
|
|
270
|
+
/**
|
|
271
|
+
* Reads many documents by id in one request.
|
|
272
|
+
*
|
|
273
|
+
* The result leaves out an id the index does not hold while the call still
|
|
274
|
+
* succeeds, so compare the size against what you asked for.
|
|
275
|
+
*
|
|
276
|
+
* @param indexName - This names the index holding the documents.
|
|
277
|
+
* @param docIds - These are the ids to read.
|
|
278
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
279
|
+
* this request.
|
|
280
|
+
* @returns The map holds every document found, keyed by id.
|
|
281
|
+
*/
|
|
282
|
+
getMultiple(indexName: string, docIds: string[], options?: RequestOptions): Promise<Map<string, AnyDocument>>;
|
|
283
|
+
/**
|
|
284
|
+
* Pages through the stored documents without searching, in document-id order
|
|
285
|
+
* until the parameters name a sort.
|
|
286
|
+
*
|
|
287
|
+
* @typeParam T - This is the shape of the stored documents.
|
|
288
|
+
* @param indexName - This names the index to page through.
|
|
289
|
+
* @param params - These set the page size, the cursor, and any filter, sort,
|
|
290
|
+
* or projection.
|
|
291
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
292
|
+
* this request.
|
|
293
|
+
* @returns The page holds the documents, and the cursor that reaches the next
|
|
294
|
+
* one.
|
|
295
|
+
*/
|
|
296
|
+
listDocuments<T = AnyDocument>(indexName: string, params?: ListParams, options?: RequestOptions): Promise<ListResult<T>>;
|
|
297
|
+
/**
|
|
298
|
+
* Loads a corpus in one request and answers once the whole load has finished.
|
|
299
|
+
*
|
|
300
|
+
* The server writes the documents in bounded batches, so one bad record never
|
|
301
|
+
* abandons the rest. Where a load would outlast a proxy's response timeout,
|
|
302
|
+
* reach for {@link BulkOperations.startImport}, which answers straight away
|
|
303
|
+
* and reports progress through a task.
|
|
304
|
+
*
|
|
305
|
+
* This call sets no deadline of its own, so it waits for as long as the load
|
|
306
|
+
* takes until {@link NarsilClientOptions.timeoutMs} or a per-call `timeoutMs`
|
|
307
|
+
* sets one.
|
|
308
|
+
*
|
|
309
|
+
* @param indexName - This names the index that receives the corpus.
|
|
310
|
+
* @param source - These are the documents, or the NDJSON you already hold.
|
|
311
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
312
|
+
* this request.
|
|
313
|
+
* @returns The result counts what the server accepted and refused, and lists
|
|
314
|
+
* the first refusals.
|
|
315
|
+
* @throws A `NarsilError` with `PAYLOAD_TOO_LARGE` when the corpus passes the
|
|
316
|
+
* server's import limit, which defaults to 100 MB.
|
|
317
|
+
*/
|
|
318
|
+
importDocuments(indexName: string, source: ImportSource, options?: RequestOptions): Promise<ImportResult>;
|
|
319
|
+
/**
|
|
320
|
+
* Starts a corpus load as a task, and answers once the server has read the
|
|
321
|
+
* body. A load longer than a request timeout runs this way.
|
|
322
|
+
*
|
|
323
|
+
* Follow the returned record with {@link TaskOperations.waitForTask}, which
|
|
324
|
+
* reports the bytes read as the load runs. Stop the load with
|
|
325
|
+
* {@link TaskOperations.cancelTask}.
|
|
326
|
+
*
|
|
327
|
+
* This call sets no deadline of its own, so it waits for the server to read
|
|
328
|
+
* the body until {@link NarsilClientOptions.timeoutMs} or a per-call
|
|
329
|
+
* `timeoutMs` sets one.
|
|
330
|
+
*
|
|
331
|
+
* @param indexName - This names the index that receives the corpus.
|
|
332
|
+
* @param source - These are the documents, or the NDJSON you already hold.
|
|
333
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
334
|
+
* this request.
|
|
335
|
+
* @returns The record is the task to poll.
|
|
336
|
+
* @throws A `NarsilError` with `NOT_FOUND` when the server predates the
|
|
337
|
+
* asynchronous import, which {@link ServerOperations.supports} reports before
|
|
338
|
+
* you call.
|
|
339
|
+
*/
|
|
340
|
+
startImport(indexName: string, source: ImportSource, options?: RequestOptions): Promise<TaskRecord>;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* This says what an upsert did, which is how {@link DocumentOperations.put}
|
|
345
|
+
* reports whether the id already held a document.
|
|
346
|
+
*
|
|
347
|
+
* @public
|
|
348
|
+
*/
|
|
349
|
+
interface PutResult {
|
|
350
|
+
/** The document is stored under this id. */
|
|
351
|
+
id: string;
|
|
352
|
+
/** This is true when the id held nothing before, and false when the write replaced a document. */
|
|
353
|
+
created: boolean;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* These methods write and read one document at a time over HTTP.
|
|
357
|
+
*
|
|
358
|
+
* Each one has the name of the {@link Narsil} method it mirrors. Reach for
|
|
359
|
+
* {@link BulkOperations} to load a corpus, because a document per request would
|
|
360
|
+
* cost a round trip each.
|
|
361
|
+
*
|
|
362
|
+
* @public
|
|
363
|
+
*/
|
|
364
|
+
interface DocumentOperations {
|
|
365
|
+
/**
|
|
366
|
+
* Adds one document to an index and returns the id it is stored under.
|
|
367
|
+
*
|
|
368
|
+
* The id comes from the `docId` argument when you pass one, otherwise from
|
|
369
|
+
* the document's own `id` field, and otherwise the server generates it.
|
|
370
|
+
*
|
|
371
|
+
* @param indexName - This names the index that receives the document.
|
|
372
|
+
* @param document - Its fields must match the types the schema declares.
|
|
373
|
+
* @param docId - Pass an id to control it yourself, or omit it and read the
|
|
374
|
+
* returned value.
|
|
375
|
+
* @param insertOptions - These per-write settings reach the server, such as
|
|
376
|
+
* skipping the defensive copy.
|
|
377
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
378
|
+
* this request.
|
|
379
|
+
* @returns The document is stored under this id.
|
|
380
|
+
*/
|
|
381
|
+
insert(indexName: string, document: AnyDocument, docId?: string, insertOptions?: InsertOptions, options?: RequestOptions): Promise<string>;
|
|
382
|
+
/**
|
|
383
|
+
* Reads one stored document back.
|
|
384
|
+
*
|
|
385
|
+
* @param indexName - This names the index holding the document.
|
|
386
|
+
* @param docId - This names the document to read.
|
|
387
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
388
|
+
* this request.
|
|
389
|
+
* @returns The stored document comes back, and `undefined` says the index
|
|
390
|
+
* holds no such id.
|
|
391
|
+
* @throws A `NarsilError` with `INDEX_NOT_FOUND` for an unknown index.
|
|
392
|
+
*/
|
|
393
|
+
get(indexName: string, docId: string, options?: RequestOptions): Promise<AnyDocument | undefined>;
|
|
394
|
+
/**
|
|
395
|
+
* Reports whether an index holds a document under an id, without returning
|
|
396
|
+
* the document itself.
|
|
397
|
+
*
|
|
398
|
+
* @param indexName - This names the index to look in.
|
|
399
|
+
* @param docId - This is the id to look for.
|
|
400
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
401
|
+
* this request.
|
|
402
|
+
* @returns This is true when the id holds a document.
|
|
403
|
+
*/
|
|
404
|
+
has(indexName: string, docId: string, options?: RequestOptions): Promise<boolean>;
|
|
405
|
+
/**
|
|
406
|
+
* Writes a document at an id, whether or not one is already there, which
|
|
407
|
+
* suits an application that assigns its own identifiers.
|
|
408
|
+
*
|
|
409
|
+
* @param indexName - This names the index that receives the document.
|
|
410
|
+
* @param docId - This is the id to write at.
|
|
411
|
+
* @param document - Its fields must match the types the schema declares.
|
|
412
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
413
|
+
* this request.
|
|
414
|
+
* @returns The result names the id, and says whether the write created the
|
|
415
|
+
* document or replaced one.
|
|
416
|
+
*/
|
|
417
|
+
put(indexName: string, docId: string, document: AnyDocument, options?: RequestOptions): Promise<PutResult>;
|
|
418
|
+
/**
|
|
419
|
+
* Replaces the stored document at an id.
|
|
420
|
+
*
|
|
421
|
+
* @param indexName - This names the index holding the document.
|
|
422
|
+
* @param docId - This names the document to replace.
|
|
423
|
+
* @param document - This replacement goes through the same schema validation
|
|
424
|
+
* an insert would.
|
|
425
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
426
|
+
* this request.
|
|
427
|
+
* @throws A `NarsilError` with `DOC_NOT_FOUND` when the index holds no such
|
|
428
|
+
* document.
|
|
429
|
+
*/
|
|
430
|
+
update(indexName: string, docId: string, document: AnyDocument, options?: RequestOptions): Promise<void>;
|
|
431
|
+
/**
|
|
432
|
+
* Removes one document.
|
|
433
|
+
*
|
|
434
|
+
* @param indexName - This names the index holding the document.
|
|
435
|
+
* @param docId - This names the document to remove.
|
|
436
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
437
|
+
* this request.
|
|
438
|
+
* @throws A `NarsilError` with `DOC_NOT_FOUND` when the index holds no such
|
|
439
|
+
* document.
|
|
440
|
+
*/
|
|
441
|
+
remove(indexName: string, docId: string, options?: RequestOptions): Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* Counts the documents in an index.
|
|
444
|
+
*
|
|
445
|
+
* @param indexName - This names the index to count.
|
|
446
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
447
|
+
* this request.
|
|
448
|
+
* @returns The count covers every document the index holds.
|
|
449
|
+
*/
|
|
450
|
+
countDocuments(indexName: string, options?: RequestOptions): Promise<number>;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* These methods create, list, describe, and drop indexes over HTTP.
|
|
455
|
+
*
|
|
456
|
+
* Each one has the name of the {@link Narsil} method it mirrors, so a call
|
|
457
|
+
* written against an embedded engine works against a server.
|
|
458
|
+
*
|
|
459
|
+
* @public
|
|
460
|
+
*/
|
|
461
|
+
interface IndexOperations {
|
|
462
|
+
/**
|
|
463
|
+
* Creates an index you can insert documents into and query.
|
|
464
|
+
*
|
|
465
|
+
* The configuration covers whatever JSON can express of the engine's own. A
|
|
466
|
+
* custom tokeniser, a stop-word function, and an embedding adapter are all
|
|
467
|
+
* functions, so name a language and a server-registered adapter instead.
|
|
468
|
+
*
|
|
469
|
+
* @param name - Every later call uses this name to reach the index.
|
|
470
|
+
* @param config - This holds the schema, the language, and the partitioning
|
|
471
|
+
* and scoring settings, in the form JSON can express.
|
|
472
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
473
|
+
* this request.
|
|
474
|
+
* @throws A `NarsilError` with `INDEX_ALREADY_EXISTS` when the name is taken,
|
|
475
|
+
* and with `CONFIG_INVALID` when the server refuses the settings.
|
|
476
|
+
*/
|
|
477
|
+
createIndex(name: string, config: HttpIndexConfig, options?: RequestOptions): Promise<void>;
|
|
478
|
+
/**
|
|
479
|
+
* Lists every index the server holds, with its size and its language.
|
|
480
|
+
*
|
|
481
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
482
|
+
* this request.
|
|
483
|
+
* @returns Each index appears once, in creation order.
|
|
484
|
+
*/
|
|
485
|
+
listIndexes(options?: RequestOptions): Promise<IndexInfo[]>;
|
|
486
|
+
/**
|
|
487
|
+
* Removes an index and everything it holds. The documents do not come back.
|
|
488
|
+
*
|
|
489
|
+
* @param name - This names the index to drop.
|
|
490
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
491
|
+
* this request.
|
|
492
|
+
*/
|
|
493
|
+
dropIndex(name: string, options?: RequestOptions): Promise<void>;
|
|
494
|
+
/**
|
|
495
|
+
* Returns one index's document count, partition count, memory estimate,
|
|
496
|
+
* language, and schema.
|
|
497
|
+
*
|
|
498
|
+
* @param indexName - This names the index to describe.
|
|
499
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
500
|
+
* this request.
|
|
501
|
+
* @returns The figures describe the index as it stands now.
|
|
502
|
+
* @throws A `NarsilError` with `INDEX_NOT_FOUND` for an unknown name.
|
|
503
|
+
*/
|
|
504
|
+
getStats(indexName: string, options?: RequestOptions): Promise<IndexStats>;
|
|
505
|
+
/**
|
|
506
|
+
* Returns per-partition figures for one index, which is where you look when
|
|
507
|
+
* an index fills unevenly.
|
|
508
|
+
*
|
|
509
|
+
* @param indexName - This names the index to describe.
|
|
510
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
511
|
+
* this request.
|
|
512
|
+
* @returns Each partition appears once, in partition order.
|
|
513
|
+
*/
|
|
514
|
+
getPartitionStats(indexName: string, options?: RequestOptions): Promise<PartitionStatsResult[]>;
|
|
515
|
+
/**
|
|
516
|
+
* Removes every document from an index while the index itself stays, with its
|
|
517
|
+
* schema and its settings.
|
|
518
|
+
*
|
|
519
|
+
* @param indexName - This names the index to empty.
|
|
520
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
521
|
+
* this request.
|
|
522
|
+
*/
|
|
523
|
+
clear(indexName: string, options?: RequestOptions): Promise<void>;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* These methods search an index over HTTP.
|
|
528
|
+
*
|
|
529
|
+
* Each one has the name of the {@link Narsil} method it mirrors and takes the
|
|
530
|
+
* same parameters, so a query written against an embedded engine runs against a
|
|
531
|
+
* server unchanged.
|
|
532
|
+
*
|
|
533
|
+
* @public
|
|
534
|
+
*/
|
|
535
|
+
interface SearchOperations {
|
|
536
|
+
/**
|
|
537
|
+
* Runs a search and returns the ranked hits.
|
|
538
|
+
*
|
|
539
|
+
* The parameters hold the text, the filters, the sort, the facets, the
|
|
540
|
+
* grouping, and the vector or hybrid settings, exactly as the engine takes
|
|
541
|
+
* them. Where a vector search names `text` instead of a vector, the server
|
|
542
|
+
* must hold the embedding adapter the index was created with.
|
|
543
|
+
*
|
|
544
|
+
* @typeParam T - This is the shape of the stored documents, which flows
|
|
545
|
+
* through to each hit's `document`.
|
|
546
|
+
* @param indexName - This names the index to search.
|
|
547
|
+
* @param params - These carry everything the search asks for.
|
|
548
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
549
|
+
* this request.
|
|
550
|
+
* @returns The result holds the hits, the total match count, and whatever
|
|
551
|
+
* else the query asked for.
|
|
552
|
+
* @throws A `NarsilError` with `SEARCH_RESULT_WINDOW_EXCEEDED` when `offset`
|
|
553
|
+
* plus `limit` passes the server's result window, which the cursor pages
|
|
554
|
+
* beyond.
|
|
555
|
+
*/
|
|
556
|
+
query<T = AnyDocument>(indexName: string, params: QueryParams, options?: RequestOptions): Promise<QueryResult<T>>;
|
|
557
|
+
/**
|
|
558
|
+
* Counts what a search would match, without building or ranking a single hit,
|
|
559
|
+
* which is enough to show a result count beside a filter.
|
|
560
|
+
*
|
|
561
|
+
* @param indexName - This names the index to count in.
|
|
562
|
+
* @param params - These are the parameters {@link SearchOperations.query}
|
|
563
|
+
* takes.
|
|
564
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
565
|
+
* this request.
|
|
566
|
+
* @returns The result holds the match count and how long it took.
|
|
567
|
+
*/
|
|
568
|
+
preflight(indexName: string, params: QueryParams, options?: RequestOptions): Promise<PreflightResult>;
|
|
569
|
+
/**
|
|
570
|
+
* Completes a prefix from the terms the index holds, ready to offer as
|
|
571
|
+
* you-type suggestions.
|
|
572
|
+
*
|
|
573
|
+
* @param indexName - This names the index to complete from.
|
|
574
|
+
* @param params - These set the prefix and how many completions to return.
|
|
575
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
576
|
+
* this request.
|
|
577
|
+
* @returns The completions run most widely used first.
|
|
578
|
+
*/
|
|
579
|
+
suggest(indexName: string, params: SuggestParams, options?: RequestOptions): Promise<SuggestResult>;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* This is what a server reports about the build it runs, so you can tie a
|
|
584
|
+
* result or an incident to the exact code that produced it.
|
|
585
|
+
*
|
|
586
|
+
* The values are whatever the build stamped in, so an unstamped build reports
|
|
587
|
+
* nulls.
|
|
588
|
+
*
|
|
589
|
+
* @public
|
|
590
|
+
*/
|
|
591
|
+
interface ServerVersion {
|
|
592
|
+
/** This names the product, and is always `narsil`. */
|
|
593
|
+
name: string;
|
|
594
|
+
/** The server was built from this package version. */
|
|
595
|
+
version: string | null;
|
|
596
|
+
/** The server was built from this git commit. */
|
|
597
|
+
gitSha: string | null;
|
|
598
|
+
/** This is true when the working tree held uncommitted changes at build time. */
|
|
599
|
+
dirty: boolean;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* These methods ask a server what it is and what it serves, before you ask it
|
|
603
|
+
* for any work.
|
|
604
|
+
*
|
|
605
|
+
* Every route behind them answers without credentials, so a probe or a health
|
|
606
|
+
* check reaches them without a key.
|
|
607
|
+
*
|
|
608
|
+
* @public
|
|
609
|
+
*/
|
|
610
|
+
interface ServerOperations {
|
|
611
|
+
/**
|
|
612
|
+
* Reports the build the server runs.
|
|
613
|
+
*
|
|
614
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
615
|
+
* this request.
|
|
616
|
+
* @returns The report names the package version and the commit the server was
|
|
617
|
+
* built from.
|
|
618
|
+
*/
|
|
619
|
+
version(options?: RequestOptions): Promise<ServerVersion>;
|
|
620
|
+
/**
|
|
621
|
+
* Lists the optional routes and modes this server serves.
|
|
622
|
+
*
|
|
623
|
+
* A server that predates a capability leaves it out, while one that predates
|
|
624
|
+
* the whole endpoint reports an empty list and the call still succeeds.
|
|
625
|
+
*
|
|
626
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
627
|
+
* this request.
|
|
628
|
+
* @returns The list names each capability the server announces.
|
|
629
|
+
*/
|
|
630
|
+
capabilities(options?: RequestOptions): Promise<string[]>;
|
|
631
|
+
/**
|
|
632
|
+
* Reports whether the server serves one optional capability, such as
|
|
633
|
+
* `ASYNC_IMPORT_CAPABILITY`.
|
|
634
|
+
*
|
|
635
|
+
* The client reads the answer once and keeps it for its own lifetime, because
|
|
636
|
+
* a server cannot take on a capability without restarting.
|
|
637
|
+
*
|
|
638
|
+
* @param capability - This names the capability to ask about.
|
|
639
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
640
|
+
* the one request that reads the answer.
|
|
641
|
+
* @returns This is true when the server announced it.
|
|
642
|
+
*/
|
|
643
|
+
supports(capability: string, options?: RequestOptions): Promise<boolean>;
|
|
644
|
+
/**
|
|
645
|
+
* Reports whether the server answers HTTP at all.
|
|
646
|
+
*
|
|
647
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
648
|
+
* this request.
|
|
649
|
+
* @returns This is true when the liveness probe answered.
|
|
650
|
+
* @throws A `NarsilError` with `CLIENT_CONNECTION_FAILED` when the client
|
|
651
|
+
* cannot reach the server, which is a different failure from a server that
|
|
652
|
+
* answers and reports itself unready.
|
|
653
|
+
*/
|
|
654
|
+
isAlive(options?: RequestOptions): Promise<boolean>;
|
|
655
|
+
/**
|
|
656
|
+
* Reports whether the server is ready to take work, which turns false while
|
|
657
|
+
* it starts up and again once it starts draining.
|
|
658
|
+
*
|
|
659
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
660
|
+
* this request.
|
|
661
|
+
* @returns This is true when the readiness probe answered ready.
|
|
662
|
+
* @throws A `NarsilError` with `CLIENT_CONNECTION_FAILED` when the client
|
|
663
|
+
* cannot reach the server.
|
|
664
|
+
*/
|
|
665
|
+
isReady(options?: RequestOptions): Promise<boolean>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* These settings say how {@link TaskOperations.waitForTask} follows a task.
|
|
670
|
+
*
|
|
671
|
+
* `timeoutMs` bounds each poll request, as it does everywhere else, while
|
|
672
|
+
* `waitTimeoutMs` bounds the whole wait.
|
|
673
|
+
*
|
|
674
|
+
* @public
|
|
675
|
+
*/
|
|
676
|
+
interface WaitForTaskOptions extends RequestOptions {
|
|
677
|
+
/**
|
|
678
|
+
* The client asks the server again this often, and every 250 ms unless you
|
|
679
|
+
* say otherwise, which is how often a running import writes its progress.
|
|
680
|
+
*/
|
|
681
|
+
pollIntervalMs?: number;
|
|
682
|
+
/**
|
|
683
|
+
* The wait fails with `CLIENT_TASK_TIMEOUT` after this many milliseconds
|
|
684
|
+
* while the task keeps running. It waits for as long as the task takes unless
|
|
685
|
+
* you set this.
|
|
686
|
+
*/
|
|
687
|
+
waitTimeoutMs?: number;
|
|
688
|
+
/**
|
|
689
|
+
* The client calls this each time the record changes, which is what a
|
|
690
|
+
* progress bar renders. It calls it for the terminal record as well, and
|
|
691
|
+
* never twice for the same figures.
|
|
692
|
+
*/
|
|
693
|
+
onProgress?: (record: TaskRecord) => void;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* These methods follow the long-running operations: an import, a restore, a
|
|
697
|
+
* rebalance, a vector optimisation, and an analysis rebuild.
|
|
698
|
+
*
|
|
699
|
+
* Each of those answers straight away with a task record, so these methods
|
|
700
|
+
* read, follow, and stop the work behind it.
|
|
701
|
+
*
|
|
702
|
+
* @public
|
|
703
|
+
*/
|
|
704
|
+
interface TaskOperations {
|
|
705
|
+
/**
|
|
706
|
+
* Reads one task record back.
|
|
707
|
+
*
|
|
708
|
+
* @param taskId - This names the task to read.
|
|
709
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
710
|
+
* this request.
|
|
711
|
+
* @returns The record comes back, and `null` says the server holds no such
|
|
712
|
+
* task, which is also the answer once a record has gone.
|
|
713
|
+
*/
|
|
714
|
+
getTask(taskId: string, options?: RequestOptions): Promise<TaskRecord | null>;
|
|
715
|
+
/**
|
|
716
|
+
* Lists task records, newest first.
|
|
717
|
+
*
|
|
718
|
+
* @param query - This says which records to keep and where the page starts.
|
|
719
|
+
* Omit it for the newest 20 records the server still holds.
|
|
720
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
721
|
+
* this request.
|
|
722
|
+
* @returns The page holds the records, the total the filters matched, and the
|
|
723
|
+
* offset the next page starts at.
|
|
724
|
+
*/
|
|
725
|
+
listTasks(query?: TaskListQuery, options?: RequestOptions): Promise<TaskListPage>;
|
|
726
|
+
/**
|
|
727
|
+
* Asks a running task to stop.
|
|
728
|
+
*
|
|
729
|
+
* The work stops between units, so the task reaches `cancelled` only once it
|
|
730
|
+
* has stopped, and a request that comes too late leaves it `succeeded`.
|
|
731
|
+
* Whatever the task had already written stays written.
|
|
732
|
+
*
|
|
733
|
+
* @param taskId - This names the task to stop.
|
|
734
|
+
* @param options - This sets the signal, the deadline, and the headers for
|
|
735
|
+
* this request.
|
|
736
|
+
* @returns The record shows the task as it stood when the cancel arrived.
|
|
737
|
+
* @throws A `NarsilError` with `TASK_NOT_FOUND` for an unknown task,
|
|
738
|
+
* `TASK_NOT_CANCELLABLE` for one that has already finished, and
|
|
739
|
+
* `TASK_OWNED_BY_ANOTHER_INSTANCE` when another server instance runs it.
|
|
740
|
+
*/
|
|
741
|
+
cancelTask(taskId: string, options?: RequestOptions): Promise<TaskRecord>;
|
|
742
|
+
/**
|
|
743
|
+
* Polls a task until it finishes, reporting each step on the way.
|
|
744
|
+
*
|
|
745
|
+
* A failed task comes back with `status: 'failed'` and its `error` set while
|
|
746
|
+
* this method throws nothing, because a part-finished import still reports
|
|
747
|
+
* what it indexed. Read the status you get back.
|
|
748
|
+
*
|
|
749
|
+
* @param taskId - This names the task to follow.
|
|
750
|
+
* @param options - These set the poll interval, the overall deadline, the
|
|
751
|
+
* progress callback, and the signal, per-request deadline, and headers.
|
|
752
|
+
* @returns The record shows the task at whichever terminal status it reached.
|
|
753
|
+
* @throws A `NarsilError` with `CLIENT_TASK_TIMEOUT` when the wait passes
|
|
754
|
+
* `waitTimeoutMs`, and with `TASK_NOT_FOUND` when the record expires before
|
|
755
|
+
* the task finishes.
|
|
756
|
+
*/
|
|
757
|
+
waitForTask(taskId: string, options?: WaitForTaskOptions): Promise<TaskRecord>;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* This client reaches one Narsil server, and it runs every operation that
|
|
762
|
+
* server serves.
|
|
763
|
+
*
|
|
764
|
+
* Every method has the name the embedded engine uses, so a call written against
|
|
765
|
+
* {@link Narsil} works here. HTTP forces two differences: every method takes
|
|
766
|
+
* per-call request settings as its last argument, and the operations that can
|
|
767
|
+
* run for minutes answer with a task record while the work carries on.
|
|
768
|
+
*
|
|
769
|
+
* The client sends through `fetch` alone, so it runs in a browser, in Node, and
|
|
770
|
+
* in an edge function.
|
|
771
|
+
*
|
|
772
|
+
* @public
|
|
773
|
+
*/
|
|
774
|
+
interface NarsilClient extends IndexOperations, DocumentOperations, BulkOperations, SearchOperations, TaskOperations, AdminOperations, ServerOperations {
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Builds a client for one Narsil server.
|
|
778
|
+
*
|
|
779
|
+
* The client opens no connection, and it holds no state beyond the
|
|
780
|
+
* capabilities it has read, so nothing needs closing. Keep one client for the
|
|
781
|
+
* application's lifetime.
|
|
782
|
+
*
|
|
783
|
+
* @param options - These set the server address, the credentials, and the
|
|
784
|
+
* defaults every request inherits.
|
|
785
|
+
* @returns The client is ready to use.
|
|
786
|
+
* @throws A `NarsilError` with `CONFIG_INVALID` when it cannot read the address
|
|
787
|
+
* as a URL.
|
|
788
|
+
*
|
|
789
|
+
* @public
|
|
790
|
+
*/
|
|
791
|
+
declare function createNarsilClient(options: NarsilClientOptions): NarsilClient;
|
|
792
|
+
|
|
793
|
+
export { type AdminOperations as A, type BulkOperations as B, type DocumentOperations as D, type FetchFunction as F, type ImportSource as I, type NarsilClient as N, type PutResult as P, type RequestOptions as R, type SearchOperations as S, type TaskOperations as T, type WaitForTaskOptions as W, type IndexOperations as a, type NarsilClientOptions as b, type ServerOperations as c, type ServerVersion as d, createNarsilClient as e };
|