@delali/narsil 0.3.1-next.156 → 0.3.1-next.160

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 (564) hide show
  1. package/dist/adapters/filesystem.mjs +3 -3
  2. package/dist/adapters/gcs.mjs +3 -3
  3. package/dist/adapters/indexeddb.mjs +1 -1
  4. package/dist/adapters/s3.mjs +3 -3
  5. package/dist/browser/{chunk-3V7DNNZL.mjs → chunk-4RNSFVWI.mjs} +20997 -19899
  6. package/dist/browser/chunk-MMHIIL5B.mjs +564 -0
  7. package/dist/browser/chunk-MZHQ65VI.mjs +1228 -0
  8. package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
  9. package/dist/browser/{chunk-VLJQW4J6.mjs → core-leaf-TJAGWPZZ.mjs} +4674 -3102
  10. package/dist/browser/{durability-config-TIYKW6XX.mjs → durability-config-SGB5ZP5K.mjs} +8 -3
  11. package/dist/browser/embed-RF2MPGAO.mjs +222 -0
  12. package/dist/{geo-index-MRH5JMIR.mjs → browser/geo-index-GNHY4PUB.mjs} +190 -93
  13. package/dist/{react-native/chunks/module-TTEVPRCW.mjs → browser/module-362VSIGR.mjs} +1570 -275
  14. package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
  15. package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
  16. package/dist/browser/optional-writes-WMZX4OEC.mjs +3196 -0
  17. package/dist/browser/phrase-module-22TKMXWI.mjs +616 -0
  18. package/dist/browser/resolve-vector-text-KI65IHMD.mjs +60 -0
  19. package/dist/{react-native/chunks/restore-hooks-IBGIY3DR.mjs → browser/restore-queue-S4BWOGMU.mjs} +98 -36
  20. package/dist/{react-native/chunks/runtime-R5E3TB3J.mjs → browser/runtime-NU6VOVH2.mjs} +61 -25
  21. package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
  22. package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
  23. package/dist/browser/storage-leaf-X6CNRHJS.mjs +18221 -0
  24. package/dist/browser/store-leaf-AEMTAVHX.mjs +2069 -0
  25. package/dist/browser/{chunk-SSTPBZZX.mjs → suggestions-leaf-3Y6MR6OF.mjs} +441 -119
  26. package/dist/browser/worker-copies-WQCPP3TS.mjs +2750 -0
  27. package/dist/{capabilities-Da4ywVVl.d.ts → capabilities-BKDrry0z.d.ts} +2 -2
  28. package/dist/chunk-2JRERUNZ.mjs +217 -0
  29. package/dist/chunk-2RIS76RJ.mjs +212 -0
  30. package/dist/chunk-3B775F3C.mjs +252 -0
  31. package/dist/{chunk-K5QFDYST.mjs → chunk-3D6RZGJH.mjs} +3 -3
  32. package/dist/{chunk-INJYO3BU.mjs → chunk-4CAMH7FO.mjs} +1 -1
  33. package/dist/{chunk-U476IXKQ.mjs → chunk-4PY4JYMY.mjs} +2 -1
  34. package/dist/chunk-6EZW2GQL.mjs +978 -0
  35. package/dist/chunk-75UNINFA.mjs +271 -0
  36. package/dist/chunk-77AUVDQ5.mjs +7 -0
  37. package/dist/{browser/chunk-23XRXIBW.mjs → chunk-7MWYORQC.mjs} +10 -3
  38. package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
  39. package/dist/{chunk-XIHUI4KB.mjs → chunk-AB27FWZM.mjs} +8 -3
  40. package/dist/{chunk-XAXKV65G.mjs → chunk-BXM7XM4G.mjs} +7 -3
  41. package/dist/{chunk-HJJI72X7.mjs → chunk-C7YQHCSO.mjs} +1 -1
  42. package/dist/{chunk-RVGRFOGN.mjs → chunk-D456ZFPQ.mjs} +2 -1
  43. package/dist/{chunk-KKQC526K.mjs → chunk-E2F6LZR3.mjs} +19 -21
  44. package/dist/{chunk-I2KPOLOZ.mjs → chunk-FE3MRIBN.mjs} +104 -13
  45. package/dist/{chunk-KYYABCSW.mjs → chunk-FETZYCH7.mjs} +15 -1
  46. package/dist/{chunk-ZKP7G7TV.mjs → chunk-FVZ5DB6Y.mjs} +3 -2
  47. package/dist/{chunk-2UV4QBHW.mjs → chunk-GF4K7IUK.mjs} +317 -120
  48. package/dist/chunk-GXCDWLQI.mjs +193 -0
  49. package/dist/{chunk-25KDNIZZ.mjs → chunk-H64YDF5M.mjs} +3 -3
  50. package/dist/{browser/chunk-CRE3G7F3.mjs → chunk-HOOR4CP5.mjs} +63 -7
  51. package/dist/chunk-IB4BYLE3.mjs +127 -0
  52. package/dist/{chunk-3C7MTCCI.mjs → chunk-IE3Q62QD.mjs} +2 -2
  53. package/dist/chunk-IH3G6SJO.mjs +40 -0
  54. package/dist/chunk-JV74RKCY.mjs +3041 -0
  55. package/dist/{chunk-FRBFVQFN.mjs → chunk-K67I3RF4.mjs} +261 -101
  56. package/dist/chunk-KLVMK3R5.mjs +47 -0
  57. package/dist/{chunk-5VV4R6P7.mjs → chunk-LAWIJRMJ.mjs} +4154 -2577
  58. package/dist/chunk-LF4GB4PO.mjs +281 -0
  59. package/dist/chunk-NC4QLCZC.mjs +59 -0
  60. package/dist/chunk-OOO54OVC.mjs +627 -0
  61. package/dist/chunk-OUWZKNO3.mjs +207 -0
  62. package/dist/{chunk-FJKKCV4D.mjs → chunk-P5YLI5ED.mjs} +343 -182
  63. package/dist/{chunk-6I6AYAXS.mjs → chunk-PTTMGRG5.mjs} +9 -10
  64. package/dist/{browser/chunk-SRMZXJSL.mjs → chunk-Q3ZZH5Z7.mjs} +6 -0
  65. package/dist/chunk-QBVTYY4J.mjs +54 -0
  66. package/dist/{react-native/chunks/chunk-GXX3DQXP.mjs → chunk-R4CE4IVU.mjs} +352 -165
  67. package/dist/chunk-S2POFTLN.mjs +10 -0
  68. package/dist/{chunk-KJ3RTZDJ.mjs → chunk-S3BSDBF7.mjs} +10 -3
  69. package/dist/{chunk-FAKFUDZZ.mjs → chunk-SHGN3QIF.mjs} +80 -13
  70. package/dist/chunk-SXIRM4MX.mjs +3549 -0
  71. package/dist/{react-native/chunks/chunk-EJ33LCHV.mjs → chunk-TGPKS2UM.mjs} +47 -1
  72. package/dist/chunk-TINW4BSH.mjs +31301 -0
  73. package/dist/{cold-module-6MO2XJF2.mjs → chunk-TSLV5P2J.mjs} +397 -79
  74. package/dist/{chunk-HHBUCIUY.mjs → chunk-TW543F33.mjs} +3 -3
  75. package/dist/chunk-U6B7DUQW.mjs +788 -0
  76. package/dist/{chunk-FYOVBEMM.mjs → chunk-V3SGPXWQ.mjs} +8 -9
  77. package/dist/chunk-W34VJXY7.mjs +4723 -0
  78. package/dist/chunk-YETKPX5M.mjs +5 -0
  79. package/dist/chunk-ZQ6QY42L.mjs +59 -0
  80. package/dist/{client-DRv7UVeY.d.ts → client-CTp8RRiK.d.ts} +16 -4
  81. package/dist/client.d.ts +8 -8
  82. package/dist/client.mjs +70 -18
  83. package/dist/{config-DMwffLKn.d.ts → config-PCNzWjHL.d.ts} +6 -3
  84. package/dist/{config-CoSig5Ox.d.ts → config-_WT5grSL.d.ts} +3 -3
  85. package/dist/core-leaf-KXFGP74A.mjs +7 -0
  86. package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
  87. package/dist/direct-executor-MKTZBR26.mjs +16 -0
  88. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  89. package/dist/distribution/coordinator/etcd.mjs +7 -4
  90. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  91. package/dist/distribution/coordinator/in-memory.mjs +1 -2
  92. package/dist/distribution/transport/grpc.mjs +7 -2
  93. package/dist/distribution/transport/tcp.mjs +7 -1
  94. package/dist/distribution.d.ts +7 -7
  95. package/dist/distribution.mjs +1192 -1077
  96. package/dist/{react-native/chunks/durability-config-QXVZEO7T.mjs → durability-config-XV4XR7Y4.mjs} +7 -3
  97. package/dist/embed-4H7RTBVL.mjs +221 -0
  98. package/dist/embeddings/openai.mjs +2 -2
  99. package/dist/{engine-CFxPYqEk.d.ts → engine-DBRVR_d-.d.ts} +1252 -1239
  100. package/dist/{browser/geo-index-HHWGMNIS.mjs → geo-index-2ZMMWWSK.mjs} +190 -92
  101. package/dist/{index-C4AmUnl1.d.ts → index-Ck9w5WHz.d.ts} +1 -1
  102. package/dist/index.browser.mjs +4 -15
  103. package/dist/index.d.ts +1495 -78
  104. package/dist/index.mjs +14 -50
  105. package/dist/index.react-native.mjs +11 -28
  106. package/dist/invalidation/filesystem.mjs +1 -2
  107. package/dist/languages/albanian.mjs +1 -1
  108. package/dist/languages/amharic.mjs +1 -1
  109. package/dist/languages/arabic.mjs +1 -1
  110. package/dist/languages/armenian.mjs +1 -1
  111. package/dist/languages/azerbaijani.mjs +1 -1
  112. package/dist/languages/bambara.mjs +1 -1
  113. package/dist/languages/basque.mjs +1 -1
  114. package/dist/languages/belarusian.mjs +1 -1
  115. package/dist/languages/bengali.mjs +1 -1
  116. package/dist/languages/bosnian.mjs +1 -1
  117. package/dist/languages/breton.mjs +1 -1
  118. package/dist/languages/bulgarian.mjs +1 -1
  119. package/dist/languages/burmese.mjs +1 -1
  120. package/dist/languages/catalan.mjs +1 -1
  121. package/dist/languages/chinese.mjs +1 -1
  122. package/dist/languages/croatian.mjs +1 -1
  123. package/dist/languages/czech.mjs +1 -1
  124. package/dist/languages/dagbani.mjs +1 -1
  125. package/dist/languages/danish.mjs +1 -1
  126. package/dist/languages/dutch.mjs +1 -1
  127. package/dist/languages/english.mjs +1 -1
  128. package/dist/languages/esperanto.mjs +1 -1
  129. package/dist/languages/estonian.mjs +1 -1
  130. package/dist/languages/ewe.mjs +1 -1
  131. package/dist/languages/faroese.mjs +1 -1
  132. package/dist/languages/fijian.mjs +1 -1
  133. package/dist/languages/finnish.mjs +1 -1
  134. package/dist/languages/french.mjs +1 -1
  135. package/dist/languages/ga.mjs +1 -1
  136. package/dist/languages/galician.mjs +1 -1
  137. package/dist/languages/georgian.mjs +1 -1
  138. package/dist/languages/german.mjs +1 -1
  139. package/dist/languages/greek.mjs +1 -1
  140. package/dist/languages/guarani.mjs +1 -1
  141. package/dist/languages/gujarati.mjs +1 -1
  142. package/dist/languages/haitian-creole.mjs +1 -1
  143. package/dist/languages/hausa.mjs +1 -1
  144. package/dist/languages/hawaiian.mjs +1 -1
  145. package/dist/languages/hebrew.mjs +1 -1
  146. package/dist/languages/hindi.mjs +1 -1
  147. package/dist/languages/hungarian.mjs +1 -1
  148. package/dist/languages/icelandic.mjs +1 -1
  149. package/dist/languages/igbo.mjs +1 -1
  150. package/dist/languages/indonesian.mjs +1 -1
  151. package/dist/languages/irish.mjs +1 -1
  152. package/dist/languages/italian.mjs +1 -1
  153. package/dist/languages/japanese.mjs +1 -1
  154. package/dist/languages/kannada.mjs +1 -1
  155. package/dist/languages/kazakh.mjs +1 -1
  156. package/dist/languages/khmer.mjs +1 -1
  157. package/dist/languages/kinyarwanda.mjs +1 -1
  158. package/dist/languages/kirundi.mjs +1 -1
  159. package/dist/languages/korean.mjs +1 -1
  160. package/dist/languages/kurmanji.mjs +1 -1
  161. package/dist/languages/kyrgyz.mjs +1 -1
  162. package/dist/languages/lao.mjs +1 -1
  163. package/dist/languages/latin.mjs +1 -1
  164. package/dist/languages/latvian.mjs +1 -1
  165. package/dist/languages/lingala.mjs +1 -1
  166. package/dist/languages/lithuanian.mjs +1 -1
  167. package/dist/languages/luxembourgish.mjs +1 -1
  168. package/dist/languages/macedonian.mjs +1 -1
  169. package/dist/languages/malagasy.mjs +1 -1
  170. package/dist/languages/malay.mjs +1 -1
  171. package/dist/languages/malayalam.mjs +1 -1
  172. package/dist/languages/maltese.mjs +1 -1
  173. package/dist/languages/maori.mjs +1 -1
  174. package/dist/languages/marathi.mjs +1 -1
  175. package/dist/languages/nepali.mjs +1 -1
  176. package/dist/languages/norwegian.mjs +1 -1
  177. package/dist/languages/oromo.mjs +1 -1
  178. package/dist/languages/persian.mjs +1 -1
  179. package/dist/languages/polish.mjs +1 -1
  180. package/dist/languages/portuguese.mjs +1 -1
  181. package/dist/languages/punjabi.mjs +1 -1
  182. package/dist/languages/romanian.mjs +1 -1
  183. package/dist/languages/russian.mjs +1 -1
  184. package/dist/languages/samoan.mjs +1 -1
  185. package/dist/languages/sanskrit.mjs +1 -1
  186. package/dist/languages/scottish-gaelic.mjs +1 -1
  187. package/dist/languages/serbian.mjs +1 -1
  188. package/dist/languages/shona.mjs +1 -1
  189. package/dist/languages/sinhala.mjs +1 -1
  190. package/dist/languages/slovak.mjs +1 -1
  191. package/dist/languages/slovenian.mjs +1 -1
  192. package/dist/languages/sorani.mjs +1 -1
  193. package/dist/languages/spanish.mjs +1 -1
  194. package/dist/languages/swahili.mjs +1 -1
  195. package/dist/languages/swedish.mjs +1 -1
  196. package/dist/languages/tagalog.mjs +1 -1
  197. package/dist/languages/tamil.mjs +1 -1
  198. package/dist/languages/tatar.mjs +1 -1
  199. package/dist/languages/telugu.mjs +1 -1
  200. package/dist/languages/thai.mjs +1 -1
  201. package/dist/languages/tibetan.mjs +1 -1
  202. package/dist/languages/tigrinya.mjs +1 -1
  203. package/dist/languages/tongan.mjs +1 -1
  204. package/dist/languages/turkish.mjs +1 -1
  205. package/dist/languages/twi.mjs +1 -1
  206. package/dist/languages/ukrainian.mjs +1 -1
  207. package/dist/languages/urdu.mjs +1 -1
  208. package/dist/languages/vietnamese.mjs +1 -1
  209. package/dist/languages/welsh.mjs +1 -1
  210. package/dist/languages/wolof.mjs +1 -1
  211. package/dist/languages/xhosa.mjs +1 -1
  212. package/dist/languages/yoruba.mjs +1 -1
  213. package/dist/languages/zulu.mjs +1 -1
  214. package/dist/{long-query-thread-YA4IAYSY.mjs → long-query-thread-JMGNGF6V.mjs} +74 -58
  215. package/dist/{module-N55W4Q5C.mjs → module-ZJ6ARG6V.mjs} +444 -111
  216. package/dist/msgpack-leaf-5WFRP6JM.mjs +9 -0
  217. package/dist/optional-reads-BR3BOVZW.mjs +3373 -0
  218. package/dist/optional-writes-DDFHYUOH.mjs +218 -0
  219. package/dist/{paged-partition-archive-PXW5XAYU.mjs → paged-partition-archive-G576XGVE.mjs} +29 -69
  220. package/dist/partial-words.browser.mjs +1649 -0
  221. package/dist/partial-words.mjs +15 -14
  222. package/dist/{chunk-CITFCZKF.mjs → pattern.browser.mjs} +153 -186
  223. package/dist/pattern.mjs +6 -8
  224. package/dist/persistence/durability/checkpoint-worker.d.ts +32 -24
  225. package/dist/persistence/durability/checkpoint-worker.mjs +27 -58
  226. package/dist/phrase-module-XK3T44VU.mjs +634 -0
  227. package/dist/query-actions-OMXJEC2J.mjs +118 -0
  228. package/dist/query-suggestions/merge-worker.mjs +18 -54
  229. package/dist/query-suggestions.browser.mjs +26 -226
  230. package/dist/query-suggestions.d.ts +2 -2
  231. package/dist/query-suggestions.mjs +16 -67
  232. package/dist/react-native/chunks/chunk-4EXKQ2IB.mjs +565 -0
  233. package/dist/react-native/chunks/chunk-52QD7CBJ.mjs +52 -0
  234. package/dist/react-native/chunks/chunk-72OKYHZL.mjs +969 -0
  235. package/dist/react-native/chunks/chunk-AQOWRH2C.mjs +802 -0
  236. package/dist/react-native/chunks/chunk-FTQ7JNMU.mjs +898 -0
  237. package/dist/react-native/chunks/chunk-G3CUQ333.mjs +42 -0
  238. package/dist/{chunk-TBC3XUL2.mjs → react-native/chunks/chunk-HRDMIQ63.mjs} +53 -1
  239. package/dist/react-native/chunks/{chunk-KV46CT4D.mjs → chunk-IY6U6HRA.mjs} +63 -7
  240. package/dist/react-native/chunks/chunk-J2NQW353.mjs +212 -0
  241. package/dist/react-native/chunks/chunk-L4R5ITVG.mjs +29047 -0
  242. package/dist/react-native/chunks/chunk-OK3WUA6N.mjs +54 -0
  243. package/dist/react-native/chunks/{chunk-MVXELMJX.mjs → chunk-PVMEHBQO.mjs} +1 -1
  244. package/dist/react-native/chunks/{chunk-DZ7H7D2C.mjs → chunk-TQ26BKBH.mjs} +6 -0
  245. package/dist/react-native/chunks/{chunk-6VBXNFLE.mjs → chunk-VUJCSQG5.mjs} +3 -1
  246. package/dist/react-native/chunks/{chunk-ENLMYKSX.mjs → chunk-XEGKQKLY.mjs} +5385 -3114
  247. package/dist/react-native/chunks/chunk-YOTP2FPE.mjs +232 -0
  248. package/dist/react-native/chunks/chunk-ZIU6TWXG.mjs +127 -0
  249. package/dist/react-native/chunks/core-leaf-5B4JXCVA.mjs +6 -0
  250. package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
  251. package/dist/{durability-config-GE4U7MCZ.mjs → react-native/chunks/durability-config-3IOXIPYZ.mjs} +7 -3
  252. package/dist/react-native/chunks/embed-3WQ2CCR5.mjs +221 -0
  253. package/dist/react-native/chunks/{geo-index-PX3BIHAH.mjs → geo-index-QEYKEVPH.mjs} +190 -93
  254. package/dist/react-native/chunks/{chunk-CKNRFDTZ.mjs → gzip.react-native-DLO4WW27.mjs} +2 -1
  255. package/dist/{browser/module-TCT66FWA.mjs → react-native/chunks/module-VUA27HZZ.mjs} +1018 -540
  256. package/dist/react-native/chunks/msgpack-leaf-TR66ZVAX.mjs +7 -0
  257. package/dist/react-native/chunks/optional-reads-WDTLLHUT.mjs +3364 -0
  258. package/dist/react-native/chunks/optional-writes-FZV3QW34.mjs +267 -0
  259. package/dist/react-native/chunks/phrase-module-KCQWVXYZ.mjs +635 -0
  260. package/dist/react-native/chunks/resolve-vector-text-LXRYXF7M.mjs +59 -0
  261. package/dist/react-native/chunks/restore-queue-EI2V2I4S.mjs +179 -0
  262. package/dist/{browser/runtime-OTAGEFQW.mjs → react-native/chunks/runtime-BUCSAK4U.mjs} +61 -25
  263. package/dist/react-native/chunks/segment-codec-leaf-6ULP7H3I.mjs +12 -0
  264. package/dist/react-native/chunks/segment-merge-leaf-F4GQZNK6.mjs +13 -0
  265. package/dist/react-native/chunks/storage-leaf-OAXBU2L6.mjs +18042 -0
  266. package/dist/react-native/chunks/store-leaf-GY2ZZFXB.mjs +14 -0
  267. package/dist/react-native/chunks/{chunk-UQ4OAXKU.mjs → suggestions-leaf-SQEZ4IBS.mjs} +332 -118
  268. package/dist/react-native/chunks/worker-copies-EEHSCFJW.mjs +2627 -0
  269. package/dist/react-native/partial-words.mjs +954 -35
  270. package/dist/react-native/pattern.mjs +238 -111
  271. package/dist/react-native/query-suggestions.mjs +33 -239
  272. package/dist/react-native/sync.mjs +127 -50
  273. package/dist/react-native/synonyms.mjs +256 -112
  274. package/dist/react.d.ts +9 -9
  275. package/dist/react.mjs +6 -0
  276. package/dist/{rerank-MQ37IYRV.mjs → rerank-Y6MWBMTT.mjs} +17 -8
  277. package/dist/rerankers/http.mjs +2 -2
  278. package/dist/resolve-vector-text-4PDRTPNQ.mjs +2 -0
  279. package/dist/restore-queue-KPYSRJ4A.mjs +184 -0
  280. package/dist/runtime-4GKUIAKV.mjs +595 -0
  281. package/dist/{schema-Jwt928nJ.d.ts → schema-C_7yRJLt.d.ts} +1 -1
  282. package/dist/segment-codec-leaf-6IFBSBPN.mjs +17 -0
  283. package/dist/segment-merge-leaf-VE3FUSVE.mjs +17 -0
  284. package/dist/server.d.ts +35 -13
  285. package/dist/server.mjs +90 -101
  286. package/dist/{browser/durability-wiring-A7BVG2DW.mjs → storage-leaf-HMIIOUYN.mjs} +2348 -902
  287. package/dist/store-leaf-M7T7SUZJ.mjs +19 -0
  288. package/dist/stored-values-BWIMpiT_.d.ts +25 -0
  289. package/dist/suggestions-leaf-Q3Q5D6XV.mjs +53 -0
  290. package/dist/sync/filesystem.d.ts +3 -3
  291. package/dist/sync/filesystem.mjs +27 -11
  292. package/dist/sync/indexeddb.browser.mjs +287 -0
  293. package/dist/sync/indexeddb.d.ts +3 -3
  294. package/dist/sync/indexeddb.mjs +7 -2
  295. package/dist/sync.browser.mjs +120 -70
  296. package/dist/sync.d.ts +4 -4
  297. package/dist/sync.mjs +121 -57
  298. package/dist/{chunk-I5B7RXU7.mjs → synonyms.browser.mjs} +248 -135
  299. package/dist/synonyms.mjs +15 -11
  300. package/dist/{tasks-qrJojgST.d.ts → tasks-B4tT4vmP.d.ts} +4 -4
  301. package/dist/thread-SNILJXX3.mjs +30 -0
  302. package/dist/{types-BZCGjfLn.d.ts → types-CTg0KaMy.d.ts} +2 -2
  303. package/dist/vector/search-worker.d.ts +7 -1
  304. package/dist/vector/search-worker.mjs +9 -13
  305. package/dist/worker-copies-ZLZS2CUM.mjs +2152 -0
  306. package/dist/workers/entry.mjs +60 -30
  307. package/openapi.json +137 -50
  308. package/package.json +233 -8
  309. package/dist/analysis-change-5BQOQ4BF.mjs +0 -55
  310. package/dist/analysis-change-entry-TXX6JSMX.mjs +0 -1
  311. package/dist/archive-history-E4R73RWD.mjs +0 -29
  312. package/dist/browser/analysis-change-435CUEPZ.mjs +0 -933
  313. package/dist/browser/analysis-change-entry-HZXKPPGV.mjs +0 -1
  314. package/dist/browser/archive-history-4IP5XQZY.mjs +0 -29
  315. package/dist/browser/chunk-2CFI5VVV.mjs +0 -241
  316. package/dist/browser/chunk-2TI4SSUP.mjs +0 -315
  317. package/dist/browser/chunk-3I27KXQD.mjs +0 -34
  318. package/dist/browser/chunk-3SSRJMFN.mjs +0 -100
  319. package/dist/browser/chunk-4NGKC4H4.mjs +0 -2635
  320. package/dist/browser/chunk-4RD3AFSB.mjs +0 -32
  321. package/dist/browser/chunk-5W3MMTLG.mjs +0 -19
  322. package/dist/browser/chunk-6LWDPLTB.mjs +0 -177
  323. package/dist/browser/chunk-7IGKGWSQ.mjs +0 -79
  324. package/dist/browser/chunk-7U3WVJUP.mjs +0 -150
  325. package/dist/browser/chunk-ATEBYXP6.mjs +0 -10
  326. package/dist/browser/chunk-BHFQATSC.mjs +0 -432
  327. package/dist/browser/chunk-DSXIBE6N.mjs +0 -78
  328. package/dist/browser/chunk-EA63E3D2.mjs +0 -857
  329. package/dist/browser/chunk-ELV4OZOI.mjs +0 -29
  330. package/dist/browser/chunk-EXQZGUQH.mjs +0 -193
  331. package/dist/browser/chunk-G64Q6OJF.mjs +0 -96
  332. package/dist/browser/chunk-GPPOG6PT.mjs +0 -9
  333. package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
  334. package/dist/browser/chunk-IZXVW2ZJ.mjs +0 -217
  335. package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
  336. package/dist/browser/chunk-K4Q6KX3R.mjs +0 -2528
  337. package/dist/browser/chunk-KZWSX6BH.mjs +0 -645
  338. package/dist/browser/chunk-MGI4BCXC.mjs +0 -63
  339. package/dist/browser/chunk-ML7THVLJ.mjs +0 -38
  340. package/dist/browser/chunk-MOG4OVDK.mjs +0 -51
  341. package/dist/browser/chunk-NLWTBAGB.mjs +0 -111
  342. package/dist/browser/chunk-NQAME3RK.mjs +0 -21
  343. package/dist/browser/chunk-NXQG7DRA.mjs +0 -318
  344. package/dist/browser/chunk-OEDCEZXJ.mjs +0 -92
  345. package/dist/browser/chunk-OIZS5KIX.mjs +0 -6
  346. package/dist/browser/chunk-RA6LSBCM.mjs +0 -43
  347. package/dist/browser/chunk-STOWQFT3.mjs +0 -1829
  348. package/dist/browser/chunk-TK63WFXK.mjs +0 -90
  349. package/dist/browser/chunk-TY7L6OXO.mjs +0 -69
  350. package/dist/browser/chunk-U3JOQGWX.mjs +0 -19
  351. package/dist/browser/chunk-U4YDIBUT.mjs +0 -653
  352. package/dist/browser/chunk-VI7BQR4U.mjs +0 -21
  353. package/dist/browser/chunk-WI4MR75E.mjs +0 -86
  354. package/dist/browser/chunk-WN464PTL.mjs +0 -375
  355. package/dist/browser/chunk-WXLBZJMT.mjs +0 -25
  356. package/dist/browser/chunk-XAWNZ4G2.mjs +0 -151
  357. package/dist/browser/chunk-ZI2V4VD7.mjs +0 -21
  358. package/dist/browser/cold-module-2EHCIV4K.mjs +0 -759
  359. package/dist/browser/engine-hooks-E4UD67JD.mjs +0 -17
  360. package/dist/browser/gzip-5S7ROJFJ.mjs +0 -1
  361. package/dist/browser/import-DXYB6756.mjs +0 -19
  362. package/dist/browser/methods-KTQCSIN4.mjs +0 -30
  363. package/dist/browser/module-NIYMEA5R.mjs +0 -23
  364. package/dist/browser/operations-OJ3BXS55.mjs +0 -5
  365. package/dist/browser/phrase-module-HAT3TLZN.mjs +0 -328
  366. package/dist/browser/pool-3JLET5RO.mjs +0 -297
  367. package/dist/browser/release-76MXRPGV.mjs +0 -33
  368. package/dist/browser/restore-hooks-YPN4ZFCY.mjs +0 -114
  369. package/dist/browser/restore-queue-G3RQGL3Y.mjs +0 -55
  370. package/dist/browser/retention-ZWVMNC3Q.mjs +0 -210
  371. package/dist/browser/snapshot-VEQNIE6C.mjs +0 -963
  372. package/dist/browser/start-BM442C6R.mjs +0 -25
  373. package/dist/browser/sync-state-P5XG6LTQ.mjs +0 -15
  374. package/dist/browser/write-2EVMZWDE.mjs +0 -194
  375. package/dist/chunk-2NE7VCYE.mjs +0 -212
  376. package/dist/chunk-37CD3OKS.mjs +0 -87
  377. package/dist/chunk-3HYC4JRF.mjs +0 -50
  378. package/dist/chunk-3MXV3VHR.mjs +0 -46
  379. package/dist/chunk-3OH67G7R.mjs +0 -214
  380. package/dist/chunk-46KY2PJD.mjs +0 -905
  381. package/dist/chunk-4KKXNJM6.mjs +0 -242
  382. package/dist/chunk-5YNRKI2C.mjs +0 -81
  383. package/dist/chunk-6HTGOXIK.mjs +0 -875
  384. package/dist/chunk-6OEGXLBX.mjs +0 -57
  385. package/dist/chunk-6RC4K46J.mjs +0 -86
  386. package/dist/chunk-7GFE3PEY.mjs +0 -40
  387. package/dist/chunk-7GXJUJ24.mjs +0 -49
  388. package/dist/chunk-7LXHHCXZ.mjs +0 -1397
  389. package/dist/chunk-7V5IUP2T.mjs +0 -63
  390. package/dist/chunk-A4L7YTKX.mjs +0 -458
  391. package/dist/chunk-BEZH7VEH.mjs +0 -23
  392. package/dist/chunk-BTPGQC6Z.mjs +0 -27
  393. package/dist/chunk-BU4SAIC4.mjs +0 -196
  394. package/dist/chunk-BWZ3P4MU.mjs +0 -20
  395. package/dist/chunk-CSLGFPFQ.mjs +0 -218
  396. package/dist/chunk-CZQ33DLW.mjs +0 -78
  397. package/dist/chunk-DP5C7YFQ.mjs +0 -543
  398. package/dist/chunk-DWEPMFJE.mjs +0 -240
  399. package/dist/chunk-EEBCDP36.mjs +0 -32
  400. package/dist/chunk-EFBDHH5P.mjs +0 -7081
  401. package/dist/chunk-FB6463IN.mjs +0 -1499
  402. package/dist/chunk-FCJ553HS.mjs +0 -655
  403. package/dist/chunk-FNGAM5B7.mjs +0 -2639
  404. package/dist/chunk-FOCV4CBZ.mjs +0 -87
  405. package/dist/chunk-FQBFZAWG.mjs +0 -27
  406. package/dist/chunk-G6HRSGOU.mjs +0 -74
  407. package/dist/chunk-GES7U2PM.mjs +0 -68
  408. package/dist/chunk-GH4WQ22V.mjs +0 -34
  409. package/dist/chunk-GQPTDQCL.mjs +0 -54
  410. package/dist/chunk-HFPMMRQT.mjs +0 -206
  411. package/dist/chunk-HJSN7UYG.mjs +0 -10
  412. package/dist/chunk-I53G4JAU.mjs +0 -1974
  413. package/dist/chunk-I54T6CQP.mjs +0 -117
  414. package/dist/chunk-IPN7S4KX.mjs +0 -130
  415. package/dist/chunk-J4IJTTEX.mjs +0 -226
  416. package/dist/chunk-JDJBQLRO.mjs +0 -1126
  417. package/dist/chunk-JWRUUCWD.mjs +0 -151
  418. package/dist/chunk-K4ZIGL2O.mjs +0 -290
  419. package/dist/chunk-KAKQ74LS.mjs +0 -53
  420. package/dist/chunk-KF4EXSM4.mjs +0 -21
  421. package/dist/chunk-KHKIRS5D.mjs +0 -113
  422. package/dist/chunk-KOKM4PQN.mjs +0 -52
  423. package/dist/chunk-KP7TYHWT.mjs +0 -92
  424. package/dist/chunk-KZ3NX2P7.mjs +0 -21
  425. package/dist/chunk-L5ORED7V.mjs +0 -25
  426. package/dist/chunk-L6V6BST3.mjs +0 -1435
  427. package/dist/chunk-LHKOSI2J.mjs +0 -58
  428. package/dist/chunk-LQG5G2LY.mjs +0 -39
  429. package/dist/chunk-MATMVH65.mjs +0 -9
  430. package/dist/chunk-MP7ABPTD.mjs +0 -189
  431. package/dist/chunk-MQOJIO5B.mjs +0 -316
  432. package/dist/chunk-NF4DT3IH.mjs +0 -85
  433. package/dist/chunk-ORN5BLL7.mjs +0 -11
  434. package/dist/chunk-P5ZI2P2W.mjs +0 -7481
  435. package/dist/chunk-PELHVTO7.mjs +0 -24
  436. package/dist/chunk-PWC4VB3Q.mjs +0 -106
  437. package/dist/chunk-Q2UL2TPC.mjs +0 -21
  438. package/dist/chunk-QHPYS427.mjs +0 -66
  439. package/dist/chunk-QJVOLKU6.mjs +0 -111
  440. package/dist/chunk-QOW2JPUI.mjs +0 -634
  441. package/dist/chunk-QYRNLLLI.mjs +0 -99
  442. package/dist/chunk-RDXO6JST.mjs +0 -63
  443. package/dist/chunk-RFBLQLLZ.mjs +0 -16
  444. package/dist/chunk-RLOES5SX.mjs +0 -31
  445. package/dist/chunk-RZWWB2XR.mjs +0 -96
  446. package/dist/chunk-S5LN746F.mjs +0 -10
  447. package/dist/chunk-SA5LOGO3.mjs +0 -470
  448. package/dist/chunk-SQJWAIF4.mjs +0 -12
  449. package/dist/chunk-TDIK6NTV.mjs +0 -10
  450. package/dist/chunk-TGS5UXBE.mjs +0 -216
  451. package/dist/chunk-TQXHPFWT.mjs +0 -177
  452. package/dist/chunk-TZ3355VS.mjs +0 -121
  453. package/dist/chunk-TZTRKM33.mjs +0 -74
  454. package/dist/chunk-U55XJEIG.mjs +0 -18
  455. package/dist/chunk-UHICS3JI.mjs +0 -83
  456. package/dist/chunk-VD7J552I.mjs +0 -28
  457. package/dist/chunk-VTTRFF2C.mjs +0 -3711
  458. package/dist/chunk-WX4LAO6M.mjs +0 -656
  459. package/dist/chunk-WZ7YV54N.mjs +0 -152
  460. package/dist/chunk-X5CV2E2B.mjs +0 -1
  461. package/dist/chunk-XXHN7J46.mjs +0 -101
  462. package/dist/chunk-Y4WPNHMC.mjs +0 -50
  463. package/dist/chunk-YEKL4JBK.mjs +0 -96
  464. package/dist/chunk-YTWZVGCB.mjs +0 -382
  465. package/dist/chunk-Z2KAFCRT.mjs +0 -30
  466. package/dist/chunk-ZXNQEW43.mjs +0 -18
  467. package/dist/chunk-ZYAY26KG.mjs +0 -29
  468. package/dist/direct-executor-FTMYY3TI.mjs +0 -34
  469. package/dist/durability-wiring-VIF5MOSY.mjs +0 -4064
  470. package/dist/engine-hooks-EGUGNZYE.mjs +0 -54
  471. package/dist/gzip-F4HMIEEQ.mjs +0 -1
  472. package/dist/import-XKDPJQDP.mjs +0 -56
  473. package/dist/methods-7IOINERF.mjs +0 -30
  474. package/dist/module-FQ4JWNQJ.mjs +0 -62
  475. package/dist/operations-G5EP6JPX.mjs +0 -5
  476. package/dist/phrase-module-XW5MKWP5.mjs +0 -330
  477. package/dist/pool-Y4A46T36.mjs +0 -298
  478. package/dist/react-native/chunks/analysis-change-LT5QBQ3H.mjs +0 -926
  479. package/dist/react-native/chunks/analysis-change-entry-SCVWK6OU.mjs +0 -1
  480. package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +0 -29
  481. package/dist/react-native/chunks/chunk-2PRHILX3.mjs +0 -529
  482. package/dist/react-native/chunks/chunk-3JWDECAZ.mjs +0 -858
  483. package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +0 -1
  484. package/dist/react-native/chunks/chunk-3WI35N75.mjs +0 -226
  485. package/dist/react-native/chunks/chunk-4DII3ZSM.mjs +0 -73
  486. package/dist/react-native/chunks/chunk-4J74WHQM.mjs +0 -177
  487. package/dist/react-native/chunks/chunk-4JYO3JD2.mjs +0 -242
  488. package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +0 -17
  489. package/dist/react-native/chunks/chunk-6WA3C3DV.mjs +0 -85
  490. package/dist/react-native/chunks/chunk-AAAETEJK.mjs +0 -27
  491. package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +0 -32
  492. package/dist/react-native/chunks/chunk-C5G6TJ7A.mjs +0 -140
  493. package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +0 -43
  494. package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +0 -10
  495. package/dist/react-native/chunks/chunk-DNXOMPAQ.mjs +0 -191
  496. package/dist/react-native/chunks/chunk-DVDX4SDR.mjs +0 -375
  497. package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +0 -12
  498. package/dist/react-native/chunks/chunk-F753DA54.mjs +0 -23
  499. package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +0 -40
  500. package/dist/react-native/chunks/chunk-FTZHMRD2.mjs +0 -18
  501. package/dist/react-native/chunks/chunk-G43IPIDG.mjs +0 -151
  502. package/dist/react-native/chunks/chunk-HJBJBH26.mjs +0 -34
  503. package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +0 -10
  504. package/dist/react-native/chunks/chunk-IYNT75CE.mjs +0 -111
  505. package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +0 -38
  506. package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +0 -15
  507. package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +0 -68
  508. package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +0 -93
  509. package/dist/react-native/chunks/chunk-LZSLNSUN.mjs +0 -193
  510. package/dist/react-native/chunks/chunk-MIP4SOR6.mjs +0 -22803
  511. package/dist/react-native/chunks/chunk-MJDQU5MW.mjs +0 -1225
  512. package/dist/react-native/chunks/chunk-MUWD2H2S.mjs +0 -21
  513. package/dist/react-native/chunks/chunk-NB3LP33V.mjs +0 -315
  514. package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +0 -8
  515. package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +0 -78
  516. package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +0 -29
  517. package/dist/react-native/chunks/chunk-PDRWWPKV.mjs +0 -2532
  518. package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +0 -79
  519. package/dist/react-native/chunks/chunk-POPDAGH6.mjs +0 -2636
  520. package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +0 -9
  521. package/dist/react-native/chunks/chunk-QUKQNI3H.mjs +0 -647
  522. package/dist/react-native/chunks/chunk-RDWG33MM.mjs +0 -79
  523. package/dist/react-native/chunks/chunk-SK2PWYDH.mjs +0 -654
  524. package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +0 -96
  525. package/dist/react-native/chunks/chunk-TP6KCKER.mjs +0 -63
  526. package/dist/react-native/chunks/chunk-U4KSKA4Z.mjs +0 -23
  527. package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +0 -68
  528. package/dist/react-native/chunks/chunk-VWUDIOT6.mjs +0 -218
  529. package/dist/react-native/chunks/chunk-WBYQRHDY.mjs +0 -86
  530. package/dist/react-native/chunks/chunk-YH7QY657.mjs +0 -288
  531. package/dist/react-native/chunks/chunk-YZW4CHM6.mjs +0 -562
  532. package/dist/react-native/chunks/chunk-ZLWVW734.mjs +0 -100
  533. package/dist/react-native/chunks/chunk-ZXZFN7FI.mjs +0 -432
  534. package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +0 -92
  535. package/dist/react-native/chunks/cold-module-KVZYUGRY.mjs +0 -772
  536. package/dist/react-native/chunks/durability-wiring-34OYO32E.mjs +0 -4942
  537. package/dist/react-native/chunks/engine-hooks-M7JV46NH.mjs +0 -30
  538. package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +0 -3
  539. package/dist/react-native/chunks/import-H6AQREWI.mjs +0 -32
  540. package/dist/react-native/chunks/methods-6W5U4C3H.mjs +0 -30
  541. package/dist/react-native/chunks/module-LBZPGOWH.mjs +0 -36
  542. package/dist/react-native/chunks/operations-GNRMD6EX.mjs +0 -5
  543. package/dist/react-native/chunks/phrase-module-QK22HSQ2.mjs +0 -329
  544. package/dist/react-native/chunks/pool-JR3NJCAF.mjs +0 -297
  545. package/dist/react-native/chunks/release-D7ZTIANM.mjs +0 -33
  546. package/dist/react-native/chunks/restore-queue-ZZX54AH7.mjs +0 -55
  547. package/dist/react-native/chunks/retention-EW4TTDFB.mjs +0 -223
  548. package/dist/react-native/chunks/snapshot-REYVIN3X.mjs +0 -975
  549. package/dist/react-native/chunks/start-BQK6KN3R.mjs +0 -38
  550. package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +0 -15
  551. package/dist/react-native/chunks/write-FQAYCZF5.mjs +0 -207
  552. package/dist/release-BH3DKW3T.mjs +0 -33
  553. package/dist/restore-hooks-CDERDEF4.mjs +0 -153
  554. package/dist/restore-queue-7NNSTROA.mjs +0 -55
  555. package/dist/retention-QSVBBNRM.mjs +0 -66
  556. package/dist/runtime-COIUORCN.mjs +0 -177
  557. package/dist/snapshot-RH4NSKIZ.mjs +0 -782
  558. package/dist/start-MCKCOGIW.mjs +0 -66
  559. package/dist/sync-state-ZWHLAFLE.mjs +0 -15
  560. package/dist/thread-O4SBJJJS.mjs +0 -50
  561. package/dist/write-3FK7NG3Y.mjs +0 -232
  562. /package/dist/browser/{chunk-M3MQE2X7.mjs → digest-leaf-64IPRPZD.mjs} +0 -0
  563. /package/dist/browser/{chunk-JNOAKDUM.mjs → gzip-JF3S6PPT.mjs} +0 -0
  564. /package/dist/{chunk-ZXNNR73R.mjs → gzip-2UCZW2MM.mjs} +0 -0
@@ -0,0 +1,1228 @@
1
+ // src/errors.ts
2
+ var NARSIL_ERROR_MARKER = /* @__PURE__ */ Symbol.for("@delali/narsil.NarsilError");
3
+ var ErrorCodes = {
4
+ SCHEMA_INVALID_TYPE: "SCHEMA_INVALID_TYPE",
5
+ SCHEMA_DEPTH_EXCEEDED: "SCHEMA_DEPTH_EXCEEDED",
6
+ SCHEMA_INVALID_VECTOR_DIMENSION: "SCHEMA_INVALID_VECTOR_DIMENSION",
7
+ SCHEMA_INVALID_GEOPOINT: "SCHEMA_INVALID_GEOPOINT",
8
+ DOC_NOT_FOUND: "DOC_NOT_FOUND",
9
+ DOC_ALREADY_EXISTS: "DOC_ALREADY_EXISTS",
10
+ DOC_VALIDATION_FAILED: "DOC_VALIDATION_FAILED",
11
+ INDEX_NOT_FOUND: "INDEX_NOT_FOUND",
12
+ INDEX_ALREADY_EXISTS: "INDEX_ALREADY_EXISTS",
13
+ INDEX_ORPHANED: "INDEX_ORPHANED",
14
+ INDEX_REOPEN_CAPACITY_EXHAUSTED: "INDEX_REOPEN_CAPACITY_EXHAUSTED",
15
+ INSTANCE_SHUT_DOWN: "INSTANCE_SHUT_DOWN",
16
+ PARTITION_CORRUPTED: "PARTITION_CORRUPTED",
17
+ PARTITION_REBALANCING_BACKPRESSURE: "PARTITION_REBALANCING_BACKPRESSURE",
18
+ WORKER_CRASHED: "WORKER_CRASHED",
19
+ WORKER_BUSY: "WORKER_BUSY",
20
+ WORKER_TIMEOUT: "WORKER_TIMEOUT",
21
+ WORKER_ACTION_FAILED: "WORKER_ACTION_FAILED",
22
+ PERSISTENCE_SAVE_FAILED: "PERSISTENCE_SAVE_FAILED",
23
+ PERSISTENCE_LOAD_FAILED: "PERSISTENCE_LOAD_FAILED",
24
+ PERSISTENCE_DELETE_FAILED: "PERSISTENCE_DELETE_FAILED",
25
+ PERSISTENCE_CRC_MISMATCH: "PERSISTENCE_CRC_MISMATCH",
26
+ PERSISTENCE_WAL_CORRUPT: "PERSISTENCE_WAL_CORRUPT",
27
+ PERSISTENCE_FSYNC_FAILED: "PERSISTENCE_FSYNC_FAILED",
28
+ PERSISTENCE_DEPENDENCY_MISSING: "PERSISTENCE_DEPENDENCY_MISSING",
29
+ BACKUP_NOT_FOUND: "BACKUP_NOT_FOUND",
30
+ BACKUP_ALREADY_EXISTS: "BACKUP_ALREADY_EXISTS",
31
+ BACKUP_DAMAGED: "BACKUP_DAMAGED",
32
+ BACKUP_DURABILITY_REQUIRED: "BACKUP_DURABILITY_REQUIRED",
33
+ BACKUP_IN_PROGRESS: "BACKUP_IN_PROGRESS",
34
+ BACKUP_STORE_CLAIMED: "BACKUP_STORE_CLAIMED",
35
+ BACKUP_STORE_NOT_CONFIGURED: "BACKUP_STORE_NOT_CONFIGURED",
36
+ BACKUP_NOT_READY: "BACKUP_NOT_READY",
37
+ SYNC_DURABILITY_REQUIRED: "SYNC_DURABILITY_REQUIRED",
38
+ SYNC_BACKUP_STORE_REQUIRED: "SYNC_BACKUP_STORE_REQUIRED",
39
+ SYNC_NOT_READY: "SYNC_NOT_READY",
40
+ SYNC_NOT_ENABLED: "SYNC_NOT_ENABLED",
41
+ SYNC_SNAPSHOT_PREPARING: "SYNC_SNAPSHOT_PREPARING",
42
+ QUERY_SUGGESTIONS_NOT_ENABLED: "QUERY_SUGGESTIONS_NOT_ENABLED",
43
+ SEARCH_INVALID_FIELD: "SEARCH_INVALID_FIELD",
44
+ VECTOR_DIMENSION_MISMATCH: "VECTOR_DIMENSION_MISMATCH",
45
+ SEARCH_INVALID_FILTER: "SEARCH_INVALID_FILTER",
46
+ SEARCH_INVALID_MODE: "SEARCH_INVALID_MODE",
47
+ SEARCH_INVALID_CURSOR: "SEARCH_INVALID_CURSOR",
48
+ SEARCH_RESULT_WINDOW_EXCEEDED: "SEARCH_RESULT_WINDOW_EXCEEDED",
49
+ SEARCH_WORK_CAP_EXCEEDED: "SEARCH_WORK_CAP_EXCEEDED",
50
+ /**
51
+ * An engine fault: a write changed the index during a search that held every
52
+ * write, so the search could not answer from one state. A correct engine
53
+ * never raises it, and retrying the request does not help.
54
+ */
55
+ SEARCH_STATE_MOVED: "SEARCH_STATE_MOVED",
56
+ SEARCH_INVALID_PHRASE: "SEARCH_INVALID_PHRASE",
57
+ SEARCH_PHRASE_NOT_READY: "SEARCH_PHRASE_NOT_READY",
58
+ BM25_NOT_READY: "BM25_NOT_READY",
59
+ LANGUAGE_NOT_SUPPORTED: "LANGUAGE_NOT_SUPPORTED",
60
+ ENVELOPE_VERSION_MISMATCH: "ENVELOPE_VERSION_MISMATCH",
61
+ ENVELOPE_INVALID_MAGIC: "ENVELOPE_INVALID_MAGIC",
62
+ PARTITION_CAPACITY_EXCEEDED: "PARTITION_CAPACITY_EXCEEDED",
63
+ RESTORE_MEMORY_EXCEEDED: "RESTORE_MEMORY_EXCEEDED",
64
+ MEMORY_WRITE_BLOCKED: "MEMORY_WRITE_BLOCKED",
65
+ ANALYSIS_CHANGE_REPLACED: "ANALYSIS_CHANGE_REPLACED",
66
+ ANALYSIS_CHANGE_NOT_READY: "ANALYSIS_CHANGE_NOT_READY",
67
+ ANALYSIS_GENERATION_MISSING: "ANALYSIS_GENERATION_MISSING",
68
+ ANALYSIS_REBUILD_MEMORY_EXCEEDED: "ANALYSIS_REBUILD_MEMORY_EXCEEDED",
69
+ EMBEDDING_FAILED: "EMBEDDING_FAILED",
70
+ EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH",
71
+ EMBEDDING_NO_SOURCE: "EMBEDDING_NO_SOURCE",
72
+ EMBEDDING_CONFIG_INVALID: "EMBEDDING_CONFIG_INVALID",
73
+ RERANK_FAILED: "RERANK_FAILED",
74
+ RERANK_CONFIG_INVALID: "RERANK_CONFIG_INVALID",
75
+ DOC_MISSING_REQUIRED_FIELD: "DOC_MISSING_REQUIRED_FIELD",
76
+ CONFIG_INVALID: "CONFIG_INVALID",
77
+ QUERY_ROUTING_FAILED: "QUERY_ROUTING_FAILED",
78
+ QUERY_PARTIAL_FAILURE: "QUERY_PARTIAL_FAILURE",
79
+ QUERY_NODE_TIMEOUT: "QUERY_NODE_TIMEOUT",
80
+ QUERY_NO_ACTIVE_REPLICA: "QUERY_NO_ACTIVE_REPLICA",
81
+ SEARCH_CONTEXT_MISSING: "SEARCH_CONTEXT_MISSING",
82
+ CLUSTER_OPERATION_UNSUPPORTED: "CLUSTER_OPERATION_UNSUPPORTED",
83
+ CLUSTER_WRITE_BLOCKED: "CLUSTER_WRITE_BLOCKED",
84
+ ALLOCATION_NO_DATA_NODES: "ALLOCATION_NO_DATA_NODES",
85
+ ALLOCATION_INVALID_CONFIG: "ALLOCATION_INVALID_CONFIG",
86
+ ALLOCATION_FAILED: "ALLOCATION_FAILED",
87
+ CONTROLLER_METADATA_INVALID: "CONTROLLER_METADATA_INVALID",
88
+ NODE_BOOTSTRAP_FAILED: "NODE_BOOTSTRAP_FAILED",
89
+ NODE_ALREADY_JOINED: "NODE_ALREADY_JOINED",
90
+ NODE_NOT_JOINED: "NODE_NOT_JOINED",
91
+ NODE_NOT_READY: "NODE_NOT_READY",
92
+ NODE_NOT_CONTROLLER: "NODE_NOT_CONTROLLER",
93
+ NODE_VERSION_INCOMPATIBLE: "NODE_VERSION_INCOMPATIBLE",
94
+ COORDINATOR_DEPENDENCY_MISSING: "COORDINATOR_DEPENDENCY_MISSING",
95
+ COORDINATOR_AUTH_FAILED: "COORDINATOR_AUTH_FAILED",
96
+ COORDINATOR_UNAVAILABLE: "COORDINATOR_UNAVAILABLE",
97
+ TRANSPORT_DEPENDENCY_MISSING: "TRANSPORT_DEPENDENCY_MISSING",
98
+ NATIVE_DEPENDENCY_MISSING: "NATIVE_DEPENDENCY_MISSING",
99
+ REPLICATION_ENTRY_INVALID: "REPLICATION_ENTRY_INVALID",
100
+ REPLICATION_INSYNC_REMOVAL_FAILED: "REPLICATION_INSYNC_REMOVAL_FAILED",
101
+ REPLICATION_ROLLBACK_FAILED: "REPLICATION_ROLLBACK_FAILED",
102
+ REPLICATION_OUTCOME_UNKNOWN: "REPLICATION_OUTCOME_UNKNOWN",
103
+ REPLICATION_WRITE_CONFLICT: "REPLICATION_WRITE_CONFLICT",
104
+ REPLICATION_LOG_FULL: "REPLICATION_LOG_FULL",
105
+ REPLICATION_ENTRY_CORRUPT: "REPLICATION_ENTRY_CORRUPT",
106
+ REPLICATION_SNAPSHOT_CORRUPT: "REPLICATION_SNAPSHOT_CORRUPT",
107
+ REPLICATION_TERM_MISMATCH: "REPLICATION_TERM_MISMATCH",
108
+ REPLICATION_SYNC_FAILED: "REPLICATION_SYNC_FAILED",
109
+ PARTITION_NOT_PRIMARY: "PARTITION_NOT_PRIMARY",
110
+ PARTITION_UNASSIGNED: "PARTITION_UNASSIGNED",
111
+ INSUFFICIENT_REPLICAS: "INSUFFICIENT_REPLICAS",
112
+ SNAPSHOT_SYNC_UNAUTHORIZED: "SNAPSHOT_SYNC_UNAUTHORIZED",
113
+ SNAPSHOT_SYNC_REQUEST_INVALID: "SNAPSHOT_SYNC_REQUEST_INVALID",
114
+ SNAPSHOT_SYNC_INDEX_NOT_FOUND: "SNAPSHOT_SYNC_INDEX_NOT_FOUND",
115
+ SNAPSHOT_SYNC_CAPACITY_EXHAUSTED: "SNAPSHOT_SYNC_CAPACITY_EXHAUSTED",
116
+ SNAPSHOT_SYNC_SNAPSHOT_FAILED: "SNAPSHOT_SYNC_SNAPSHOT_FAILED",
117
+ SNAPSHOT_SYNC_DECODE_FAILED: "SNAPSHOT_SYNC_DECODE_FAILED",
118
+ SNAPSHOT_SYNC_FRAME_INVALID: "SNAPSHOT_SYNC_FRAME_INVALID",
119
+ SNAPSHOT_SYNC_HEADER_INVALID: "SNAPSHOT_SYNC_HEADER_INVALID",
120
+ SNAPSHOT_SYNC_HEADER_MISMATCH: "SNAPSHOT_SYNC_HEADER_MISMATCH",
121
+ SNAPSHOT_SYNC_CHUNK_OUT_OF_ORDER: "SNAPSHOT_SYNC_CHUNK_OUT_OF_ORDER",
122
+ SNAPSHOT_SYNC_CHUNK_OVERFLOW: "SNAPSHOT_SYNC_CHUNK_OVERFLOW",
123
+ SNAPSHOT_SYNC_CHUNK_SIZE_EXCEEDED: "SNAPSHOT_SYNC_CHUNK_SIZE_EXCEEDED",
124
+ SNAPSHOT_SYNC_CHUNK_MISSING: "SNAPSHOT_SYNC_CHUNK_MISSING",
125
+ SNAPSHOT_SYNC_END_MISSING: "SNAPSHOT_SYNC_END_MISSING",
126
+ SNAPSHOT_SYNC_CHECKSUM_MISMATCH: "SNAPSHOT_SYNC_CHECKSUM_MISMATCH",
127
+ SNAPSHOT_SYNC_PRIMARY_ERROR: "SNAPSHOT_SYNC_PRIMARY_ERROR",
128
+ SNAPSHOT_SYNC_NO_TARGETS: "SNAPSHOT_SYNC_NO_TARGETS",
129
+ SNAPSHOT_SYNC_TRANSPORT_FAILED: "SNAPSHOT_SYNC_TRANSPORT_FAILED",
130
+ SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE: "SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE",
131
+ SNAPSHOT_SYNC_RESTORE_FAILED: "SNAPSHOT_SYNC_RESTORE_FAILED",
132
+ SNAPSHOT_SYNC_RESTORE_CLEANUP_FAILED: "SNAPSHOT_SYNC_RESTORE_CLEANUP_FAILED",
133
+ SNAPSHOT_SYNC_TIMEOUT: "SNAPSHOT_SYNC_TIMEOUT",
134
+ SNAPSHOT_SYNC_ALLOCATION_UNAVAILABLE: "SNAPSHOT_SYNC_ALLOCATION_UNAVAILABLE",
135
+ SNAPSHOT_SYNC_NOT_ASSIGNED: "SNAPSHOT_SYNC_NOT_ASSIGNED",
136
+ SNAPSHOT_SYNC_ABORTED: "SNAPSHOT_SYNC_ABORTED"
137
+ };
138
+ var ServerErrorCodes = {
139
+ INVALID_REQUEST: "INVALID_REQUEST",
140
+ INVALID_JSON: "INVALID_JSON",
141
+ EMPTY_BODY: "EMPTY_BODY",
142
+ PAYLOAD_TOO_LARGE: "PAYLOAD_TOO_LARGE",
143
+ NOT_FOUND: "NOT_FOUND",
144
+ TASK_NOT_FOUND: "TASK_NOT_FOUND",
145
+ TASK_NOT_CANCELLABLE: "TASK_NOT_CANCELLABLE",
146
+ TASK_OWNED_BY_ANOTHER_INSTANCE: "TASK_OWNED_BY_ANOTHER_INSTANCE",
147
+ TASK_INTERRUPTED: "TASK_INTERRUPTED",
148
+ TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS",
149
+ HOOK_ERROR: "HOOK_ERROR",
150
+ INTERNAL_ERROR: "INTERNAL_ERROR"
151
+ };
152
+ var ClientErrorCodes = {
153
+ CLIENT_CONNECTION_FAILED: "CLIENT_CONNECTION_FAILED",
154
+ CLIENT_REQUEST_TIMEOUT: "CLIENT_REQUEST_TIMEOUT",
155
+ CLIENT_REQUEST_ABORTED: "CLIENT_REQUEST_ABORTED",
156
+ CLIENT_INVALID_RESPONSE: "CLIENT_INVALID_RESPONSE",
157
+ CLIENT_TASK_TIMEOUT: "CLIENT_TASK_TIMEOUT",
158
+ CLIENT_UNEXPECTED_ERROR: "CLIENT_UNEXPECTED_ERROR",
159
+ SYNC_ANALYSIS_UNAVAILABLE: "SYNC_ANALYSIS_UNAVAILABLE"
160
+ };
161
+ var NarsilError = class extends Error {
162
+ /** This says which failure it is. */
163
+ code;
164
+ /** This carries the values behind the failure, such as the field, index, or limit involved. It is empty when the code says everything. */
165
+ details;
166
+ /**
167
+ * Builds an error carrying a code the caller can branch on.
168
+ *
169
+ * @param code - The failure this error reports, from {@link ErrorCodes} for
170
+ * an engine failure, {@link ServerErrorCodes} for one the HTTP layer raised,
171
+ * or {@link ClientErrorCodes} for one that stopped a request from reaching a
172
+ * server.
173
+ * @param message - Plain description, for a log or a person.
174
+ * @param details - Values behind the failure, which reach
175
+ * {@link NarsilError.details}.
176
+ */
177
+ constructor(code, message, details) {
178
+ super(message);
179
+ this.name = "NarsilError";
180
+ this.code = code;
181
+ this.details = details ?? {};
182
+ Object.defineProperty(this, NARSIL_ERROR_MARKER, { value: true });
183
+ }
184
+ };
185
+ function isNarsilError(value) {
186
+ return typeof value === "object" && value !== null && NARSIL_ERROR_MARKER in value;
187
+ }
188
+ function createNarsilError(code, message, details) {
189
+ return new NarsilError(code, message, details);
190
+ }
191
+ function describeError(error) {
192
+ return error instanceof Error ? error.message : String(error);
193
+ }
194
+
195
+ // src/schema/constants.ts
196
+ var MAX_NESTING_DEPTH = 4;
197
+ var MAX_DOCUMENT_NESTING_DEPTH = 32;
198
+ var DEFAULT_PATTERN_VALUE_LIMIT = 8192;
199
+ var MIN_PATTERN_VALUE_LIMIT = 1;
200
+ var MAX_PATTERN_VALUE_LIMIT = 65536;
201
+ var MAX_VECTOR_DIMENSION = 4096;
202
+ var MAX_STORED_VECTOR_DIMENSION = 65535;
203
+ var MAX_TEXT_FIELDS = 65536;
204
+ var MAX_DOCUMENT_BYTES = 16777216;
205
+ var PARSED_FIELD_TYPE_CACHE_ENTRIES = 1024;
206
+
207
+ // src/schema/validator/shared.ts
208
+ var VECTOR_PATTERN = /^vector\[(\d+)]$/;
209
+ function isGeopointOrVectorType(fieldType) {
210
+ return fieldType === "geopoint" || fieldType !== void 0 && VECTOR_PATTERN.test(fieldType);
211
+ }
212
+ var FIELD_NAME_PATTERN = /^[A-Za-z0-9_]+$/;
213
+ var RESERVED_ROOT_FIELDS = /* @__PURE__ */ new Set(["id"]);
214
+ var PROTOTYPE_POLLUTION_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
215
+ function isPlainObject(value) {
216
+ return typeof value === "object" && value !== null && !Array.isArray(value);
217
+ }
218
+
219
+ // src/schema/validator/field-type.ts
220
+ var FIELD_OPTION_ORDER = ["sortable", "pattern", "partial"];
221
+ var OPTIONS_BY_BASE = {
222
+ string: FIELD_OPTION_ORDER,
223
+ "string[]": FIELD_OPTION_ORDER,
224
+ verbatim: ["sortable"],
225
+ "verbatim[]": ["sortable"],
226
+ number: [],
227
+ "number[]": [],
228
+ boolean: [],
229
+ "boolean[]": [],
230
+ enum: [],
231
+ "enum[]": [],
232
+ geopoint: [],
233
+ vector: []
234
+ };
235
+ var TYPE_SEPARATOR = ":";
236
+ function isNamedBase(name) {
237
+ return name !== "vector" && Object.hasOwn(OPTIONS_BY_BASE, name);
238
+ }
239
+ function describeAllowedOptions(baseName, allowed) {
240
+ if (allowed.length === 0) return `the "${baseName}" type has no options`;
241
+ const quoted = allowed.map((option) => `"${option}"`);
242
+ if (quoted.length === 1) return `the only option of the "${baseName}" type is ${quoted[0]}`;
243
+ return `the options of the "${baseName}" type are ${quoted.slice(0, -1).join(", ")}, and ${quoted[quoted.length - 1]}`;
244
+ }
245
+ function invalidType(path, type, message) {
246
+ throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, message, { field: path, type });
247
+ }
248
+ function parseBase(baseName, path, type) {
249
+ if (isNamedBase(baseName)) return { base: baseName, dimension: 0 };
250
+ const vectorMatch = VECTOR_PATTERN.exec(baseName);
251
+ if (vectorMatch === null) {
252
+ invalidType(path, type, `Field "${path}" has an unsupported type: "${type}"`);
253
+ }
254
+ const dimension = Number.parseInt(vectorMatch[1], 10);
255
+ if (dimension <= 0 || dimension > MAX_STORED_VECTOR_DIMENSION) {
256
+ throw new NarsilError(
257
+ ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
258
+ `Vector field "${path}" has ${dimension} dimensions, but a vector field holds from 1 to ${MAX_STORED_VECTOR_DIMENSION}`,
259
+ { field: path, dimension, maximum: MAX_STORED_VECTOR_DIMENSION }
260
+ );
261
+ }
262
+ return { base: "vector", dimension };
263
+ }
264
+ function parseFieldType(type, path) {
265
+ const separatorIndex = type.indexOf(TYPE_SEPARATOR);
266
+ const baseName = separatorIndex === -1 ? type : type.slice(0, separatorIndex);
267
+ const { base, dimension } = parseBase(baseName, path, type);
268
+ const allowed = OPTIONS_BY_BASE[base];
269
+ const options = /* @__PURE__ */ new Set();
270
+ if (separatorIndex !== -1) {
271
+ for (const option of type.slice(separatorIndex + 1).split(TYPE_SEPARATOR)) {
272
+ if (!allowed.includes(option)) {
273
+ invalidType(
274
+ path,
275
+ type,
276
+ `Field "${path}" has type "${type}" with the option "${option}", but ${describeAllowedOptions(baseName, allowed)}`
277
+ );
278
+ }
279
+ if (options.has(option)) {
280
+ invalidType(path, type, `Field "${path}" has the "${option}" option twice in type "${type}"`);
281
+ }
282
+ options.add(option);
283
+ }
284
+ }
285
+ const ordered = FIELD_OPTION_ORDER.filter((option) => options.has(option));
286
+ const verbatim = base === "verbatim" || base === "verbatim[]";
287
+ return {
288
+ type: [baseName, ...ordered].join(TYPE_SEPARATOR),
289
+ base,
290
+ sortable: options.has("sortable"),
291
+ pattern: verbatim || options.has("pattern"),
292
+ partial: options.has("partial"),
293
+ dimension
294
+ };
295
+ }
296
+ var parsedTypesByName = /* @__PURE__ */ new Map();
297
+ function parsedTypeOf(type) {
298
+ if (type === void 0) return void 0;
299
+ const known = parsedTypesByName.get(type);
300
+ if (known !== void 0) return known;
301
+ try {
302
+ const parsed = Object.freeze(parseFieldType(type, ""));
303
+ if (parsedTypesByName.size < PARSED_FIELD_TYPE_CACHE_ENTRIES) parsedTypesByName.set(type, parsed);
304
+ return parsed;
305
+ } catch {
306
+ return void 0;
307
+ }
308
+ }
309
+ function withSortableOption(parsed) {
310
+ if (parsed.sortable) return parsed.type;
311
+ const separatorIndex = parsed.type.indexOf(TYPE_SEPARATOR);
312
+ const baseName = separatorIndex === -1 ? parsed.type : parsed.type.slice(0, separatorIndex);
313
+ return parseFieldType(`${baseName}${TYPE_SEPARATOR}sortable${parsed.type.slice(baseName.length)}`, "").type;
314
+ }
315
+ function isListBase(base) {
316
+ return base.endsWith("[]");
317
+ }
318
+ function isWordIndexedBase(base) {
319
+ return base === "string" || base === "string[]";
320
+ }
321
+ function isSingleStringFieldType(fieldType) {
322
+ return parsedTypeOf(fieldType)?.base === "string";
323
+ }
324
+ function isWordIndexedFieldType(fieldType) {
325
+ const parsed = parsedTypeOf(fieldType);
326
+ return parsed !== void 0 && isWordIndexedBase(parsed.base);
327
+ }
328
+ function isStringValuedBase(base) {
329
+ return base === "string" || base === "string[]" || base === "verbatim" || base === "verbatim[]";
330
+ }
331
+
332
+ // src/core/ordering/code-points.ts
333
+ function exceedsCodePoints(value, maximum) {
334
+ if (value.length <= maximum) return false;
335
+ let counted = 0;
336
+ let i = 0;
337
+ while (i < value.length) {
338
+ const unit = value.charCodeAt(i);
339
+ if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
340
+ const low = value.charCodeAt(i + 1);
341
+ if (low >= 56320 && low < 57344) i++;
342
+ }
343
+ i++;
344
+ counted++;
345
+ if (counted > maximum) return true;
346
+ }
347
+ return false;
348
+ }
349
+ var SURROGATE_UNIT = /[\ud800-\udfff]/;
350
+ var REPLACEMENT_CHARACTER = "\uFFFD";
351
+ function firstUnpairedSurrogate(value) {
352
+ for (let i = 0; i < value.length; i++) {
353
+ const unit = value.charCodeAt(i);
354
+ if (unit < 55296 || unit >= 57344) continue;
355
+ if (unit >= 56320) return i;
356
+ const low = value.charCodeAt(i + 1);
357
+ if (!(low >= 56320 && low < 57344)) return i;
358
+ i++;
359
+ }
360
+ return -1;
361
+ }
362
+ function holdsUnpairedSurrogate(value) {
363
+ return SURROGATE_UNIT.test(value) && firstUnpairedSurrogate(value) >= 0;
364
+ }
365
+ function withUnpairedSurrogatesReplaced(value) {
366
+ const first = firstUnpairedSurrogate(value);
367
+ if (first < 0) return value;
368
+ let repaired = value.slice(0, first);
369
+ for (let i = first; i < value.length; i++) {
370
+ const unit = value.charCodeAt(i);
371
+ if (unit < 55296 || unit >= 57344) {
372
+ repaired += value[i];
373
+ continue;
374
+ }
375
+ const low = value.charCodeAt(i + 1);
376
+ if (unit < 56320 && low >= 56320 && low < 57344) {
377
+ repaired += value.slice(i, i + 2);
378
+ i++;
379
+ continue;
380
+ }
381
+ repaired += REPLACEMENT_CHARACTER;
382
+ }
383
+ return repaired;
384
+ }
385
+ function codePointCount(value) {
386
+ let counted = 0;
387
+ for (let i = 0; i < value.length; i++) {
388
+ const unit = value.charCodeAt(i);
389
+ if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
390
+ const low = value.charCodeAt(i + 1);
391
+ if (low >= 56320 && low < 57344) i++;
392
+ }
393
+ counted++;
394
+ }
395
+ return counted;
396
+ }
397
+ function adjustUtf16Unit(unit) {
398
+ if (unit < 55296) return unit;
399
+ if (unit < 57344) return unit + 8192;
400
+ return unit - 2048;
401
+ }
402
+ function compareCodePoints(a, b) {
403
+ const shorter = a.length < b.length ? a.length : b.length;
404
+ let i = 0;
405
+ while (i < shorter && a.charCodeAt(i) === b.charCodeAt(i)) i++;
406
+ if (i === shorter) return a.length - b.length;
407
+ return adjustUtf16Unit(a.charCodeAt(i)) - adjustUtf16Unit(b.charCodeAt(i));
408
+ }
409
+
410
+ // src/geo/constants.ts
411
+ var DEG_TO_RAD = Math.PI / 180;
412
+ var MAX_LATITUDE_DEGREES = 90;
413
+ var MAX_LONGITUDE_DEGREES = 180;
414
+ var MIN_POLYGON_POINTS = 3;
415
+ var ANTIMERIDIAN_SPAN_DEGREES = 180;
416
+ var FULL_TURN_DEGREES = 360;
417
+ var EARTH_RADIUS_METERS = 63710088e-1;
418
+ var LOCATION_CODE_BITS_PER_AXIS = 26;
419
+ var LOCATION_CELLS_PER_AXIS = 2 ** LOCATION_CODE_BITS_PER_AXIS;
420
+ var MAX_COVERING_CELLS = 16;
421
+
422
+ // src/geo/coordinates.ts
423
+ function isLatitude(value) {
424
+ return value >= -MAX_LATITUDE_DEGREES && value <= MAX_LATITUDE_DEGREES;
425
+ }
426
+ function isLongitude(value) {
427
+ return value >= -MAX_LONGITUDE_DEGREES && value <= MAX_LONGITUDE_DEGREES;
428
+ }
429
+
430
+ // src/schema/validator/field-values.ts
431
+ function validateGeopoint(path, value) {
432
+ if (!isPlainObject(value)) {
433
+ throw new NarsilError(
434
+ ErrorCodes.SCHEMA_INVALID_GEOPOINT,
435
+ `Field "${path}" expected a geopoint object with lat and lon`,
436
+ {
437
+ field: path,
438
+ received: Array.isArray(value) ? "array" : typeof value
439
+ }
440
+ );
441
+ }
442
+ if (typeof value.lat !== "number" || typeof value.lon !== "number" || Number.isNaN(value.lat) || Number.isNaN(value.lon)) {
443
+ throw new NarsilError(ErrorCodes.SCHEMA_INVALID_GEOPOINT, `Field "${path}" geopoint requires numeric lat and lon`, {
444
+ field: path,
445
+ lat: Number.isNaN(value.lat) ? "NaN" : typeof value.lat,
446
+ lon: Number.isNaN(value.lon) ? "NaN" : typeof value.lon
447
+ });
448
+ }
449
+ if (!isLatitude(value.lat)) {
450
+ throw new NarsilError(
451
+ ErrorCodes.SCHEMA_INVALID_GEOPOINT,
452
+ `Field "${path}" geopoint lat must be between -90 and 90`,
453
+ {
454
+ field: path,
455
+ lat: value.lat
456
+ }
457
+ );
458
+ }
459
+ if (!isLongitude(value.lon)) {
460
+ throw new NarsilError(
461
+ ErrorCodes.SCHEMA_INVALID_GEOPOINT,
462
+ `Field "${path}" geopoint lon must be between -180 and 180`,
463
+ {
464
+ field: path,
465
+ lon: value.lon
466
+ }
467
+ );
468
+ }
469
+ }
470
+ function validateVector(path, value, expectedDimension) {
471
+ const isArray = Array.isArray(value);
472
+ const isFloat32 = value instanceof Float32Array;
473
+ if (!isArray && !isFloat32) {
474
+ throw new NarsilError(
475
+ ErrorCodes.DOC_VALIDATION_FAILED,
476
+ `Field "${path}" expected a vector (Array or Float32Array)`,
477
+ { field: path, received: typeof value }
478
+ );
479
+ }
480
+ const arr = value;
481
+ if (arr.length !== expectedDimension) {
482
+ throw new NarsilError(
483
+ ErrorCodes.DOC_VALIDATION_FAILED,
484
+ `Field "${path}" expected vector of dimension ${expectedDimension}, got ${arr.length}`,
485
+ { field: path, expected: expectedDimension, received: arr.length }
486
+ );
487
+ }
488
+ for (let i = 0; i < arr.length; i++) {
489
+ if (typeof arr[i] !== "number" || !Number.isFinite(arr[i])) {
490
+ throw new NarsilError(
491
+ ErrorCodes.DOC_VALIDATION_FAILED,
492
+ `Field "${path}" vector element at index ${i} is not a valid number`,
493
+ { field: path, index: i, value: arr[i] }
494
+ );
495
+ }
496
+ }
497
+ }
498
+ function validateTypedArray(path, value, elementType) {
499
+ if (!Array.isArray(value)) {
500
+ throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path}" expected an array`, {
501
+ field: path,
502
+ received: typeof value
503
+ });
504
+ }
505
+ for (let i = 0; i < value.length; i++) {
506
+ const el = value[i];
507
+ if (typeof el !== elementType) {
508
+ throw new NarsilError(
509
+ ErrorCodes.DOC_VALIDATION_FAILED,
510
+ `Field "${path}" array element at index ${i} expected ${elementType}, got ${typeof el}`,
511
+ { field: path, index: i, expected: elementType, received: typeof el }
512
+ );
513
+ }
514
+ if (elementType === "number" && !Number.isFinite(el)) {
515
+ throw new NarsilError(
516
+ ErrorCodes.DOC_VALIDATION_FAILED,
517
+ `Field "${path}" array element at index ${i} is ${String(el)}, while a number field holds finite numbers alone`,
518
+ { field: path, index: i }
519
+ );
520
+ }
521
+ }
522
+ }
523
+ function validatePatternValue(path, value, patternValueLimit, index) {
524
+ if (!exceedsCodePoints(value, patternValueLimit)) return;
525
+ const subject = index === void 0 ? `The value of field "${path}"` : `Element ${index} of field "${path}"`;
526
+ throw new NarsilError(
527
+ ErrorCodes.DOC_VALIDATION_FAILED,
528
+ `${subject} is longer than ${patternValueLimit} code points, which is the pattern value limit of this index`,
529
+ { field: path, limit: patternValueLimit, ...index === void 0 ? {} : { index } }
530
+ );
531
+ }
532
+ function validateFieldValue(path, value, type, patternValueLimit) {
533
+ switch (type.base) {
534
+ case "string":
535
+ case "verbatim":
536
+ if (typeof value !== "string") {
537
+ throw new NarsilError(
538
+ ErrorCodes.DOC_VALIDATION_FAILED,
539
+ `Field "${path}" expected string, got ${typeof value}`,
540
+ {
541
+ field: path,
542
+ expected: "string",
543
+ received: typeof value
544
+ }
545
+ );
546
+ }
547
+ if (type.pattern) validatePatternValue(path, value, patternValueLimit);
548
+ return;
549
+ case "number":
550
+ if (typeof value !== "number" || !Number.isFinite(value)) {
551
+ throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path}" expected a finite number`, {
552
+ field: path,
553
+ expected: "number",
554
+ received: typeof value === "number" ? String(value) : typeof value
555
+ });
556
+ }
557
+ return;
558
+ case "boolean":
559
+ if (typeof value !== "boolean") {
560
+ throw new NarsilError(
561
+ ErrorCodes.DOC_VALIDATION_FAILED,
562
+ `Field "${path}" expected boolean, got ${typeof value}`,
563
+ {
564
+ field: path,
565
+ expected: "boolean",
566
+ received: typeof value
567
+ }
568
+ );
569
+ }
570
+ return;
571
+ case "enum":
572
+ if (typeof value !== "string") {
573
+ throw new NarsilError(
574
+ ErrorCodes.DOC_VALIDATION_FAILED,
575
+ `Field "${path}" expected enum (string), got ${typeof value}`,
576
+ {
577
+ field: path,
578
+ expected: "enum",
579
+ received: typeof value
580
+ }
581
+ );
582
+ }
583
+ return;
584
+ case "geopoint":
585
+ validateGeopoint(path, value);
586
+ return;
587
+ case "string[]":
588
+ case "verbatim[]":
589
+ validateTypedArray(path, value, "string");
590
+ if (type.pattern) {
591
+ const elements = value;
592
+ for (let i = 0; i < elements.length; i++) validatePatternValue(path, elements[i], patternValueLimit, i);
593
+ }
594
+ return;
595
+ case "number[]":
596
+ validateTypedArray(path, value, "number");
597
+ return;
598
+ case "boolean[]":
599
+ validateTypedArray(path, value, "boolean");
600
+ return;
601
+ case "enum[]":
602
+ validateTypedArray(path, value, "string");
603
+ return;
604
+ case "vector":
605
+ validateVector(path, value, type.dimension);
606
+ return;
607
+ }
608
+ }
609
+
610
+ // src/schema/validator/storable.ts
611
+ var RESERVED_OBJECT_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
612
+ var UNPAIRED_SURROGATE_REASON = "holds an unpaired surrogate, the half of a character such as an emoji whose other half is missing, so the engine cannot store it as UTF-8";
613
+ function reject(path, reason) {
614
+ throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path === "" ? "(document)" : path}" ${reason}`, {
615
+ field: path
616
+ });
617
+ }
618
+ function isPlainObject2(value) {
619
+ const proto = Object.getPrototypeOf(value);
620
+ return proto === Object.prototype || proto === null;
621
+ }
622
+ function walkStorable(value, path, depth, ancestors, skip) {
623
+ if (value === null || value === void 0) return;
624
+ const kind = typeof value;
625
+ if (kind === "string") {
626
+ if (holdsUnpairedSurrogate(value)) reject(path, UNPAIRED_SURROGATE_REASON);
627
+ return;
628
+ }
629
+ if (kind === "boolean" || kind === "number") return;
630
+ if (kind === "bigint" || kind === "symbol" || kind === "function") {
631
+ reject(path, `holds a ${kind}, which cannot be stored or recovered`);
632
+ }
633
+ const container = value;
634
+ if (container instanceof Date) {
635
+ if (Number.isNaN(container.getTime())) reject(path, "holds an invalid date, which the engine cannot store");
636
+ return;
637
+ }
638
+ if (container instanceof Uint8Array) return;
639
+ const isArray = Array.isArray(container);
640
+ if (!isArray && !isPlainObject2(container)) {
641
+ reject(
642
+ path,
643
+ "holds a value that does not survive storage; use plain objects, arrays, strings, numbers, booleans, dates, or Uint8Array bytes"
644
+ );
645
+ }
646
+ if (depth >= MAX_DOCUMENT_NESTING_DEPTH) {
647
+ reject(path, `nests deeper than ${MAX_DOCUMENT_NESTING_DEPTH} levels`);
648
+ }
649
+ if (ancestors.has(container)) {
650
+ reject(path, "refers back to one of its own ancestors");
651
+ }
652
+ ancestors.add(container);
653
+ if (isArray) {
654
+ const items = container;
655
+ for (let i = 0; i < items.length; i++) {
656
+ walkStorable(items[i], `${path}[${i}]`, depth + 1, ancestors, skip);
657
+ }
658
+ } else {
659
+ const record = container;
660
+ for (const key of Object.keys(record)) {
661
+ const keyPath = path === "" ? key : `${path}.${key}`;
662
+ if (RESERVED_OBJECT_KEYS.has(key)) {
663
+ reject(keyPath, "uses a reserved object key");
664
+ }
665
+ if (holdsUnpairedSurrogate(key)) reject(keyPath, `has a name that ${UNPAIRED_SURROGATE_REASON}`);
666
+ if (skip.has(keyPath)) continue;
667
+ walkStorable(record[key], keyPath, depth + 1, ancestors, skip);
668
+ }
669
+ }
670
+ ancestors.delete(container);
671
+ }
672
+ function assertStorableDocument(document, skipFieldPaths) {
673
+ walkStorable(document, "", 0, /* @__PURE__ */ new Set(), skipFieldPaths ?? /* @__PURE__ */ new Set());
674
+ }
675
+
676
+ // src/schema/validator/document.ts
677
+ var vectorPathCache = /* @__PURE__ */ new WeakMap();
678
+ function vectorFieldPaths(schema) {
679
+ let paths = vectorPathCache.get(schema);
680
+ if (paths !== void 0) return paths;
681
+ paths = /* @__PURE__ */ new Set();
682
+ const collect = (level, prefix) => {
683
+ for (const [field, type] of Object.entries(level)) {
684
+ const path = prefix === "" ? field : `${prefix}.${field}`;
685
+ if (typeof type === "string" && VECTOR_PATTERN.test(type)) {
686
+ paths?.add(path);
687
+ } else if (isPlainObject(type)) {
688
+ collect(type, path);
689
+ }
690
+ }
691
+ };
692
+ collect(schema, "");
693
+ vectorPathCache.set(schema, paths);
694
+ return paths;
695
+ }
696
+ var parsedLevelCache = /* @__PURE__ */ new WeakMap();
697
+ function parsedLevel(schema, prefix) {
698
+ let entries = parsedLevelCache.get(schema);
699
+ if (entries !== void 0) return entries;
700
+ entries = Object.entries(schema).map(([field, type]) => {
701
+ if (isPlainObject(type)) return { field, nested: type, type: null };
702
+ const path = prefix ? `${prefix}.${field}` : field;
703
+ return { field, nested: null, type: parseFieldType(type, path) };
704
+ });
705
+ parsedLevelCache.set(schema, entries);
706
+ return entries;
707
+ }
708
+ function validateDocumentFields(doc, schema, prefix, patternValueLimit) {
709
+ for (const { field, nested, type } of parsedLevel(schema, prefix)) {
710
+ const value = doc[field];
711
+ if (value === void 0 || value === null) continue;
712
+ const path = prefix ? `${prefix}.${field}` : field;
713
+ if (nested !== null) {
714
+ if (!isPlainObject(value)) {
715
+ throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path}" expected an object`, {
716
+ field: path,
717
+ received: Array.isArray(value) ? "array" : typeof value
718
+ });
719
+ }
720
+ validateDocumentFields(value, nested, path, patternValueLimit);
721
+ continue;
722
+ }
723
+ if (type !== null) validateFieldValue(path, value, type, patternValueLimit);
724
+ }
725
+ }
726
+ function validateDocument(document, schema, patternValueLimit = DEFAULT_PATTERN_VALUE_LIMIT) {
727
+ if (!isPlainObject(document)) {
728
+ throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, "Document must be a plain object", {
729
+ received: typeof document
730
+ });
731
+ }
732
+ requireIdFieldKey(document);
733
+ assertStorableDocument(document, vectorFieldPaths(schema));
734
+ validateDocumentFields(document, schema, "", patternValueLimit);
735
+ }
736
+ function requireIdFieldKey(document) {
737
+ if (!Object.hasOwn(document, "id")) return;
738
+ const id = document.id;
739
+ if (typeof id === "string" && id.length > 0) return;
740
+ throw new NarsilError(
741
+ ErrorCodes.DOC_VALIDATION_FAILED,
742
+ `Field "id" holds ${typeof id === "string" ? "an empty string" : id === null ? "null" : `a ${typeof id}`}, while the engine stores a document under its id field, so that field must hold a non-empty string`,
743
+ { field: "id", received: id === null ? "null" : typeof id }
744
+ );
745
+ }
746
+ function collectExtraFields(doc, schema, prefix, extras) {
747
+ for (const key of Object.keys(doc)) {
748
+ if (key === "id") continue;
749
+ const path = prefix ? `${prefix}.${key}` : key;
750
+ if (!Object.hasOwn(schema, key)) {
751
+ extras.push(path);
752
+ continue;
753
+ }
754
+ const schemaType = schema[key];
755
+ if (isPlainObject(schemaType) && isPlainObject(doc[key])) {
756
+ collectExtraFields(doc[key], schemaType, path, extras);
757
+ }
758
+ }
759
+ }
760
+ function validateDocumentStrict(document, schema) {
761
+ const extras = [];
762
+ collectExtraFields(document, schema, "", extras);
763
+ if (extras.length > 0) {
764
+ throw new NarsilError(
765
+ ErrorCodes.DOC_VALIDATION_FAILED,
766
+ `Document contains fields not defined in schema: ${extras.join(", ")}`,
767
+ { extraFields: extras }
768
+ );
769
+ }
770
+ }
771
+ function resolveNestedValue(document, path) {
772
+ if (!path.includes(".")) return document[path];
773
+ const segments = path.split(".");
774
+ let current = document;
775
+ for (const segment of segments) {
776
+ if (current === null || current === void 0 || typeof current !== "object") return void 0;
777
+ current = current[segment];
778
+ }
779
+ return current;
780
+ }
781
+ function validateRequiredFields(document, required) {
782
+ if (required.length === 0) return;
783
+ for (const field of required) {
784
+ const value = resolveNestedValue(document, field);
785
+ if (value === void 0 || value === null) {
786
+ throw new NarsilError(ErrorCodes.DOC_MISSING_REQUIRED_FIELD, `Document is missing required field "${field}"`, {
787
+ field
788
+ });
789
+ }
790
+ }
791
+ }
792
+
793
+ // src/schema/validator/document-size.ts
794
+ var LARGEST_HEADER_BYTES = 5;
795
+ var LARGEST_NUMBER_BYTES = 9;
796
+ var LARGEST_TIMESTAMP_BYTES = 15;
797
+ var LARGEST_UTF8_BYTES_PER_UNIT = 3;
798
+ function upperBoundBytes(value, budget, depth) {
799
+ if (value === null || value === void 0 || typeof value === "boolean") return 1;
800
+ if (typeof value === "number") return LARGEST_NUMBER_BYTES;
801
+ if (typeof value === "string") return LARGEST_HEADER_BYTES + value.length * LARGEST_UTF8_BYTES_PER_UNIT;
802
+ if (value instanceof Date) return LARGEST_TIMESTAMP_BYTES;
803
+ if (ArrayBuffer.isView(value)) return LARGEST_HEADER_BYTES + value.byteLength;
804
+ if (typeof value !== "object" || depth > MAX_DOCUMENT_NESTING_DEPTH) return LARGEST_NUMBER_BYTES;
805
+ let total = LARGEST_HEADER_BYTES;
806
+ if (Array.isArray(value)) {
807
+ for (const item of value) {
808
+ total += upperBoundBytes(item, budget - total, depth + 1);
809
+ if (total > budget) return total;
810
+ }
811
+ return total;
812
+ }
813
+ const record = value;
814
+ for (const key of Object.keys(record)) {
815
+ total += LARGEST_HEADER_BYTES + key.length * LARGEST_UTF8_BYTES_PER_UNIT;
816
+ total += upperBoundBytes(record[key], budget - total, depth + 1);
817
+ if (total > budget) return total;
818
+ }
819
+ return total;
820
+ }
821
+ function messagePackUpperBoundBytes(value) {
822
+ return upperBoundBytes(value, Number.POSITIVE_INFINITY, 0);
823
+ }
824
+ function encodedBytesOf(code, document) {
825
+ try {
826
+ return code.encodeDocument(document).byteLength;
827
+ } catch {
828
+ return null;
829
+ }
830
+ }
831
+ function requireDocumentWithinSizeLimit(document) {
832
+ if (upperBoundBytes(document, MAX_DOCUMENT_BYTES, 0) <= MAX_DOCUMENT_BYTES) return null;
833
+ const code = loadedMessagePack();
834
+ if (code !== null) {
835
+ requireEncodedDocumentWithinSizeLimit(code, document);
836
+ return null;
837
+ }
838
+ return loadMessagePack().then((loaded2) => requireEncodedDocumentWithinSizeLimit(loaded2, document));
839
+ }
840
+ function requireEncodedDocumentWithinSizeLimit(code, document) {
841
+ const encodedBytes = encodedBytesOf(code, document);
842
+ if (encodedBytes === null || encodedBytes <= MAX_DOCUMENT_BYTES) return;
843
+ throw new NarsilError(
844
+ ErrorCodes.DOC_VALIDATION_FAILED,
845
+ `The document takes ${encodedBytes} bytes as MessagePack, vector values included, but a document may take at most ${MAX_DOCUMENT_BYTES}`,
846
+ { bytes: encodedBytes, maximum: MAX_DOCUMENT_BYTES }
847
+ );
848
+ }
849
+
850
+ // src/core/ordering/constants.ts
851
+ var SORT_VALUE_MAX_CODE_POINTS = 512;
852
+
853
+ // src/core/ordering/sort-values.ts
854
+ var SORT_MODES = ["min", "max", "avg", "median"];
855
+ function isSortMode(value) {
856
+ return value === "min" || value === "max" || value === "avg" || value === "median";
857
+ }
858
+ function defaultSortMode(direction) {
859
+ return direction === "desc" ? "max" : "min";
860
+ }
861
+ function sortModeOf(entry) {
862
+ return entry.mode ?? defaultSortMode(entry.direction);
863
+ }
864
+ function truncateSortString(value) {
865
+ if (value.length <= SORT_VALUE_MAX_CODE_POINTS) return value;
866
+ let index = 0;
867
+ let counted = 0;
868
+ while (index < value.length && counted < SORT_VALUE_MAX_CODE_POINTS) {
869
+ const unit = value.charCodeAt(index);
870
+ if (unit >= 55296 && unit < 56320 && index + 1 < value.length) {
871
+ const low = value.charCodeAt(index + 1);
872
+ if (low >= 56320 && low < 57344) index++;
873
+ }
874
+ index++;
875
+ counted++;
876
+ }
877
+ return value.slice(0, index);
878
+ }
879
+ function toComparableSortValue(value) {
880
+ if (typeof value === "string") return truncateSortString(value);
881
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
882
+ if (typeof value === "boolean") return value;
883
+ return null;
884
+ }
885
+
886
+ // src/schema/validator/schema.ts
887
+ function validateSchemaFields(schema, depth, prefix) {
888
+ if (depth > MAX_NESTING_DEPTH) {
889
+ throw new NarsilError(
890
+ ErrorCodes.SCHEMA_DEPTH_EXCEEDED,
891
+ `Schema nesting exceeds the maximum depth of ${MAX_NESTING_DEPTH} at "${prefix}"`,
892
+ { path: prefix, maxDepth: MAX_NESTING_DEPTH }
893
+ );
894
+ }
895
+ let canonical = null;
896
+ const replace = (field, value) => {
897
+ if (canonical === null) canonical = { ...schema };
898
+ canonical[field] = value;
899
+ };
900
+ for (const [field, type] of Object.entries(schema)) {
901
+ const path = prefix ? `${prefix}.${field}` : field;
902
+ if (PROTOTYPE_POLLUTION_KEYS.has(field)) {
903
+ throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, `Field name "${field}" is not allowed in a schema`, {
904
+ field,
905
+ path
906
+ });
907
+ }
908
+ if (!FIELD_NAME_PATTERN.test(field)) {
909
+ throw new NarsilError(
910
+ ErrorCodes.SCHEMA_INVALID_TYPE,
911
+ `Field name "${field}" contains characters that are not allowed; use letters, digits, and underscores only`,
912
+ { field, path }
913
+ );
914
+ }
915
+ if (depth === 1 && RESERVED_ROOT_FIELDS.has(field)) {
916
+ throw new NarsilError(
917
+ ErrorCodes.SCHEMA_INVALID_TYPE,
918
+ `Field "${field}" is reserved and cannot be defined in a schema`,
919
+ { field, path }
920
+ );
921
+ }
922
+ if (isPlainObject(type)) {
923
+ const nested = validateSchemaFields(type, depth + 1, path);
924
+ if (nested !== type) replace(field, nested);
925
+ continue;
926
+ }
927
+ if (typeof type !== "string") {
928
+ throw new NarsilError(
929
+ ErrorCodes.SCHEMA_INVALID_TYPE,
930
+ `Field "${path}" has an invalid type definition: ${String(type)}`,
931
+ {
932
+ field: path,
933
+ type: String(type)
934
+ }
935
+ );
936
+ }
937
+ const parsed = parseFieldType(type, path);
938
+ if (parsed.type !== type) replace(field, parsed.type);
939
+ }
940
+ return canonical ?? schema;
941
+ }
942
+ function validateSchema(schema) {
943
+ if (!isPlainObject(schema)) {
944
+ throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must be a plain object", {
945
+ received: typeof schema
946
+ });
947
+ }
948
+ if (Object.keys(schema).length === 0) {
949
+ throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must define at least one field");
950
+ }
951
+ const validated = validateSchemaFields(schema, 1, "");
952
+ requireTextFieldCount(schemaFieldsOf(validated).filter((field) => isWordIndexedBase(field.base)).length);
953
+ return validated;
954
+ }
955
+ function requireTextFieldCount(count) {
956
+ if (count <= MAX_TEXT_FIELDS) return;
957
+ throw new NarsilError(
958
+ ErrorCodes.SCHEMA_INVALID_TYPE,
959
+ `The schema declares ${count} string and string[] fields, but a schema holds at most ${MAX_TEXT_FIELDS}`,
960
+ { textFields: count, maximum: MAX_TEXT_FIELDS }
961
+ );
962
+ }
963
+ function requireCreatableSchema(schema) {
964
+ for (const field of schemaFieldsOf(schema)) {
965
+ if (field.base !== "vector" || field.dimension <= MAX_VECTOR_DIMENSION) continue;
966
+ throw new NarsilError(
967
+ ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
968
+ `Vector field "${field.path}" has ${field.dimension} dimensions, but a new index takes at most ${MAX_VECTOR_DIMENSION}`,
969
+ { field: field.path, dimension: field.dimension, maximum: MAX_VECTOR_DIMENSION }
970
+ );
971
+ }
972
+ }
973
+ function requireValidFieldTypes(flatSchema) {
974
+ let textFields = 0;
975
+ for (const [path, type] of Object.entries(flatSchema)) {
976
+ if (typeof type !== "string") {
977
+ throw new NarsilError(
978
+ ErrorCodes.SCHEMA_INVALID_TYPE,
979
+ `Field "${path}" has an invalid type definition: ${String(type)}`,
980
+ { field: path, type: String(type) }
981
+ );
982
+ }
983
+ if (isWordIndexedBase(parseFieldType(type, path).base)) textFields += 1;
984
+ }
985
+ requireTextFieldCount(textFields);
986
+ }
987
+ function flattenRecursive(schema, prefix, result) {
988
+ for (const [field, type] of Object.entries(schema)) {
989
+ const path = prefix ? `${prefix}.${field}` : field;
990
+ if (isPlainObject(type)) {
991
+ flattenRecursive(type, path, result);
992
+ } else {
993
+ result[path] = type;
994
+ }
995
+ }
996
+ }
997
+ var flattenedSchemas = /* @__PURE__ */ new WeakMap();
998
+ function flattenSchema(schema) {
999
+ const cached = flattenedSchemas.get(schema);
1000
+ if (cached !== void 0) return cached;
1001
+ const result = /* @__PURE__ */ Object.create(null);
1002
+ flattenRecursive(schema, "", result);
1003
+ flattenedSchemas.set(schema, Object.freeze(result));
1004
+ return result;
1005
+ }
1006
+ var parsedSchemas = /* @__PURE__ */ new WeakMap();
1007
+ function schemaFieldsOf(schema) {
1008
+ const cached = parsedSchemas.get(schema);
1009
+ if (cached !== void 0) return cached;
1010
+ const fields = [];
1011
+ for (const [path, type] of Object.entries(flattenSchema(schema))) {
1012
+ fields.push({ ...parseFieldType(type, path), path });
1013
+ }
1014
+ const frozen = Object.freeze(fields);
1015
+ parsedSchemas.set(schema, frozen);
1016
+ return frozen;
1017
+ }
1018
+ var partialFieldsBySchema = /* @__PURE__ */ new WeakMap();
1019
+ function partialFieldsOf(schema) {
1020
+ const cached = partialFieldsBySchema.get(schema);
1021
+ if (cached !== void 0) return cached;
1022
+ const paths = [];
1023
+ for (const field of schemaFieldsOf(schema)) {
1024
+ if (field.partial) paths.push(field.path);
1025
+ }
1026
+ const frozen = Object.freeze(paths.sort(compareCodePoints));
1027
+ partialFieldsBySchema.set(schema, frozen);
1028
+ return frozen;
1029
+ }
1030
+ function extractVectorFieldsFromSchema(schema) {
1031
+ const result = /* @__PURE__ */ new Map();
1032
+ for (const field of schemaFieldsOf(schema)) {
1033
+ if (field.base === "vector") result.set(field.path, field.dimension);
1034
+ }
1035
+ return result;
1036
+ }
1037
+
1038
+ // src/vector/hnsw/constants.ts
1039
+ var MAX_LAYER_CAP = 32;
1040
+ var MAX_M = 512;
1041
+ var MIN_M = 2;
1042
+ var EARLIER_RELEASE_MIN_M = 1;
1043
+ var INITIAL_UPPER_SLOTS = 64;
1044
+ var INITIAL_LIST_CAPACITY = 64;
1045
+ var PLACEMENT_ROOM_REQUESTS = 8;
1046
+ var FARTHEST_REJECTED_LINKS_KEPT = 1;
1047
+ var COMPACTION_TOMBSTONE_RATIO = 0.1;
1048
+ var COMPACTION_ABSOLUTE_THRESHOLD = 1e3;
1049
+ var DEFAULT_EF_SEARCH = 50;
1050
+ var NEAREST_LINK_FALLBACK_HOSTS = 4;
1051
+ var CONNECT_STEPS_BETWEEN_CLOCK_CHECKS = 256;
1052
+ var CONNECT_RESTARTS_BEFORE_ONE_PASS = 8;
1053
+
1054
+ // src/schema/validator/vector-promotion.ts
1055
+ var QUANTIZATION_MODES = /* @__PURE__ */ new Set(["osq8", "osq4", "osq2", "osq1", "none"]);
1056
+ var STORAGE_MODES = /* @__PURE__ */ new Set(["memory", "disk"]);
1057
+ function fail(message, details) {
1058
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, message, details);
1059
+ }
1060
+ function isPositiveInteger(value) {
1061
+ return Number.isInteger(value) && value >= 1;
1062
+ }
1063
+ function isQuantizationMode(value) {
1064
+ return typeof value === "string" && QUANTIZATION_MODES.has(value);
1065
+ }
1066
+ function isStorageMode(value) {
1067
+ return typeof value === "string" && STORAGE_MODES.has(value);
1068
+ }
1069
+ function validateVectorStorage(config, filesystemDurability) {
1070
+ if (config?.storage === "disk" && !filesystemDurability) {
1071
+ fail("vectorPromotion.storage 'disk' needs filesystem durability, because a checkpoint file holds the vectors", {
1072
+ storage: config.storage
1073
+ });
1074
+ }
1075
+ }
1076
+ function validateTextStorage(textStorage, filesystemDurability) {
1077
+ if (textStorage === void 0 || textStorage === "memory" || textStorage === "disk" && filesystemDurability) return;
1078
+ fail("textStorage must be 'memory', or 'disk' with filesystem durability", { textStorage });
1079
+ }
1080
+ function raiseEarlierReleaseGraphSetting(config) {
1081
+ if (typeof config !== "object" || config === null) return config;
1082
+ const hnsw = config.hnswConfig;
1083
+ if (typeof hnsw !== "object" || hnsw === null) return config;
1084
+ if (hnsw.m !== EARLIER_RELEASE_MIN_M) return config;
1085
+ return { ...config, hnswConfig: { ...hnsw, m: MIN_M } };
1086
+ }
1087
+ function validateVectorPromotion(config) {
1088
+ if (config === void 0) return;
1089
+ if (config.threshold !== void 0 && !isPositiveInteger(config.threshold)) {
1090
+ fail("vectorPromotion.threshold must be a positive integer", { threshold: config.threshold });
1091
+ }
1092
+ const quantization = config.quantization;
1093
+ if (quantization !== void 0 && !isQuantizationMode(quantization)) {
1094
+ fail("vectorPromotion.quantization must be 'osq8', 'osq4', 'osq2', 'osq1', or 'none'", { quantization });
1095
+ }
1096
+ const storage = config.storage;
1097
+ if (storage !== void 0 && !isStorageMode(storage)) {
1098
+ fail("vectorPromotion.storage must be 'memory' or 'disk'", { storage });
1099
+ }
1100
+ const hnsw = config.hnswConfig;
1101
+ if (hnsw === void 0) return;
1102
+ if (hnsw.m !== void 0 && (!Number.isInteger(hnsw.m) || hnsw.m < MIN_M || hnsw.m > MAX_M)) {
1103
+ fail(`vectorPromotion.hnswConfig.m must be a whole number from ${MIN_M} to ${MAX_M}`, { m: hnsw.m });
1104
+ }
1105
+ if (hnsw.efConstruction !== void 0 && !isPositiveInteger(hnsw.efConstruction)) {
1106
+ fail("vectorPromotion.hnswConfig.efConstruction must be a positive integer", {
1107
+ efConstruction: hnsw.efConstruction
1108
+ });
1109
+ }
1110
+ const metric = hnsw.metric;
1111
+ if (metric !== void 0 && metric !== "cosine" && metric !== "dotProduct" && metric !== "euclidean") {
1112
+ fail("vectorPromotion.hnswConfig.metric must be 'cosine', 'dotProduct', or 'euclidean'", { metric });
1113
+ }
1114
+ }
1115
+
1116
+ // src/core/partition/utils.ts
1117
+ function getOrCreateFieldNameIndex(table, fieldName) {
1118
+ const existing = table.indexMap.get(fieldName);
1119
+ if (existing !== void 0) return existing;
1120
+ const idx = table.names.length;
1121
+ table.names.push(fieldName);
1122
+ table.indexMap.set(fieldName, idx);
1123
+ return idx;
1124
+ }
1125
+ var VECTOR_PATTERN2 = /^vector\[(\d+)]$/;
1126
+ function getNestedValue(obj, path) {
1127
+ if (obj === null || typeof obj !== "object") return void 0;
1128
+ if (!path.includes(".")) return Object.hasOwn(obj, path) ? obj[path] : void 0;
1129
+ const parts = path.split(".");
1130
+ let current = obj;
1131
+ for (let i = 0; i < parts.length; i++) {
1132
+ if (current === null || current === void 0 || typeof current !== "object") return void 0;
1133
+ if (!Object.hasOwn(current, parts[i])) return void 0;
1134
+ current = current[parts[i]];
1135
+ }
1136
+ return current;
1137
+ }
1138
+ function stringArraysEqual(a, b) {
1139
+ if (a === b) return true;
1140
+ if (!a || !b) return false;
1141
+ if (a.length !== b.length) return false;
1142
+ for (let i = 0; i < a.length; i++) {
1143
+ if (a[i] !== b[i]) return false;
1144
+ }
1145
+ return true;
1146
+ }
1147
+ function textFieldsChanged(oldDoc, newDoc, fields) {
1148
+ for (const { path, base } of fields) {
1149
+ if (!isWordIndexedBase(base)) continue;
1150
+ const oldVal = getNestedValue(oldDoc, path);
1151
+ const newVal = getNestedValue(newDoc, path);
1152
+ if (base === "string") {
1153
+ if (oldVal !== newVal) return true;
1154
+ } else {
1155
+ if (!stringArraysEqual(oldVal, newVal)) return true;
1156
+ }
1157
+ }
1158
+ return false;
1159
+ }
1160
+ function parseVectorDimension(fieldType) {
1161
+ const match = VECTOR_PATTERN2.exec(fieldType);
1162
+ return match ? Number.parseInt(match[1], 10) : null;
1163
+ }
1164
+ function tokenizeOptions(options) {
1165
+ return {
1166
+ stem: true,
1167
+ removeStopWords: true,
1168
+ collectSurfaces: options?.collectSurfaces === true,
1169
+ stopWordOverride: options?.stopWordOverride,
1170
+ customTokenizer: options?.customTokenizer
1171
+ };
1172
+ }
1173
+ function getFlatSchema(state, schema) {
1174
+ if (state.lastSchemaRef === schema && state.flatSchemaCache) return state.flatSchemaCache;
1175
+ state.flatSchemaCache = flattenSchema(schema);
1176
+ state.lastSchemaRef = schema;
1177
+ return state.flatSchemaCache;
1178
+ }
1179
+
1180
+ // src/serialization/constants.ts
1181
+ var CHECKSUM_YIELD_CHUNK_BYTES = 4 * 1024 * 1024;
1182
+ var NATIVE_CRC32_MIN_BYTES = 16;
1183
+ var MAX_FILE_BYTES = 2147483647;
1184
+ var MAX_DOCUMENT_ENCODING_DEPTH = 100;
1185
+ var DOCUMENT_REPLY_ENVELOPE_DEPTH = 4;
1186
+ var BYTE_ORDER_MARK_WALK_BYTES_PER_HEADER = 256;
1187
+ var DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES = 1048576;
1188
+ var VALID_HNSW_METRICS = /* @__PURE__ */ new Set(["cosine", "dotProduct", "euclidean"]);
1189
+
1190
+ // src/serialization/msgpack-code.ts
1191
+ var loaded = null;
1192
+ var loading = null;
1193
+ function loadMessagePack() {
1194
+ if (loaded !== null) return Promise.resolve(loaded);
1195
+ loading ??= import('./msgpack-leaf-44XNWSSY.mjs').then(
1196
+ (code) => {
1197
+ code.bindMsgpackHost({
1198
+ BYTE_ORDER_MARK_WALK_BYTES_PER_HEADER,
1199
+ DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES,
1200
+ DOCUMENT_REPLY_ENVELOPE_DEPTH,
1201
+ ErrorCodes,
1202
+ getNestedValue,
1203
+ MAX_DOCUMENT_ENCODING_DEPTH,
1204
+ NarsilError
1205
+ });
1206
+ loaded = code;
1207
+ return code;
1208
+ },
1209
+ (cause) => {
1210
+ loading = null;
1211
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The MessagePack code could not load", {
1212
+ cause: cause instanceof Error ? cause.message : String(cause)
1213
+ });
1214
+ }
1215
+ );
1216
+ return loading;
1217
+ }
1218
+ function loadedMessagePack() {
1219
+ return loaded;
1220
+ }
1221
+ function requireLoadedMessagePack() {
1222
+ if (loaded === null) {
1223
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The engine reached MessagePack code before it loaded that code");
1224
+ }
1225
+ return loaded;
1226
+ }
1227
+
1228
+ export { ANTIMERIDIAN_SPAN_DEGREES, BYTE_ORDER_MARK_WALK_BYTES_PER_HEADER, CHECKSUM_YIELD_CHUNK_BYTES, COMPACTION_ABSOLUTE_THRESHOLD, COMPACTION_TOMBSTONE_RATIO, CONNECT_RESTARTS_BEFORE_ONE_PASS, CONNECT_STEPS_BETWEEN_CLOCK_CHECKS, ClientErrorCodes, DEFAULT_EF_SEARCH, DEG_TO_RAD, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, DOCUMENT_REPLY_ENVELOPE_DEPTH, EARLIER_RELEASE_MIN_M, EARTH_RADIUS_METERS, ErrorCodes, FARTHEST_REJECTED_LINKS_KEPT, FULL_TURN_DEGREES, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, LOCATION_CELLS_PER_AXIS, LOCATION_CODE_BITS_PER_AXIS, MAX_COVERING_CELLS, MAX_DOCUMENT_ENCODING_DEPTH, MAX_DOCUMENT_NESTING_DEPTH, MAX_FILE_BYTES, MAX_LATITUDE_DEGREES, MAX_LAYER_CAP, MAX_LONGITUDE_DEGREES, MAX_M, MAX_NESTING_DEPTH, MAX_PATTERN_VALUE_LIMIT, MIN_M, MIN_PATTERN_VALUE_LIMIT, MIN_POLYGON_POINTS, NATIVE_CRC32_MIN_BYTES, NEAREST_LINK_FALLBACK_HOSTS, NarsilError, PLACEMENT_ROOM_REQUESTS, PROTOTYPE_POLLUTION_KEYS, SORT_MODES, SORT_VALUE_MAX_CODE_POINTS, ServerErrorCodes, VALID_HNSW_METRICS, VECTOR_PATTERN, codePointCount, compareCodePoints, createNarsilError, defaultSortMode, describeError, exceedsCodePoints, extractVectorFieldsFromSchema, flattenSchema, getFlatSchema, getNestedValue, getOrCreateFieldNameIndex, holdsUnpairedSurrogate, isGeopointOrVectorType, isLatitude, isListBase, isLongitude, isNarsilError, isPlainObject, isQuantizationMode, isSingleStringFieldType, isSortMode, isStorageMode, isStringValuedBase, isWordIndexedBase, isWordIndexedFieldType, loadMessagePack, loadedMessagePack, messagePackUpperBoundBytes, parseVectorDimension, parsedTypeOf, partialFieldsOf, raiseEarlierReleaseGraphSetting, requireCreatableSchema, requireDocumentWithinSizeLimit, requireLoadedMessagePack, requireValidFieldTypes, schemaFieldsOf, sortModeOf, textFieldsChanged, toComparableSortValue, tokenizeOptions, truncateSortString, validateDocument, validateDocumentStrict, validateRequiredFields, validateSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, withSortableOption, withUnpairedSurrogatesReplaced };