@delali/narsil 0.3.1-next.90 → 0.3.1-next.94

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 (104) hide show
  1. package/dist/adapters/filesystem.mjs +1 -1
  2. package/dist/adapters/indexeddb.mjs +1 -1
  3. package/dist/browser/{chunk-3GZQKGVQ.mjs → chunk-4JTBL63P.mjs} +13 -5
  4. package/dist/browser/{chunk-3ZRMZIH4.mjs → chunk-5S74HQRT.mjs} +208 -78
  5. package/dist/browser/{chunk-FHFFWLEK.mjs → chunk-HARBSUWP.mjs} +3 -4
  6. package/dist/browser/{chunk-RAHUQOJL.mjs → chunk-HC6DMR4T.mjs} +2445 -2107
  7. package/dist/browser/{chunk-JACCR3BJ.mjs → chunk-PP6N5CCS.mjs} +2 -2
  8. package/dist/browser/{chunk-NQW2YXEX.mjs → chunk-WKPJ4E73.mjs} +1 -1
  9. package/dist/browser/{durability-wiring-VSUBLUDK.mjs → durability-wiring-7DKYHKT5.mjs} +498 -71
  10. package/dist/browser/{module-E25UDADM.mjs → module-O5WH32EL.mjs} +102 -54
  11. package/dist/browser/release-76MXRPGV.mjs +33 -0
  12. package/dist/browser/replace-RURXTGVG.mjs +57 -0
  13. package/dist/browser/restore-queue-Z7FZZNKH.mjs +35 -0
  14. package/dist/browser/{snapshot-5MXBEDXF.mjs → snapshot-PPTZ565G.mjs} +368 -103
  15. package/dist/browser/{write-6SBYTS62.mjs → write-2ZAA7UDH.mjs} +4 -4
  16. package/dist/{capabilities-SJPttcgQ.d.ts → capabilities-xsJfdFoQ.d.ts} +11 -3
  17. package/dist/chunk-2GZGBOQI.mjs +426 -0
  18. package/dist/{chunk-CVQWQVFX.mjs → chunk-4ZJWRETC.mjs} +2 -2
  19. package/dist/chunk-7KC56574.mjs +507 -0
  20. package/dist/{chunk-MXS5HWIH.mjs → chunk-7VALMHZF.mjs} +89 -17
  21. package/dist/chunk-7X5JST5L.mjs +114 -0
  22. package/dist/{chunk-UKSUENHK.mjs → chunk-AF2CIKYC.mjs} +40 -26
  23. package/dist/{chunk-BVOJIYRV.mjs → chunk-BB7MASRQ.mjs} +1 -1
  24. package/dist/{chunk-R6BMMQXH.mjs → chunk-C45FUYPI.mjs} +193 -79
  25. package/dist/{chunk-EMXAYPTQ.mjs → chunk-CHOGQSHK.mjs} +2326 -3503
  26. package/dist/{chunk-QZN3MIJ3.mjs → chunk-ES33L3HO.mjs} +2 -2
  27. package/dist/{chunk-VY4DXZ5P.mjs → chunk-EWBXO45L.mjs} +3 -3
  28. package/dist/{chunk-QAMUC2BJ.mjs → chunk-EX62BQT6.mjs} +10 -9
  29. package/dist/{chunk-MWJIAREY.mjs → chunk-EZD4MWOU.mjs} +4 -4
  30. package/dist/{chunk-YCJLVNWR.mjs → chunk-F52QGNZ2.mjs} +1 -1
  31. package/dist/{chunk-URGLSNKR.mjs → chunk-GJZHU4FC.mjs} +202 -16
  32. package/dist/{chunk-S4LQDSUL.mjs → chunk-J53IHLG7.mjs} +7 -7
  33. package/dist/{chunk-R7OSDAFK.mjs → chunk-K6A4FCVR.mjs} +1 -1
  34. package/dist/chunk-KOKM4PQN.mjs +52 -0
  35. package/dist/{chunk-GCM3JFVA.mjs → chunk-OHP7QR33.mjs} +2 -1
  36. package/dist/{chunk-T6CNO72J.mjs → chunk-QM3VPX4Z.mjs} +2 -2
  37. package/dist/{chunk-V7YUSKKZ.mjs → chunk-QWWCLRXX.mjs} +10 -6
  38. package/dist/chunk-QY7GC2MW.mjs +33 -0
  39. package/dist/{chunk-DCK4P5BI.mjs → chunk-R36MIGBU.mjs} +100 -59
  40. package/dist/{chunk-YRX6XMOQ.mjs → chunk-R6PR4WYZ.mjs} +1 -0
  41. package/dist/{chunk-RVM7AODE.mjs → chunk-RDJKYKMQ.mjs} +2 -2
  42. package/dist/{chunk-OOSIDHA3.mjs → chunk-RSRVGAIQ.mjs} +1 -1
  43. package/dist/{chunk-XSZVS4S3.mjs → chunk-RUIXODYU.mjs} +9 -4
  44. package/dist/{chunk-A3UB2MXL.mjs → chunk-SBCEHIPL.mjs} +4 -507
  45. package/dist/{chunk-TPJU7NDJ.mjs → chunk-SYWGORQB.mjs} +1 -0
  46. package/dist/chunk-UAUZGXJP.mjs +3591 -0
  47. package/dist/{chunk-CL4OM7GB.mjs → chunk-WBS3EYC4.mjs} +12 -8
  48. package/dist/{chunk-J2BPXTD7.mjs → chunk-WLOF6HSP.mjs} +3 -3
  49. package/dist/chunk-X5CV2E2B.mjs +1 -0
  50. package/dist/{chunk-ULRPNYAG.mjs → chunk-Z3MOCHG5.mjs} +120 -62
  51. package/dist/chunk-ZHS44YKF.mjs +35 -0
  52. package/dist/{client-BMK53IR2.d.ts → client-CgayPw2R.d.ts} +27 -3
  53. package/dist/client.d.ts +9 -8
  54. package/dist/client.mjs +16 -2
  55. package/dist/{config-UJx1dyX1.d.ts → config-3kBsQ0Pi.d.ts} +2 -2
  56. package/dist/{config-BUR-7eVQ.d.ts → config-B-RnO6dr.d.ts} +2 -2
  57. package/dist/direct-executor-IJTRU3YN.mjs +22 -0
  58. package/dist/distribution/coordinator/etcd.d.ts +3 -2
  59. package/dist/distribution/coordinator/etcd.mjs +5 -1
  60. package/dist/distribution/coordinator/in-memory.d.ts +3 -2
  61. package/dist/distribution/coordinator/in-memory.mjs +4 -0
  62. package/dist/distribution/transport/grpc.mjs +3 -3
  63. package/dist/distribution/transport/in-memory.mjs +1 -1
  64. package/dist/distribution/transport/tcp.mjs +2 -2
  65. package/dist/distribution.d.ts +43 -9
  66. package/dist/distribution.mjs +4620 -4293
  67. package/dist/{durability-wiring-ZLRQU6FG.mjs → durability-wiring-Y55SCPFC.mjs} +524 -93
  68. package/dist/embeddings/openai.mjs +1 -1
  69. package/dist/{engine-9X6W5naj.d.ts → engine-DSUfY2F0.d.ts} +53 -17
  70. package/dist/{index-vCMu8OeQ.d.ts → index-ONAEaqtx.d.ts} +8 -1
  71. package/dist/index.browser.mjs +2 -2
  72. package/dist/index.d.ts +44 -25
  73. package/dist/index.mjs +22 -18
  74. package/dist/{memory-CV9NAxLY.d.ts → memory-wuXcYOD1.d.ts} +99 -79
  75. package/dist/{module-WIDYIJLY.mjs → module-VITS4ZR5.mjs} +72 -38
  76. package/dist/partial-words.mjs +5 -4
  77. package/dist/pattern.mjs +3 -3
  78. package/dist/persistence/durability/checkpoint-worker.d.ts +60 -58
  79. package/dist/persistence/durability/checkpoint-worker.mjs +27 -23
  80. package/dist/react.d.ts +8 -7
  81. package/dist/react.mjs +1 -0
  82. package/dist/release-BH3DKW3T.mjs +33 -0
  83. package/dist/replace-CEO5KJJ3.mjs +57 -0
  84. package/dist/restore-queue-4SG45BLF.mjs +35 -0
  85. package/dist/{schema-DtsgmNfU.d.ts → schema-DttzM-ln.d.ts} +12 -0
  86. package/dist/server.d.ts +11 -10
  87. package/dist/server.mjs +38 -11
  88. package/dist/snapshot-XBKE7PUG.mjs +738 -0
  89. package/dist/synonyms-CpOAHPa-.d.ts +52 -0
  90. package/dist/synonyms.d.ts +22 -0
  91. package/dist/synonyms.mjs +12 -0
  92. package/dist/{tasks-BGaZJyoY.d.ts → tasks-Bj9WBlFG.d.ts} +4 -1
  93. package/dist/{thread-ZP3UMIZT.mjs → thread-U7XYJWGG.mjs} +17 -12
  94. package/dist/vector/search-worker.d.ts +2 -1
  95. package/dist/vector/search-worker.mjs +6 -6
  96. package/dist/workers/entry.mjs +6 -6
  97. package/dist/{write-PXDKPG2R.mjs → write-BMNV7P2H.mjs} +24 -20
  98. package/package.json +15 -7
  99. package/dist/chunk-PR4O7CAP.mjs +0 -18
  100. package/dist/chunk-X4SEXL4U.mjs +0 -2310
  101. package/dist/chunk-Y2F66IQJ.mjs +0 -74
  102. package/dist/chunk-ZJ4CSAB2.mjs +0 -13
  103. package/dist/direct-executor-EGESD26S.mjs +0 -18
  104. package/dist/snapshot-22CUEYYW.mjs +0 -469
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from '../chunk-TPJU7NDJ.mjs';
1
+ import { NarsilError, ErrorCodes } from '../chunk-SYWGORQB.mjs';
2
2
 
3
3
  // src/embeddings/constants.ts
4
4
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
@@ -1,6 +1,7 @@
1
1
  import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { B as BatchResult, I as IndexInfo, g as IndexStats, P as PartitionStatsResult, L as ListParams, h as ListResult, Q as QueryParams, e as QueryResult, j as PreflightResult, k as SuggestParams, l as SuggestResult, D as DocumentImportResult, M as MemoryStats, V as VectorMaintenanceResult, m as NarsilEventMap } from './memory-CV9NAxLY.js';
3
- import { A as AnyDocument, a as InsertOptions, W as WriteOptions, I as IndexConfig, P as PartitionConfig } from './schema-DtsgmNfU.js';
2
+ import { B as BatchResult, I as IndexInfo, g as IndexStats, P as PartitionStatsResult, L as ListParams, h as ListResult, Q as QueryParams, e as QueryResult, j as PreflightResult, k as SuggestParams, l as SuggestResult, D as DocumentImportResult, M as MemoryStats, V as VectorMaintenanceResult, m as NarsilEventMap } from './memory-wuXcYOD1.js';
3
+ import { A as AnyDocument, a as InsertOptions, W as WriteOptions, I as IndexConfig, P as PartitionConfig } from './schema-DttzM-ln.js';
4
+ import { a as SynonymRule } from './synonyms-CpOAHPa-.js';
4
5
 
5
6
  /**
6
7
  * Opens and closes durable indexes without deleting them.
@@ -24,6 +25,42 @@ interface IndexLifecycleOperations {
24
25
  close(indexName: string): Promise<void>;
25
26
  }
26
27
 
28
+ /**
29
+ * Reads and replaces the synonym set of an index, which
30
+ * {@link IndexConfig.synonyms} sets when the index is created.
31
+ *
32
+ * @public
33
+ */
34
+ interface SynonymOperations {
35
+ /**
36
+ * Replaces the synonym set of an index, so that every search that starts
37
+ * after the promise resolves expands its words with the new set.
38
+ *
39
+ * The engine applies the set without rebuilding the index, because a
40
+ * synonym set changes no stored token. It saves the set with the index, so
41
+ * the set stays in place after a restart, and every snapshot of the index
42
+ * includes it. Where the index has copies on worker threads, the promise
43
+ * resolves only once every copy uses the new set. Pass an empty list to
44
+ * remove the set.
45
+ *
46
+ * @param indexName - The index whose set the engine replaces.
47
+ * @param synonyms - The new set, in the shape that {@link SynonymRule}
48
+ * describes.
49
+ * @throws A `NarsilError` with `CONFIG_INVALID` when a rule breaks that
50
+ * shape, when a word analyses to no token or to more than one, or when the
51
+ * set passes 100,000 rules, 500,000 words, or 4,194,304 bytes of words in
52
+ * UTF-8. The index then keeps the set that it held before the call.
53
+ */
54
+ updateSynonyms(indexName: string, synonyms: SynonymRule[]): Promise<void>;
55
+ /**
56
+ * Returns the synonym set of an index with every word as the caller wrote
57
+ * it, or an empty list when the index holds no set.
58
+ *
59
+ * @param indexName - The index whose set the engine returns.
60
+ */
61
+ getSynonyms(indexName: string): Promise<SynonymRule[]>;
62
+ }
63
+
27
64
  /**
28
65
  * Adds, replaces, and removes documents, and waits for the worker copies to
29
66
  * catch up with those writes.
@@ -141,13 +178,12 @@ type ByteSource = Uint8Array | ReadableStream<Uint8Array> | AsyncIterable<Uint8A
141
178
  *
142
179
  * One instance holds every index you create, so an application usually keeps a
143
180
  * single engine for its lifetime and reaches each index by name. Build one
144
- * with {@link createNarsil}. The write methods come from
145
- * {@link DocumentWriteOperations} and the open and close methods from
146
- * {@link IndexLifecycleOperations}.
181
+ * with {@link createNarsil}. Its write, open and close, and synonym methods come from
182
+ * {@link DocumentWriteOperations}, {@link IndexLifecycleOperations}, and {@link SynonymOperations}.
147
183
  *
148
184
  * @public
149
185
  */
150
- interface Narsil extends IndexLifecycleOperations, DocumentWriteOperations {
186
+ interface Narsil extends IndexLifecycleOperations, DocumentWriteOperations, SynonymOperations {
151
187
  /**
152
188
  * Creates an index you can insert documents into and query.
153
189
  *
@@ -335,24 +371,24 @@ interface Narsil extends IndexLifecycleOperations, DocumentWriteOperations {
335
371
  * Creates an index from a snapshot under the name that you pass, replacing
336
372
  * any index of that name.
337
373
  *
338
- * The engine accepts the archive that {@link Narsil.snapshot} streams. It
339
- * also accepts the single `.nrsl` file that `snapshot` returned in release
340
- * 0.3, and it inserts that file's documents and vectors as new writes. The
341
- * engine reads an archive one file at a time. Before it replaces an existing
342
- * index, it checks each file against the archive's manifest and decodes
343
- * every document, so a failed check leaves the existing index unchanged.
374
+ * The engine accepts the archive that {@link Narsil.snapshot} streams and
375
+ * the `.nrsl` file of release 0.3. It checks each archive file against its
376
+ * manifest and loads the restored index beside the existing one, which
377
+ * answers requests until the swap. A failed restore leaves the existing index
378
+ * serving, and after a crash the engine reopens either the old or the new one.
344
379
  *
345
380
  * @param indexName - The name that the restored index takes.
346
- * @param data - The snapshot's bytes, as one array, a stream, or an async
347
- * iterable of chunks.
381
+ * @param data - The snapshot's bytes, as an array, a stream, or async chunks.
348
382
  * @throws A `NarsilError` with `PERSISTENCE_LOAD_FAILED` when the archive is
349
383
  * malformed or a file's length differs from the manifest. The engine raises
350
384
  * `PERSISTENCE_CRC_MISMATCH` when a file's checksum differs from its
351
385
  * contents, and `ENVELOPE_VERSION_MISMATCH` when a file has a format version
352
386
  * other than the ones that this release implements. It raises
353
- * `CONFIG_INVALID` when the archive's configuration is invalid, and
387
+ * `CONFIG_INVALID` when the archive's configuration is invalid,
354
388
  * `DOC_VALIDATION_FAILED` when the data is empty or the release 0.3 file is
355
- * invalid.
389
+ * invalid, `RESTORE_MEMORY_EXCEEDED` when the restored index and the one that
390
+ * it replaces need more memory than is free, and `WORKER_TIMEOUT` when a
391
+ * worker still holds the old index 30 seconds after the engine asks for it.
356
392
  */
357
393
  restore(indexName: string, data: ByteSource): Promise<void>;
358
394
  /**
@@ -508,4 +544,4 @@ interface Narsil extends IndexLifecycleOperations, DocumentWriteOperations {
508
544
  shutdown(): Promise<void>;
509
545
  }
510
546
 
511
- export type { ByteSource as B, DocumentWriteOperations as D, IndexLifecycleOperations as I, Narsil as N };
547
+ export type { ByteSource as B, DocumentWriteOperations as D, IndexLifecycleOperations as I, Narsil as N, SynonymOperations as S };
@@ -1,4 +1,4 @@
1
- import { S as SchemaDefinition } from './schema-DtsgmNfU.js';
1
+ import { S as SchemaDefinition } from './schema-DttzM-ln.js';
2
2
 
3
3
  /**
4
4
  * What a node does in a cluster. A node may hold several roles at once.
@@ -333,6 +333,13 @@ interface ClusterCoordinator {
333
333
  * @returns True when the write went through.
334
334
  */
335
335
  compareAndSet(key: string, expected: Uint8Array | null, value: Uint8Array): Promise<boolean>;
336
+ /**
337
+ * Removes one key of cluster metadata, and does nothing when the key already
338
+ * holds nothing.
339
+ *
340
+ * @param key - The key to remove.
341
+ */
342
+ delete(key: string): Promise<void>;
336
343
  /**
337
344
  * Reads one index's schema, which is how a node joining later learns the
338
345
  * layout of an index it has never held.
@@ -1,2 +1,2 @@
1
- export { VERSION, clearNormalizationCache, configureNormalizationCache, createNarsil, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerLanguage, registerPartialWordSearch, registerPatternSearch, registerStopWords, registerTokenizer, resetNormalizationCache } from './browser/chunk-RAHUQOJL.mjs';
2
- export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError, isSimdAvailable } from './browser/chunk-FHFFWLEK.mjs';
1
+ export { VERSION, clearNormalizationCache, configureNormalizationCache, createNarsil, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerLanguage, registerPartialWordSearch, registerPatternSearch, registerStopWords, registerSynonyms, registerTokenizer, resetNormalizationCache } from './browser/chunk-HC6DMR4T.mjs';
2
+ export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError, isSimdAvailable } from './browser/chunk-HARBSUWP.mjs';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
- import { c as StopWordOverride, C as CustomTokenizer } from './schema-DtsgmNfU.js';
2
- export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldOptionChain, d as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition, b as ScoringMode, T as TextFieldOption, V as VectorIndexConfig, e as VectorQuantizationMode, f as VectorStorageMode, W as WriteOptions } from './schema-DtsgmNfU.js';
1
+ import { c as StopWordOverride, C as CustomTokenizer } from './schema-DttzM-ln.js';
2
+ export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldOptionChain, d as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition, b as ScoringMode, T as TextFieldOption, V as VectorIndexConfig, e as VectorQuantizationMode, f as VectorStorageMode, W as WriteOptions } from './schema-DttzM-ln.js';
3
3
  import { P as PartialWordSearch } from './partial-words-DTIHO8G4.js';
4
4
  import { P as PatternSearch } from './pattern-Cledccbl.js';
5
+ import { S as SynonymSearch } from './synonyms-CpOAHPa-.js';
6
+ export { O as OneWaySynonymRule, a as SynonymRule, T as TwoWaySynonymRule } from './synonyms-CpOAHPa-.js';
5
7
  import { L as LanguageModule } from './language-DB8KG1z5.js';
6
8
  export { T as TokenizerConfig } from './language-DB8KG1z5.js';
7
- export { A as ArrayFilter, B as BatchResult, C as ClientErrorCode, a as ClientErrorCodes, n as ComparisonFilter, D as DocumentImportResult, o as DocumentProjection, E as ErrorCode, b as ErrorCodes, F as FacetConfig, p as FacetResult, q as FieldFilter, r as FilterExpression, G as GeoFilter, s as GeoPolygonFilter, t as GeoRadiusFilter, u as GroupConfig, v as GroupReducer, w as GroupResult, H as HighlightConfig, x as HighlightMatch, y as Hit, z as HybridConfig, I as IndexInfo, g as IndexStats, L as ListParams, h as ListResult, J as ListedDocument, M as MemoryStats, N as NarsilError, c as NarsilErrorCode, f as NarsilEventHandlers, m as NarsilEventMap, P as PartitionStatsResult, j as PreflightResult, K as PresenceFilter, O as ProcessMemoryReport, R as QueryCoverage, Q as QueryParams, e as QueryResult, T as ScoreComponents, U as SearchMode, S as ServerErrorCode, d as ServerErrorCodes, W as SortField, X as SortSpec, Y as StringFilter, k as SuggestParams, l as SuggestResult, Z as TermMatchPolicy, V as VectorMaintenanceResult, _ as VectorQueryConfig, $ as WorkerCopyReport, i as isNarsilError } from './memory-CV9NAxLY.js';
8
- import { N as NarsilConfig } from './config-BUR-7eVQ.js';
9
- export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as IndexLifecycleConfig, b as InsertContext, M as MainCopyQueries, c as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, d as StaleAnalysis, U as UpdateContext, W as WorkerConfig, e as WorkerContext } from './config-BUR-7eVQ.js';
10
- import { N as Narsil } from './engine-9X6W5naj.js';
11
- export { B as ByteSource, D as DocumentWriteOperations, I as IndexLifecycleOperations } from './engine-9X6W5naj.js';
9
+ export { A as ArrayFilter, B as BatchResult, C as ClientErrorCode, a as ClientErrorCodes, n as ComparisonFilter, D as DocumentImportResult, o as DocumentProjection, E as ErrorCode, b as ErrorCodes, F as FacetConfig, p as FacetResult, q as FieldFilter, r as FilterExpression, G as GeoFilter, s as GeoPolygonFilter, t as GeoRadiusFilter, u as GroupConfig, v as GroupReducer, w as GroupResult, H as HighlightConfig, x as HighlightMatch, y as Hit, z as HybridConfig, I as IndexInfo, g as IndexStats, L as ListParams, h as ListResult, J as ListedDocument, M as MemoryStats, N as NarsilError, c as NarsilErrorCode, f as NarsilEventHandlers, m as NarsilEventMap, P as PartitionStatsResult, j as PreflightResult, K as PresenceFilter, O as ProcessMemoryReport, R as QueryCoverage, Q as QueryParams, e as QueryResult, T as ScoreComponents, U as SearchMode, S as ServerErrorCode, d as ServerErrorCodes, W as SortField, X as SortSpec, Y as StringFilter, k as SuggestParams, l as SuggestResult, Z as TermMatchPolicy, V as VectorMaintenanceResult, _ as VectorQueryConfig, $ as WorkerCopyReport, i as isNarsilError } from './memory-wuXcYOD1.js';
10
+ import { N as NarsilConfig } from './config-B-RnO6dr.js';
11
+ export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as IndexLifecycleConfig, b as InsertContext, M as MainCopyQueries, c as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, d as StaleAnalysis, U as UpdateContext, W as WorkerConfig, e as WorkerContext } from './config-B-RnO6dr.js';
12
+ import { N as Narsil } from './engine-DSUfY2F0.js';
13
+ export { B as ByteSource, D as DocumentWriteOperations, I as IndexLifecycleOperations, S as SynonymOperations } from './engine-DSUfY2F0.js';
12
14
  export { E as EmbeddingAdapter, I as InvalidationAdapter, a as InvalidationEvent, b as PartitionStatistics, P as PersistenceAdapter } from './adapters-79OIa4xm.js';
13
15
 
14
16
  /**
@@ -82,6 +84,23 @@ declare function getTokenizer(name: string): CustomTokenizer;
82
84
  */
83
85
  declare function getStopWords(name: string): StopWordOverride;
84
86
 
87
+ /**
88
+ * Creates a search engine that runs inside your process, with no server to
89
+ * provision.
90
+ *
91
+ * The engine holds every index you create, so an application usually keeps one
92
+ * instance for its lifetime. When you configure persistence, this recovers the
93
+ * indexes already on disk before it resolves. Lifecycle settings register
94
+ * those indexes as closed and load each one when its first request arrives.
95
+ *
96
+ * @param config - This carries the persistence, partitioning, and worker
97
+ * invalidation settings. Omit it for an engine that keeps everything in memory.
98
+ * @returns The engine, ready for {@link Narsil.createIndex} to run against.
99
+ *
100
+ * @public
101
+ */
102
+ declare function createNarsil(config?: NarsilConfig): Promise<Narsil>;
103
+
85
104
  /**
86
105
  * Call this to give the engine the partial-word search code, so that it can
87
106
  * create and load an index with a field whose type includes `partial`.
@@ -118,6 +137,23 @@ declare function registerPartialWordSearch(module: PartialWordSearch): void;
118
137
  */
119
138
  declare function registerPatternSearch(module: PatternSearch): void;
120
139
 
140
+ /**
141
+ * Call this to give the engine its synonym code, so that it can create and
142
+ * load an index that holds a synonym set.
143
+ *
144
+ * A Node process loads that code by itself, so only a browser app has to make
145
+ * this call. In a browser, import `synonyms` from `@delali/narsil/synonyms` and
146
+ * pass it here before the app creates or loads an index with a synonym set.
147
+ *
148
+ * @param module - Pass the `synonyms` object that `@delali/narsil/synonyms`
149
+ * exports.
150
+ * @throws The engine throws a `NarsilError` with `CONFIG_INVALID` for any
151
+ * other object.
152
+ *
153
+ * @public
154
+ */
155
+ declare function registerSynonyms(module: SynonymSearch): void;
156
+
121
157
  /**
122
158
  * Sets how many normalised tokens the engine keeps cached.
123
159
  *
@@ -186,23 +222,6 @@ declare function registerLanguage(module: LanguageModule): void;
186
222
  */
187
223
  declare function getLanguage(name: string): LanguageModule;
188
224
 
189
- /**
190
- * Creates a search engine that runs inside your process, with no server to
191
- * provision.
192
- *
193
- * The engine holds every index you create, so an application usually keeps one
194
- * instance for its lifetime. When you configure persistence, this recovers the
195
- * indexes already on disk before it resolves. Lifecycle settings register
196
- * those indexes as closed and load each one when its first request arrives.
197
- *
198
- * @param config - This carries the persistence, partitioning, and worker
199
- * invalidation settings. Omit it for an engine that keeps everything in memory.
200
- * @returns The engine, ready for {@link Narsil.createIndex} to run against.
201
- *
202
- * @public
203
- */
204
- declare function createNarsil(config?: NarsilConfig): Promise<Narsil>;
205
-
206
225
  /**
207
226
  * Reports whether the runtime can run the SIMD module that speeds up vector
208
227
  * distance work.
@@ -230,4 +249,4 @@ declare function isSimdAvailable(): boolean;
230
249
  */
231
250
  declare const VERSION = "0.1.0";
232
251
 
233
- export { CustomTokenizer, LanguageModule, Narsil, NarsilConfig, PartialWordSearch, PatternSearch, StopWordOverride, VERSION, clearNormalizationCache, configureNormalizationCache, createNarsil, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, isSimdAvailable, registerLanguage, registerPartialWordSearch, registerPatternSearch, registerStopWords, registerTokenizer, resetNormalizationCache };
252
+ export { CustomTokenizer, LanguageModule, Narsil, NarsilConfig, PartialWordSearch, PatternSearch, StopWordOverride, SynonymSearch, VERSION, clearNormalizationCache, configureNormalizationCache, createNarsil, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, isSimdAvailable, registerLanguage, registerPartialWordSearch, registerPatternSearch, registerStopWords, registerSynonyms, registerTokenizer, resetNormalizationCache };
package/dist/index.mjs CHANGED
@@ -1,28 +1,32 @@
1
- export { VERSION, createNarsil } from './chunk-R6BMMQXH.mjs';
2
- export { getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerStopWords, registerTokenizer } from './chunk-EMXAYPTQ.mjs';
3
- import './chunk-DCK4P5BI.mjs';
4
- export { registerPartialWordSearch, registerPatternSearch } from './chunk-X4SEXL4U.mjs';
5
- import './chunk-J2BPXTD7.mjs';
6
- export { getLanguage, registerLanguage } from './chunk-PR4O7CAP.mjs';
7
- import './chunk-RVM7AODE.mjs';
1
+ export { VERSION, createNarsil } from './chunk-C45FUYPI.mjs';
2
+ import './chunk-R36MIGBU.mjs';
3
+ import './chunk-RDJKYKMQ.mjs';
4
+ export { registerSynonyms } from './chunk-UAUZGXJP.mjs';
5
+ export { registerPartialWordSearch, registerPatternSearch } from './chunk-CHOGQSHK.mjs';
6
+ import './chunk-WLOF6HSP.mjs';
8
7
  import './chunk-AV4IJKD2.mjs';
9
8
  import './chunk-Q5DC6WAB.mjs';
9
+ export { getLanguage, registerLanguage } from './chunk-ZHS44YKF.mjs';
10
10
  import './chunk-TGP5M5R7.mjs';
11
- export { isSimdAvailable } from './chunk-Y2F66IQJ.mjs';
12
- import './chunk-ZJ4CSAB2.mjs';
13
- import './chunk-QZN3MIJ3.mjs';
14
- import './chunk-T6CNO72J.mjs';
11
+ import './chunk-U2BKYEC7.mjs';
12
+ export { isSimdAvailable } from './chunk-KOKM4PQN.mjs';
13
+ import './chunk-QY7GC2MW.mjs';
14
+ import './chunk-ES33L3HO.mjs';
15
+ import './chunk-QM3VPX4Z.mjs';
15
16
  import './chunk-WQBCBKY3.mjs';
16
- export { clearNormalizationCache, configureNormalizationCache, getNormalizationCacheSize, resetNormalizationCache } from './chunk-A3UB2MXL.mjs';
17
- import './chunk-CVQWQVFX.mjs';
17
+ import './chunk-SBCEHIPL.mjs';
18
+ import './chunk-4ZJWRETC.mjs';
18
19
  import './chunk-FGMGUDHX.mjs';
19
20
  import './chunk-KEHK2O6P.mjs';
20
21
  import './chunk-GES7U2PM.mjs';
21
- import './chunk-BVOJIYRV.mjs';
22
- import './chunk-U2BKYEC7.mjs';
22
+ import './chunk-BB7MASRQ.mjs';
23
+ export { getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerStopWords, registerTokenizer } from './chunk-2GZGBOQI.mjs';
24
+ import './chunk-X5CV2E2B.mjs';
25
+ import './chunk-7X5JST5L.mjs';
26
+ export { clearNormalizationCache, configureNormalizationCache, getNormalizationCacheSize, resetNormalizationCache } from './chunk-7KC56574.mjs';
23
27
  import './chunk-R6A773WK.mjs';
24
28
  import './chunk-YTJCGKM4.mjs';
25
- import './chunk-YRX6XMOQ.mjs';
26
- import './chunk-R7OSDAFK.mjs';
29
+ import './chunk-R6PR4WYZ.mjs';
30
+ import './chunk-K6A4FCVR.mjs';
27
31
  import './chunk-L5ORED7V.mjs';
28
- export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError } from './chunk-TPJU7NDJ.mjs';
32
+ export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError } from './chunk-SYWGORQB.mjs';
@@ -1,4 +1,4 @@
1
- import { A as AnyDocument, S as SchemaDefinition, b as ScoringMode } from './schema-DtsgmNfU.js';
1
+ import { A as AnyDocument, S as SchemaDefinition, b as ScoringMode } from './schema-DttzM-ln.js';
2
2
 
3
3
  /**
4
4
  * Every code a {@link NarsilError} carries, grouped by the part of the engine
@@ -46,6 +46,7 @@ declare const ErrorCodes: {
46
46
  readonly ENVELOPE_VERSION_MISMATCH: "ENVELOPE_VERSION_MISMATCH";
47
47
  readonly ENVELOPE_INVALID_MAGIC: "ENVELOPE_INVALID_MAGIC";
48
48
  readonly PARTITION_CAPACITY_EXCEEDED: "PARTITION_CAPACITY_EXCEEDED";
49
+ readonly RESTORE_MEMORY_EXCEEDED: "RESTORE_MEMORY_EXCEEDED";
49
50
  readonly EMBEDDING_FAILED: "EMBEDDING_FAILED";
50
51
  readonly EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH";
51
52
  readonly EMBEDDING_NO_SOURCE: "EMBEDDING_NO_SOURCE";
@@ -889,6 +890,101 @@ type FilterExpression = {
889
890
  not?: FilterExpression;
890
891
  };
891
892
 
893
+ /**
894
+ * Vector-search inputs passed under `QueryParams.vector`.
895
+ *
896
+ * Supply either a raw `value` array or a `text` string for auto-embedding;
897
+ * passing both throws `EMBEDDING_CONFIG_INVALID`. Result count is governed
898
+ * by the outer query's `limit`, not by any field on this object.
899
+ *
900
+ * @public
901
+ */
902
+ interface VectorQueryConfig {
903
+ /**
904
+ * Name of the schema field that holds the vector to compare against.
905
+ * Must reference a field declared as `vector[N]` in the index schema.
906
+ */
907
+ field: string;
908
+ /**
909
+ * Raw query vector, given as a number array or a `Float32Array`. Length
910
+ * must match the indexed field's dimension or the search rejects the
911
+ * request with `VECTOR_DIMENSION_MISMATCH`.
912
+ */
913
+ value?: number[] | Float32Array;
914
+ /**
915
+ * Text to embed at query time using the index or instance embedding
916
+ * adapter. Mutually exclusive with `value`; requires a configured adapter.
917
+ */
918
+ text?: string;
919
+ /**
920
+ * Score floor applied during ranking. Hits scoring below this value
921
+ * are dropped before `limit` is enforced, so the returned hit count
922
+ * can be smaller than `limit` even when more documents exist. The
923
+ * floor is interpreted in score space for every metric; for
924
+ * `euclidean`, distance is mapped to a similarity score of
925
+ * `1 / (1 + distance)` first. Defaults to no floor.
926
+ */
927
+ similarity?: number;
928
+ /**
929
+ * Similarity metric used for ranking. Defaults to `cosine`. Choose
930
+ * `dotProduct` for raw inner-product scoring on already-normalised
931
+ * vectors and `euclidean` for distance-based ordering.
932
+ */
933
+ metric?: 'cosine' | 'dotProduct' | 'euclidean';
934
+ /**
935
+ * The engine keeps this many candidates as it walks the HNSW graph, so a
936
+ * higher value can find more of the true neighbours, although each query
937
+ * takes longer. The engine applies it only once the field holds a graph.
938
+ * The engine fetches k hits, where k is one more than the number of hits up
939
+ * to the end of the page, so k is `limit` plus 1 on a first page. When a
940
+ * query leaves `efSearch` unset, the engine keeps the larger of 50 and k
941
+ * plus a margin, where the margin is 50 below 768 dimensions, 75 from 768
942
+ * to 1,023 dimensions, and 0 at 1,024 dimensions and above. Under a
943
+ * filter, the engine counts only the candidates that pass the filter.
944
+ */
945
+ efSearch?: number;
946
+ /**
947
+ * The engine re-scores this many times k candidates in a quantized field
948
+ * against the full-precision vectors before it returns the best `limit`,
949
+ * where k is one more than the number of hits up to the end of the page, so
950
+ * k is `limit` plus 1 on a first page. For a value below 1, or for a value
951
+ * that is not a finite number, the engine throws a `NarsilError` with code
952
+ * `CONFIG_INVALID`. The engine ignores it on a field whose quantization is
953
+ * `none`. When a query leaves it unset, the engine sets the number of
954
+ * candidates that it re-scores from k and from the field's dimension. It
955
+ * rounds that number up, and it re-scores at least 3k candidates under
956
+ * `osq1` and `osq2`, and at least k under `osq4` and `osq8`. Below 768
957
+ * dimensions, it re-scores 3.23k + 55.9√k under `osq1` and 2.6k + 17√k under
958
+ * `osq2`. From 768 to 1,023 dimensions, it re-scores 2.2k + 27√k under
959
+ * `osq1` and k + 16√k under `osq2`. At 1,024 dimensions and above, it
960
+ * re-scores 3k under both. Under `osq4`, it re-scores 5k below 1,024
961
+ * dimensions and 2k from 1,024 dimensions, while under `osq8` it re-scores
962
+ * 2k at every dimension. Under a filter, the engine counts only the
963
+ * candidates that pass the filter. On vectors spread evenly across every
964
+ * dimension, a one-bit or two-bit code can find fewer than 95% of the true
965
+ * nearest neighbours at these defaults, so raise `oversample` on a query that
966
+ * needs more of them.
967
+ */
968
+ oversample?: number;
969
+ }
970
+ /**
971
+ * How a hybrid query merges its keyword ranking with its vector ranking.
972
+ *
973
+ * `rrf` combines the two by rank alone, which needs no tuning and handles
974
+ * scores that live on different scales. `linear` blends the scores directly,
975
+ * which gives you control once you know what each side's scores look like.
976
+ *
977
+ * @public
978
+ */
979
+ interface HybridConfig {
980
+ /** The engine merges the rankings this way, and by rank fusion by default. It throws `CONFIG_INVALID` for any other value. */
981
+ strategy?: 'rrf' | 'linear';
982
+ /** The engine uses this rank-fusion constant under `rrf` alone, where a larger value reduces the lead of the top ranks. Set a whole number of at least 1, or leave it out for 60. The engine throws `CONFIG_INVALID` for any other value. */
983
+ k?: number;
984
+ /** The engine uses this weight of the vector score, from 0 to 1, under `linear` alone, and 0.5 where you leave it out. It throws `CONFIG_INVALID` for a value outside that range. */
985
+ alpha?: number;
986
+ }
987
+
892
988
  /**
893
989
  * Everything {@link Narsil.suggest} accepts.
894
990
  *
@@ -1080,8 +1176,8 @@ interface QueryParams {
1080
1176
  partialWords?: boolean;
1081
1177
  /**
1082
1178
  * With this set, the engine matches each query term only against an equal
1083
- * indexed term, so it turns off fuzzy matching, prefix completion, and
1084
- * partial-word matching. The engine still stems the query, because the
1179
+ * indexed term, so it turns off fuzzy matching, prefix completion,
1180
+ * partial-word matching, and synonyms. The engine still stems the query, because the
1085
1181
  * index stores stemmed terms, so a search for `running` matches a document
1086
1182
  * that contains `runs` through the stem that both words share.
1087
1183
  */
@@ -1169,82 +1265,6 @@ type DocumentProjection = boolean | {
1169
1265
  /** Names the fields to drop, so every other field is kept. */
1170
1266
  exclude?: string[];
1171
1267
  };
1172
- /**
1173
- * Vector-search inputs passed under `QueryParams.vector`.
1174
- *
1175
- * Supply either a raw `value` array or a `text` string for auto-embedding;
1176
- * passing both throws `EMBEDDING_CONFIG_INVALID`. Result count is governed
1177
- * by the outer query's `limit`, not by any field on this object.
1178
- *
1179
- * @public
1180
- */
1181
- interface VectorQueryConfig {
1182
- /**
1183
- * Name of the schema field that holds the vector to compare against.
1184
- * Must reference a field declared as `vector[N]` in the index schema.
1185
- */
1186
- field: string;
1187
- /**
1188
- * Raw query vector, given as a number array or a `Float32Array`. Length
1189
- * must match the indexed field's dimension or the search rejects the
1190
- * request with `VECTOR_DIMENSION_MISMATCH`.
1191
- */
1192
- value?: number[] | Float32Array;
1193
- /**
1194
- * Text to embed at query time using the index or instance embedding
1195
- * adapter. Mutually exclusive with `value`; requires a configured adapter.
1196
- */
1197
- text?: string;
1198
- /**
1199
- * Score floor applied during ranking. Hits scoring below this value
1200
- * are dropped before `limit` is enforced, so the returned hit count
1201
- * can be smaller than `limit` even when more documents exist. The
1202
- * floor is interpreted in score space for every metric; for
1203
- * `euclidean`, distance is mapped to a similarity score of
1204
- * `1 / (1 + distance)` first. Defaults to no floor.
1205
- */
1206
- similarity?: number;
1207
- /**
1208
- * Similarity metric used for ranking. Defaults to `cosine`. Choose
1209
- * `dotProduct` for raw inner-product scoring on already-normalised
1210
- * vectors and `euclidean` for distance-based ordering.
1211
- */
1212
- metric?: 'cosine' | 'dotProduct' | 'euclidean';
1213
- /**
1214
- * HNSW exploration factor for approximate search. Higher values raise
1215
- * recall at the cost of latency. Ignored while the field is still
1216
- * served by the brute-force backend. Defaults to the engine's built-in
1217
- * value when omitted.
1218
- */
1219
- efSearch?: number;
1220
- /**
1221
- * How many times `limit` a quantized field re-scores against its
1222
- * full-precision vectors before it returns the best `limit`. A value below
1223
- * 1 or one that is not a finite number fails with `CONFIG_INVALID`. The
1224
- * engine ignores this on a field whose quantization is `none`. When a query
1225
- * omits it, the engine takes 3 for `osq1` and `osq2`, 2 for `osq8`, and 2
1226
- * for `osq4` at 1,024 dimensions and above, but 5 for `osq4` below 1,024,
1227
- * where a four-bit code ranks the true neighbours less reliably.
1228
- */
1229
- oversample?: number;
1230
- }
1231
- /**
1232
- * How a hybrid query merges its keyword ranking with its vector ranking.
1233
- *
1234
- * `rrf` combines the two by rank alone, which needs no tuning and handles
1235
- * scores that live on different scales. `linear` blends the scores directly,
1236
- * which gives you control once you know what each side's scores look like.
1237
- *
1238
- * @public
1239
- */
1240
- interface HybridConfig {
1241
- /** The engine merges the rankings this way, and by rank fusion by default. It throws `CONFIG_INVALID` for any other value. */
1242
- strategy?: 'rrf' | 'linear';
1243
- /** The engine uses this rank-fusion constant under `rrf` alone, where a larger value reduces the lead of the top ranks. Set a whole number of at least 1, or leave it out for 60. The engine throws `CONFIG_INVALID` for any other value. */
1244
- k?: number;
1245
- /** The engine uses this weight of the vector score, from 0 to 1, under `linear` alone, and 0.5 where you leave it out. It throws `CONFIG_INVALID` for a value outside that range. */
1246
- alpha?: number;
1247
- }
1248
1268
  /**
1249
1269
  * Fields a query counts values for, keyed by field name.
1250
1270
  *