@delali/narsil 0.3.1-next.153 → 0.3.1-next.155

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 (330) hide show
  1. package/README.md +3 -1
  2. package/dist/adapters/filesystem.mjs +2 -2
  3. package/dist/adapters/gcs.mjs +2 -2
  4. package/dist/adapters/indexeddb.mjs +1 -1
  5. package/dist/adapters/s3.mjs +2 -2
  6. package/dist/{analysis-change-2OYM7ARW.mjs → analysis-change-3TFIHT5E.mjs} +32 -23
  7. package/dist/{react-native/chunks/analysis-change-entry-CXNRW324.mjs → analysis-change-entry-KA6JAO4X.mjs} +1 -1
  8. package/dist/archive-history-E4R73RWD.mjs +29 -0
  9. package/dist/browser/{analysis-change-2V2HZ2NY.mjs → analysis-change-TC36BU47.mjs} +39 -10
  10. package/dist/{analysis-change-entry-QD7YNDEE.mjs → browser/analysis-change-entry-4MH3CZXH.mjs} +1 -1
  11. package/dist/browser/archive-history-4IP5XQZY.mjs +29 -0
  12. package/dist/browser/chunk-23XRXIBW.mjs +85 -0
  13. package/dist/browser/chunk-3UIEB4QF.mjs +63 -0
  14. package/dist/browser/{chunk-CSCKZBVJ.mjs → chunk-4EWUGZYZ.mjs} +4 -4
  15. package/dist/browser/chunk-4WCVMOU3.mjs +151 -0
  16. package/dist/browser/{chunk-QJCO3TJU.mjs → chunk-56W3HQVJ.mjs} +9 -150
  17. package/dist/{react-native/chunks/chunk-VGUWIZFQ.mjs → browser/chunk-5TCXK5SB.mjs} +2 -2
  18. package/dist/browser/chunk-5W3MMTLG.mjs +19 -0
  19. package/dist/browser/chunk-7IGKGWSQ.mjs +79 -0
  20. package/dist/browser/chunk-A5KUEGDY.mjs +241 -0
  21. package/dist/browser/{chunk-HT7J73QL.mjs → chunk-ABCXENU5.mjs} +2 -2
  22. package/dist/browser/chunk-ATEBYXP6.mjs +10 -0
  23. package/dist/browser/chunk-BXM5XOCA.mjs +315 -0
  24. package/dist/browser/chunk-CJSYBQ4J.mjs +100 -0
  25. package/dist/browser/chunk-DSXIBE6N.mjs +78 -0
  26. package/dist/browser/chunk-ELV4OZOI.mjs +29 -0
  27. package/dist/{react-native/chunks/chunk-QC4ZRBSX.mjs → browser/chunk-EXQZGUQH.mjs} +2 -79
  28. package/dist/browser/{chunk-2A2IPRC3.mjs → chunk-FNIFPFB7.mjs} +5 -31
  29. package/dist/browser/chunk-G64Q6OJF.mjs +96 -0
  30. package/dist/browser/chunk-GPPOG6PT.mjs +9 -0
  31. package/dist/browser/chunk-IKDKX5VQ.mjs +1007 -0
  32. package/dist/browser/chunk-JIJXMI42.mjs +1829 -0
  33. package/dist/browser/chunk-JVBP5EYO.mjs +1106 -0
  34. package/dist/browser/{chunk-TQ5UMFG5.mjs → chunk-K4GCSZLI.mjs} +15 -6
  35. package/dist/browser/{chunk-PM4MUM5N.mjs → chunk-K5AXJBLL.mjs} +6 -5
  36. package/dist/browser/chunk-KKAMCABR.mjs +432 -0
  37. package/dist/browser/{chunk-IAXZAVYL.mjs → chunk-LFIWRCEA.mjs} +1 -159
  38. package/dist/browser/chunk-M3MQE2X7.mjs +151 -0
  39. package/dist/browser/chunk-ML7THVLJ.mjs +38 -0
  40. package/dist/browser/chunk-NLWTBAGB.mjs +111 -0
  41. package/dist/browser/chunk-OEDCEZXJ.mjs +92 -0
  42. package/dist/browser/{chunk-MPK76GVS.mjs → chunk-RA6LSBCM.mjs} +1 -21
  43. package/dist/browser/{chunk-GJKXW3SF.mjs → chunk-RND5CLX3.mjs} +147 -253
  44. package/dist/{react-native/chunks/chunk-DFQJ4IJB.mjs → browser/chunk-RQBUNZQW.mjs} +2 -2
  45. package/dist/browser/{chunk-VD7JEUIR.mjs → chunk-RRO3EV4C.mjs} +9 -8
  46. package/dist/browser/{chunk-KWYQ6KX4.mjs → chunk-SMEQ36NT.mjs} +162 -2019
  47. package/dist/{chunk-MDF6PDIA.mjs → browser/chunk-SRMZXJSL.mjs} +8 -1
  48. package/dist/browser/{chunk-7ZJTRUVW.mjs → chunk-SUDNZKPL.mjs} +2 -2
  49. package/dist/browser/{chunk-LURXVCHG.mjs → chunk-U3JOQGWX.mjs} +1 -1
  50. package/dist/browser/chunk-VI7BQR4U.mjs +21 -0
  51. package/dist/browser/{chunk-B3JM6Z74.mjs → chunk-XY4VVBBO.mjs} +3 -2
  52. package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
  53. package/dist/browser/chunk-ZI2V4VD7.mjs +21 -0
  54. package/dist/browser/{cold-module-YECAK4MN.mjs → cold-module-NEUGHUPA.mjs} +21 -14
  55. package/dist/browser/durability-config-TIYKW6XX.mjs +89 -0
  56. package/dist/browser/{durability-wiring-LM7WFL6X.mjs → durability-wiring-CVGPRO6D.mjs} +1299 -881
  57. package/dist/browser/engine-hooks-YXMPHZKZ.mjs +16 -0
  58. package/dist/browser/import-OM6QAW45.mjs +18 -0
  59. package/dist/browser/methods-KTQCSIN4.mjs +30 -0
  60. package/dist/browser/{module-XQLEOYNM.mjs → module-3HNFCBJ5.mjs} +10 -8
  61. package/dist/browser/{module-KAMRAJLE.mjs → module-E33X4AOK.mjs} +17 -10
  62. package/dist/browser/operations-OJ3BXS55.mjs +5 -0
  63. package/dist/browser/{phrase-module-CNKMUY4U.mjs → phrase-module-ZXXU7S3B.mjs} +1 -1
  64. package/dist/browser/{pool-DTYSPBMQ.mjs → pool-3JLET5RO.mjs} +3 -2
  65. package/dist/browser/restore-hooks-IF2ZROUP.mjs +113 -0
  66. package/dist/browser/restore-queue-ZBS7CJA6.mjs +55 -0
  67. package/dist/browser/retention-ASWUHAYI.mjs +209 -0
  68. package/dist/browser/{runtime-D2ULZGCN.mjs → runtime-OTAGEFQW.mjs} +1 -1
  69. package/dist/browser/{snapshot-UGZVMP4H.mjs → snapshot-PN7ZW6Q4.mjs} +80 -315
  70. package/dist/browser/start-ZIRB7MQ2.mjs +24 -0
  71. package/dist/browser/sync-state-P5XG6LTQ.mjs +15 -0
  72. package/dist/browser/{write-I5P5MW4O.mjs → write-HMDYCTV2.mjs} +17 -11
  73. package/dist/{capabilities-BT-HLDC8.d.ts → capabilities-Da4ywVVl.d.ts} +94 -7
  74. package/dist/{chunk-LDGGR7YT.mjs → chunk-2MANFZJ3.mjs} +2 -2
  75. package/dist/{chunk-IZT3G24Q.mjs → chunk-2NE7VCYE.mjs} +2 -2
  76. package/dist/{chunk-3TVDTACC.mjs → chunk-3C7MTCCI.mjs} +1 -1
  77. package/dist/chunk-3HB3PEC6.mjs +240 -0
  78. package/dist/chunk-3HHQLEEQ.mjs +1092 -0
  79. package/dist/chunk-3OH67G7R.mjs +214 -0
  80. package/dist/{chunk-ZS6CMXAE.mjs → chunk-3R4UZWQG.mjs} +98 -250
  81. package/dist/{chunk-65WCV5JO.mjs → chunk-4BYWRYPM.mjs} +1 -1
  82. package/dist/{chunk-SOUZMPME.mjs → chunk-4KRC2APY.mjs} +7 -194
  83. package/dist/{chunk-5QMHMELB.mjs → chunk-5FLRXF73.mjs} +8 -1
  84. package/dist/chunk-5FVU47TB.mjs +20 -0
  85. package/dist/chunk-5YNRKI2C.mjs +81 -0
  86. package/dist/chunk-6L3XJXGU.mjs +470 -0
  87. package/dist/chunk-6MSZ543Y.mjs +32 -0
  88. package/dist/{chunk-T4CJDBBE.mjs → chunk-6OEGXLBX.mjs} +1 -1
  89. package/dist/{chunk-3SBJVQLL.mjs → chunk-6RC4K46J.mjs} +2 -2
  90. package/dist/chunk-7GXJUJ24.mjs +49 -0
  91. package/dist/{chunk-FNBNZCGP.mjs → chunk-AILVAOLX.mjs} +2 -2
  92. package/dist/chunk-BDRIVYOK.mjs +72 -0
  93. package/dist/chunk-BUMREPLU.mjs +15 -0
  94. package/dist/chunk-BY6ZDGYS.mjs +50 -0
  95. package/dist/{chunk-5WB2A3XU.mjs → chunk-DCNKVEDB.mjs} +511 -27
  96. package/dist/{chunk-NITCPDFL.mjs → chunk-DIBHI6W5.mjs} +2 -2
  97. package/dist/{chunk-4QCSHLNM.mjs → chunk-DUOLGBTE.mjs} +3 -3
  98. package/dist/chunk-GES7U2PM.mjs +68 -0
  99. package/dist/chunk-GH4WQ22V.mjs +34 -0
  100. package/dist/chunk-GQPTDQCL.mjs +54 -0
  101. package/dist/chunk-H4KHPLHJ.mjs +382 -0
  102. package/dist/{chunk-7TE2AJIH.mjs → chunk-H6VIGE62.mjs} +13 -10
  103. package/dist/{chunk-J7M73VY7.mjs → chunk-HJJI72X7.mjs} +1 -1
  104. package/dist/{chunk-DGRM4EZZ.mjs → chunk-HNVVEQP7.mjs} +1 -1
  105. package/dist/{chunk-RBEHLIKX.mjs → chunk-HW5TNXBO.mjs} +35 -11
  106. package/dist/{chunk-KYVRZAYP.mjs → chunk-I54T6CQP.mjs} +2 -69
  107. package/dist/{chunk-IRWP524D.mjs → chunk-INJYO3BU.mjs} +1 -1
  108. package/dist/chunk-IPN7S4KX.mjs +130 -0
  109. package/dist/{chunk-CSHHU7PA.mjs → chunk-J4IWBIVY.mjs} +11 -30
  110. package/dist/{chunk-G5KHSM6E.mjs → chunk-K4ZIGL2O.mjs} +1 -1
  111. package/dist/{chunk-6RKSY3BX.mjs → chunk-KBDBPVLN.mjs} +5 -5
  112. package/dist/{chunk-J4BDAH2W.mjs → chunk-KBKEXQZA.mjs} +2 -2
  113. package/dist/{chunk-IJSFWGVW.mjs → chunk-KFLK5NA2.mjs} +3 -3
  114. package/dist/{chunk-YGQOPB2Z.mjs → chunk-KHKIRS5D.mjs} +1 -1
  115. package/dist/chunk-KJ3RTZDJ.mjs +101 -0
  116. package/dist/{chunk-2PNYKG2D.mjs → chunk-KMUNHGBQ.mjs} +139 -432
  117. package/dist/chunk-KP7TYHWT.mjs +92 -0
  118. package/dist/{chunk-VP6XRMWR.mjs → chunk-KPIV4RUC.mjs} +6 -32
  119. package/dist/{chunk-NPXVQS33.mjs → chunk-KXCVQWOR.mjs} +4 -3
  120. package/dist/chunk-KYYABCSW.mjs +72 -0
  121. package/dist/{chunk-6F6USYII.mjs → chunk-L7ZD4L3K.mjs} +267 -265
  122. package/dist/{chunk-U46IZNCW.mjs → chunk-LC3FDWTX.mjs} +3 -2
  123. package/dist/{chunk-6BWLDLS3.mjs → chunk-LHKOSI2J.mjs} +1 -1
  124. package/dist/chunk-LNGE7SLY.mjs +151 -0
  125. package/dist/{react-native/chunks/chunk-YH7W556M.mjs → chunk-MP7ABPTD.mjs} +12 -2
  126. package/dist/chunk-MT2NRTA6.mjs +216 -0
  127. package/dist/chunk-NF4DT3IH.mjs +85 -0
  128. package/dist/{chunk-POUYICOU.mjs → chunk-OIJ64LGT.mjs} +1 -1
  129. package/dist/{chunk-SEAJS664.mjs → chunk-PCRA7HTI.mjs} +5 -5
  130. package/dist/chunk-PHQNACDT.mjs +63 -0
  131. package/dist/chunk-Q622CTMC.mjs +74 -0
  132. package/dist/{chunk-NVTFQFUL.mjs → chunk-Q7G3BV3Y.mjs} +1 -1
  133. package/dist/chunk-QDZJM7NI.mjs +23 -0
  134. package/dist/{chunk-52QQWEBS.mjs → chunk-QH3YIQP4.mjs} +36 -7
  135. package/dist/chunk-QJVOLKU6.mjs +111 -0
  136. package/dist/chunk-QUJHMPTP.mjs +30 -0
  137. package/dist/{chunk-3E4RRF5J.mjs → chunk-RSVULW4Q.mjs} +100 -8
  138. package/dist/{chunk-IJPK5PGM.mjs → chunk-RVGRFOGN.mjs} +1 -1
  139. package/dist/chunk-RZWWB2XR.mjs +96 -0
  140. package/dist/{chunk-KQJVNPRM.mjs → chunk-S2EQU2GE.mjs} +19 -16
  141. package/dist/chunk-S5LN746F.mjs +10 -0
  142. package/dist/{chunk-LJ4ENXOD.mjs → chunk-SG3JBNHY.mjs} +2 -2
  143. package/dist/{chunk-B2FTZNNF.mjs → chunk-SMVH6JBE.mjs} +34 -14
  144. package/dist/chunk-SY3EWKQY.mjs +242 -0
  145. package/dist/{chunk-NYSONUB7.mjs → chunk-TQXHPFWT.mjs} +1 -1
  146. package/dist/{chunk-ZHAXP7SD.mjs → chunk-U4BS74YN.mjs} +26 -238
  147. package/dist/chunk-UHICS3JI.mjs +83 -0
  148. package/dist/chunk-UZRZKNNZ.mjs +101 -0
  149. package/dist/chunk-V6EUBAIT.mjs +19 -0
  150. package/dist/{chunk-TTCKT2RT.mjs → chunk-VGF7CFRP.mjs} +134 -11
  151. package/dist/chunk-VHBNF4MA.mjs +543 -0
  152. package/dist/{chunk-AWNHDBKV.mjs → chunk-VQEUR6T6.mjs} +16 -8
  153. package/dist/chunk-WQRN64Q6.mjs +196 -0
  154. package/dist/{chunk-DMNPYF54.mjs → chunk-WZ7YV54N.mjs} +2 -2
  155. package/dist/chunk-Y4WPNHMC.mjs +50 -0
  156. package/dist/{chunk-2HJWQPR6.mjs → chunk-YEDIDCR7.mjs} +6 -122
  157. package/dist/chunk-YEKL4JBK.mjs +96 -0
  158. package/dist/{chunk-UGVUW27S.mjs → chunk-Z2BE2MAM.mjs} +14 -10
  159. package/dist/{chunk-3HV7M5OJ.mjs → chunk-ZAUJFLEN.mjs} +11 -135
  160. package/dist/{chunk-FDG4KXX5.mjs → chunk-ZHCUZZE5.mjs} +6 -4
  161. package/dist/chunk-ZTW5WTGG.mjs +167 -0
  162. package/dist/chunk-ZYAY26KG.mjs +29 -0
  163. package/dist/{client-Cn3gNxUU.d.ts → client-DRv7UVeY.d.ts} +193 -11
  164. package/dist/client.d.ts +9 -7
  165. package/dist/client.mjs +120 -7
  166. package/dist/{cold-module-PYSSBIL7.mjs → cold-module-7XXCEGTZ.mjs} +43 -33
  167. package/dist/config-CoSig5Ox.d.ts +482 -0
  168. package/dist/{config-CfhH1IWQ.d.ts → config-DMwffLKn.d.ts} +20 -5
  169. package/dist/{direct-executor-WYALQSMD.mjs → direct-executor-G5TK7NLA.mjs} +18 -13
  170. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  171. package/dist/distribution/coordinator/etcd.mjs +1 -1
  172. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  173. package/dist/distribution/transport/grpc.mjs +4 -4
  174. package/dist/distribution/transport/in-memory.mjs +2 -2
  175. package/dist/distribution/transport/tcp.mjs +3 -3
  176. package/dist/distribution.d.ts +41 -9
  177. package/dist/distribution.mjs +9304 -7271
  178. package/dist/durability-config-GE4U7MCZ.mjs +89 -0
  179. package/dist/{durability-wiring-7VBZEJLG.mjs → durability-wiring-NCKUC5EO.mjs} +1293 -872
  180. package/dist/embeddings/openai.mjs +2 -2
  181. package/dist/{config-aIsy7mcL.d.ts → engine-CFxPYqEk.d.ts} +716 -407
  182. package/dist/engine-hooks-DHCMOADY.mjs +47 -0
  183. package/dist/{import-GJOMB2HC.mjs → import-NBFXFCSG.mjs} +32 -24
  184. package/dist/{index-MsF7e5hL.d.ts → index-C4AmUnl1.d.ts} +1 -1
  185. package/dist/index.browser.mjs +9 -4
  186. package/dist/index.d.ts +7 -6
  187. package/dist/index.mjs +29 -21
  188. package/dist/index.react-native.mjs +19 -12
  189. package/dist/{long-query-thread-SCUE62TO.mjs → long-query-thread-J4DVRM4A.mjs} +33 -19
  190. package/dist/methods-7IOINERF.mjs +30 -0
  191. package/dist/{module-6RLIKSZQ.mjs → module-DWKPBSMN.mjs} +38 -28
  192. package/dist/{module-AVQEIB7O.mjs → module-UN76TF7I.mjs} +14 -14
  193. package/dist/operations-G5EP6JPX.mjs +5 -0
  194. package/dist/{paged-partition-archive-KGRW366Y.mjs → paged-partition-archive-DPNWVSK2.mjs} +46 -31
  195. package/dist/partial-words.mjs +7 -5
  196. package/dist/pattern.mjs +4 -3
  197. package/dist/persistence/durability/checkpoint-worker.d.ts +16 -1
  198. package/dist/persistence/durability/checkpoint-worker.mjs +40 -29
  199. package/dist/{phrase-module-OUQIRUQU.mjs → phrase-module-ZI4WSQVH.mjs} +1 -1
  200. package/dist/{pool-UPV5PVPY.mjs → pool-Y4A46T36.mjs} +2 -2
  201. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  202. package/dist/query-suggestions/merge-worker.mjs +81 -0
  203. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  204. package/dist/query-suggestions.browser.mjs +246 -0
  205. package/dist/query-suggestions.d.ts +20 -0
  206. package/dist/query-suggestions.mjs +62 -0
  207. package/dist/react-native/chunks/{analysis-change-DXPZRGWF.mjs → analysis-change-6BPDPH6K.mjs} +50 -19
  208. package/dist/{browser/analysis-change-entry-JL5U2N3Q.mjs → react-native/chunks/analysis-change-entry-JLL42PH6.mjs} +1 -1
  209. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +29 -0
  210. package/dist/react-native/chunks/chunk-3JIBF3XT.mjs +191 -0
  211. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +1 -0
  212. package/dist/react-native/chunks/{chunk-UFNCLEQM.mjs → chunk-4DII3ZSM.mjs} +1 -1
  213. package/dist/react-native/chunks/{chunk-BRNAVOKP.mjs → chunk-4J74WHQM.mjs} +2 -2
  214. package/dist/react-native/chunks/chunk-4LCEN2IU.mjs +315 -0
  215. package/dist/react-native/chunks/{chunk-PU55IOG4.mjs → chunk-4Y53T4YE.mjs} +6 -190
  216. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +17 -0
  217. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +9 -0
  218. package/dist/react-native/chunks/chunk-6WA3C3DV.mjs +85 -0
  219. package/dist/react-native/chunks/chunk-7GRCBBME.mjs +63 -0
  220. package/dist/react-native/chunks/{chunk-2J2727V4.mjs → chunk-7PXRWYUU.mjs} +1 -1
  221. package/dist/{browser/chunk-VBX2TI5V.mjs → react-native/chunks/chunk-ALOIBXWN.mjs} +2 -2
  222. package/dist/react-native/chunks/{chunk-FS7BYE23.mjs → chunk-C3PTWYKT.mjs} +10 -153
  223. package/dist/react-native/chunks/{chunk-DKJTZ625.mjs → chunk-C5G6TJ7A.mjs} +2 -69
  224. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +43 -0
  225. package/dist/react-native/chunks/{chunk-LRGWK367.mjs → chunk-CKNRFDTZ.mjs} +1 -1
  226. package/dist/react-native/chunks/chunk-CUH5F57W.mjs +242 -0
  227. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +10 -0
  228. package/dist/{browser/chunk-55WYRLDZ.mjs → react-native/chunks/chunk-DVDX4SDR.mjs} +2 -2
  229. package/dist/{browser/chunk-PIS7ZAP7.mjs → react-native/chunks/chunk-DZ7H7D2C.mjs} +12 -2
  230. package/dist/react-native/chunks/{chunk-KOCTCUXW.mjs → chunk-EIOYM5TO.mjs} +17 -9
  231. package/dist/react-native/chunks/chunk-F753DA54.mjs +23 -0
  232. package/dist/react-native/chunks/chunk-GIZTJXYW.mjs +1007 -0
  233. package/dist/react-native/chunks/{chunk-CLE3LZ77.mjs → chunk-GJFXPHXI.mjs} +5 -4
  234. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  235. package/dist/react-native/chunks/{chunk-IDFMNRIC.mjs → chunk-HUOYZJ3Q.mjs} +140 -430
  236. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +111 -0
  237. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +38 -0
  238. package/dist/react-native/chunks/{chunk-LQAKO5QV.mjs → chunk-JLIIWJUV.mjs} +2 -2
  239. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +15 -0
  240. package/dist/react-native/chunks/chunk-KJIG57UD.mjs +1106 -0
  241. package/dist/react-native/chunks/{chunk-KLZGAOLT.mjs → chunk-KTTAU63H.mjs} +5 -5
  242. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +68 -0
  243. package/dist/{browser/chunk-NVEJJP4R.mjs → react-native/chunks/chunk-LZSLNSUN.mjs} +2 -79
  244. package/dist/react-native/chunks/{chunk-3CTWSQRW.mjs → chunk-MJDQU5MW.mjs} +4 -30
  245. package/dist/react-native/chunks/{chunk-NFGBOI46.mjs → chunk-MVXELMJX.mjs} +1 -1
  246. package/dist/react-native/chunks/{chunk-D7LFYPYI.mjs → chunk-N2WUOWLL.mjs} +12 -10
  247. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +78 -0
  248. package/dist/react-native/chunks/{chunk-JYL35A4A.mjs → chunk-OL3WDV53.mjs} +7 -33
  249. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +29 -0
  250. package/dist/react-native/chunks/{chunk-UCJU6WNH.mjs → chunk-PEHS2UO3.mjs} +7 -6
  251. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +79 -0
  252. package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
  253. package/dist/react-native/chunks/chunk-QJXTNPLQ.mjs +100 -0
  254. package/dist/react-native/chunks/{chunk-ZCKNBPQ4.mjs → chunk-RDWG33MM.mjs} +2 -2
  255. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +96 -0
  256. package/dist/react-native/chunks/chunk-TYIRMPD3.mjs +432 -0
  257. package/dist/react-native/chunks/{chunk-TLYD7IJ2.mjs → chunk-U4KSKA4Z.mjs} +1 -1
  258. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +68 -0
  259. package/dist/react-native/chunks/{chunk-7IQR3SZO.mjs → chunk-VXGE4ZXL.mjs} +151 -257
  260. package/dist/react-native/chunks/{chunk-R4OPUZQ5.mjs → chunk-WBYQRHDY.mjs} +2 -2
  261. package/dist/react-native/chunks/chunk-YH7QY657.mjs +288 -0
  262. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +92 -0
  263. package/dist/react-native/chunks/{cold-module-KFGEWYEL.mjs → cold-module-5PHF6DZR.mjs} +31 -22
  264. package/dist/react-native/chunks/durability-config-QXVZEO7T.mjs +89 -0
  265. package/dist/react-native/chunks/{durability-wiring-QKJB2QBT.mjs → durability-wiring-KO565FZC.mjs} +1309 -889
  266. package/dist/react-native/chunks/engine-hooks-MVRRHH6B.mjs +28 -0
  267. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +3 -0
  268. package/dist/react-native/chunks/import-YVZA4V4V.mjs +30 -0
  269. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +30 -0
  270. package/dist/react-native/chunks/{module-UJ5VUARS.mjs → module-H5MVPSP2.mjs} +13 -11
  271. package/dist/react-native/chunks/module-ZL5ZG6YB.mjs +34 -0
  272. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +5 -0
  273. package/dist/react-native/chunks/{phrase-module-76UAPPSG.mjs → phrase-module-RTVKEWJT.mjs} +1 -1
  274. package/dist/react-native/chunks/{pool-CD4ANYUI.mjs → pool-JR3NJCAF.mjs} +3 -2
  275. package/dist/react-native/chunks/restore-hooks-SILFPU6B.mjs +125 -0
  276. package/dist/react-native/chunks/restore-queue-HSYP2AEC.mjs +55 -0
  277. package/dist/react-native/chunks/retention-7I7UAWYK.mjs +221 -0
  278. package/dist/react-native/chunks/{runtime-3MCDLJAF.mjs → runtime-R5E3TB3J.mjs} +1 -1
  279. package/dist/react-native/chunks/{snapshot-KVBD4LRC.mjs → snapshot-EZYB6SLF.mjs} +90 -323
  280. package/dist/react-native/chunks/start-SHVZ72I5.mjs +36 -0
  281. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +15 -0
  282. package/dist/react-native/chunks/{write-ES5A3WUA.mjs → write-JUESXHDL.mjs} +27 -19
  283. package/dist/react-native/partial-words.mjs +8 -5
  284. package/dist/react-native/pattern.mjs +4 -3
  285. package/dist/react-native/query-suggestions.mjs +258 -0
  286. package/dist/react-native/sync.mjs +2299 -0
  287. package/dist/react-native/synonyms.mjs +7 -4
  288. package/dist/react.d.ts +11 -10
  289. package/dist/react.mjs +8 -1
  290. package/dist/{rerank-3W54N6P2.mjs → rerank-MQ37IYRV.mjs} +4 -4
  291. package/dist/rerankers/http.mjs +2 -2
  292. package/dist/restore-hooks-HZ3ILAMO.mjs +146 -0
  293. package/dist/restore-queue-JVGENGGE.mjs +55 -0
  294. package/dist/retention-HROPV2QU.mjs +59 -0
  295. package/dist/{runtime-L2DZYY6N.mjs → runtime-COIUORCN.mjs} +5 -5
  296. package/dist/{schema-D33CyXCy.d.ts → schema-Jwt928nJ.d.ts} +1 -1
  297. package/dist/server.d.ts +119 -20
  298. package/dist/server.mjs +1123 -58
  299. package/dist/{snapshot-WMX6JCLP.mjs → snapshot-4HS2G2UM.mjs} +106 -49
  300. package/dist/start-UTWHGH42.mjs +59 -0
  301. package/dist/sync/filesystem.d.ts +30 -0
  302. package/dist/sync/filesystem.mjs +271 -0
  303. package/dist/sync/indexeddb.d.ts +30 -0
  304. package/dist/sync/indexeddb.mjs +237 -0
  305. package/dist/sync-state-ZWHLAFLE.mjs +15 -0
  306. package/dist/sync.browser.mjs +2294 -0
  307. package/dist/sync.d.ts +23 -0
  308. package/dist/sync.mjs +2268 -0
  309. package/dist/synonyms.mjs +6 -4
  310. package/dist/{tasks-C4ElXr4P.d.ts → tasks-qrJojgST.d.ts} +13 -5
  311. package/dist/thread-6MOXY2KD.mjs +45 -0
  312. package/dist/types-BZCGjfLn.d.ts +227 -0
  313. package/dist/vector/search-worker.d.ts +1 -1
  314. package/dist/vector/search-worker.mjs +7 -7
  315. package/dist/workers/entry.mjs +8 -8
  316. package/dist/{write-SKJ6HW7O.mjs → write-GTTWWRRG.mjs} +36 -28
  317. package/openapi.json +912 -5
  318. package/package.json +45 -8
  319. package/dist/browser/import-QOY6ZH6X.mjs +0 -12
  320. package/dist/browser/restore-queue-UQ6AAUVX.mjs +0 -41
  321. package/dist/chunk-7LDMWKP6.mjs +0 -209
  322. package/dist/engine-CJRUHXgf.d.ts +0 -664
  323. package/dist/react-native/chunks/chunk-L4M7QJNP.mjs +0 -110
  324. package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +0 -25
  325. package/dist/react-native/chunks/gzip.react-native-7JWCLVOB.mjs +0 -3
  326. package/dist/react-native/chunks/import-XFBCCENV.mjs +0 -22
  327. package/dist/react-native/chunks/module-FHJ2GOBI.mjs +0 -25
  328. package/dist/react-native/chunks/restore-queue-H5VCN453.mjs +0 -41
  329. package/dist/restore-queue-AOF5OTQV.mjs +0 -41
  330. package/dist/thread-I7DVHHW7.mjs +0 -31
@@ -1,5 +1,7 @@
1
- import { P as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter, R as RerankAdapter } from './adapters-pljAqmrC.js';
2
- import { A as AnyDocument, S as SchemaDefinition, B as BM25Params, e as ScoringMode, a as IndexConfig } from './schema-D33CyXCy.js';
1
+ import { E as EmbeddingAdapter, R as RerankAdapter } from './adapters-pljAqmrC.js';
2
+ import { A as AnyDocument, S as SchemaDefinition, B as BM25Params, e as ScoringMode, a as InsertOptions, W as WriteOptions, I as IndexConfig, P as PartitionConfig } from './schema-Jwt928nJ.js';
3
+ import { h as QuerySuggestionsBuildEvent, j as QuerySuggestionsWarningEvent } from './query-suggestions-CBYkrQ5T.js';
4
+ import { a as SynonymRule } from './synonyms-CpOAHPa-.js';
3
5
 
4
6
  /**
5
7
  * Every code a {@link NarsilError} carries, grouped by the part of the engine
@@ -45,6 +47,12 @@ declare const ErrorCodes: {
45
47
  readonly BACKUP_STORE_CLAIMED: "BACKUP_STORE_CLAIMED";
46
48
  readonly BACKUP_STORE_NOT_CONFIGURED: "BACKUP_STORE_NOT_CONFIGURED";
47
49
  readonly BACKUP_NOT_READY: "BACKUP_NOT_READY";
50
+ readonly SYNC_DURABILITY_REQUIRED: "SYNC_DURABILITY_REQUIRED";
51
+ readonly SYNC_BACKUP_STORE_REQUIRED: "SYNC_BACKUP_STORE_REQUIRED";
52
+ readonly SYNC_NOT_READY: "SYNC_NOT_READY";
53
+ readonly SYNC_NOT_ENABLED: "SYNC_NOT_ENABLED";
54
+ readonly SYNC_SNAPSHOT_PREPARING: "SYNC_SNAPSHOT_PREPARING";
55
+ readonly QUERY_SUGGESTIONS_NOT_ENABLED: "QUERY_SUGGESTIONS_NOT_ENABLED";
48
56
  readonly SEARCH_INVALID_FIELD: "SEARCH_INVALID_FIELD";
49
57
  readonly VECTOR_DIMENSION_MISMATCH: "VECTOR_DIMENSION_MISMATCH";
50
58
  readonly SEARCH_INVALID_FILTER: "SEARCH_INVALID_FILTER";
@@ -175,8 +183,10 @@ type ServerErrorCode = (typeof ServerErrorCodes)[keyof typeof ServerErrorCodes];
175
183
  * a server, or where the caller cannot read the answer.
176
184
  *
177
185
  * The HTTP client raises the first five. The React bindings raise
178
- * `CLIENT_UNEXPECTED_ERROR` alone, which reports a fault inside a hook. No
179
- * server sends any of them, so a failure under one means the exchange broke
186
+ * `CLIENT_UNEXPECTED_ERROR` alone, which reports a fault inside a hook. A
187
+ * synced device raises `SYNC_ANALYSIS_UNAVAILABLE` before it downloads a
188
+ * snapshot whose language, tokeniser, or stop words it has not registered,
189
+ * and it keeps its copy of the index. No server sends any of them, so a failure under one means the exchange broke
180
190
  * before the operation ran. `STATUS_BY_CODE` in `src/server/errors.ts`
181
191
  * therefore maps none of them, because no request can arrive under one and no
182
192
  * HTTP status belongs to one.
@@ -190,6 +200,7 @@ declare const ClientErrorCodes: {
190
200
  readonly CLIENT_INVALID_RESPONSE: "CLIENT_INVALID_RESPONSE";
191
201
  readonly CLIENT_TASK_TIMEOUT: "CLIENT_TASK_TIMEOUT";
192
202
  readonly CLIENT_UNEXPECTED_ERROR: "CLIENT_UNEXPECTED_ERROR";
203
+ readonly SYNC_ANALYSIS_UNAVAILABLE: "SYNC_ANALYSIS_UNAVAILABLE";
193
204
  };
194
205
  /**
195
206
  * Any one of the codes in {@link ClientErrorCodes}.
@@ -559,7 +570,7 @@ interface SuggestResult {
559
570
  }
560
571
  /**
561
572
  * The state of one vector field, and what maintenance would cost, as
562
- * {@link Narsil.vectorMaintenanceStatus} reports it.
573
+ * {@link VectorMaintenanceOperations.vectorMaintenanceStatus} reports it.
563
574
  *
564
575
  * Removing a vector leaves a tombstone in the graph, and enough of them slow a
565
576
  * search down. Read this to decide when compaction earns its cost.
@@ -592,9 +603,9 @@ interface VectorMaintenanceResult {
592
603
  * background, during which a search reads them from the field's files.
593
604
  */
594
605
  loadingFromFiles: boolean;
595
- /** {@link Narsil.compactVectors} would take about this many milliseconds. */
606
+ /** {@link VectorMaintenanceOperations.compactVectors} would take about this many milliseconds. */
596
607
  estimatedCompactMs: number;
597
- /** {@link Narsil.optimizeVectors} would take about this many milliseconds. */
608
+ /** {@link VectorMaintenanceOperations.optimizeVectors} would take about this many milliseconds. */
598
609
  estimatedOptimizeMs: number;
599
610
  }
600
611
  /**
@@ -1481,170 +1492,6 @@ interface HighlightConfig {
1481
1492
  maxSnippetLength?: number;
1482
1493
  }
1483
1494
 
1484
- /**
1485
- * Hooks that the engine calls alongside its own work, so that an application
1486
- * can add validation, auditing, enrichment, or metrics without forking the
1487
- * engine.
1488
- *
1489
- * Every hook is optional. A `before` hook fires first and rejects the
1490
- * operation by throwing, while an `after` hook fires once the operation
1491
- * succeeds. Where a `before` hook on a write throws a {@link NarsilError}, the
1492
- * engine passes that error to the caller unchanged. It turns any other error
1493
- * into `DOC_VALIDATION_FAILED` with the same message, for a single write and
1494
- * for each entry of a batch alike. The engine awaits a hook that returns a
1495
- * promise, so slow work in one hook slows every write or search that it
1496
- * covers.
1497
- *
1498
- * @public
1499
- */
1500
- interface NarsilPlugin {
1501
- /** This name identifies the plugin in errors and in event payloads. */
1502
- name: string;
1503
- /** Fires before the engine indexes a document. Throw to reject the write. */
1504
- beforeInsert?(ctx: InsertContext): void | Promise<void>;
1505
- /** Fires once the engine has indexed a document. */
1506
- afterInsert?(ctx: InsertContext): void | Promise<void>;
1507
- /** Fires before the engine removes a document. Throw to reject the removal. */
1508
- beforeRemove?(ctx: RemoveContext): void | Promise<void>;
1509
- /** Fires once the engine has removed a document. */
1510
- afterRemove?(ctx: RemoveContext): void | Promise<void>;
1511
- /** Fires before the engine replaces a document. Throw to reject the update. */
1512
- beforeUpdate?(ctx: UpdateContext): void | Promise<void>;
1513
- /** Fires once the engine has replaced a document. */
1514
- afterUpdate?(ctx: UpdateContext): void | Promise<void>;
1515
- /**
1516
- * Fires before every search, and before every preflight. Throw to reject the
1517
- * query. It fires before the engine embeds a `vector.text` query, so a hook
1518
- * that counts or refuses work stops the call to the embedding provider, and
1519
- * `ctx.params.vector` still holds the text that the caller passed.
1520
- * {@link Narsil.suggest} scans the term dictionary and searches no document,
1521
- * so it fires no hook.
1522
- */
1523
- beforeSearch?(ctx: SearchContext): void | Promise<void>;
1524
- /**
1525
- * Fires once a search returns. The context holds a copy of the results, so a
1526
- * change that you make here leaves the caller's own result untouched. Where
1527
- * this hook throws, the engine logs a warning and answers the query all the
1528
- * same, because the search is already over.
1529
- */
1530
- afterSearch?(ctx: SearchContext): void | Promise<void>;
1531
- /**
1532
- * Fires once the engine creates an index, and a `restore` fires it too,
1533
- * because a restore recreates the index that it replaces. Where this hook
1534
- * throws, the engine logs a warning and keeps the index, because the hook
1535
- * fires after the index exists.
1536
- */
1537
- onIndexCreate?(ctx: IndexContext): void | Promise<void>;
1538
- /**
1539
- * Fires once the engine drops an index, and a `restore` fires it too,
1540
- * because a restore drops the index that it replaces. Where this hook
1541
- * throws, the engine logs a warning, because the hook fires after the index
1542
- * is gone.
1543
- */
1544
- onIndexDrop?(ctx: IndexContext): void | Promise<void>;
1545
- /**
1546
- * Fires once {@link Narsil.rebalance} moves an index onto a new partition
1547
- * count, which is the only way that the count changes. An index opens with
1548
- * the count that `partitions.maxPartitions` sets, because the engine adds no
1549
- * partition on its own. Subscribe to the `partitionWatermark` event to learn
1550
- * when an index fills its capacity.
1551
- */
1552
- onPartitionSplit?(ctx: PartitionContext): void | Promise<void>;
1553
- /** Fires once the engine loads worker copies of its indexes. */
1554
- onWorkerPromote?(ctx: WorkerContext): void | Promise<void>;
1555
- }
1556
- /**
1557
- * What a plugin receives around an insert.
1558
- *
1559
- * @public
1560
- */
1561
- interface InsertContext {
1562
- /** The engine writes the document to this index. */
1563
- indexName: string;
1564
- /** The document is stored under this id, which the engine resolves before the `before` hook runs. */
1565
- docId: string;
1566
- /** This is the document itself, and the engine indexes whatever a `before` hook leaves here. */
1567
- document: AnyDocument;
1568
- }
1569
- /**
1570
- * What a plugin receives around a removal.
1571
- *
1572
- * @public
1573
- */
1574
- interface RemoveContext {
1575
- /** The engine removes the document from this index. */
1576
- indexName: string;
1577
- /** The engine removes this document. */
1578
- docId: string;
1579
- }
1580
- /**
1581
- * What a plugin receives around an update.
1582
- *
1583
- * @public
1584
- */
1585
- interface UpdateContext {
1586
- /** The document belongs to this index. */
1587
- indexName: string;
1588
- /** The engine replaces this document. */
1589
- docId: string;
1590
- /** The index holds this document before the update. */
1591
- oldDocument: AnyDocument;
1592
- /** This document replaces it, and the engine indexes whatever a `before` hook leaves here. */
1593
- newDocument: AnyDocument;
1594
- }
1595
- /**
1596
- * What a plugin receives around a search.
1597
- *
1598
- * @public
1599
- */
1600
- interface SearchContext {
1601
- /** The search runs against this index. */
1602
- indexName: string;
1603
- /** These are the parameters the query runs with, and a `before` hook that changes them rewrites the search. */
1604
- params: QueryParams;
1605
- /**
1606
- * These are the results, which an `after` hook alone receives. A preflight
1607
- * fires `beforeSearch` and stops there, because it answers with a count and
1608
- * no hits. Read this field inside an `afterSearch` hook alone.
1609
- */
1610
- results?: QueryResult;
1611
- }
1612
- /**
1613
- * What a plugin receives when the engine creates or drops an index.
1614
- *
1615
- * @public
1616
- */
1617
- interface IndexContext {
1618
- /** The engine creates or drops this index. */
1619
- indexName: string;
1620
- /** The index holds this configuration. */
1621
- config: IndexConfig;
1622
- }
1623
- /**
1624
- * What a plugin receives when a rebalance changes an index's partition count.
1625
- *
1626
- * @public
1627
- */
1628
- interface PartitionContext {
1629
- /** The rebalance moved this index. */
1630
- indexName: string;
1631
- /** The index held this many partitions before the rebalance. */
1632
- oldPartitionCount: number;
1633
- /** The index holds this many partitions now. */
1634
- newPartitionCount: number;
1635
- }
1636
- /**
1637
- * What a plugin receives when the engine moves onto worker threads.
1638
- *
1639
- * @public
1640
- */
1641
- interface WorkerContext {
1642
- /** The pool holds this many workers. */
1643
- workerCount: number;
1644
- /** The engine promoted for this reason, such as the threshold that the index crossed. */
1645
- reason: string;
1646
- }
1647
-
1648
1495
  /**
1649
1496
  * Snapshot of V8 heap usage as reported by `process.memoryUsage()`, with the
1650
1497
  * limit the heap may grow to. All values are bytes. `null` in environments
@@ -1941,6 +1788,17 @@ type NarsilEventMap = {
1941
1788
  /** This is the error that the adapter threw. */
1942
1789
  error: Error;
1943
1790
  };
1791
+ /**
1792
+ * A popular query suggestions build started, completed, failed, or skipped.
1793
+ * The payload carries counts alone, never a phrase.
1794
+ */
1795
+ querySuggestionsBuild: QuerySuggestionsBuildEvent;
1796
+ /**
1797
+ * The engine skipped a history file, failed to save the counts of a day,
1798
+ * reached a daily limit, or holds an index with the feature on while it has
1799
+ * no key. The payload carries no search text.
1800
+ */
1801
+ querySuggestionsWarning: QuerySuggestionsWarningEvent;
1944
1802
  };
1945
1803
  /**
1946
1804
  * This map holds a listener for any event of {@link NarsilEventMap}, so that
@@ -1953,297 +1811,748 @@ type NarsilEventHandlers = {
1953
1811
  };
1954
1812
 
1955
1813
  /**
1956
- * Everything {@link createNarsil} accepts when it builds an engine.
1957
- *
1958
- * Every field is optional, and an engine created without any of them keeps
1959
- * its indexes in memory alone. Add persistence to survive a restart, add
1960
- * invalidation to share a store with another process, and add durability to
1961
- * recover the writes made since the last snapshot.
1962
- *
1963
- * @public
1964
- */
1965
- interface NarsilConfig {
1966
- /** This adapter writes partitions somewhere they outlive the process. */
1967
- persistence?: PersistenceAdapter;
1968
- /** This channel carries partition changes to other instances sharing the store. */
1969
- invalidation?: InvalidationAdapter;
1970
- /** These hooks observe or reject writes, searches, and lifecycle changes. */
1971
- plugins?: NarsilPlugin[];
1972
- /** This supplies the id for a document inserted without one. The engine generates a UUID v7 by default. */
1973
- idGenerator?: () => string;
1974
- /** These settings control when an index gains worker copies, how many threads they share, and when an idle index gives them up. */
1975
- workers?: WorkerConfig;
1976
- /** Every index uses this adapter unless its own config names another. */
1977
- embedding?: EmbeddingAdapter;
1978
- /** Named adapters; names persist in index metadata so recovery can rebind. */
1979
- embeddingAdapters?: Record<string, EmbeddingAdapter>;
1980
- /**
1981
- * These rerank adapters are registered under their keys, so that a query
1982
- * can give a key in `rerank.adapter`. The engine throws
1983
- * `RERANK_CONFIG_INVALID` for an empty key and for an entry without a
1814
+ * Registers the adapters that indexes and queries reach by name, which is
1815
+ * what lets a binding outlive a restart and reach a worker thread or another
1816
+ * node.
1817
+ *
1818
+ * @public
1819
+ */
1820
+ interface AdapterRegistrationOperations {
1821
+ /**
1822
+ * Registers an embedding adapter under a name that an index config can
1823
+ * give and that durability metadata keeps. Registering a name again binds
1824
+ * every index that gives that name to the new adapter.
1825
+ *
1826
+ * @param name - The name that an index config gives in `embedding.adapter`.
1827
+ * @param adapter - The adapter that embeds documents and queries.
1828
+ */
1829
+ registerEmbeddingAdapter(name: string, adapter: EmbeddingAdapter): void;
1830
+ /**
1831
+ * Registers a rerank adapter under a name that a query gives in
1832
+ * `rerank.adapter`. Registering a name again sends every later query that
1833
+ * gives that name to the new adapter. The engine throws
1834
+ * `RERANK_CONFIG_INVALID` for an empty name and for an adapter without a
1984
1835
  * `rerank` function.
1836
+ *
1837
+ * @param name - The name that a query gives in `rerank.adapter`.
1838
+ * @param adapter - The adapter that scores the top hits of a query.
1985
1839
  */
1986
- rerankAdapters?: Record<string, RerankAdapter>;
1840
+ registerRerankAdapter(name: string, adapter: RerankAdapter): void;
1841
+ }
1842
+
1843
+ /**
1844
+ * The analysis settings that {@link AnalysisOperations.changeAnalysis} changes
1845
+ * on a live index. A key that you leave out keeps its current value.
1846
+ *
1847
+ * @public
1848
+ */
1849
+ interface AnalysisChange {
1850
+ /** This is the name of a registered language. */
1851
+ language?: string;
1987
1852
  /**
1988
- * The engine waits this many milliseconds for a rerank adapter to score one
1989
- * query, and 30,000 by default. It then cancels the call through the
1990
- * adapter's abort signal and throws `RERANK_FAILED`. Set a whole number of
1991
- * at least 1; {@link createNarsil} throws `CONFIG_INVALID` for any other
1992
- * value.
1853
+ * This is a name that {@link registerTokenizer} bound. Pass `null` to return
1854
+ * to the tokeniser of the language.
1855
+ */
1856
+ tokenizer?: string | null;
1857
+ /**
1858
+ * This is a name that {@link registerStopWords} bound, or a list of words.
1859
+ * Pass `null` to return to the stop words of the language.
1993
1860
  */
1994
- rerankTimeout?: number;
1995
- /**
1996
- * A query may rerank at most this many of its top hits, which caps the
1997
- * documents that one query sends to a model. Set a whole number from 1 to
1998
- * 1,000, or leave it out for 100; {@link createNarsil} throws
1999
- * `CONFIG_INVALID` for any other value.
2000
- */
2001
- maxRerankWindow?: number;
2002
- /** These settings recover the writes made since the last snapshot. */
2003
- durability?: DurabilityConfig;
2004
- /** These settings control what the engine does when an index's stored analysis differs from its language module. */
2005
- analysis?: AnalysisConfig;
2006
- /** These limits close indexes while keeping their durable files ready to reopen. */
2007
- lifecycle?: IndexLifecycleConfig;
2008
- /**
2009
- * These listeners receive events from the moment that the engine starts.
2010
- * The engine registers each one before it recovers any index, so a listener
2011
- * here receives the `layoutUpgrade` events of that recovery, which come
2012
- * before {@link createNarsil} returns the engine. For a name outside
2013
- * {@link NarsilEventMap}, or an entry that is not a function,
2014
- * {@link createNarsil} throws `CONFIG_INVALID`.
2015
- */
2016
- events?: NarsilEventHandlers;
2017
- /**
2018
- * This is the most work that the engine may do on the pattern tests and
2019
- * phrases of one search, counted over every partition that it searches. For
2020
- * a phrase, the engine adds one unit for each posting of its starting word
2021
- * that it visits, and one for each position that it compares. For a pattern
2022
- * test, it adds one unit for each run of three code points that it looks up in a pattern
2023
- * index, one for each entry that it reads from a pattern index, and one for
2024
- * each step of its matcher. For a text whose case fold is shorter than three
2025
- * code points, it counts each document that it checks as an entry that it
2026
- * reads. It counts an `in` or `nin` test as one `eq` test for each distinct
2027
- * value in its list. For an `eq` test with a `tolerance`, it also adds one
2028
- * unit for each cell that it fills in the table of edit distances between
2029
- * the text and a value. It also counts the preparation of that test once for
2030
- * a search, however many worker copies prepare it. Once the count passes the
2031
- * cap, the engine throws `SEARCH_WORK_CAP_EXCEEDED`. The cap
2032
- * defaults to 25,000,000 units. For any value other than a whole number from
2033
- * 1 to `Number.MAX_SAFE_INTEGER`, {@link createNarsil} throws
2034
- * `CONFIG_INVALID`.
2035
- */
2036
- patternWorkCap?: number;
2037
- /**
2038
- * These fractions set the memory levels at which the engine stops and resumes
2039
- * accepting inserts and updates, so that a write cannot take the process past
2040
- * its memory limit. Inside a cluster node, the node's own memory settings
2041
- * apply in place of these. For a fraction outside the range that
2042
- * {@link MemoryConfig} describes, {@link createNarsil} throws `CONFIG_INVALID`
2043
- * on Node.js and on a phone. A browser reports no memory limit, so the
2044
- * engine there ignores this setting and leaves it unchecked.
2045
- */
2046
- memory?: MemoryConfig;
1861
+ stopWords?: string | readonly string[] | ReadonlySet<string> | null;
1862
+ }
1863
+ /**
1864
+ * Changes how an index turns text into terms while the index keeps answering
1865
+ * searches.
1866
+ *
1867
+ * @public
1868
+ */
1869
+ interface AnalysisOperations {
1870
+ /**
1871
+ * Gives you an index that matches text under new settings, while the index
1872
+ * keeps answering searches and accepting writes.
1873
+ *
1874
+ * The engine builds the new terms beside the old ones. Searches keep matching
1875
+ * under the old settings during that time, while every write that the engine
1876
+ * accepts reaches the new terms. Each search matches under one set of
1877
+ * settings, either the old or the new, and the rebuild leaves vectors alone.
1878
+ * The promise resolves once a durable checkpoint holds the new terms, or once
1879
+ * the switch happens on an engine without durability. After a restart at any
1880
+ * point, the engine goes on to finish the change.
1881
+ *
1882
+ * @param indexName - The index to change.
1883
+ * @param change - The settings to change. A change to the values that the
1884
+ * index already holds completes with no rebuild.
1885
+ * @throws A `NarsilError` with `LANGUAGE_NOT_SUPPORTED` for an unregistered
1886
+ * language, with `CONFIG_INVALID` for an unregistered name, a tokeniser
1887
+ * instance, a stop word function, or a synonym word that breaks the synonym
1888
+ * rules under the new settings, with `ANALYSIS_REBUILD_MEMORY_EXCEEDED` when a
1889
+ * second copy of the terms does not fit in memory, with
1890
+ * `ANALYSIS_CHANGE_REPLACED` when a later change or a restore replaces this
1891
+ * one or when a restore of the index is in flight, with
1892
+ * `ANALYSIS_CHANGE_NOT_READY` when the previous change has no durable
1893
+ * checkpoint yet, with `PERSISTENCE_SAVE_FAILED` when the new terms
1894
+ * answer searches before a durable checkpoint holds them, and with
1895
+ * `PARTITION_REBALANCING_BACKPRESSURE` during a rebalance.
1896
+ */
1897
+ changeAnalysis(indexName: string, change: AnalysisChange): Promise<void>;
2047
1898
  }
1899
+
2048
1900
  /**
2049
- * The memory levels at which an engine stops and resumes accepting inserts and
2050
- * updates.
1901
+ * Changes the BM25 setting of a live index, which
1902
+ * {@link IndexConfig.bm25} sets when the index is created.
2051
1903
  *
2052
- * The engine measures its process memory and its heap before a write whenever
2053
- * its latest measurement is more than one second old. It counts as full once
2054
- * either figure passes `blockWritesAbove` of its limit, and as clear again once
2055
- * both fall below `resumeWritesBelow`, so that an engine near the threshold
2056
- * does not switch writes on and off. While the engine is full, it refuses every
2057
- * insert and update with `MEMORY_WRITE_BLOCKED` and the reason `memory_full`,
2058
- * and it accepts removes, searches, and document reads, so that you can free
2059
- * memory by removing documents. It also refuses a document whose indexing could
2060
- * take the memory in use past the block level, with the reason
2061
- * `write_would_fill_memory`. In a batch, it refuses that document and every
2062
- * later one, and it keeps the documents that it has already indexed. A runtime
2063
- * that reports no memory limit, such as a browser, leaves every write
2064
- * unchecked.
1904
+ * @public
1905
+ */
1906
+ interface BM25Operations {
1907
+ /**
1908
+ * Replaces the BM25 setting of an index, so that every search that starts
1909
+ * after the promise resolves scores under the new setting.
1910
+ *
1911
+ * The call replaces the whole setting, so a value that it leaves out returns
1912
+ * to its default, and `{}` clears the setting. The engine rebuilds nothing,
1913
+ * because the setting changes no stored token. It saves the setting with the
1914
+ * index, so the setting stays in place after a restart, and every snapshot
1915
+ * of the index includes it. Where the index has copies on worker threads,
1916
+ * the promise resolves only once every copy holds the new setting. A cursor
1917
+ * from before the change keeps working, and its next pages can repeat or
1918
+ * skip documents, because the scores that order them can change.
1919
+ *
1920
+ * @param indexName - The index whose setting the engine replaces.
1921
+ * @param bm25 - The new setting, in the shape that {@link BM25Params} describes.
1922
+ * @throws A `NarsilError` with `CONFIG_INVALID` when `k1` is not a number from
1923
+ * 0 to 1,000, when `b` is not a number from 0 to 1, or when `fields` holds a
1924
+ * name that is not a text field. The index then keeps the setting that it
1925
+ * held before the call.
1926
+ */
1927
+ updateBM25(indexName: string, bm25: BM25Params): Promise<void>;
1928
+ }
1929
+
1930
+ /**
1931
+ * The bytes that {@link Narsil.restore} and {@link Narsil.importDocumentExport}
1932
+ * accept, as one array, a stream of chunks, or an async iterable of chunks,
1933
+ * such as a Node.js file stream.
1934
+ *
1935
+ * @public
1936
+ */
1937
+ type ByteSource = Uint8Array | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
1938
+
1939
+ /**
1940
+ * Opens and closes durable indexes without deleting them.
2065
1941
  *
2066
1942
  * @public
2067
1943
  */
2068
- interface MemoryConfig {
1944
+ interface IndexLifecycleOperations {
2069
1945
  /**
2070
- * The engine counts as full once either memory figure passes this fraction
2071
- * of its limit. It must lie above `resumeWritesBelow` and at most 1, and it
2072
- * is 0.9 where you set none. On Node.js, the engine compares its heap with
2073
- * the smaller of this setting and 0.75, because V8 stops a process after four
2074
- * full collections in a row that each leave the old generation holding at
2075
- * least 0.8 of its limit.
1946
+ * Loads a closed index from its durable checkpoint and resets a parked recovery failure.
1947
+ *
1948
+ * @param indexName - The index to load.
1949
+ * @returns A promise that settles when the index is ready for operations.
2076
1950
  */
2077
- blockWritesAbove?: number;
1951
+ open(indexName: string): Promise<void>;
2078
1952
  /**
2079
- * A full engine accepts writes again once both memory figures fall below
2080
- * this fraction of their limits. It must lie above 0 and below
2081
- * `blockWritesAbove`, and it is 0.8 where you set none. On Node.js, the
2082
- * engine compares its heap with the smaller of this setting and 0.65, for the
2083
- * same reason that it caps the heap side of `blockWritesAbove` at 0.75.
1953
+ * Drains active work, checkpoints the index, releases its memory, and keeps its durable files.
1954
+ *
1955
+ * @param indexName - The index to close.
1956
+ * @returns A promise that settles after the index releases its memory.
2084
1957
  */
2085
- resumeWritesBelow?: number;
1958
+ close(indexName: string): Promise<void>;
2086
1959
  }
1960
+
2087
1961
  /**
2088
- * Limits on the indexes one engine keeps open in memory.
1962
+ * The device sync setting of one index, which {@link SyncOperations.updateSync} takes.
1963
+ *
1964
+ * Turn sync on only for an index whose every document belongs to one user, because every device that syncs the index
1965
+ * receives the whole index. Create one index for each user, and leave sync off for a public index or for an index that
1966
+ * holds the data of several users.
2089
1967
  *
2090
1968
  * @public
2091
1969
  */
2092
- interface IndexLifecycleConfig {
2093
- /** An index closes after this many milliseconds without activity. */
2094
- idleTimeoutMs?: number;
2095
- /** The engine keeps at most this many indexes open at once. */
2096
- maxOpenIndexes?: number;
2097
- /** Open indexes may use at most this many estimated bytes in total. */
2098
- maxOpenBytes?: number;
2099
- /** At most this many callers may wait behind one index reopen. */
2100
- maxReopenWaiters?: number;
1970
+ interface SyncSetting {
1971
+ /** This turns sync on or off. Turning it on gives the index a new epoch, so every synced device loads a new copy. */
1972
+ enabled: boolean;
1973
+ /** This is the age in milliseconds after which the server deletes a log segment from history. It defaults to 30
1974
+ * days. */
1975
+ historyMaxAgeMs?: number;
1976
+ /** This is the byte count above which the server deletes the oldest log segment from history. It defaults to the
1977
+ * length of the published snapshot. */
1978
+ historyMaxBytes?: number;
2101
1979
  }
2102
1980
  /**
2103
- * Describes an index whose stored terms came from an older analysis than the
2104
- * one its language module carries today.
1981
+ * The device sync state of one index, which {@link SyncOperations.getSync} returns.
2105
1982
  *
2106
- * The engine hands this to {@link AnalysisConfig.onStaleAnalysis} together
2107
- * with the rebuild that fixes it, so you decide when the work runs.
1983
+ * @public
1984
+ */
1985
+ interface SyncStatus extends SyncSetting {
1986
+ /** This is true once a device has asked for the published snapshot, from when the server keeps history. */
1987
+ active: boolean;
1988
+ /** This is the index epoch, 32 lowercase hexadecimal digits, or `null` while sync is off. */
1989
+ epoch: string | null;
1990
+ }
1991
+ /**
1992
+ * The methods that turn device sync on and off for an index.
2108
1993
  *
2109
1994
  * @public
2110
1995
  */
2111
- interface StaleAnalysis {
2112
- /** This index holds terms that are out of date. */
2113
- indexName: string;
2114
- /** The index was built with this language module. */
2115
- language: string;
2116
- /** The index recorded this revision when it was written, and `null` for an index written before revisions existed. */
2117
- storedRevision: string | null;
2118
- /** The language module carries this revision now. */
2119
- currentRevision: string;
2120
- /** The rebuild reindexes this many documents. */
2121
- documentCount: number;
1996
+ interface SyncOperations {
1997
+ /**
1998
+ * Replaces the device sync setting of an index.
1999
+ *
2000
+ * Turning sync on gives the index a new epoch. Changing a history limit while sync is on keeps the epoch. Turning
2001
+ * sync off deletes the published snapshot and the history, and the server closes every feed of the index with
2002
+ * close code 4410. The engine saves the setting with the index, so the setting stays in place after a restart, and
2003
+ * no snapshot of the index includes it.
2004
+ *
2005
+ * @param indexName - The index whose setting the engine replaces.
2006
+ * @param setting - The new setting.
2007
+ * @throws A `NarsilError` with `SYNC_DURABILITY_REQUIRED` when the engine has no write-ahead log durability, and
2008
+ * with `CONFIG_INVALID` when a history limit is not a positive whole number.
2009
+ */
2010
+ updateSync(indexName: string, setting: SyncSetting): Promise<void>;
2011
+ /**
2012
+ * Returns the device sync state of an index.
2013
+ *
2014
+ * @param indexName - The index whose state the engine returns.
2015
+ * @returns The setting, whether a device has asked for the snapshot, and the epoch.
2016
+ * @throws A `NarsilError` with `INDEX_NOT_FOUND` when no index has that name.
2017
+ */
2018
+ getSync(indexName: string): Promise<SyncStatus>;
2122
2019
  }
2020
+
2123
2021
  /**
2124
- * What the engine does when an index's stored terms no longer match the
2125
- * analysis its language module produces.
2022
+ * Reads and replaces the synonym set of an index, which
2023
+ * {@link IndexConfig.synonyms} sets when the index is created.
2126
2024
  *
2127
- * A stale index answers text queries from terms an older analysis wrote, and
2128
- * every such result reports `analysisStale`. Rebuilding fixes it, and this
2129
- * setting controls whether the engine starts that work itself.
2025
+ * @public
2026
+ */
2027
+ interface SynonymOperations {
2028
+ /**
2029
+ * Replaces the synonym set of an index, so that every search that starts
2030
+ * after the promise resolves expands its words with the new set.
2031
+ *
2032
+ * The engine applies the set without rebuilding the index, because a
2033
+ * synonym set changes no stored token. It saves the set with the index, so
2034
+ * the set stays in place after a restart, and every snapshot of the index
2035
+ * includes it. Where the index has copies on worker threads, the promise
2036
+ * resolves only once every copy uses the new set. Pass an empty list to
2037
+ * remove the set.
2038
+ *
2039
+ * @param indexName - The index whose set the engine replaces.
2040
+ * @param synonyms - The new set, in the shape that {@link SynonymRule}
2041
+ * describes.
2042
+ * @throws A `NarsilError` with `CONFIG_INVALID` when a rule breaks that
2043
+ * shape, when a word analyses to no token or to more than one, or when the
2044
+ * set passes 100,000 rules, 500,000 words, or 4,194,304 bytes of words in
2045
+ * UTF-8. The index then keeps the set that it held before the call.
2046
+ */
2047
+ updateSynonyms(indexName: string, synonyms: SynonymRule[]): Promise<void>;
2048
+ /**
2049
+ * Returns the synonym set of an index with every word as the caller wrote
2050
+ * it, or an empty list when the index holds no set.
2051
+ *
2052
+ * @param indexName - The index whose set the engine returns.
2053
+ */
2054
+ getSynonyms(indexName: string): Promise<SynonymRule[]>;
2055
+ }
2056
+
2057
+ /**
2058
+ * Reports on and rebuilds the graphs of an index's vector fields.
2130
2059
  *
2131
2060
  * @public
2132
2061
  */
2133
- interface AnalysisConfig {
2134
- /** `auto` rebuilds a stale index in the background, and `manual` leaves it to you. The engine rebuilds automatically by default. */
2135
- rebuild?: 'auto' | 'manual';
2062
+ interface VectorMaintenanceOperations {
2063
+ /**
2064
+ * Rebuilds a vector field's graph without the tombstones removed documents
2065
+ * left behind, which returns the memory they held and speeds searches up.
2066
+ *
2067
+ * Read {@link VectorMaintenanceOperations.vectorMaintenanceStatus} first to
2068
+ * see whether the work is worth its cost.
2069
+ *
2070
+ * @param indexName - The index holding the field.
2071
+ * @param fieldName - The vector field to compact. Omit it to compact every
2072
+ * vector field in the index.
2073
+ */
2074
+ compactVectors(indexName: string, fieldName?: string): Promise<void>;
2075
+ /**
2076
+ * Rebuilds a vector field's graph from scratch, which recovers the recall a
2077
+ * long run of inserts and removals costs.
2078
+ *
2079
+ * This is heavier than {@link VectorMaintenanceOperations.compactVectors} and
2080
+ * gives a better graph, so run it once a search starts missing documents it
2081
+ * should find, rather than on a schedule.
2082
+ *
2083
+ * @param indexName - The index holding the field.
2084
+ * @param fieldName - The vector field to rebuild. Omit it to rebuild every
2085
+ * vector field in the index.
2086
+ */
2087
+ optimizeVectors(indexName: string, fieldName?: string): Promise<void>;
2136
2088
  /**
2137
- * Called once for each stale index the engine finds.
2089
+ * Reports the state of each vector field in an index, and what compaction or
2090
+ * optimisation would cost.
2138
2091
  *
2139
- * @param index - The index that is stale, and how far behind it is.
2140
- * @param rebuild - Starts the rebuild and resolves once every partition
2141
- * carries current terms. Under `manual` nothing rebuilds until you call it.
2092
+ * @param indexName - The index to describe.
2093
+ * @returns One entry per vector field, or an empty list while the index is closed.
2142
2094
  */
2143
- onStaleAnalysis?(index: StaleAnalysis, rebuild: () => Promise<void>): void | Promise<void>;
2095
+ vectorMaintenanceStatus(indexName: string): VectorMaintenanceResult[];
2144
2096
  }
2097
+
2145
2098
  /**
2146
- * Write-ahead logging and checkpointing, which recover the writes made since
2147
- * the last snapshot.
2148
- *
2149
- * The `wal` tier logs every mutation before applying it, so a crash costs
2150
- * nothing once the log replays. The `snapshot` tier writes whole partitions on
2151
- * an interval, which is cheaper to run and loses whatever arrived after the
2152
- * last write.
2153
- *
2154
- * @public
2155
- */
2156
- interface DurabilityConfig {
2157
- /** `wal` logs every mutation, and `snapshot` writes whole partitions on an interval. */
2158
- tier?: 'wal' | 'snapshot';
2159
- /** The engine writes the log and its checkpoints into this directory. */
2160
- directory?: string;
2161
- /** `sync` flushes before a write resolves, and `async` flushes on the interval below. */
2162
- mode?: 'sync' | 'async';
2163
- /** In `async` mode the engine flushes this many milliseconds apart. */
2164
- flushIntervalMs?: number;
2165
- /** The log rolls over to a new segment once it reaches this size. */
2166
- segmentMaxBytes?: number;
2167
- /** The engine checkpoints this many milliseconds apart, which shortens the replay a restart has to do. */
2168
- checkpointIntervalMs?: number;
2169
- /** This many mutations trigger a checkpoint before the interval elapses. */
2170
- checkpointMutationThreshold?: number;
2171
- /**
2172
- * The engine merges a partition's checkpoint segments once that partition
2173
- * holds more than this many of them, 12 by default. The value is a whole
2174
- * number of segments.
2175
- */
2176
- compactionThreshold?: number;
2099
+ * Adds, replaces, and removes documents, and waits for the worker copies to
2100
+ * catch up with those writes.
2101
+ *
2102
+ * A write returns once the main copy holds it, and the worker copies apply
2103
+ * it afterwards, so a query that a copy answers can come back without a write
2104
+ * that returned before it. Every write takes a `wait` option for the cases
2105
+ * where the next query has to see it.
2106
+ *
2107
+ * @public
2108
+ */
2109
+ interface DocumentWriteOperations {
2110
+ /**
2111
+ * Adds one document to an index and returns the id it is stored under.
2112
+ *
2113
+ * The id comes from the `docId` argument when you pass one, otherwise from
2114
+ * the document's own `id` field, and otherwise the engine generates it. Use
2115
+ * {@link DocumentWriteOperations.insertBatch} for a large load, so that one
2116
+ * bad document cannot abandon the rest.
2117
+ *
2118
+ * @param indexName - The index that receives the document.
2119
+ * @param document - Its fields must match the types the schema declares.
2120
+ * @param docId - Pass an id to control it yourself, or omit it and read the
2121
+ * returned value. An id that differs from the document's own `id` field
2122
+ * raises `DOC_VALIDATION_FAILED`, because the stored document would
2123
+ * otherwise contradict the key that it is stored under.
2124
+ * @param options - Per-write settings, such as skipping the defensive copy
2125
+ * or waiting for every worker copy to apply the write.
2126
+ * @returns The id the document is stored under.
2127
+ */
2128
+ insert(indexName: string, document: AnyDocument, docId?: string, options?: InsertOptions): Promise<string>;
2129
+ /**
2130
+ * Adds many documents in one pass and reports each one's outcome.
2131
+ *
2132
+ * A document the engine rejects appears in `failed` with the error that
2133
+ * rejected it, and every other document is still written, which is what
2134
+ * makes this the call to load a corpus with.
2135
+ *
2136
+ * @param indexName - The index that receives the documents.
2137
+ * @param documents - The documents to write, each carrying its own id or
2138
+ * leaving the engine to generate one.
2139
+ * @param options - Per-write settings applied to every document.
2140
+ * @returns The ids written, and each rejection with its error.
2141
+ */
2142
+ insertBatch(indexName: string, documents: AnyDocument[], options?: InsertOptions): Promise<BatchResult>;
2143
+ /**
2144
+ * Removes one document.
2145
+ *
2146
+ * @param indexName - The index holding the document.
2147
+ * @param docId - The document to remove.
2148
+ * @param options - Per-write settings, such as waiting for every worker
2149
+ * copy to apply the removal.
2150
+ * @throws A `NarsilError` with `DOC_NOT_FOUND` when the index holds no such
2151
+ * document.
2152
+ */
2153
+ remove(indexName: string, docId: string, options?: WriteOptions): Promise<void>;
2154
+ /**
2155
+ * Removes many documents in one pass and reports each one's outcome.
2156
+ *
2157
+ * @param indexName - The index holding the documents.
2158
+ * @param docIds - The documents to remove.
2159
+ * @param options - Per-write settings applied to the whole batch.
2160
+ * @returns The ids removed, and each failure with its error.
2161
+ */
2162
+ removeBatch(indexName: string, docIds: string[], options?: WriteOptions): Promise<BatchResult>;
2163
+ /**
2164
+ * Replaces a stored document with the one you pass.
2165
+ *
2166
+ * The engine removes the old document and indexes the new one, so the
2167
+ * document you supply has to be complete, with every field it should hold
2168
+ * afterwards.
2169
+ *
2170
+ * @param indexName - The index holding the document.
2171
+ * @param docId - The document to replace.
2172
+ * @param document - The complete replacement.
2173
+ * @param options - Per-write settings, such as waiting for every worker
2174
+ * copy to apply the replacement.
2175
+ */
2176
+ update(indexName: string, docId: string, document: AnyDocument, options?: WriteOptions): Promise<void>;
2177
+ /**
2178
+ * Replaces many documents in one pass and reports each one's outcome.
2179
+ *
2180
+ * @param indexName - The index holding the documents.
2181
+ * @param updates - Each id with the complete document that replaces it.
2182
+ * @param options - Per-write settings applied to the whole batch.
2183
+ * @returns The ids replaced, and each failure with its error.
2184
+ */
2185
+ updateBatch(indexName: string, updates: Array<{
2186
+ docId: string;
2187
+ document: AnyDocument;
2188
+ }>, options?: WriteOptions): Promise<BatchResult>;
2189
+ /**
2190
+ * Resolves once every worker copy of an index has applied every write that
2191
+ * returned before the call.
2192
+ *
2193
+ * Call this after a run of writes, or pass `wait: true` on one write,
2194
+ * before a query that has to see them. An index that holds no copies
2195
+ * resolves at once.
2196
+ *
2197
+ * @param indexName - The index whose copies have to catch up.
2198
+ */
2199
+ waitForWrites(indexName: string): Promise<void>;
2177
2200
  }
2201
+
2178
2202
  /**
2179
- * Which queries the main copy of an index answers once the index holds worker
2180
- * copies. Under `lone`, the main copy answers a query the engine receives
2181
- * while no copy holds one, on an index of at most 50,000 documents. Once
2182
- * every copy is busy, it also answers one query per turn of the event loop.
2183
- * Under `none`, every query on an index that holds copies goes to one of
2184
- * them, while the main copy still answers a query on an index whose copies
2185
- * are loading.
2203
+ * What {@link Narsil.snapshot} adds to the archive beyond the checkpoint.
2186
2204
  *
2187
2205
  * @public
2188
2206
  */
2189
- type MainCopyQueries = 'lone' | 'none';
2207
+ interface SnapshotOptions {
2208
+ /**
2209
+ * Set this to add the index's popular query history, which holds raw
2210
+ * searches, so that a restore on a node with the same key keeps the counts.
2211
+ * Defaults to false, because a backup that holds history can keep searches
2212
+ * past their retention.
2213
+ */
2214
+ queryHistory?: boolean;
2215
+ }
2190
2216
  /**
2191
- * How the engine holds worker copies of its indexes, and how many threads
2192
- * they may use.
2217
+ * The search engine, and everything you do with it.
2193
2218
  *
2194
- * A small index answers fastest on the main thread. Once an index holds as
2195
- * many documents as the copy threshold, the engine loads a copy of it onto
2196
- * every worker thread, and each query then runs whole on the copy with the
2197
- * fewest queries in flight. The same switch governs the vector search pool.
2219
+ * One instance holds every index you create, so an application usually keeps a
2220
+ * single engine for its lifetime and reaches each index by name. Build one
2221
+ * with {@link createNarsil}. Its write, open and close, synonym, analysis, BM25,
2222
+ * device sync, vector maintenance, and adapter registration methods come from
2223
+ * {@link DocumentWriteOperations}, {@link IndexLifecycleOperations},
2224
+ * {@link SynonymOperations}, {@link AnalysisOperations},
2225
+ * {@link BM25Operations}, {@link SyncOperations},
2226
+ * {@link VectorMaintenanceOperations}, and
2227
+ * {@link AdapterRegistrationOperations}.
2198
2228
  *
2199
2229
  * @public
2200
2230
  */
2201
- interface WorkerConfig {
2231
+ interface Narsil extends IndexLifecycleOperations, DocumentWriteOperations, SynonymOperations, AnalysisOperations, BM25Operations, SyncOperations, VectorMaintenanceOperations, AdapterRegistrationOperations {
2232
+ /**
2233
+ * Creates an index you can insert documents into and query.
2234
+ *
2235
+ * The schema sets the type of each field, marks which fields you can
2236
+ * filter and sort on, and controls how the engine tokenises text. The
2237
+ * `language` option picks the analyser that stems those text fields.
2238
+ *
2239
+ * @param name - Every later call uses this name to reach the index.
2240
+ * @param config - This carries the schema, and the language, partitioning,
2241
+ * and scoring settings.
2242
+ */
2243
+ createIndex(name: string, config: IndexConfig): Promise<void>;
2244
+ /**
2245
+ * Removes an index and everything it holds, including whatever persistence
2246
+ * wrote for it. The documents do not come back.
2247
+ *
2248
+ * @param name - The index to drop.
2249
+ */
2250
+ dropIndex(name: string): Promise<void>;
2202
2251
  /**
2203
- * Whether the engine may hold worker copies and a vector search pool. It is
2204
- * on everywhere but a browser page. Set it to false to hold the process to
2205
- * one thread, which leaves both pools absent. Where a bundler folds
2206
- * `@delali/narsil` into an application bundle, the engine finds no worker
2207
- * entry: left unset, it answers on one thread and prints one warning, and
2208
- * set to true, `createNarsil` throws `CONFIG_INVALID`.
2252
+ * Lists every index this engine holds, with its size and its language.
2253
+ *
2254
+ * @returns One entry per index, in creation order.
2209
2255
  */
2210
- enabled?: boolean;
2256
+ listIndexes(): IndexInfo[];
2211
2257
  /**
2212
- * The keyword copies and the vector search pool share this many threads
2213
- * between them, half each, in an embedded engine, so a budget of 4 gives 2
2214
- * keyword copies and 2 vector search workers. The HTTP server holds a copy
2215
- * on every one of them and receives requests there. The engine takes the
2216
- * host's cores minus one by default, between 2 and 8. It caps a value that
2217
- * you set at 31, which is how many scratch slots the shared vector arena
2218
- * reserves.
2258
+ * Returns one index's document count, partition count, memory estimate,
2259
+ * language, and schema.
2260
+ *
2261
+ * @param indexName - The index to describe.
2262
+ * @returns The index's current figures.
2263
+ * @throws A `NarsilError` with `INDEX_NOT_FOUND` for an unknown name.
2219
2264
  */
2220
- count?: number;
2221
- /** An index gains worker copies once it holds this many documents, 1,000 by default. */
2222
- promotionThreshold?: number;
2265
+ getStats(indexName: string): IndexStats;
2223
2266
  /**
2224
- * The engine drops an index's copies after this many milliseconds without a
2225
- * read or a write, five minutes by default, and loads them again on the
2226
- * next request while the main copy answers it. It may not exceed
2227
- * `lifecycle.idleTimeoutMs`, and where it is unset the copies take the
2228
- * smaller of five minutes and that interval.
2267
+ * Returns per-partition figures for one index, which is where you look when
2268
+ * an index grows unevenly or a rebalance is worth running.
2269
+ *
2270
+ * @param indexName - The index to describe.
2271
+ * @returns One entry per open partition, in partition order, or an empty list while the index is closed.
2229
2272
  */
2230
- idleTimeoutMs?: number;
2273
+ getPartitionStats(indexName: string): PartitionStatsResult[];
2231
2274
  /**
2232
- * Which queries the main copy answers, `lone` by default. Set `none` where
2233
- * the main thread also serves the host's own work, such as HTTP requests,
2234
- * because a query answered on the main copy then delays every other request
2235
- * waiting on that thread. A server created with `createServer` sets `none` on
2236
- * an engine that leaves this unset.
2275
+ * Fetches one stored document by id, without searching.
2276
+ *
2277
+ * A vector field comes back as a `Float32Array`, whatever form you give it.
2278
+ * `JSON.stringify` writes one as an object keyed by index, so convert it
2279
+ * with `Array.from`, or project the field away, before you serialise the
2280
+ * document yourself. The HTTP routes convert it for you.
2281
+ *
2282
+ * @param indexName - The index holding the document.
2283
+ * @param docId - The document to fetch.
2284
+ * @returns The document, or `undefined` when the index holds no such id.
2285
+ */
2286
+ get(indexName: string, docId: string): Promise<AnyDocument | undefined>;
2287
+ /**
2288
+ * Fetches many stored documents by id in one pass.
2289
+ *
2290
+ * @param indexName - The index holding the documents.
2291
+ * @param docIds - The documents to fetch.
2292
+ * @returns A map from id to document, holding an entry for each id that
2293
+ * exists and nothing for the rest.
2294
+ */
2295
+ getMultiple(indexName: string, docIds: string[]): Promise<Map<string, AnyDocument>>;
2296
+ /**
2297
+ * Reports whether an index holds a document, without reading it.
2298
+ *
2299
+ * @param indexName - The index to check.
2300
+ * @param docId - The document to look for.
2301
+ * @returns True when the index holds that id.
2237
2302
  */
2238
- mainCopyQueries?: MainCopyQueries;
2303
+ has(indexName: string, docId: string): Promise<boolean>;
2239
2304
  /**
2240
- * Each worker imports this module on start-up, which is how a worker reaches
2241
- * a custom tokeniser or language. Give an absolute path or a URL, such as
2242
- * `new URL('./bootstrap.js', import.meta.url).href`, because a worker
2243
- * resolves a relative specifier against Narsil's own directory. A relative
2244
- * value raises `CONFIG_INVALID`.
2305
+ * Counts the documents an index holds.
2306
+ *
2307
+ * @param indexName - The index to count.
2308
+ * @returns The document count across every partition.
2309
+ */
2310
+ countDocuments(indexName: string): Promise<number>;
2311
+ /**
2312
+ * Reads one page of stored documents in document-id order, without
2313
+ * searching, which is how you page through a whole index.
2314
+ *
2315
+ * Leave `cursor` out for the first page, pass the returned cursor back for
2316
+ * each page after it, and stop when the cursor comes back null. A document
2317
+ * that stays in the index for the whole listing comes back exactly once. The
2318
+ * engine skips a document you remove part-way through. It returns one you
2319
+ * insert part-way through once that document's id sorts above the cursor.
2320
+ * The cursor holds no engine state, so it stays valid after a restart, a
2321
+ * snapshot restore, and a rebalance.
2322
+ *
2323
+ * The engine compares document ids by their UTF-16 code units, so `"10"`
2324
+ * sorts ahead of `"9"`.
2325
+ *
2326
+ * Set `document` to drop a vector field, because the engine otherwise reads
2327
+ * every listed document's vector back out of the index.
2328
+ *
2329
+ * @typeParam T - Shape of the stored documents, which flows through to each
2330
+ * entry's `document`.
2331
+ * @param indexName - The index to walk.
2332
+ * @param params - These set the cursor, the page size, the filter, and how
2333
+ * much of each document comes back.
2334
+ * @returns The page, the cursor for the next page, how many documents the
2335
+ * listing walks in total, and the time the page took.
2336
+ */
2337
+ listDocuments<T = AnyDocument>(indexName: string, params?: ListParams): Promise<ListResult<T>>;
2338
+ /**
2339
+ * Runs a search against an index and returns the ranked hits.
2340
+ *
2341
+ * One call covers keyword search, vector search, and a hybrid of the two,
2342
+ * chosen by the `mode` parameter. BM25 ranks keyword results by default.
2343
+ * Every hit carries its score and its document, along with highlights when
2344
+ * you ask for them.
2345
+ *
2346
+ * @typeParam T - Shape of the stored documents, which flows through to each
2347
+ * hit's `document`.
2348
+ * @param indexName - The index the search runs against.
2349
+ * @param params - These set the search term, filters, field boosts, sorting,
2350
+ * facets, highlighting, and the result limit.
2351
+ * @returns The hits, the total count, the elapsed time, and any facets or
2352
+ * groups the query asked for.
2353
+ */
2354
+ query<T = AnyDocument>(indexName: string, params: QueryParams): Promise<QueryResult<T>>;
2355
+ /**
2356
+ * Counts what a query would match without building a single hit, which is
2357
+ * how a result-count badge stays cheap. A full-text count also skips scoring
2358
+ * unless the query carries `minScore`, which prunes matches by score, or a
2359
+ * `termMatch` policy other than `any`, which prunes them by term coverage. A
2360
+ * vector or hybrid count still runs its search.
2361
+ *
2362
+ * @param indexName - The index the query would run against.
2363
+ * @param params - The same parameters {@link Narsil.query} takes. Anything
2364
+ * that shapes the output alone, such as `limit` or `highlight`, is ignored.
2365
+ * @returns The match count and the time the count took.
2366
+ */
2367
+ preflight(indexName: string, params: QueryParams): Promise<PreflightResult>;
2368
+ /**
2369
+ * Returns the indexed terms that complete a prefix, ready to offer as
2370
+ * you-type suggestions.
2371
+ *
2372
+ * The terms come back as the index holds them, which means stems unless the
2373
+ * index was created with `surfaceForms`.
2374
+ *
2375
+ * @param indexName - The index to draw completions from.
2376
+ * @param params - The prefix typed so far, and how many completions to
2377
+ * return.
2378
+ * @returns The completions, most widely used first.
2379
+ */
2380
+ suggest(indexName: string, params: SuggestParams): Promise<SuggestResult>;
2381
+ /**
2382
+ * Rebuilds an index's terms from the documents it already stores, and
2383
+ * resolves once every partition carries terms the current language module
2384
+ * produced.
2385
+ *
2386
+ * An index whose stored analysis revision differs from the one its language
2387
+ * module carries answers text queries from terms an earlier analysis wrote,
2388
+ * and every such result reports `analysisStale`. Call this after the engine
2389
+ * reports a stale index to configuration that declined an automatic rebuild.
2390
+ * Calling it for an index whose terms are current does nothing.
2391
+ *
2392
+ * @param indexName - The index whose terms are rebuilt.
2393
+ */
2394
+ rebuildAnalysis(indexName: string): Promise<void>;
2395
+ /**
2396
+ * Returns a stream of the index's snapshot archive. The archive is a pax
2397
+ * file containing the index's configuration and the files of one
2398
+ * checkpoint, and any implementation of the Narsil format can restore it.
2399
+ *
2400
+ * With write-ahead log durability, the engine takes a checkpoint before it
2401
+ * starts the stream, so the archive contains every write that the engine
2402
+ * acknowledged before the call. The engine keeps that checkpoint's files on
2403
+ * disk until the stream ends or you cancel it. Without write-ahead log
2404
+ * durability, the engine builds the archive's files from the index in
2405
+ * memory.
2406
+ *
2407
+ * @param indexName - The index to stream.
2408
+ * @param options - Set `queryHistory` to add the index's popular query
2409
+ * history, which holds raw searches, after the checkpoint's files.
2410
+ * @returns A stream of the archive's bytes, which you can write to a file or
2411
+ * send over a network.
2412
+ */
2413
+ snapshot(indexName: string, options?: SnapshotOptions): Promise<ReadableStream<Uint8Array>>;
2414
+ /**
2415
+ * Creates an index from a snapshot under the name that you pass, replacing
2416
+ * any index of that name.
2417
+ *
2418
+ * The engine accepts the archive that {@link Narsil.snapshot} streams and
2419
+ * the `.nrsl` file of release 0.3. It checks each archive file against its
2420
+ * manifest and loads the restored index beside the existing one, which
2421
+ * answers requests until the swap. A failed restore leaves the existing index
2422
+ * serving, and after a crash the engine reopens either the old or the new one.
2423
+ *
2424
+ * @param indexName - The name that the restored index takes.
2425
+ * @param data - The snapshot's bytes, as an array, a stream, or async chunks.
2426
+ * @throws A `NarsilError` with `PERSISTENCE_LOAD_FAILED` when the archive is
2427
+ * malformed or a file's length differs from the manifest. The engine raises
2428
+ * `PERSISTENCE_CRC_MISMATCH` when a file's checksum differs from its
2429
+ * contents, and `ENVELOPE_VERSION_MISMATCH` when a file has a format version
2430
+ * other than the ones that this release implements. It raises
2431
+ * `CONFIG_INVALID` when the archive's configuration is invalid,
2432
+ * `DOC_VALIDATION_FAILED` when the data is empty or the release 0.3 file is
2433
+ * invalid, `RESTORE_MEMORY_EXCEEDED` when the restored index needs more
2434
+ * memory than the process has free, and `WORKER_TIMEOUT` when a
2435
+ * worker still holds the old index 30 seconds after the engine asks for it.
2436
+ */
2437
+ restore(indexName: string, data: ByteSource): Promise<void>;
2438
+ /**
2439
+ * Returns a stream of the index's document export. The export is JSON Lines
2440
+ * text whose format stays the same in every release, so you can use it to
2441
+ * move an index across releases or between implementations.
2442
+ *
2443
+ * The first line is a header containing the format name, the format
2444
+ * version, and the index configuration. Each later line contains one
2445
+ * document, with its ID under `id` and the value of each vector field as an
2446
+ * array of numbers. With write-ahead log durability, the engine exports every
2447
+ * document from one checkpoint; otherwise, it exports them from the index in
2448
+ * memory at one moment.
2449
+ *
2450
+ * JSON has no type for a date, for raw bytes, or for an infinite number or
2451
+ * `NaN`, so the engine writes each such value as a tag. Each tag is an
2452
+ * object with one key that begins with `$`, such as
2453
+ * `{"$date":[1700000000,123000000]}`. The engine also wraps a stored object
2454
+ * whose only key begins with `$` in an `$object` tag, because the import
2455
+ * decodes every other object of that shape as a tag.
2456
+ *
2457
+ * @param indexName - The index to export.
2458
+ * @returns A stream of the export's UTF-8 bytes.
2459
+ */
2460
+ exportDocuments(indexName: string): Promise<ReadableStream<Uint8Array>>;
2461
+ /**
2462
+ * Imports a document export into the named index. Where the name is free,
2463
+ * the engine creates the index from the export's configuration.
2464
+ *
2465
+ * The engine writes the documents in batches and replaces any document
2466
+ * whose ID the index already contains. Because it replaces existing
2467
+ * documents, you can run an interrupted import again to make the index equal
2468
+ * to the export. When a line is invalid or the engine rejects its document,
2469
+ * the engine records the refusal and continues with the next line.
2470
+ *
2471
+ * The engine converts each tag that {@link Narsil.exportDocuments} writes
2472
+ * into the value that the tag stands for. When an object has one key that
2473
+ * begins with `$` and that key names no tag, or when a tag holds an invalid
2474
+ * value, the engine refuses the line.
2475
+ *
2476
+ * @param indexName - The index that receives the documents.
2477
+ * @param data - The export's bytes, as one array, a stream, or an async
2478
+ * iterable of chunks.
2479
+ * @returns The number of imported documents, the number of refused lines,
2480
+ * and the 1,000 refusals with the lowest line numbers.
2481
+ * @throws A `NarsilError` with `CONFIG_INVALID` when the first line is
2482
+ * anything other than a version 1 header, or when the named index exists
2483
+ * with a different schema.
2484
+ */
2485
+ importDocumentExport(indexName: string, data: ByteSource): Promise<DocumentImportResult>;
2486
+ /**
2487
+ * Writes an index's current state to the durability directory, so a restart
2488
+ * replays less of the log.
2489
+ *
2490
+ * @param indexName - The index to checkpoint.
2491
+ */
2492
+ checkpoint(indexName: string): Promise<void>;
2493
+ /**
2494
+ * Removes every document from an index and keeps the index itself, along
2495
+ * with its schema and settings.
2496
+ *
2497
+ * @param indexName - The index to empty.
2498
+ */
2499
+ clear(indexName: string): Promise<void>;
2500
+ /**
2501
+ * Spreads an index's documents across a different number of partitions.
2502
+ *
2503
+ * The engine keeps answering queries throughout, and it queues the writes
2504
+ * that arrive while the work runs, replaying them in order once it finishes.
2505
+ *
2506
+ * @param indexName - The index to rebalance.
2507
+ * @param targetPartitionCount - Partitions the index ends up with.
2508
+ */
2509
+ rebalance(indexName: string, targetPartitionCount: number): Promise<void>;
2510
+ /**
2511
+ * Changes how an index grows into new partitions, without moving the
2512
+ * documents it already holds.
2513
+ *
2514
+ * @param indexName - The index to reconfigure.
2515
+ * @param config - The partitioning fields to change. Anything you leave out
2516
+ * keeps its current value.
2517
+ */
2518
+ updatePartitionConfig(indexName: string, config: Partial<PartitionConfig>): Promise<void>;
2519
+ /**
2520
+ * Reports what this engine and its host process are using, which is what you
2521
+ * size a host from.
2522
+ *
2523
+ * @returns Process heap figures, the engine's own estimate, and one entry
2524
+ * per worker once the engine has promoted.
2525
+ */
2526
+ getMemoryStats(): Promise<MemoryStats>;
2527
+ /**
2528
+ * Starts delivering one kind of engine event to your listener.
2529
+ *
2530
+ * These events report work the engine does on its own, away from the call
2531
+ * that triggered it, so this is where a failed background save or a worker
2532
+ * crash reaches you.
2533
+ *
2534
+ * @typeParam K - The event name, which fixes the payload the listener gets.
2535
+ * @param event - Which event to listen for.
2536
+ * @param handler - Called once per event.
2537
+ */
2538
+ on<K extends keyof NarsilEventMap>(event: K, handler: (payload: NarsilEventMap[K]) => void): void;
2539
+ /**
2540
+ * Removes a listener {@link Narsil.on} registered, so it receives no
2541
+ * further events.
2542
+ *
2543
+ * @typeParam K - The event name.
2544
+ * @param event - The event the listener was registered for.
2545
+ * @param handler - The same function reference that was registered.
2546
+ */
2547
+ off<K extends keyof NarsilEventMap>(event: K, handler: (payload: NarsilEventMap[K]) => void): void;
2548
+ /**
2549
+ * Closes the engine: it flushes pending writes, ends its workers, and
2550
+ * releases every adapter it opened.
2551
+ *
2552
+ * Call it before the process exits, because writes still in flight are lost
2553
+ * otherwise. The engine rejects new work once this starts.
2245
2554
  */
2246
- bootstrapModule?: string;
2555
+ shutdown(): Promise<void>;
2247
2556
  }
2248
2557
 
2249
- export { type PartitionContext as $, type AnalysisConfig as A, type BatchResult as B, type ClientErrorCode as C, type DocumentImportResult as D, type ErrorCode as E, type FacetConfig as F, type GroupResult as G, type HeldCheckpointReport as H, type IndexInfo as I, type HighlightMatch as J, type Hit as K, type ListParams as L, type MemoryStats as M, NarsilError as N, type HybridConfig as O, type PartitionStatsResult as P, type QueryParams as Q, type IndexContext as R, type ServerErrorCode as S, type IndexLifecycleConfig as T, type InsertContext as U, type VectorMaintenanceResult as V, type ListedDocument as W, type MainCopyQueries as X, type MemoryConfig as Y, type NarsilEventHandlers as Z, type NarsilPlugin as _, ClientErrorCodes as a, type PresenceFilter as a0, type ProcessMemoryReport as a1, type QueryCoverage as a2, type RemoveContext as a3, type RerankConfig as a4, type ScoreComponents as a5, type SearchContext as a6, type SearchMode as a7, type SortField as a8, type SortSpec as a9, type StaleAnalysis as aa, type StringFilter as ab, type TermMatchPolicy as ac, type UpdateContext as ad, type VectorQueryConfig as ae, type WorkerConfig as af, type WorkerContext as ag, type WorkerCopyReport as ah, ErrorCodes as b, type NarsilErrorCode as c, ServerErrorCodes as d, type NarsilConfig as e, type ListResult as f, type SuggestParams as g, type SuggestResult as h, isNarsilError as i, type PreflightResult as j, type IndexStats as k, type NarsilEventMap as l, type QueryResult as m, type GroupConfig as n, type ArrayFilter as o, type ComparisonFilter as p, type DocumentProjection as q, type DurabilityConfig as r, type FacetResult as s, type FieldFilter as t, type FilterExpression as u, type GeoFilter as v, type GeoPolygonFilter as w, type GeoRadiusFilter as x, type GroupReducer as y, type HighlightConfig as z };
2558
+ export { type IndexLifecycleOperations as $, type AnalysisChange as A, type BatchResult as B, type ClientErrorCode as C, type DocumentImportResult as D, type ErrorCode as E, type FacetConfig as F, type GroupResult as G, type FacetResult as H, type IndexInfo as I, type FieldFilter as J, type FilterExpression as K, type ListParams as L, type MemoryStats as M, NarsilError as N, type GeoFilter as O, type PartitionStatsResult as P, type QueryParams as Q, type GeoPolygonFilter as R, type ServerErrorCode as S, type GeoRadiusFilter as T, type GroupReducer as U, type VectorMaintenanceResult as V, type HeldCheckpointReport as W, type HighlightConfig as X, type HighlightMatch as Y, type Hit as Z, type HybridConfig as _, ClientErrorCodes as a, type ListedDocument as a0, type PresenceFilter as a1, type ProcessMemoryReport as a2, type QueryCoverage as a3, type RerankConfig as a4, type ScoreComponents as a5, type SearchMode as a6, type SortField as a7, type SortSpec as a8, type StringFilter as a9, type SyncOperations as aa, type SynonymOperations as ab, type TermMatchPolicy as ac, type VectorMaintenanceOperations as ad, type VectorQueryConfig as ae, type WorkerCopyReport as af, ErrorCodes as b, type NarsilErrorCode as c, ServerErrorCodes as d, type SnapshotOptions as e, type SyncSetting as f, type Narsil as g, type QueryResult as h, isNarsilError as i, type NarsilEventHandlers as j, type SyncStatus as k, type ListResult as l, type SuggestParams as m, type SuggestResult as n, type PreflightResult as o, type IndexStats as p, type NarsilEventMap as q, type GroupConfig as r, type AdapterRegistrationOperations as s, type AnalysisOperations as t, type ArrayFilter as u, type BM25Operations as v, type ByteSource as w, type ComparisonFilter as x, type DocumentProjection as y, type DocumentWriteOperations as z };