@delali/narsil 0.2.4-next.48 → 0.2.4-next.50
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 +2 -2
- package/dist/adapters/indexeddb.mjs +15 -10
- package/dist/{options-BC68VPoE.d.ts → capabilities-JrVQOwi4.d.ts} +55 -47
- package/dist/{chunk-BFIH7OV5.mjs → chunk-2GWVQWGA.mjs} +3 -1
- package/dist/chunk-AV4IJKD2.mjs +35 -0
- package/dist/{chunk-EV45L35L.mjs → chunk-BEIK3EOZ.mjs} +845 -2407
- package/dist/chunk-CBLS46IE.mjs +10 -0
- package/dist/chunk-CMVG2UEF.mjs +2038 -0
- package/dist/chunk-CV5H7XL7.mjs +876 -0
- package/dist/{chunk-JQUL2T6I.mjs → chunk-GCM3JFVA.mjs} +1 -2
- package/dist/{chunk-XWICBGYT.mjs → chunk-MHE7YWAU.mjs} +3 -5
- package/dist/{chunk-UZTT2BKQ.mjs → chunk-ND34I3SV.mjs} +1202 -1881
- package/dist/{chunk-PM52SMBT.mjs → chunk-OOSIDHA3.mjs} +2 -1
- package/dist/chunk-ORBLD3EL.mjs +6 -0
- package/dist/chunk-PIWKZPP7.mjs +64 -0
- package/dist/{chunk-4COAUBLJ.mjs → chunk-PMBHH44R.mjs} +124 -8
- package/dist/chunk-RP23PWMV.mjs +11 -0
- package/dist/chunk-UNEEFTEU.mjs +7 -0
- package/dist/{chunk-WTONLDU3.mjs → chunk-WYJXSLER.mjs} +9 -19
- package/dist/{chunk-DFZDV5FV.mjs → chunk-X6YZO4MQ.mjs} +19 -15
- package/dist/chunk-XE6XR2OE.mjs +23 -0
- package/dist/chunk-YEO6G2NG.mjs +6 -0
- package/dist/chunk-ZHUQKZBE.mjs +1292 -0
- package/dist/{client-C5BkUqB8.d.ts → client-CBOVHdjp.d.ts} +31 -7
- package/dist/client.d.ts +7 -7
- package/dist/client.mjs +250 -232
- package/dist/{config-B-ZI-ft5.d.ts → config-Czh2YNDi.d.ts} +2 -2
- package/dist/{config-BZRExglL.d.ts → config-OON7IJ_B.d.ts} +50 -13
- package/dist/direct-executor-OREXU72C.mjs +12 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/etcd.mjs +2 -3
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.mjs +2 -2
- package/dist/distribution/transport/grpc.mjs +7 -9
- package/dist/distribution/transport/in-memory.mjs +2 -1
- package/dist/distribution/transport/tcp.mjs +3 -2
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +142 -101
- package/dist/embeddings/openai.mjs +5 -3
- package/dist/{engine-Cjr1uBLa.d.ts → engine-9PtFY50q.d.ts} +125 -69
- package/dist/index.browser.mjs +4689 -3330
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +14 -8
- package/dist/invalidation/broadcast-channel.mjs +2 -1
- package/dist/invalidation/filesystem.mjs +3 -4
- package/dist/{search-DDHjfXhJ.d.ts → memory-Bzd5xcEW.d.ts} +89 -63
- package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +14 -8
- package/dist/react.d.ts +4 -4
- package/dist/react.mjs +7 -5
- package/dist/{schema-B7juWg8Q.d.ts → schema-BqRx9t4E.d.ts} +22 -3
- package/dist/server.d.ts +47 -42
- package/dist/server.mjs +338 -821
- package/dist/thread-PZLEO6JL.mjs +310 -0
- package/dist/{types-DsSSjY4d.d.ts → types-DXPxaXPO.d.ts} +1 -1
- package/dist/vector/hnsw-build-worker.mjs +3 -4
- package/dist/vector/search-worker.mjs +4 -123
- package/dist/workers/entry.mjs +47 -3
- package/package.json +5 -1
- package/dist/direct-executor-EOTFGXTO.mjs +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
|
|
2
|
-
import { I as IndexInfo, f as IndexStats, P as PartitionStatsResult,
|
|
3
|
-
import {
|
|
2
|
+
import { B as BatchResult, I as IndexInfo, f as IndexStats, P as PartitionStatsResult, L as ListParams, g as ListResult, Q as QueryParams, e as QueryResult, h as PreflightResult, i as SuggestParams, j as SuggestResult, M as MemoryStats, V as VectorMaintenanceResult } from './memory-Bzd5xcEW.js';
|
|
3
|
+
import { A as AnyDocument, b as InsertOptions, W as WriteOptions, I as IndexConfig, P as PartitionConfig } from './schema-BqRx9t4E.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Every event the engine emits, with the payload each one carries.
|
|
@@ -16,8 +16,12 @@ type NarsilEventMap = {
|
|
|
16
16
|
/**
|
|
17
17
|
* A worker thread died. The pool drops it and fails its outstanding requests
|
|
18
18
|
* with `WORKER_CRASHED`, while the remaining workers keep answering because
|
|
19
|
-
* each holds a full worker copy of every promoted index.
|
|
20
|
-
*
|
|
19
|
+
* each holds a full worker copy of every promoted index. After a delay the
|
|
20
|
+
* engine spawns a replacement, loads every copy onto it, and puts it back
|
|
21
|
+
* into rotation. Once no worker is left, queries fall back to the main
|
|
22
|
+
* thread, which holds every document, and the next request after the delay
|
|
23
|
+
* starts a new pool. The delay starts at one second and doubles up to a
|
|
24
|
+
* minute while replacements keep failing.
|
|
21
25
|
*/
|
|
22
26
|
workerCrash: {
|
|
23
27
|
/** This worker died. */
|
|
@@ -27,16 +31,16 @@ type NarsilEventMap = {
|
|
|
27
31
|
/** This ended the worker. */
|
|
28
32
|
error: Error;
|
|
29
33
|
};
|
|
30
|
-
/**
|
|
34
|
+
/** An index gained worker copies, whether it reached the copy threshold or loaded its copies again after an idle spell. */
|
|
31
35
|
workerPromote: {
|
|
32
|
-
/** The pool
|
|
36
|
+
/** The pool holds this many workers. */
|
|
33
37
|
workerCount: number;
|
|
34
|
-
/** The
|
|
38
|
+
/** The index gained its copies for this reason, such as the copy threshold it reached. */
|
|
35
39
|
reason: string;
|
|
36
40
|
};
|
|
37
|
-
/**
|
|
41
|
+
/** An index could not gain worker copies. It keeps answering on the main thread. */
|
|
38
42
|
workerPromoteFailure: {
|
|
39
|
-
/** The engine tried to
|
|
43
|
+
/** The engine tried to load the copies for this reason. */
|
|
40
44
|
reason: string;
|
|
41
45
|
/** This stopped it. */
|
|
42
46
|
error: Error;
|
|
@@ -63,6 +67,24 @@ type NarsilEventMap = {
|
|
|
63
67
|
/** The index holds this many partitions. */
|
|
64
68
|
partitionCount: number;
|
|
65
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* The process heap crossed nine tenths of its limit during a write or a
|
|
72
|
+
* load, so the next large index may end the process with an out-of-memory
|
|
73
|
+
* error. The engine emits the event once per crossing and arms it again
|
|
74
|
+
* once the heap falls below eight tenths of the limit. Raise the limit with
|
|
75
|
+
* `--max-old-space-size-percentage` or `--max-old-space-size`, or close an
|
|
76
|
+
* idle index; see {@link ProcessMemoryReport.heapLimit}.
|
|
77
|
+
*/
|
|
78
|
+
heapPressure: {
|
|
79
|
+
/** The heap crossed nine tenths of its limit during a write to this index or a load of it. */
|
|
80
|
+
indexName: string;
|
|
81
|
+
/** The process is using this much heap, in bytes. */
|
|
82
|
+
heapUsed: number;
|
|
83
|
+
/** The heap may grow to this many bytes. */
|
|
84
|
+
heapLimit: number;
|
|
85
|
+
/** The engine estimates that the index holds this many bytes. */
|
|
86
|
+
estimatedMemoryBytes: number;
|
|
87
|
+
};
|
|
66
88
|
/** A rebuild is bringing an index's terms up to its language module's current analysis. */
|
|
67
89
|
analysisRebuild: {
|
|
68
90
|
/** This index is being rebuilt. */
|
|
@@ -111,73 +133,31 @@ interface IndexLifecycleOperations {
|
|
|
111
133
|
}
|
|
112
134
|
|
|
113
135
|
/**
|
|
114
|
-
*
|
|
136
|
+
* Adds, replaces, and removes documents, and waits for the worker copies to
|
|
137
|
+
* catch up with those writes.
|
|
115
138
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
139
|
+
* A write returns once the main copy holds it, and the worker copies apply
|
|
140
|
+
* it afterwards, so a query that a copy answers can come back without a write
|
|
141
|
+
* that returned before it. Every write takes a `wait` option for the cases
|
|
142
|
+
* where the next query has to see it.
|
|
119
143
|
*
|
|
120
144
|
* @public
|
|
121
145
|
*/
|
|
122
|
-
interface
|
|
123
|
-
/**
|
|
124
|
-
* Creates an index you can insert documents into and query.
|
|
125
|
-
*
|
|
126
|
-
* The schema sets the type of each field, marks which fields you can
|
|
127
|
-
* filter and sort on, and controls how the engine tokenises text. The
|
|
128
|
-
* `language` option picks the analyser that stems those text fields.
|
|
129
|
-
*
|
|
130
|
-
* @param name - Every later call uses this name to reach the index.
|
|
131
|
-
* @param config - This carries the schema, and the language, partitioning,
|
|
132
|
-
* and scoring settings.
|
|
133
|
-
*/
|
|
134
|
-
createIndex(name: string, config: IndexConfig): Promise<void>;
|
|
135
|
-
/** Registers an adapter under a name that index configs can reference and
|
|
136
|
-
* durability metadata can persist; re-registering rebinds referencing indexes. */
|
|
137
|
-
registerEmbeddingAdapter(name: string, adapter: EmbeddingAdapter): void;
|
|
138
|
-
/**
|
|
139
|
-
* Removes an index and everything it holds, including whatever persistence
|
|
140
|
-
* wrote for it. The documents do not come back.
|
|
141
|
-
*
|
|
142
|
-
* @param name - The index to drop.
|
|
143
|
-
*/
|
|
144
|
-
dropIndex(name: string): Promise<void>;
|
|
145
|
-
/**
|
|
146
|
-
* Lists every index this engine holds, with its size and its language.
|
|
147
|
-
*
|
|
148
|
-
* @returns One entry per index, in creation order.
|
|
149
|
-
*/
|
|
150
|
-
listIndexes(): IndexInfo[];
|
|
151
|
-
/**
|
|
152
|
-
* Returns one index's document count, partition count, memory estimate,
|
|
153
|
-
* language, and schema.
|
|
154
|
-
*
|
|
155
|
-
* @param indexName - The index to describe.
|
|
156
|
-
* @returns The index's current figures.
|
|
157
|
-
* @throws A `NarsilError` with `INDEX_NOT_FOUND` for an unknown name.
|
|
158
|
-
*/
|
|
159
|
-
getStats(indexName: string): IndexStats;
|
|
160
|
-
/**
|
|
161
|
-
* Returns per-partition figures for one index, which is where you look when
|
|
162
|
-
* an index grows unevenly or a rebalance is worth running.
|
|
163
|
-
*
|
|
164
|
-
* @param indexName - The index to describe.
|
|
165
|
-
* @returns One entry per open partition, in partition order, or an empty list while the index is closed.
|
|
166
|
-
*/
|
|
167
|
-
getPartitionStats(indexName: string): PartitionStatsResult[];
|
|
146
|
+
interface DocumentWriteOperations {
|
|
168
147
|
/**
|
|
169
148
|
* Adds one document to an index and returns the id it is stored under.
|
|
170
149
|
*
|
|
171
150
|
* The id comes from the `docId` argument when you pass one, otherwise from
|
|
172
151
|
* the document's own `id` field, and otherwise the engine generates it. Use
|
|
173
|
-
* {@link
|
|
174
|
-
* cannot abandon the rest.
|
|
152
|
+
* {@link DocumentWriteOperations.insertBatch} for a large load, so that one
|
|
153
|
+
* bad document cannot abandon the rest.
|
|
175
154
|
*
|
|
176
155
|
* @param indexName - The index that receives the document.
|
|
177
156
|
* @param document - Its fields must match the types the schema declares.
|
|
178
157
|
* @param docId - Pass an id to control it yourself, or omit it and read the
|
|
179
158
|
* returned value.
|
|
180
|
-
* @param options - Per-write settings, such as skipping the defensive copy
|
|
159
|
+
* @param options - Per-write settings, such as skipping the defensive copy
|
|
160
|
+
* or waiting for every worker copy to apply the write.
|
|
181
161
|
* @returns The id the document is stored under.
|
|
182
162
|
*/
|
|
183
163
|
insert(indexName: string, document: AnyDocument, docId?: string, options?: InsertOptions): Promise<string>;
|
|
@@ -200,41 +180,117 @@ interface Narsil extends IndexLifecycleOperations {
|
|
|
200
180
|
*
|
|
201
181
|
* @param indexName - The index holding the document.
|
|
202
182
|
* @param docId - The document to remove.
|
|
183
|
+
* @param options - Per-write settings, such as waiting for every worker
|
|
184
|
+
* copy to apply the removal.
|
|
203
185
|
* @throws A `NarsilError` with `DOC_NOT_FOUND` when the index holds no such
|
|
204
186
|
* document.
|
|
205
187
|
*/
|
|
206
|
-
remove(indexName: string, docId: string): Promise<void>;
|
|
188
|
+
remove(indexName: string, docId: string, options?: WriteOptions): Promise<void>;
|
|
207
189
|
/**
|
|
208
190
|
* Removes many documents in one pass and reports each one's outcome.
|
|
209
191
|
*
|
|
210
192
|
* @param indexName - The index holding the documents.
|
|
211
193
|
* @param docIds - The documents to remove.
|
|
194
|
+
* @param options - Per-write settings applied to the whole batch.
|
|
212
195
|
* @returns The ids removed, and each failure with its error.
|
|
213
196
|
*/
|
|
214
|
-
removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
|
|
197
|
+
removeBatch(indexName: string, docIds: string[], options?: WriteOptions): Promise<BatchResult>;
|
|
215
198
|
/**
|
|
216
199
|
* Replaces a stored document with the one you pass.
|
|
217
200
|
*
|
|
218
201
|
* The engine removes the old document and indexes the new one, so the
|
|
219
|
-
* document you supply has to be complete
|
|
220
|
-
*
|
|
202
|
+
* document you supply has to be complete, with every field it should hold
|
|
203
|
+
* afterwards.
|
|
221
204
|
*
|
|
222
205
|
* @param indexName - The index holding the document.
|
|
223
206
|
* @param docId - The document to replace.
|
|
224
207
|
* @param document - The complete replacement.
|
|
208
|
+
* @param options - Per-write settings, such as waiting for every worker
|
|
209
|
+
* copy to apply the replacement.
|
|
225
210
|
*/
|
|
226
|
-
update(indexName: string, docId: string, document: AnyDocument): Promise<void>;
|
|
211
|
+
update(indexName: string, docId: string, document: AnyDocument, options?: WriteOptions): Promise<void>;
|
|
227
212
|
/**
|
|
228
213
|
* Replaces many documents in one pass and reports each one's outcome.
|
|
229
214
|
*
|
|
230
215
|
* @param indexName - The index holding the documents.
|
|
231
216
|
* @param updates - Each id with the complete document that replaces it.
|
|
217
|
+
* @param options - Per-write settings applied to the whole batch.
|
|
232
218
|
* @returns The ids replaced, and each failure with its error.
|
|
233
219
|
*/
|
|
234
220
|
updateBatch(indexName: string, updates: Array<{
|
|
235
221
|
docId: string;
|
|
236
222
|
document: AnyDocument;
|
|
237
|
-
}
|
|
223
|
+
}>, options?: WriteOptions): Promise<BatchResult>;
|
|
224
|
+
/**
|
|
225
|
+
* Resolves once every worker copy of an index has applied every write that
|
|
226
|
+
* returned before the call.
|
|
227
|
+
*
|
|
228
|
+
* Call this after a run of writes, or pass `wait: true` on one write,
|
|
229
|
+
* before a query that has to see them. An index that holds no copies
|
|
230
|
+
* resolves at once.
|
|
231
|
+
*
|
|
232
|
+
* @param indexName - The index whose copies have to catch up.
|
|
233
|
+
*/
|
|
234
|
+
waitForWrites(indexName: string): Promise<void>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The search engine, and everything you do with it.
|
|
239
|
+
*
|
|
240
|
+
* One instance holds every index you create, so an application usually keeps a
|
|
241
|
+
* single engine for its lifetime and reaches each index by name. Build one
|
|
242
|
+
* with {@link createNarsil}. The write methods come from
|
|
243
|
+
* {@link DocumentWriteOperations} and the open and close methods from
|
|
244
|
+
* {@link IndexLifecycleOperations}.
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
interface Narsil extends IndexLifecycleOperations, DocumentWriteOperations {
|
|
249
|
+
/**
|
|
250
|
+
* Creates an index you can insert documents into and query.
|
|
251
|
+
*
|
|
252
|
+
* The schema sets the type of each field, marks which fields you can
|
|
253
|
+
* filter and sort on, and controls how the engine tokenises text. The
|
|
254
|
+
* `language` option picks the analyser that stems those text fields.
|
|
255
|
+
*
|
|
256
|
+
* @param name - Every later call uses this name to reach the index.
|
|
257
|
+
* @param config - This carries the schema, and the language, partitioning,
|
|
258
|
+
* and scoring settings.
|
|
259
|
+
*/
|
|
260
|
+
createIndex(name: string, config: IndexConfig): Promise<void>;
|
|
261
|
+
/** Registers an adapter under a name that index configs can reference and
|
|
262
|
+
* durability metadata can persist; re-registering rebinds referencing indexes. */
|
|
263
|
+
registerEmbeddingAdapter(name: string, adapter: EmbeddingAdapter): void;
|
|
264
|
+
/**
|
|
265
|
+
* Removes an index and everything it holds, including whatever persistence
|
|
266
|
+
* wrote for it. The documents do not come back.
|
|
267
|
+
*
|
|
268
|
+
* @param name - The index to drop.
|
|
269
|
+
*/
|
|
270
|
+
dropIndex(name: string): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* Lists every index this engine holds, with its size and its language.
|
|
273
|
+
*
|
|
274
|
+
* @returns One entry per index, in creation order.
|
|
275
|
+
*/
|
|
276
|
+
listIndexes(): IndexInfo[];
|
|
277
|
+
/**
|
|
278
|
+
* Returns one index's document count, partition count, memory estimate,
|
|
279
|
+
* language, and schema.
|
|
280
|
+
*
|
|
281
|
+
* @param indexName - The index to describe.
|
|
282
|
+
* @returns The index's current figures.
|
|
283
|
+
* @throws A `NarsilError` with `INDEX_NOT_FOUND` for an unknown name.
|
|
284
|
+
*/
|
|
285
|
+
getStats(indexName: string): IndexStats;
|
|
286
|
+
/**
|
|
287
|
+
* Returns per-partition figures for one index, which is where you look when
|
|
288
|
+
* an index grows unevenly or a rebalance is worth running.
|
|
289
|
+
*
|
|
290
|
+
* @param indexName - The index to describe.
|
|
291
|
+
* @returns One entry per open partition, in partition order, or an empty list while the index is closed.
|
|
292
|
+
*/
|
|
293
|
+
getPartitionStats(indexName: string): PartitionStatsResult[];
|
|
238
294
|
/**
|
|
239
295
|
* Fetches one stored document by id, without searching.
|
|
240
296
|
*
|
|
@@ -478,4 +534,4 @@ interface Narsil extends IndexLifecycleOperations {
|
|
|
478
534
|
shutdown(): Promise<void>;
|
|
479
535
|
}
|
|
480
536
|
|
|
481
|
-
export type { IndexLifecycleOperations as I, NarsilEventMap as N, Narsil as a };
|
|
537
|
+
export type { DocumentWriteOperations as D, IndexLifecycleOperations as I, NarsilEventMap as N, Narsil as a };
|