@delali/narsil 0.2.4-next.49 → 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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/{options-Dtk99qUs.d.ts → capabilities-JrVQOwi4.d.ts} +55 -47
  3. package/dist/chunk-AV4IJKD2.mjs +35 -0
  4. package/dist/{chunk-M6JGMKA5.mjs → chunk-BEIK3EOZ.mjs} +503 -2273
  5. package/dist/chunk-CMVG2UEF.mjs +2038 -0
  6. package/dist/chunk-CV5H7XL7.mjs +876 -0
  7. package/dist/{chunk-KGRYQVZ5.mjs → chunk-MHE7YWAU.mjs} +2 -1
  8. package/dist/{chunk-56PJBIJ6.mjs → chunk-ND34I3SV.mjs} +427 -1455
  9. package/dist/chunk-PIWKZPP7.mjs +64 -0
  10. package/dist/{chunk-HGJC5L65.mjs → chunk-PMBHH44R.mjs} +121 -2
  11. package/dist/chunk-RP23PWMV.mjs +11 -0
  12. package/dist/{chunk-RDGXYRF4.mjs → chunk-WYJXSLER.mjs} +8 -19
  13. package/dist/{chunk-JXHUHFJ5.mjs → chunk-X6YZO4MQ.mjs} +2 -11
  14. package/dist/{chunk-OWCFK42Q.mjs → chunk-XE6XR2OE.mjs} +3 -10
  15. package/dist/chunk-ZHUQKZBE.mjs +1292 -0
  16. package/dist/{client-DX7xPcNA.d.ts → client-CBOVHdjp.d.ts} +31 -7
  17. package/dist/client.d.ts +7 -7
  18. package/dist/client.mjs +26 -10
  19. package/dist/{config-B41W23Us.d.ts → config-Czh2YNDi.d.ts} +2 -2
  20. package/dist/{config-Co-zAXqO.d.ts → config-OON7IJ_B.d.ts} +26 -5
  21. package/dist/direct-executor-OREXU72C.mjs +12 -0
  22. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  23. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  24. package/dist/distribution.d.ts +8 -8
  25. package/dist/distribution.mjs +28 -11
  26. package/dist/{engine-CABZg25p.d.ts → engine-9PtFY50q.d.ts} +114 -62
  27. package/dist/index.browser.mjs +3255 -2516
  28. package/dist/index.d.ts +7 -7
  29. package/dist/index.mjs +11 -6
  30. package/dist/{search-FjWhZN3f.d.ts → memory-Bzd5xcEW.d.ts} +88 -79
  31. package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
  32. package/dist/persistence/durability/checkpoint-worker.mjs +11 -6
  33. package/dist/react.d.ts +4 -4
  34. package/dist/{schema-B7juWg8Q.d.ts → schema-BqRx9t4E.d.ts} +22 -3
  35. package/dist/server.d.ts +47 -42
  36. package/dist/server.mjs +321 -817
  37. package/dist/thread-PZLEO6JL.mjs +310 -0
  38. package/dist/{types-DsSSjY4d.d.ts → types-DXPxaXPO.d.ts} +1 -1
  39. package/dist/vector/hnsw-build-worker.mjs +2 -1
  40. package/dist/vector/search-worker.mjs +3 -121
  41. package/dist/workers/entry.mjs +47 -3
  42. package/package.json +5 -1
  43. package/dist/direct-executor-HRTDWMVB.mjs +0 -9
@@ -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, B as BatchResult, 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 './search-FjWhZN3f.js';
3
- import { I as IndexConfig, A as AnyDocument, b as InsertOptions, P as PartitionConfig } from './schema-B7juWg8Q.js';
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.
@@ -67,6 +67,24 @@ type NarsilEventMap = {
67
67
  /** The index holds this many partitions. */
68
68
  partitionCount: number;
69
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
+ };
70
88
  /** A rebuild is bringing an index's terms up to its language module's current analysis. */
71
89
  analysisRebuild: {
72
90
  /** This index is being rebuilt. */
@@ -115,73 +133,31 @@ interface IndexLifecycleOperations {
115
133
  }
116
134
 
117
135
  /**
118
- * The search engine, and everything you do with it.
136
+ * Adds, replaces, and removes documents, and waits for the worker copies to
137
+ * catch up with those writes.
119
138
  *
120
- * One instance holds every index you create, so an application usually keeps a
121
- * single engine for its lifetime and reaches each index by name. Build one
122
- * with {@link createNarsil}.
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.
123
143
  *
124
144
  * @public
125
145
  */
126
- interface Narsil extends IndexLifecycleOperations {
127
- /**
128
- * Creates an index you can insert documents into and query.
129
- *
130
- * The schema sets the type of each field, marks which fields you can
131
- * filter and sort on, and controls how the engine tokenises text. The
132
- * `language` option picks the analyser that stems those text fields.
133
- *
134
- * @param name - Every later call uses this name to reach the index.
135
- * @param config - This carries the schema, and the language, partitioning,
136
- * and scoring settings.
137
- */
138
- createIndex(name: string, config: IndexConfig): Promise<void>;
139
- /** Registers an adapter under a name that index configs can reference and
140
- * durability metadata can persist; re-registering rebinds referencing indexes. */
141
- registerEmbeddingAdapter(name: string, adapter: EmbeddingAdapter): void;
142
- /**
143
- * Removes an index and everything it holds, including whatever persistence
144
- * wrote for it. The documents do not come back.
145
- *
146
- * @param name - The index to drop.
147
- */
148
- dropIndex(name: string): Promise<void>;
149
- /**
150
- * Lists every index this engine holds, with its size and its language.
151
- *
152
- * @returns One entry per index, in creation order.
153
- */
154
- listIndexes(): IndexInfo[];
155
- /**
156
- * Returns one index's document count, partition count, memory estimate,
157
- * language, and schema.
158
- *
159
- * @param indexName - The index to describe.
160
- * @returns The index's current figures.
161
- * @throws A `NarsilError` with `INDEX_NOT_FOUND` for an unknown name.
162
- */
163
- getStats(indexName: string): IndexStats;
164
- /**
165
- * Returns per-partition figures for one index, which is where you look when
166
- * an index grows unevenly or a rebalance is worth running.
167
- *
168
- * @param indexName - The index to describe.
169
- * @returns One entry per open partition, in partition order, or an empty list while the index is closed.
170
- */
171
- getPartitionStats(indexName: string): PartitionStatsResult[];
146
+ interface DocumentWriteOperations {
172
147
  /**
173
148
  * Adds one document to an index and returns the id it is stored under.
174
149
  *
175
150
  * The id comes from the `docId` argument when you pass one, otherwise from
176
151
  * the document's own `id` field, and otherwise the engine generates it. Use
177
- * {@link Narsil.insertBatch} for a large load, so that one bad document
178
- * cannot abandon the rest.
152
+ * {@link DocumentWriteOperations.insertBatch} for a large load, so that one
153
+ * bad document cannot abandon the rest.
179
154
  *
180
155
  * @param indexName - The index that receives the document.
181
156
  * @param document - Its fields must match the types the schema declares.
182
157
  * @param docId - Pass an id to control it yourself, or omit it and read the
183
158
  * returned value.
184
- * @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.
185
161
  * @returns The id the document is stored under.
186
162
  */
187
163
  insert(indexName: string, document: AnyDocument, docId?: string, options?: InsertOptions): Promise<string>;
@@ -204,41 +180,117 @@ interface Narsil extends IndexLifecycleOperations {
204
180
  *
205
181
  * @param indexName - The index holding the document.
206
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.
207
185
  * @throws A `NarsilError` with `DOC_NOT_FOUND` when the index holds no such
208
186
  * document.
209
187
  */
210
- remove(indexName: string, docId: string): Promise<void>;
188
+ remove(indexName: string, docId: string, options?: WriteOptions): Promise<void>;
211
189
  /**
212
190
  * Removes many documents in one pass and reports each one's outcome.
213
191
  *
214
192
  * @param indexName - The index holding the documents.
215
193
  * @param docIds - The documents to remove.
194
+ * @param options - Per-write settings applied to the whole batch.
216
195
  * @returns The ids removed, and each failure with its error.
217
196
  */
218
- removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
197
+ removeBatch(indexName: string, docIds: string[], options?: WriteOptions): Promise<BatchResult>;
219
198
  /**
220
199
  * Replaces a stored document with the one you pass.
221
200
  *
222
201
  * The engine removes the old document and indexes the new one, so the
223
- * document you supply has to be complete rather than a set of changed
224
- * fields.
202
+ * document you supply has to be complete, with every field it should hold
203
+ * afterwards.
225
204
  *
226
205
  * @param indexName - The index holding the document.
227
206
  * @param docId - The document to replace.
228
207
  * @param document - The complete replacement.
208
+ * @param options - Per-write settings, such as waiting for every worker
209
+ * copy to apply the replacement.
229
210
  */
230
- update(indexName: string, docId: string, document: AnyDocument): Promise<void>;
211
+ update(indexName: string, docId: string, document: AnyDocument, options?: WriteOptions): Promise<void>;
231
212
  /**
232
213
  * Replaces many documents in one pass and reports each one's outcome.
233
214
  *
234
215
  * @param indexName - The index holding the documents.
235
216
  * @param updates - Each id with the complete document that replaces it.
217
+ * @param options - Per-write settings applied to the whole batch.
236
218
  * @returns The ids replaced, and each failure with its error.
237
219
  */
238
220
  updateBatch(indexName: string, updates: Array<{
239
221
  docId: string;
240
222
  document: AnyDocument;
241
- }>): Promise<BatchResult>;
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[];
242
294
  /**
243
295
  * Fetches one stored document by id, without searching.
244
296
  *
@@ -482,4 +534,4 @@ interface Narsil extends IndexLifecycleOperations {
482
534
  shutdown(): Promise<void>;
483
535
  }
484
536
 
485
- 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 };