@delali/narsil 0.3.1-next.154 → 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 (297) hide show
  1. package/README.md +1 -0
  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-4GCRVRBW.mjs → analysis-change-3TFIHT5E.mjs} +25 -25
  7. package/dist/{react-native/chunks/analysis-change-entry-TNLUC6IZ.mjs → analysis-change-entry-KA6JAO4X.mjs} +1 -1
  8. package/dist/archive-history-E4R73RWD.mjs +29 -0
  9. package/dist/browser/{analysis-change-IXWPXXJJ.mjs → analysis-change-TC36BU47.mjs} +29 -10
  10. package/dist/{analysis-change-entry-KYGSXW4K.mjs → browser/analysis-change-entry-4MH3CZXH.mjs} +1 -1
  11. package/dist/browser/archive-history-4IP5XQZY.mjs +29 -0
  12. package/dist/browser/{chunk-4PD752F6.mjs → chunk-23XRXIBW.mjs} +1 -1
  13. package/dist/browser/chunk-3UIEB4QF.mjs +63 -0
  14. package/dist/browser/{chunk-AJ4HHOVT.mjs → chunk-4EWUGZYZ.mjs} +4 -4
  15. package/dist/browser/{chunk-U2E3HMYW.mjs → chunk-4WCVMOU3.mjs} +1 -1
  16. package/dist/browser/{chunk-QXTPSX2H.mjs → chunk-56W3HQVJ.mjs} +7 -7
  17. package/dist/browser/{chunk-3U3QR5YP.mjs → chunk-5TCXK5SB.mjs} +2 -2
  18. package/dist/browser/chunk-7IGKGWSQ.mjs +79 -0
  19. package/dist/browser/{chunk-J433A7P3.mjs → chunk-A5KUEGDY.mjs} +5 -5
  20. package/dist/browser/{chunk-XRV72TJD.mjs → chunk-ABCXENU5.mjs} +2 -2
  21. package/dist/browser/chunk-ATEBYXP6.mjs +10 -0
  22. package/dist/{react-native/chunks/chunk-3XKMRNRE.mjs → browser/chunk-BXM5XOCA.mjs} +27 -10
  23. package/dist/browser/chunk-CJSYBQ4J.mjs +100 -0
  24. package/dist/{react-native/chunks/chunk-DCKMICOB.mjs → browser/chunk-EXQZGUQH.mjs} +1 -1
  25. package/dist/browser/{chunk-VCOYGVP7.mjs → chunk-FNIFPFB7.mjs} +3 -3
  26. package/dist/browser/{chunk-ML6HY7T7.mjs → chunk-G64Q6OJF.mjs} +1 -1
  27. package/dist/browser/chunk-GPPOG6PT.mjs +9 -0
  28. package/dist/browser/chunk-IKDKX5VQ.mjs +1007 -0
  29. package/dist/browser/{chunk-7TTWXUH6.mjs → chunk-JIJXMI42.mjs} +3 -2
  30. package/dist/browser/chunk-JVBP5EYO.mjs +1106 -0
  31. package/dist/browser/{chunk-2FX6ROWR.mjs → chunk-K4GCSZLI.mjs} +4 -4
  32. package/dist/browser/{chunk-EUNBNLKM.mjs → chunk-K5AXJBLL.mjs} +5 -5
  33. package/dist/browser/chunk-KKAMCABR.mjs +432 -0
  34. package/dist/browser/{chunk-7MEYN7V6.mjs → chunk-LFIWRCEA.mjs} +1 -9
  35. package/dist/browser/chunk-M3MQE2X7.mjs +151 -0
  36. package/dist/browser/{chunk-W5X2UFWQ.mjs → chunk-NLWTBAGB.mjs} +12 -3
  37. package/dist/browser/chunk-OEDCEZXJ.mjs +92 -0
  38. package/dist/browser/{chunk-G7LUMBSG.mjs → chunk-RND5CLX3.mjs} +28 -18
  39. package/dist/browser/{chunk-AYY6PIKL.mjs → chunk-RQBUNZQW.mjs} +2 -2
  40. package/dist/browser/{chunk-C4KS2QNF.mjs → chunk-RRO3EV4C.mjs} +9 -9
  41. package/dist/browser/{chunk-2SHAKW2Z.mjs → chunk-SMEQ36NT.mjs} +80 -134
  42. package/dist/{chunk-KUZKUONM.mjs → browser/chunk-SRMZXJSL.mjs} +1 -0
  43. package/dist/{react-native/chunks/chunk-3O57C2ZO.mjs → browser/chunk-SUDNZKPL.mjs} +2 -2
  44. package/dist/browser/{chunk-SJB6VIZG.mjs → chunk-U3JOQGWX.mjs} +1 -1
  45. package/dist/browser/{chunk-H6QFBMVE.mjs → chunk-XY4VVBBO.mjs} +3 -3
  46. package/dist/browser/{cold-module-VTUGDYNY.mjs → cold-module-NEUGHUPA.mjs} +18 -17
  47. package/dist/browser/durability-config-TIYKW6XX.mjs +89 -0
  48. package/dist/browser/{durability-wiring-GL4A7KDV.mjs → durability-wiring-CVGPRO6D.mjs} +46 -150
  49. package/dist/browser/engine-hooks-YXMPHZKZ.mjs +16 -0
  50. package/dist/browser/{import-YI5GNB4H.mjs → import-OM6QAW45.mjs} +10 -9
  51. package/dist/browser/{methods-LMUTS7OI.mjs → methods-KTQCSIN4.mjs} +3 -3
  52. package/dist/browser/{module-EC3FYW7N.mjs → module-3HNFCBJ5.mjs} +10 -9
  53. package/dist/browser/{module-M4JNBV6V.mjs → module-E33X4AOK.mjs} +14 -13
  54. package/dist/browser/operations-OJ3BXS55.mjs +5 -0
  55. package/dist/browser/{phrase-module-NPYUVX75.mjs → phrase-module-ZXXU7S3B.mjs} +1 -1
  56. package/dist/browser/{pool-WCGDZHJP.mjs → pool-3JLET5RO.mjs} +1 -1
  57. package/dist/browser/restore-hooks-IF2ZROUP.mjs +113 -0
  58. package/dist/browser/restore-queue-ZBS7CJA6.mjs +55 -0
  59. package/dist/browser/{retention-6QMRS5VK.mjs → retention-ASWUHAYI.mjs} +16 -14
  60. package/dist/browser/{runtime-3EW2AGB6.mjs → runtime-OTAGEFQW.mjs} +1 -1
  61. package/dist/browser/{snapshot-DN3CRVUQ.mjs → snapshot-PN7ZW6Q4.mjs} +65 -31
  62. package/dist/browser/start-ZIRB7MQ2.mjs +24 -0
  63. package/dist/browser/{write-WAWAFGKQ.mjs → write-HMDYCTV2.mjs} +14 -13
  64. package/dist/{capabilities-B3Brs1Rc.d.ts → capabilities-Da4ywVVl.d.ts} +35 -3
  65. package/dist/{chunk-K4B7OH65.mjs → chunk-2MANFZJ3.mjs} +2 -2
  66. package/dist/{chunk-O43Z4MS6.mjs → chunk-2NE7VCYE.mjs} +2 -2
  67. package/dist/{chunk-3Y3J4V2R.mjs → chunk-3C7MTCCI.mjs} +1 -1
  68. package/dist/{chunk-RVKFI3A2.mjs → chunk-3HB3PEC6.mjs} +11 -8
  69. package/dist/chunk-3HHQLEEQ.mjs +1092 -0
  70. package/dist/{chunk-HVYICDY3.mjs → chunk-3OH67G7R.mjs} +1 -1
  71. package/dist/{chunk-QKZHLADX.mjs → chunk-3R4UZWQG.mjs} +26 -17
  72. package/dist/{chunk-ZIFJXCKA.mjs → chunk-4BYWRYPM.mjs} +1 -1
  73. package/dist/{chunk-VMXSVVXG.mjs → chunk-4KRC2APY.mjs} +5 -5
  74. package/dist/{chunk-IQ4R2I6N.mjs → chunk-5FLRXF73.mjs} +5 -1
  75. package/dist/chunk-5FVU47TB.mjs +20 -0
  76. package/dist/chunk-5YNRKI2C.mjs +81 -0
  77. package/dist/chunk-6L3XJXGU.mjs +470 -0
  78. package/dist/{chunk-C6ASEFZI.mjs → chunk-6OEGXLBX.mjs} +1 -1
  79. package/dist/{browser/chunk-SIR3LMTV.mjs → chunk-6RC4K46J.mjs} +2 -2
  80. package/dist/{chunk-466PYR4P.mjs → chunk-AILVAOLX.mjs} +2 -2
  81. package/dist/chunk-BDRIVYOK.mjs +72 -0
  82. package/dist/{chunk-TRISKD4Q.mjs → chunk-BY6ZDGYS.mjs} +2 -2
  83. package/dist/{chunk-NZMAXR2S.mjs → chunk-DCNKVEDB.mjs} +121 -10
  84. package/dist/{chunk-C73JLU4E.mjs → chunk-DIBHI6W5.mjs} +2 -2
  85. package/dist/{chunk-VREK3MYG.mjs → chunk-DUOLGBTE.mjs} +3 -3
  86. package/dist/{chunk-USR7FQRZ.mjs → chunk-GH4WQ22V.mjs} +2 -2
  87. package/dist/chunk-GQPTDQCL.mjs +54 -0
  88. package/dist/chunk-H4KHPLHJ.mjs +382 -0
  89. package/dist/{chunk-K7KLL263.mjs → chunk-H6VIGE62.mjs} +12 -12
  90. package/dist/{chunk-YROWNOMH.mjs → chunk-HJJI72X7.mjs} +1 -1
  91. package/dist/{chunk-37IVJLP6.mjs → chunk-HNVVEQP7.mjs} +1 -1
  92. package/dist/{chunk-PFKM7VNZ.mjs → chunk-HW5TNXBO.mjs} +28 -10
  93. package/dist/{chunk-3A5KI24C.mjs → chunk-I54T6CQP.mjs} +1 -1
  94. package/dist/{chunk-YBJDOA2T.mjs → chunk-INJYO3BU.mjs} +1 -1
  95. package/dist/{chunk-KCUIFVVW.mjs → chunk-J4IWBIVY.mjs} +9 -9
  96. package/dist/{chunk-AO2FAYIZ.mjs → chunk-K4ZIGL2O.mjs} +1 -1
  97. package/dist/{chunk-7NTMUDC5.mjs → chunk-KBDBPVLN.mjs} +5 -5
  98. package/dist/{chunk-JFNKIBDT.mjs → chunk-KBKEXQZA.mjs} +2 -2
  99. package/dist/{chunk-REL7LFLR.mjs → chunk-KFLK5NA2.mjs} +3 -3
  100. package/dist/{chunk-WCBA2LVZ.mjs → chunk-KHKIRS5D.mjs} +1 -1
  101. package/dist/{chunk-7QUGDVFC.mjs → chunk-KJ3RTZDJ.mjs} +1 -1
  102. package/dist/{chunk-LSM2YTKM.mjs → chunk-KMUNHGBQ.mjs} +81 -139
  103. package/dist/chunk-KP7TYHWT.mjs +92 -0
  104. package/dist/{chunk-MMBEANB2.mjs → chunk-KPIV4RUC.mjs} +3 -3
  105. package/dist/{chunk-62G63NMH.mjs → chunk-KXCVQWOR.mjs} +4 -4
  106. package/dist/{chunk-TV2L3BN7.mjs → chunk-L7ZD4L3K.mjs} +263 -263
  107. package/dist/{chunk-OKX2BBNW.mjs → chunk-LC3FDWTX.mjs} +2 -2
  108. package/dist/{chunk-URPCYQVJ.mjs → chunk-LHKOSI2J.mjs} +1 -1
  109. package/dist/chunk-LNGE7SLY.mjs +151 -0
  110. package/dist/{react-native/chunks/chunk-CUNGPR5R.mjs → chunk-MP7ABPTD.mjs} +1 -0
  111. package/dist/chunk-MT2NRTA6.mjs +216 -0
  112. package/dist/{chunk-Q3TCTQCC.mjs → chunk-NF4DT3IH.mjs} +1 -1
  113. package/dist/{chunk-3OFU3NJT.mjs → chunk-OIJ64LGT.mjs} +1 -1
  114. package/dist/{chunk-4HWZV5MK.mjs → chunk-PCRA7HTI.mjs} +5 -5
  115. package/dist/chunk-PHQNACDT.mjs +63 -0
  116. package/dist/{chunk-Q7MS6P2J.mjs → chunk-Q622CTMC.mjs} +2 -2
  117. package/dist/{chunk-HVKXNBFL.mjs → chunk-Q7G3BV3Y.mjs} +1 -1
  118. package/dist/{chunk-IBNLW3AV.mjs → chunk-QH3YIQP4.mjs} +20 -6
  119. package/dist/{chunk-B7S6YEBP.mjs → chunk-QJVOLKU6.mjs} +12 -3
  120. package/dist/chunk-QUJHMPTP.mjs +30 -0
  121. package/dist/{chunk-7HCZWC7B.mjs → chunk-RSVULW4Q.mjs} +49 -7
  122. package/dist/{chunk-YPUEV6ZC.mjs → chunk-RVGRFOGN.mjs} +1 -1
  123. package/dist/{chunk-JCLTESFN.mjs → chunk-RZWWB2XR.mjs} +1 -1
  124. package/dist/{chunk-X6NSJYQ3.mjs → chunk-S2EQU2GE.mjs} +13 -13
  125. package/dist/chunk-S5LN746F.mjs +10 -0
  126. package/dist/{chunk-MMEMEUOO.mjs → chunk-SG3JBNHY.mjs} +2 -2
  127. package/dist/{chunk-LKUE5GXS.mjs → chunk-SMVH6JBE.mjs} +2 -2
  128. package/dist/{chunk-IJU7LL7D.mjs → chunk-SY3EWKQY.mjs} +5 -5
  129. package/dist/{chunk-CP5RRPJR.mjs → chunk-TQXHPFWT.mjs} +1 -1
  130. package/dist/{chunk-5KGYQT6W.mjs → chunk-U4BS74YN.mjs} +26 -9
  131. package/dist/{chunk-S2N75OTN.mjs → chunk-UHICS3JI.mjs} +1 -1
  132. package/dist/chunk-UZRZKNNZ.mjs +101 -0
  133. package/dist/{chunk-DMQPFLGI.mjs → chunk-VGF7CFRP.mjs} +5 -5
  134. package/dist/chunk-VHBNF4MA.mjs +543 -0
  135. package/dist/{chunk-BPSKLCS7.mjs → chunk-VQEUR6T6.mjs} +3 -3
  136. package/dist/{chunk-Z3TNWCI5.mjs → chunk-WQRN64Q6.mjs} +2 -2
  137. package/dist/{chunk-LTUGDMV4.mjs → chunk-WZ7YV54N.mjs} +1 -1
  138. package/dist/{chunk-NTZOXVUZ.mjs → chunk-YEDIDCR7.mjs} +3 -3
  139. package/dist/{chunk-PGVPE7GJ.mjs → chunk-YEKL4JBK.mjs} +1 -1
  140. package/dist/{chunk-5FUOVJKG.mjs → chunk-Z2BE2MAM.mjs} +13 -13
  141. package/dist/{chunk-HWEDFLB7.mjs → chunk-ZAUJFLEN.mjs} +10 -10
  142. package/dist/{chunk-MLHNSAPK.mjs → chunk-ZHCUZZE5.mjs} +2 -2
  143. package/dist/{chunk-ECX4SGX6.mjs → chunk-ZTW5WTGG.mjs} +9 -9
  144. package/dist/{client-Df76GNKm.d.ts → client-DRv7UVeY.d.ts} +123 -11
  145. package/dist/client.d.ts +9 -8
  146. package/dist/client.mjs +65 -3
  147. package/dist/{cold-module-YLWMTTZG.mjs → cold-module-7XXCEGTZ.mjs} +35 -35
  148. package/dist/{config-B8DP2VwR.d.ts → config-CoSig5Ox.d.ts} +22 -3
  149. package/dist/{config-05G_hy-1.d.ts → config-DMwffLKn.d.ts} +20 -5
  150. package/dist/{direct-executor-FI5GJHWX.mjs → direct-executor-G5TK7NLA.mjs} +16 -16
  151. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  152. package/dist/distribution/coordinator/etcd.mjs +1 -1
  153. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  154. package/dist/distribution/transport/grpc.mjs +4 -4
  155. package/dist/distribution/transport/in-memory.mjs +2 -2
  156. package/dist/distribution/transport/tcp.mjs +3 -3
  157. package/dist/distribution.d.ts +8 -8
  158. package/dist/distribution.mjs +6788 -5934
  159. package/dist/durability-config-GE4U7MCZ.mjs +89 -0
  160. package/dist/{durability-wiring-RHLXDIVF.mjs → durability-wiring-NCKUC5EO.mjs} +71 -175
  161. package/dist/embeddings/openai.mjs +2 -2
  162. package/dist/{sync-uXR7MmM7.d.ts → engine-CFxPYqEk.d.ts} +702 -2
  163. package/dist/engine-hooks-DHCMOADY.mjs +47 -0
  164. package/dist/{import-SRBNC6TE.mjs → import-NBFXFCSG.mjs} +26 -26
  165. package/dist/{index-nRqDM6uS.d.ts → index-C4AmUnl1.d.ts} +1 -1
  166. package/dist/index.browser.mjs +7 -6
  167. package/dist/index.d.ts +7 -7
  168. package/dist/index.mjs +23 -23
  169. package/dist/index.react-native.mjs +13 -12
  170. package/dist/{long-query-thread-EMYTGSJP.mjs → long-query-thread-J4DVRM4A.mjs} +25 -24
  171. package/dist/{methods-ABM5ELBR.mjs → methods-7IOINERF.mjs} +3 -3
  172. package/dist/{module-MG7JMV2U.mjs → module-DWKPBSMN.mjs} +31 -31
  173. package/dist/{module-3OMJZUFT.mjs → module-UN76TF7I.mjs} +11 -11
  174. package/dist/operations-G5EP6JPX.mjs +5 -0
  175. package/dist/{paged-partition-archive-UOLHOEZJ.mjs → paged-partition-archive-DPNWVSK2.mjs} +38 -34
  176. package/dist/partial-words.mjs +7 -7
  177. package/dist/pattern.mjs +3 -3
  178. package/dist/persistence/durability/checkpoint-worker.d.ts +8 -1
  179. package/dist/persistence/durability/checkpoint-worker.mjs +32 -32
  180. package/dist/{phrase-module-O3MDRQXP.mjs → phrase-module-ZI4WSQVH.mjs} +1 -1
  181. package/dist/{pool-CQXYPFLG.mjs → pool-Y4A46T36.mjs} +1 -1
  182. package/dist/query-suggestions/merge-worker.d.ts +55 -0
  183. package/dist/query-suggestions/merge-worker.mjs +81 -0
  184. package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
  185. package/dist/query-suggestions.browser.mjs +246 -0
  186. package/dist/query-suggestions.d.ts +20 -0
  187. package/dist/query-suggestions.mjs +62 -0
  188. package/dist/react-native/chunks/{analysis-change-EAYO3Y6Q.mjs → analysis-change-6BPDPH6K.mjs} +36 -17
  189. package/dist/{browser/analysis-change-entry-FCSHFQSS.mjs → react-native/chunks/analysis-change-entry-JLL42PH6.mjs} +1 -1
  190. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +29 -0
  191. package/dist/react-native/chunks/{chunk-O32RB3BL.mjs → chunk-3JIBF3XT.mjs} +3 -3
  192. package/dist/react-native/chunks/{chunk-75VWIY35.mjs → chunk-4DII3ZSM.mjs} +1 -1
  193. package/dist/react-native/chunks/{chunk-NKIZX26F.mjs → chunk-4J74WHQM.mjs} +2 -2
  194. package/dist/{browser/chunk-TTD27VXX.mjs → react-native/chunks/chunk-4LCEN2IU.mjs} +27 -10
  195. package/dist/react-native/chunks/{chunk-AUT7PMA4.mjs → chunk-4Y53T4YE.mjs} +5 -5
  196. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +17 -0
  197. package/dist/react-native/chunks/chunk-6VBXNFLE.mjs +9 -0
  198. package/dist/react-native/chunks/{chunk-SJWDBRNP.mjs → chunk-6WA3C3DV.mjs} +1 -1
  199. package/dist/react-native/chunks/chunk-7GRCBBME.mjs +63 -0
  200. package/dist/react-native/chunks/{chunk-7GWPJDOA.mjs → chunk-7PXRWYUU.mjs} +1 -1
  201. package/dist/react-native/chunks/{chunk-GFYFQLJD.mjs → chunk-ALOIBXWN.mjs} +2 -2
  202. package/dist/react-native/chunks/{chunk-VQSKZ3EZ.mjs → chunk-C3PTWYKT.mjs} +8 -8
  203. package/dist/react-native/chunks/{chunk-OQQVRWZ2.mjs → chunk-C5G6TJ7A.mjs} +1 -1
  204. package/dist/react-native/chunks/{chunk-RVAEBN74.mjs → chunk-CKNRFDTZ.mjs} +1 -1
  205. package/dist/react-native/chunks/{chunk-UWDNZDWK.mjs → chunk-CUH5F57W.mjs} +6 -6
  206. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +10 -0
  207. package/dist/react-native/chunks/{chunk-YBEW6YTR.mjs → chunk-DVDX4SDR.mjs} +2 -2
  208. package/dist/{browser/chunk-MYITLCHT.mjs → react-native/chunks/chunk-DZ7H7D2C.mjs} +1 -0
  209. package/dist/react-native/chunks/{chunk-RYMDHGL4.mjs → chunk-EIOYM5TO.mjs} +5 -5
  210. package/dist/react-native/chunks/chunk-GIZTJXYW.mjs +1007 -0
  211. package/dist/react-native/chunks/{chunk-NP7DD4G5.mjs → chunk-GJFXPHXI.mjs} +5 -5
  212. package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
  213. package/dist/react-native/chunks/{chunk-63YSZOXB.mjs → chunk-HUOYZJ3Q.mjs} +88 -142
  214. package/dist/react-native/chunks/{chunk-DH3TVWWK.mjs → chunk-IYNT75CE.mjs} +12 -3
  215. package/dist/react-native/chunks/{chunk-NCJS3WIY.mjs → chunk-JLIIWJUV.mjs} +1 -1
  216. package/dist/react-native/chunks/chunk-KJIG57UD.mjs +1106 -0
  217. package/dist/react-native/chunks/{chunk-JX2RIAXH.mjs → chunk-KTTAU63H.mjs} +5 -5
  218. package/dist/{browser/chunk-ZPTA75ZC.mjs → react-native/chunks/chunk-LZSLNSUN.mjs} +1 -1
  219. package/dist/react-native/chunks/{chunk-ZBSWRSBG.mjs → chunk-MJDQU5MW.mjs} +1 -1
  220. package/dist/react-native/chunks/{chunk-IOY2SM2P.mjs → chunk-MVXELMJX.mjs} +1 -1
  221. package/dist/react-native/chunks/{chunk-2CGSQM4O.mjs → chunk-N2WUOWLL.mjs} +12 -12
  222. package/dist/react-native/chunks/{chunk-YHKZSLOC.mjs → chunk-OL3WDV53.mjs} +5 -5
  223. package/dist/react-native/chunks/{chunk-VVFYOADG.mjs → chunk-PEHS2UO3.mjs} +6 -6
  224. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +79 -0
  225. package/dist/react-native/chunks/chunk-QJXTNPLQ.mjs +100 -0
  226. package/dist/react-native/chunks/{chunk-EH5CFV6Z.mjs → chunk-RDWG33MM.mjs} +2 -2
  227. package/dist/react-native/chunks/{chunk-ZYDKJXQJ.mjs → chunk-SUPXRTMD.mjs} +1 -1
  228. package/dist/react-native/chunks/chunk-TYIRMPD3.mjs +432 -0
  229. package/dist/react-native/chunks/{chunk-JPAJWO6D.mjs → chunk-U4KSKA4Z.mjs} +1 -1
  230. package/dist/react-native/chunks/{chunk-I5PGWQJF.mjs → chunk-VXGE4ZXL.mjs} +31 -22
  231. package/dist/{chunk-DVWYODEB.mjs → react-native/chunks/chunk-WBYQRHDY.mjs} +2 -2
  232. package/dist/react-native/chunks/{chunk-C2H2QQFW.mjs → chunk-YH7QY657.mjs} +3 -3
  233. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +92 -0
  234. package/dist/react-native/chunks/{cold-module-TJL6AFAD.mjs → cold-module-5PHF6DZR.mjs} +24 -23
  235. package/dist/react-native/chunks/durability-config-QXVZEO7T.mjs +89 -0
  236. package/dist/react-native/chunks/{durability-wiring-RRDYJLLM.mjs → durability-wiring-KO565FZC.mjs} +52 -156
  237. package/dist/react-native/chunks/engine-hooks-MVRRHH6B.mjs +28 -0
  238. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +3 -0
  239. package/dist/react-native/chunks/import-YVZA4V4V.mjs +30 -0
  240. package/dist/react-native/chunks/{methods-X6F36SJE.mjs → methods-6W5U4C3H.mjs} +3 -3
  241. package/dist/react-native/chunks/{module-S4DKSWMF.mjs → module-H5MVPSP2.mjs} +11 -10
  242. package/dist/react-native/chunks/{module-QT5HZAY4.mjs → module-ZL5ZG6YB.mjs} +20 -19
  243. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +5 -0
  244. package/dist/react-native/chunks/{phrase-module-JZ37TB7N.mjs → phrase-module-RTVKEWJT.mjs} +1 -1
  245. package/dist/react-native/chunks/{pool-RTGXJXPU.mjs → pool-JR3NJCAF.mjs} +1 -1
  246. package/dist/react-native/chunks/restore-hooks-SILFPU6B.mjs +125 -0
  247. package/dist/react-native/chunks/restore-queue-HSYP2AEC.mjs +55 -0
  248. package/dist/react-native/chunks/{retention-PPCTP2VY.mjs → retention-7I7UAWYK.mjs} +21 -19
  249. package/dist/react-native/chunks/{runtime-KUATOLYB.mjs → runtime-R5E3TB3J.mjs} +1 -1
  250. package/dist/react-native/chunks/{snapshot-ZBIEOZTZ.mjs → snapshot-EZYB6SLF.mjs} +70 -36
  251. package/dist/react-native/chunks/start-SHVZ72I5.mjs +36 -0
  252. package/dist/react-native/chunks/{write-2W4FTX7J.mjs → write-JUESXHDL.mjs} +20 -19
  253. package/dist/react-native/partial-words.mjs +7 -6
  254. package/dist/react-native/pattern.mjs +3 -3
  255. package/dist/react-native/query-suggestions.mjs +258 -0
  256. package/dist/react-native/sync.mjs +76 -13
  257. package/dist/react-native/synonyms.mjs +4 -4
  258. package/dist/react.d.ts +11 -11
  259. package/dist/react.mjs +1 -0
  260. package/dist/{rerank-IZOB6NII.mjs → rerank-MQ37IYRV.mjs} +4 -4
  261. package/dist/rerankers/http.mjs +2 -2
  262. package/dist/restore-hooks-HZ3ILAMO.mjs +146 -0
  263. package/dist/restore-queue-JVGENGGE.mjs +55 -0
  264. package/dist/{retention-55WA7GPU.mjs → retention-HROPV2QU.mjs} +33 -32
  265. package/dist/{runtime-UZOC3NPY.mjs → runtime-COIUORCN.mjs} +5 -5
  266. package/dist/{schema-DDauvDOv.d.ts → schema-Jwt928nJ.d.ts} +1 -1
  267. package/dist/server.d.ts +108 -12
  268. package/dist/server.mjs +293 -46
  269. package/dist/{snapshot-NFX2EYN2.mjs → snapshot-4HS2G2UM.mjs} +85 -54
  270. package/dist/start-UTWHGH42.mjs +59 -0
  271. package/dist/sync/filesystem.d.ts +4 -4
  272. package/dist/sync/filesystem.mjs +4 -4
  273. package/dist/sync/indexeddb.d.ts +4 -4
  274. package/dist/sync/indexeddb.mjs +2 -2
  275. package/dist/sync.browser.mjs +74 -11
  276. package/dist/sync.d.ts +5 -5
  277. package/dist/sync.mjs +76 -14
  278. package/dist/synonyms.mjs +5 -5
  279. package/dist/{tasks-BShx8pdK.d.ts → tasks-qrJojgST.d.ts} +13 -5
  280. package/dist/{thread-P2G2FWM2.mjs → thread-6MOXY2KD.mjs} +24 -23
  281. package/dist/{types-SnO7_tAI.d.ts → types-BZCGjfLn.d.ts} +2 -3
  282. package/dist/vector/search-worker.d.ts +1 -1
  283. package/dist/vector/search-worker.mjs +5 -5
  284. package/dist/workers/entry.mjs +8 -8
  285. package/dist/{write-FGB62BHQ.mjs → write-GTTWWRRG.mjs} +30 -30
  286. package/openapi.json +798 -7
  287. package/package.json +24 -7
  288. package/dist/browser/operations-WVYLF72Q.mjs +0 -5
  289. package/dist/browser/restore-queue-TYIGDL5L.mjs +0 -41
  290. package/dist/engine-DYu-e0oR.d.ts +0 -674
  291. package/dist/operations-PGOAY2KS.mjs +0 -5
  292. package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +0 -25
  293. package/dist/react-native/chunks/gzip.react-native-DNB5YNFA.mjs +0 -3
  294. package/dist/react-native/chunks/import-JYBMEJPQ.mjs +0 -29
  295. package/dist/react-native/chunks/operations-RYKTSZQA.mjs +0 -5
  296. package/dist/react-native/chunks/restore-queue-ZBVIKJWI.mjs +0 -41
  297. package/dist/restore-queue-COI2GSSK.mjs +0 -41
@@ -1,16 +1,16 @@
1
1
  import { encodeJson, SYNC_CLOSE_SERVER_ERROR, SYNC_SUBPROTOCOL } from './chunk-KYYABCSW.mjs';
2
- import { answerRefusalOf } from './chunk-K4B7OH65.mjs';
3
- import { archiveRange } from './chunk-Q7MS6P2J.mjs';
2
+ import { answerRefusalOf } from './chunk-2MANFZJ3.mjs';
3
+ import { archiveRange } from './chunk-Q622CTMC.mjs';
4
4
  import { nativeSearchCoreIsEnabled } from './chunk-DJHHF2L5.mjs';
5
- import { readRecentMemoryFigures, readMemoryFigures } from './chunk-TV2L3BN7.mjs';
5
+ import { readRecentMemoryFigures, readMemoryFigures } from './chunk-L7ZD4L3K.mjs';
6
6
  import { DEFAULT_RERANK_WINDOW } from './chunk-HJSN7UYG.mjs';
7
7
  import { collectGarbageBeforeRefusal, collectYoungGenerationBeforeRefusal, reportRefusalAfterCollection, reservedHeapBytes, admitHeapBytes } from './chunk-XIHUI4KB.mjs';
8
8
  import { ANALYSIS_CHANGE_MEMBERS } from './chunk-EEBCDP36.mjs';
9
- import { HEAP_BLOCK_FRACTION_BELOW_V8_INEFFECTIVE_MARK_COMPACT_LINE } from './chunk-ZXNQEW43.mjs';
10
- import { loadNativeCore } from './chunk-HVKXNBFL.mjs';
11
- import { MAX_FILTER_DEPTH } from './chunk-OKX2BBNW.mjs';
9
+ import { MAX_FILTER_DEPTH } from './chunk-LC3FDWTX.mjs';
12
10
  import { MAX_SORT_FIELDS } from './chunk-FQBFZAWG.mjs';
13
- import { NarsilError, ServerErrorCodes, ErrorCodes } from './chunk-KUZKUONM.mjs';
11
+ import { HEAP_BLOCK_FRACTION_BELOW_V8_INEFFECTIVE_MARK_COMPACT_LINE } from './chunk-ZXNQEW43.mjs';
12
+ import { loadNativeCore } from './chunk-Q7G3BV3Y.mjs';
13
+ import { NarsilError, ServerErrorCodes, ErrorCodes } from './chunk-MP7ABPTD.mjs';
14
14
  import { randomUUID } from 'crypto';
15
15
  import { mkdtemp, open, rm } from 'fs/promises';
16
16
  import { tmpdir } from 'os';
@@ -235,6 +235,7 @@ var STATUS_BY_CODE = {
235
235
  SYNC_NOT_READY: 503,
236
236
  SYNC_NOT_ENABLED: 404,
237
237
  SYNC_SNAPSHOT_PREPARING: 503,
238
+ QUERY_SUGGESTIONS_NOT_ENABLED: 404,
238
239
  EMBEDDING_FAILED: 503,
239
240
  RERANK_FAILED: 503,
240
241
  QUERY_ROUTING_FAILED: 503,
@@ -990,7 +991,8 @@ var TASK_TYPE_SET = {
990
991
  changeAnalysis: true,
991
992
  backup: true,
992
993
  backupRestore: true,
993
- backupDelete: true
994
+ backupDelete: true,
995
+ querySuggestionsBuild: true
994
996
  };
995
997
  var TASK_TYPES = Object.keys(TASK_TYPE_SET);
996
998
  var TASK_STATUSES = ["running", "succeeded", "failed", "cancelled"];
@@ -1595,7 +1597,7 @@ function createRouteRunner(deps) {
1595
1597
  const requestHeaders = capturedHeaders(req, opts.headers);
1596
1598
  const declaredBytes = needsBody ? declaredBodyBytes(req.getHeader("content-length")) : null;
1597
1599
  let hookContext = null;
1598
- if (useHook) {
1600
+ if (useHook || opts.capturesContext === true) {
1599
1601
  const headers = {};
1600
1602
  req.forEach((key, value) => {
1601
1603
  headers[key] = value;
@@ -2217,6 +2219,7 @@ function maintenanceRoutes(shared) {
2217
2219
  summary: "Stream a snapshot archive of an index",
2218
2220
  tags: ["Maintenance"],
2219
2221
  request: null,
2222
+ query: "SnapshotQuery",
2220
2223
  responses: { 200: { contentType: SNAPSHOT_ARCHIVE_CONTENT_TYPE } }
2221
2224
  },
2222
2225
  {
@@ -2456,6 +2459,113 @@ function sharedRouteOptions(limits) {
2456
2459
  };
2457
2460
  }
2458
2461
 
2462
+ // src/server/routes/query-suggestions.ts
2463
+ function querySuggestionRoutes(shared) {
2464
+ const { named, namedBody } = shared;
2465
+ return [
2466
+ {
2467
+ method: "put",
2468
+ path: "/indexes/:name/query-suggestions",
2469
+ handler: "updateQuerySuggestions",
2470
+ options: namedBody,
2471
+ operationId: "updateQuerySuggestions",
2472
+ summary: "Replace the popular query suggestions setting of an index",
2473
+ tags: ["QuerySuggestions"],
2474
+ request: "QuerySuggestionsSetting",
2475
+ responses: { 200: "OkResponse" }
2476
+ },
2477
+ {
2478
+ method: "get",
2479
+ path: "/indexes/:name/query-suggestions",
2480
+ handler: "querySuggestionsStatus",
2481
+ options: named,
2482
+ operationId: "querySuggestionsStatus",
2483
+ summary: "Report the setting, the last build, and the next build of popular query suggestions",
2484
+ tags: ["QuerySuggestions"],
2485
+ request: null,
2486
+ responses: { 200: "QuerySuggestionsStatus" }
2487
+ },
2488
+ {
2489
+ method: "post",
2490
+ path: "/indexes/:name/query-suggestions/record",
2491
+ handler: "recordQuery",
2492
+ options: { ...namedBody, capturesContext: true },
2493
+ operationId: "recordQuery",
2494
+ summary: "Count a search that a person followed with a click, for the person that the server identifies",
2495
+ tags: ["QuerySuggestions"],
2496
+ request: "RecordQueryBody",
2497
+ responses: { 200: "RecordQueryResult" }
2498
+ },
2499
+ {
2500
+ method: "post",
2501
+ path: "/indexes/:name/query-suggestions/build",
2502
+ handler: "buildQuerySuggestions",
2503
+ options: named,
2504
+ operationId: "buildQuerySuggestions",
2505
+ summary: "Build the popular query suggestions of an index, as a task",
2506
+ tags: ["QuerySuggestions"],
2507
+ request: null,
2508
+ responses: { 202: "TaskRecord" }
2509
+ },
2510
+ {
2511
+ method: "get",
2512
+ path: "/indexes/:name/query-suggestions/preview",
2513
+ handler: "previewQuerySuggestions",
2514
+ options: named,
2515
+ operationId: "previewQuerySuggestions",
2516
+ summary: "List the phrases that the next build would publish",
2517
+ tags: ["QuerySuggestions"],
2518
+ request: null,
2519
+ query: "QuerySuggestionsPreviewQuery",
2520
+ responses: { 200: "QuerySuggestionsPreview" }
2521
+ },
2522
+ {
2523
+ method: "get",
2524
+ path: "/indexes/:name/query-suggestions/bans",
2525
+ handler: "readQueryBans",
2526
+ options: named,
2527
+ operationId: "readQueryBans",
2528
+ summary: "Read the ban list of popular query suggestions",
2529
+ tags: ["QuerySuggestions"],
2530
+ request: null,
2531
+ responses: { 200: "QueryBansBody" }
2532
+ },
2533
+ {
2534
+ method: "put",
2535
+ path: "/indexes/:name/query-suggestions/bans",
2536
+ handler: "replaceQueryBans",
2537
+ options: namedBody,
2538
+ operationId: "replaceQueryBans",
2539
+ summary: "Replace the ban list, and remove each newly banned phrase from every suggestions index",
2540
+ tags: ["QuerySuggestions"],
2541
+ request: "QueryBansBody",
2542
+ responses: { 200: "QueryBansBody" }
2543
+ },
2544
+ {
2545
+ method: "post",
2546
+ path: "/indexes/:name/query-suggestions/remove",
2547
+ handler: "removeQuery",
2548
+ options: namedBody,
2549
+ operationId: "removeQuery",
2550
+ summary: "Ban a phrase and remove it from every suggestions index of an index",
2551
+ tags: ["QuerySuggestions"],
2552
+ request: "RemoveQueryBody",
2553
+ responses: { 200: "RemoveQueryResponse" }
2554
+ },
2555
+ {
2556
+ method: "post",
2557
+ path: "/indexes/:name/query-suggestions/manual",
2558
+ handler: "addManualSuggestion",
2559
+ options: namedBody,
2560
+ operationId: "addManualSuggestion",
2561
+ summary: "Add a suggestion by hand, which a build leaves in place",
2562
+ tags: ["QuerySuggestions"],
2563
+ request: "ManualQuerySuggestion",
2564
+ responses: { 200: "ManualSuggestionResponse" }
2565
+ }
2566
+ ];
2567
+ }
2568
+
2459
2569
  // src/server/sync/range.ts
2460
2570
  var WHOLE = { kind: "whole" };
2461
2571
  var UNSATISFIABLE = { kind: "unsatisfiable" };
@@ -2591,7 +2701,8 @@ function serverRoutes(limits) {
2591
2701
  ...searchRoutes(shared),
2592
2702
  ...maintenanceRoutes(shared),
2593
2703
  ...backupRoutes(shared),
2594
- ...syncRoutes(shared)
2704
+ ...syncRoutes(shared),
2705
+ ...querySuggestionRoutes(shared)
2595
2706
  ];
2596
2707
  }
2597
2708
 
@@ -4,14 +4,14 @@ function holdsChangeWork(entry) {
4
4
  }
5
5
  async function abandonChangeOf(core, indexName) {
6
6
  if (!holdsChangeWork(core.indexRegistry.get(indexName))) return;
7
- const { abandonAnalysisChange } = await import('./analysis-change-4GCRVRBW.mjs');
7
+ const { abandonAnalysisChange } = await import('./analysis-change-3TFIHT5E.mjs');
8
8
  await abandonAnalysisChange(core, indexName);
9
9
  }
10
10
  async function resumeChangeOf(core, indexName) {
11
11
  if ((core.indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
12
12
  if (core.mutationCtx.capacityScope === "partition") return;
13
13
  if (core.executor.getManager(indexName) === void 0) return;
14
- const { resumeAnalysisChange } = await import('./analysis-change-4GCRVRBW.mjs');
14
+ const { resumeAnalysisChange } = await import('./analysis-change-3TFIHT5E.mjs');
15
15
  void resumeAnalysisChange(core, indexName).catch(() => void 0);
16
16
  }
17
17
  async function resumeEveryChange(core) {
@@ -1,6 +1,6 @@
1
- import { readMetadataEnvelope } from './chunk-QKZHLADX.mjs';
2
- import { readCommitMarker, nextMarkerSlot, encodeMarkerSlot, markerSlotOffset, nextSegmentKey, readWalSegments, durableRecordMissing, checkpointLastSeqNo, SEGMENT_HEADER_SIZE } from './chunk-X6NSJYQ3.mjs';
3
- import { applyDeleteEntry, applyIndexEntry } from './chunk-62G63NMH.mjs';
1
+ import { readMetadataEnvelope } from './chunk-3R4UZWQG.mjs';
2
+ import { readCommitMarker, nextMarkerSlot, encodeMarkerSlot, markerSlotOffset, nextSegmentKey, readWalSegments, durableRecordMissing, checkpointLastSeqNo, SEGMENT_HEADER_SIZE } from './chunk-S2EQU2GE.mjs';
3
+ import { applyDeleteEntry, applyIndexEntry } from './chunk-KXCVQWOR.mjs';
4
4
  import { turnIsSpent, yieldTurn } from './chunk-LQG5G2LY.mjs';
5
5
 
6
6
  // src/persistence/durability/marker-writer.ts
@@ -1,5 +1,5 @@
1
- import { openChecksummedEnvelope } from './chunk-HVYICDY3.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-KUZKUONM.mjs';
1
+ import { openChecksummedEnvelope } from './chunk-3OH67G7R.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
3
3
  import { decode } from '@msgpack/msgpack';
4
4
 
5
5
  var INDEX_CONFIGURATION_ENVELOPE_VERSION = 5;
@@ -0,0 +1,54 @@
1
+ import { MAX_GROUP_LENGTH, MAX_PERSON_UTF16_UNITS, RAW_PHRASE_UTF16_UNITS_PER_CODE_POINT } from './chunk-5YNRKI2C.mjs';
2
+
3
+ // src/query-suggestions/phrase.ts
4
+ var APOSTROPHE_VARIANTS = /[\u2018\u2019\u02bc]/g;
5
+ var HYPHEN_VARIANTS = /[\u2010\u2011]/g;
6
+ var WHITE_SPACE_RUNS = /\p{White_Space}+/gu;
7
+ var ALLOWED_PHRASE = /^[\p{L}\p{M}\p{Nd} '-]+$/u;
8
+ var LETTER = /\p{L}/gu;
9
+ var DIGIT = /\p{Nd}/gu;
10
+ var GROUP_PATTERN = new RegExp(`^[A-Za-z0-9][A-Za-z0-9_-]{0,${MAX_GROUP_LENGTH - 1}}$`);
11
+ var GROUP_FORMAT = `1 to ${MAX_GROUP_LENGTH} letters, digits, "_", and "-"`;
12
+ function countMatches(text, pattern) {
13
+ pattern.lastIndex = 0;
14
+ let count = 0;
15
+ while (pattern.exec(text) !== null) count++;
16
+ return count;
17
+ }
18
+ function codePointCount(text, stopAfter) {
19
+ let count = 0;
20
+ for (const _ of text) {
21
+ count++;
22
+ if (count > stopAfter) break;
23
+ }
24
+ return count;
25
+ }
26
+ function normalisePhrase(raw, maxLength) {
27
+ if (raw.length === 0 || raw.length > maxLength * RAW_PHRASE_UTF16_UNITS_PER_CODE_POINT) return null;
28
+ return raw.normalize("NFKC").toLowerCase().replace(APOSTROPHE_VARIANTS, "'").replace(HYPHEN_VARIANTS, "-").replace(WHITE_SPACE_RUNS, " ").trim();
29
+ }
30
+ function phraseFits(phrase, limits) {
31
+ if (phrase.length === 0 || phrase.length > limits.maxLength * 2) return false;
32
+ if (phrase !== phrase.trim() || phrase.includes(" ")) return false;
33
+ if (!ALLOWED_PHRASE.test(phrase)) return false;
34
+ if (codePointCount(phrase, limits.maxLength) > limits.maxLength) return false;
35
+ if (phrase.split(" ").length > limits.maxWords) return false;
36
+ if (countMatches(phrase, DIGIT) > limits.maxDigits) return false;
37
+ return countMatches(phrase, LETTER) >= limits.minLetters;
38
+ }
39
+ function isNormalPhrase(phrase, limits) {
40
+ return phraseFits(phrase, limits) && normalisePhrase(phrase, limits.maxLength) === phrase;
41
+ }
42
+ function acceptedPhrase(raw, limits) {
43
+ const phrase = normalisePhrase(raw, limits.maxLength);
44
+ if (phrase === null || !phraseFits(phrase, limits)) return null;
45
+ return phrase;
46
+ }
47
+ function isGroup(value) {
48
+ return typeof value === "string" && GROUP_PATTERN.test(value);
49
+ }
50
+ function isPerson(value) {
51
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_PERSON_UTF16_UNITS;
52
+ }
53
+
54
+ export { GROUP_FORMAT, acceptedPhrase, isGroup, isNormalPhrase, isPerson };
@@ -0,0 +1,382 @@
1
+ import { isGroup } from './chunk-GQPTDQCL.mjs';
2
+ import { MAX_MIN_PEOPLE, MIN_MIN_PEOPLE, DEFAULT_MIN_PEOPLE, MAX_MIN_RESULTS, MIN_MIN_RESULTS, DEFAULT_MIN_RESULTS, MAX_RETENTION_DAYS, MIN_RETENTION_DAYS, DEFAULT_RETENTION_DAYS, MAX_MAX_PHRASES_PER_DAY, DEFAULT_MAX_PHRASES_PER_DAY, MAX_MAX_PHRASES_PER_PERSON, DEFAULT_MAX_PHRASES_PER_PERSON, MAX_MAX_PEOPLE_PER_DAY, DEFAULT_MAX_PEOPLE_PER_DAY, MAX_MAX_GROUPS, DEFAULT_MAX_GROUPS, MAX_MAX_LENGTH, DEFAULT_MAX_LENGTH, DEFAULT_MIN_LETTERS, MAX_MAX_WORDS, DEFAULT_MAX_WORDS, DEFAULT_MAX_DIGITS, MAX_MAX_MERGE_PHRASES, DEFAULT_MAX_MERGE_PHRASES, MAX_MERGE_MEMORY_BYTES, MIN_MERGE_MEMORY_BYTES, DEFAULT_MERGE_MEMORY_BYTES, MAX_SAVE_INTERVAL_MS, MIN_SAVE_INTERVAL_MS, DEFAULT_SAVE_INTERVAL_MS, MAX_RESULT_CHECKS_PER_SECOND, DEFAULT_RESULT_CHECKS_PER_SECOND, MAX_SCHEDULE_LENGTH, SCHEDULE_LOOKAHEAD_DAYS, DEFAULT_TIME_ZONE, DEFAULT_SCHEDULE, MAX_FIELDS, SCHEDULE_OFF, MAX_SETTING_BYTES, MAX_SOURCE_INDEX_NAME_LENGTH, MAX_PERSON_PAIRS_PER_DAY, MAX_FILE_PEOPLE_PER_DAY, MAX_MERGE_PEOPLE, DAY_MS } from './chunk-5YNRKI2C.mjs';
3
+ import { flattenSchema } from './chunk-WQRN64Q6.mjs';
4
+ import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
5
+ import { encode } from '@msgpack/msgpack';
6
+
7
+ // src/query-suggestions/schedule.ts
8
+ var FIELD_RANGES = [
9
+ { min: 0, max: 59 },
10
+ { min: 0, max: 23 },
11
+ { min: 1, max: 31 },
12
+ { min: 1, max: 12 },
13
+ { min: 0, max: 6 }
14
+ ];
15
+ var NUMBER = /^\d{1,2}$/;
16
+ function parseNumber(text, range) {
17
+ if (!NUMBER.test(text)) return null;
18
+ const value = Number(text);
19
+ return value >= range.min && value <= range.max ? value : null;
20
+ }
21
+ function parseField(text, range) {
22
+ const allowed = new Array(range.max + 1).fill(false);
23
+ for (const part of text.split(",")) {
24
+ const [base, stepText, ...extra] = part.split("/");
25
+ if (base === void 0 || extra.length > 0) return null;
26
+ let step = 1;
27
+ if (stepText !== void 0) {
28
+ if (!NUMBER.test(stepText) || Number(stepText) < 1) return null;
29
+ step = Number(stepText);
30
+ }
31
+ let start;
32
+ let end;
33
+ if (base === "*") {
34
+ start = range.min;
35
+ end = range.max;
36
+ } else {
37
+ const bounds = base.split("-");
38
+ if (bounds.length > 2) return null;
39
+ const first = parseNumber(bounds[0] ?? "", range);
40
+ if (first === null) return null;
41
+ start = first;
42
+ if (bounds.length === 2) {
43
+ const last = parseNumber(bounds[1] ?? "", range);
44
+ if (last === null || last < first) return null;
45
+ end = last;
46
+ } else end = stepText === void 0 ? first : range.max;
47
+ }
48
+ for (let value = start; value <= end; value += step) allowed[value] = true;
49
+ }
50
+ return allowed;
51
+ }
52
+ function parseSchedule(expression) {
53
+ if (expression.length > MAX_SCHEDULE_LENGTH) return null;
54
+ const fields = expression.trim().split(/\s+/);
55
+ if (fields.length !== FIELD_RANGES.length) return null;
56
+ const parsed = [];
57
+ for (let i = 0; i < fields.length; i++) {
58
+ const field = parseField(fields[i] ?? "", FIELD_RANGES[i]);
59
+ if (field === null) return null;
60
+ parsed.push(field);
61
+ }
62
+ const [minutes, hours, daysOfMonth, months, daysOfWeek] = parsed;
63
+ return {
64
+ minutes,
65
+ hours,
66
+ daysOfMonth,
67
+ months,
68
+ daysOfWeek,
69
+ dayOfMonthAny: fields[2] === "*",
70
+ dayOfWeekAny: fields[4] === "*"
71
+ };
72
+ }
73
+ var formatters = /* @__PURE__ */ new Map();
74
+ function formatterOf(timeZone) {
75
+ let formatter = formatters.get(timeZone);
76
+ if (formatter === void 0) {
77
+ formatter = new Intl.DateTimeFormat("en-US", {
78
+ timeZone,
79
+ hourCycle: "h23",
80
+ year: "numeric",
81
+ month: "numeric",
82
+ day: "numeric",
83
+ hour: "numeric",
84
+ minute: "numeric"
85
+ });
86
+ formatters.set(timeZone, formatter);
87
+ }
88
+ return formatter;
89
+ }
90
+ function wallTimeAt(instant, timeZone) {
91
+ const parts = {};
92
+ for (const part of formatterOf(timeZone).formatToParts(instant)) {
93
+ if (part.type !== "literal") parts[part.type] = Number(part.value);
94
+ }
95
+ return { year: parts.year, month: parts.month, day: parts.day, hour: parts.hour, minute: parts.minute };
96
+ }
97
+ function wallAsUtc(wall) {
98
+ return Date.UTC(wall.year, wall.month - 1, wall.day, wall.hour, wall.minute);
99
+ }
100
+ function instantOf(wall, timeZone) {
101
+ const target = wallAsUtc(wall);
102
+ let guess = target;
103
+ for (let attempt = 0; attempt < 3; attempt++) {
104
+ const offset = wallAsUtc(wallTimeAt(guess, timeZone)) - guess;
105
+ guess = target - offset;
106
+ }
107
+ const landed = wallTimeAt(guess, timeZone);
108
+ return wallAsUtc(landed) === target ? guess : null;
109
+ }
110
+ function dayMatches(schedule, dayStartUtc) {
111
+ const date = new Date(dayStartUtc);
112
+ if (!schedule.months[date.getUTCMonth() + 1]) return false;
113
+ const monthDay = schedule.daysOfMonth[date.getUTCDate()] === true;
114
+ const weekDay = schedule.daysOfWeek[date.getUTCDay()] === true;
115
+ if (!schedule.dayOfMonthAny && !schedule.dayOfWeekAny) return monthDay || weekDay;
116
+ return monthDay && weekDay;
117
+ }
118
+ function matchesOfDay(schedule, dayStartUtc, timeZone) {
119
+ const date = new Date(dayStartUtc);
120
+ const instants = [];
121
+ for (let hour = 0; hour < 24; hour++) {
122
+ if (!schedule.hours[hour]) continue;
123
+ for (let minute = 0; minute < 60; minute++) {
124
+ if (!schedule.minutes[minute]) continue;
125
+ const wall = { year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate(), hour, minute };
126
+ const instant = instantOf(wall, timeZone);
127
+ if (instant !== null) instants.push(instant);
128
+ }
129
+ }
130
+ return instants;
131
+ }
132
+ function localDayStart(instant, timeZone) {
133
+ const wall = wallTimeAt(instant, timeZone);
134
+ return Date.UTC(wall.year, wall.month - 1, wall.day);
135
+ }
136
+ function nextMatchAfter(schedule, timeZone, after) {
137
+ const firstDay = localDayStart(after, timeZone);
138
+ for (let day = 0; day <= SCHEDULE_LOOKAHEAD_DAYS; day++) {
139
+ const dayStart = firstDay + day * DAY_MS;
140
+ if (!dayMatches(schedule, dayStart)) continue;
141
+ for (const instant of matchesOfDay(schedule, dayStart, timeZone)) {
142
+ if (instant > after) return instant;
143
+ }
144
+ }
145
+ return null;
146
+ }
147
+ function latestMatchAtOrBefore(schedule, timeZone, at) {
148
+ const firstDay = localDayStart(at, timeZone);
149
+ for (let day = 0; day <= SCHEDULE_LOOKAHEAD_DAYS; day++) {
150
+ const dayStart = firstDay - day * DAY_MS;
151
+ if (!dayMatches(schedule, dayStart)) continue;
152
+ const instants = matchesOfDay(schedule, dayStart, timeZone);
153
+ for (let i = instants.length - 1; i >= 0; i--) {
154
+ if (instants[i] <= at) return instants[i];
155
+ }
156
+ }
157
+ return null;
158
+ }
159
+
160
+ // src/query-suggestions/setting.ts
161
+ var RANGES = [
162
+ {
163
+ key: "minPeople",
164
+ wire: "min_people",
165
+ fallback: DEFAULT_MIN_PEOPLE,
166
+ min: MIN_MIN_PEOPLE,
167
+ max: MAX_MIN_PEOPLE
168
+ },
169
+ {
170
+ key: "minResults",
171
+ wire: "min_results",
172
+ fallback: DEFAULT_MIN_RESULTS,
173
+ min: MIN_MIN_RESULTS,
174
+ max: MAX_MIN_RESULTS
175
+ },
176
+ {
177
+ key: "retentionDays",
178
+ wire: "retention_days",
179
+ fallback: DEFAULT_RETENTION_DAYS,
180
+ min: MIN_RETENTION_DAYS,
181
+ max: MAX_RETENTION_DAYS
182
+ },
183
+ {
184
+ key: "maxPhrasesPerDay",
185
+ wire: "max_phrases_per_day",
186
+ fallback: DEFAULT_MAX_PHRASES_PER_DAY,
187
+ min: 1,
188
+ max: MAX_MAX_PHRASES_PER_DAY
189
+ },
190
+ {
191
+ key: "maxPhrasesPerPerson",
192
+ wire: "max_phrases_per_person",
193
+ fallback: DEFAULT_MAX_PHRASES_PER_PERSON,
194
+ min: 1,
195
+ max: MAX_MAX_PHRASES_PER_PERSON
196
+ },
197
+ {
198
+ key: "maxPeoplePerDay",
199
+ wire: "max_people_per_day",
200
+ fallback: DEFAULT_MAX_PEOPLE_PER_DAY,
201
+ min: 1,
202
+ max: MAX_MAX_PEOPLE_PER_DAY
203
+ },
204
+ { key: "maxGroups", wire: "max_groups", fallback: DEFAULT_MAX_GROUPS, min: 1, max: MAX_MAX_GROUPS },
205
+ { key: "maxLength", wire: "max_length", fallback: DEFAULT_MAX_LENGTH, min: 1, max: MAX_MAX_LENGTH },
206
+ { key: "minLetters", wire: "min_letters", fallback: DEFAULT_MIN_LETTERS, min: 1, max: "maxLength" },
207
+ { key: "maxWords", wire: "max_words", fallback: DEFAULT_MAX_WORDS, min: 1, max: MAX_MAX_WORDS },
208
+ { key: "maxDigits", wire: "max_digits", fallback: DEFAULT_MAX_DIGITS, min: 0, max: "maxLength" },
209
+ {
210
+ key: "maxMergePhrases",
211
+ wire: "max_merge_phrases",
212
+ fallback: DEFAULT_MAX_MERGE_PHRASES,
213
+ min: 1,
214
+ max: MAX_MAX_MERGE_PHRASES
215
+ },
216
+ {
217
+ key: "mergeMemoryBytes",
218
+ wire: "merge_memory_bytes",
219
+ fallback: DEFAULT_MERGE_MEMORY_BYTES,
220
+ min: MIN_MERGE_MEMORY_BYTES,
221
+ max: MAX_MERGE_MEMORY_BYTES
222
+ },
223
+ {
224
+ key: "saveIntervalMs",
225
+ wire: "save_interval_ms",
226
+ fallback: DEFAULT_SAVE_INTERVAL_MS,
227
+ min: MIN_SAVE_INTERVAL_MS,
228
+ max: MAX_SAVE_INTERVAL_MS
229
+ },
230
+ {
231
+ key: "resultChecksPerSecond",
232
+ wire: "result_checks_per_second",
233
+ fallback: DEFAULT_RESULT_CHECKS_PER_SECOND,
234
+ min: 1,
235
+ max: MAX_RESULT_CHECKS_PER_SECOND
236
+ }
237
+ ];
238
+ var SETTING_KEYS = /* @__PURE__ */ new Set(["enabled", "fields", "schedule", "timeZone", ...RANGES.map((range) => range.key)]);
239
+ function invalidSetting(message, details = {}) {
240
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, message, details);
241
+ }
242
+ function isWholeNumber(value) {
243
+ return typeof value === "number" && Number.isSafeInteger(value);
244
+ }
245
+ function knowsTimeZone(timeZone) {
246
+ try {
247
+ new Intl.DateTimeFormat("en-US", { timeZone });
248
+ return true;
249
+ } catch {
250
+ return false;
251
+ }
252
+ }
253
+ function resolveSetting(setting) {
254
+ const resolved = {
255
+ enabled: setting.enabled,
256
+ fields: [...setting.fields],
257
+ schedule: setting.schedule ?? DEFAULT_SCHEDULE,
258
+ timeZone: setting.timeZone ?? DEFAULT_TIME_ZONE
259
+ };
260
+ for (const range of RANGES) resolved[range.key] = setting[range.key] ?? range.fallback;
261
+ return resolved;
262
+ }
263
+ function requireProducts(resolved) {
264
+ if (resolved.maxPeoplePerDay * resolved.maxPhrasesPerPerson > MAX_PERSON_PAIRS_PER_DAY) {
265
+ invalidSetting(`maxPeoplePerDay times maxPhrasesPerPerson must stay at or below ${MAX_PERSON_PAIRS_PER_DAY}`);
266
+ }
267
+ if (resolved.maxPhrasesPerDay * resolved.minPeople > MAX_FILE_PEOPLE_PER_DAY) {
268
+ invalidSetting(`maxPhrasesPerDay times minPeople must stay at or below ${MAX_FILE_PEOPLE_PER_DAY}`);
269
+ }
270
+ if (resolved.maxMergePhrases * resolved.minPeople > MAX_MERGE_PEOPLE) {
271
+ invalidSetting(`maxMergePhrases times minPeople must stay at or below ${MAX_MERGE_PEOPLE}`);
272
+ }
273
+ }
274
+ function validateSetting(raw) {
275
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
276
+ invalidSetting("The query suggestions setting must be an object");
277
+ }
278
+ const input = raw;
279
+ for (const key of Object.keys(input)) {
280
+ if (!SETTING_KEYS.has(key)) invalidSetting(`The query suggestions setting holds an unknown key "${key}"`, { key });
281
+ }
282
+ if (typeof input.enabled !== "boolean") invalidSetting('The query suggestions setting needs a boolean "enabled"');
283
+ const fields = input.fields;
284
+ if (!Array.isArray(fields) || fields.length === 0 || fields.length > MAX_FIELDS) {
285
+ invalidSetting(`The query suggestions setting needs from 1 to ${MAX_FIELDS} fields`);
286
+ }
287
+ const seen = /* @__PURE__ */ new Set();
288
+ for (const field of fields) {
289
+ if (typeof field !== "string" || field.length === 0 || seen.has(field)) {
290
+ invalidSetting("Each field of the query suggestions setting must be a distinct, non-empty path");
291
+ }
292
+ seen.add(field);
293
+ }
294
+ const setting = { enabled: input.enabled, fields: [...seen] };
295
+ for (const range of RANGES) {
296
+ const value = input[range.key];
297
+ if (value === void 0) continue;
298
+ if (!isWholeNumber(value)) invalidSetting(`${range.key} must be a whole number`, { key: range.key });
299
+ setting[range.key] = value;
300
+ }
301
+ const resolved = resolveSetting(setting);
302
+ for (const range of RANGES) {
303
+ const value = resolved[range.key];
304
+ const max = typeof range.max === "number" ? range.max : resolved[range.max];
305
+ if (value < range.min || value > max) {
306
+ invalidSetting(`${range.key} must be from ${range.min} to ${max}`, { key: range.key, value });
307
+ }
308
+ }
309
+ requireProducts(resolved);
310
+ if (input.schedule !== void 0) {
311
+ if (typeof input.schedule !== "string") invalidSetting("schedule must be a string");
312
+ if (input.schedule !== SCHEDULE_OFF && parseSchedule(input.schedule) === null) {
313
+ invalidSetting('schedule must be "off" or a cron expression of five fields', { schedule: input.schedule });
314
+ }
315
+ setting.schedule = input.schedule;
316
+ }
317
+ if (input.timeZone !== void 0) {
318
+ if (typeof input.timeZone !== "string" || !knowsTimeZone(input.timeZone)) {
319
+ invalidSetting("timeZone must name an IANA time zone", { timeZone: String(input.timeZone) });
320
+ }
321
+ setting.timeZone = input.timeZone;
322
+ }
323
+ if (encode(settingToWire(setting)).byteLength > MAX_SETTING_BYTES) {
324
+ invalidSetting(`The query suggestions setting must encode to at most ${MAX_SETTING_BYTES} bytes`);
325
+ }
326
+ return setting;
327
+ }
328
+ function requireFieldsInSchema(setting, schema) {
329
+ const flat = flattenSchema(schema);
330
+ for (const field of setting.fields) {
331
+ const type = flat[field];
332
+ if (type !== "string" && type !== "string[]") {
333
+ invalidSetting(`Field "${field}" must be a string or string[] field of the schema`, { field });
334
+ }
335
+ }
336
+ }
337
+ function settingToWire(setting) {
338
+ const wire = { enabled: setting.enabled, fields: [...setting.fields] };
339
+ for (const range of RANGES) {
340
+ const value = setting[range.key];
341
+ if (value !== void 0) wire[range.wire] = value;
342
+ }
343
+ if (setting.schedule !== void 0) wire.schedule = setting.schedule;
344
+ if (setting.timeZone !== void 0) wire.time_zone = setting.timeZone;
345
+ return wire;
346
+ }
347
+ function settingFromWire(raw) {
348
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
349
+ invalidSetting("The stored query suggestions setting is not a map");
350
+ }
351
+ const wire = raw;
352
+ const camel = {};
353
+ const byWire = new Map([
354
+ ["enabled", "enabled"],
355
+ ["fields", "fields"],
356
+ ["schedule", "schedule"],
357
+ ["time_zone", "timeZone"],
358
+ ...RANGES.map((range) => [range.wire, range.key])
359
+ ]);
360
+ for (const [key, value] of Object.entries(wire)) {
361
+ const camelKey = byWire.get(key);
362
+ if (camelKey === void 0) invalidSetting(`The stored query suggestions setting holds an unknown key "${key}"`);
363
+ camel[camelKey] = value;
364
+ }
365
+ return validateSetting(camel);
366
+ }
367
+ function validateSource(raw) {
368
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
369
+ invalidSetting("The suggestions index marker must be a map");
370
+ }
371
+ const { index, group, ...rest } = raw;
372
+ if (Object.keys(rest).length > 0) invalidSetting("The suggestions index marker holds an unknown key");
373
+ if (typeof index !== "string" || index.length === 0 || index.length > MAX_SOURCE_INDEX_NAME_LENGTH) {
374
+ invalidSetting("The suggestions index marker needs the name of its source index");
375
+ }
376
+ if (!isGroup(group)) {
377
+ invalidSetting("The suggestions index marker needs a valid group");
378
+ }
379
+ return { index, group };
380
+ }
381
+
382
+ export { invalidSetting, latestMatchAtOrBefore, nextMatchAfter, parseSchedule, requireFieldsInSchema, resolveSetting, settingFromWire, settingToWire, validateSetting, validateSource };