@delali/narsil 0.3.1-next.99 → 0.4.0
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.
- package/NOTICE +45 -0
- package/README.md +27 -8
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +101 -13
- package/dist/adapters/gcs.d.ts +49 -0
- package/dist/adapters/gcs.mjs +213 -0
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +2 -7
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/adapters/memory.mjs +5 -0
- package/dist/adapters/s3.d.ts +53 -0
- package/dist/adapters/s3.mjs +263 -0
- package/dist/{adapters-BQFQ4PRz.d.ts → adapters-pljAqmrC.d.ts} +33 -0
- package/dist/browser/chunk-4E5APHTM.mjs +1459 -0
- package/dist/browser/chunk-NDYADQ4Y.mjs +23426 -0
- package/dist/browser/chunk-QAOVAYAG.mjs +564 -0
- package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
- package/dist/browser/chunk-YINZFPLT.mjs +1239 -0
- package/dist/browser/chunk-YJHGOJAC.mjs +15 -0
- package/dist/browser/{chunk-Z7QH2XHB.mjs → core-leaf-HWAXCEWX.mjs} +3987 -2103
- package/dist/browser/custom-token-results-R5BIX7SL.mjs +59 -0
- package/dist/browser/digest-leaf-64IPRPZD.mjs +151 -0
- package/dist/browser/durability-config-75NSFCQN.mjs +97 -0
- package/dist/browser/embed-GG6PS3EA.mjs +264 -0
- package/dist/browser/geo-index-GNHY4PUB.mjs +1484 -0
- package/dist/browser/gzip-JF3S6PPT.mjs +31 -0
- package/dist/browser/module-ZZTNG5JZ.mjs +5762 -0
- package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
- package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
- package/dist/browser/optional-writes-76DWMRQH.mjs +3603 -0
- package/dist/browser/phrase-module-6UGFVW5J.mjs +617 -0
- package/dist/browser/resolve-vector-text-XRR2OVHE.mjs +85 -0
- package/dist/browser/restore-queue-SG5O735W.mjs +196 -0
- package/dist/browser/{runtime-NYE5TB6O.mjs → runtime-OMKE7DF4.mjs} +83 -25
- package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
- package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
- package/dist/browser/storage-leaf-5UTR5K7J.mjs +19829 -0
- package/dist/browser/store-leaf-3L33V35P.mjs +2070 -0
- package/dist/browser/suggestions-leaf-UBNDVKBD.mjs +1430 -0
- package/dist/browser/worker-copies-JXSGYR5X.mjs +2951 -0
- package/dist/{capabilities-BTTIs96E.d.ts → capabilities-DMte5K9_.d.ts} +162 -18
- package/dist/chunk-2AFZE7Y3.mjs +72 -0
- package/dist/chunk-2CKDCC65.mjs +47 -0
- package/dist/chunk-3ECIRFS5.mjs +61 -0
- package/dist/chunk-44W3CBNG.mjs +7 -0
- package/dist/chunk-4H4RG2FR.mjs +13 -0
- package/dist/chunk-4PY4JYMY.mjs +11 -0
- package/dist/chunk-4ZPVAHWF.mjs +1289 -0
- package/dist/chunk-5EI5CXO6.mjs +197 -0
- package/dist/chunk-5F5MXWS5.mjs +283 -0
- package/dist/{chunk-OHP7QR33.mjs → chunk-5FLRXF73.mjs} +25 -4
- package/dist/chunk-6FOENO4E.mjs +273 -0
- package/dist/chunk-6GHX35ZM.mjs +108 -0
- package/dist/chunk-6MSZ543Y.mjs +32 -0
- package/dist/chunk-6N6HHBCQ.mjs +4596 -0
- package/dist/{chunk-LXPIXDUJ.mjs → chunk-7P5YWDRQ.mjs} +403 -169
- package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
- package/dist/{chunk-GGSH6KBQ.mjs → chunk-ASZLNVWW.mjs} +23 -3
- package/dist/chunk-AVBPB3MI.mjs +602 -0
- package/dist/{chunk-UCDF35PU.mjs → chunk-AVGUEEQ3.mjs} +494 -245
- package/dist/chunk-BUMREPLU.mjs +15 -0
- package/dist/chunk-BY6NALRK.mjs +31921 -0
- package/dist/chunk-C4ZMXXTL.mjs +92 -0
- package/dist/{chunk-2WYMG3OZ.mjs → chunk-C74KPRR7.mjs} +274 -19
- package/dist/{chunk-RSRVGAIQ.mjs → chunk-D456ZFPQ.mjs} +3 -2
- package/dist/chunk-DXZ6JDWG.mjs +797 -0
- package/dist/chunk-FJXJZUWF.mjs +209 -0
- package/dist/chunk-FS3HPPSC.mjs +212 -0
- package/dist/chunk-FT4KLZXW.mjs +1164 -0
- package/dist/chunk-GR5GMFJJ.mjs +104 -0
- package/dist/chunk-GXCDWLQI.mjs +193 -0
- package/dist/chunk-GXED6R3Q.mjs +271 -0
- package/dist/chunk-HLPRHOSO.mjs +17 -0
- package/dist/chunk-IL5DRCNU.mjs +3041 -0
- package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
- package/dist/chunk-K5HSUPYS.mjs +11 -0
- package/dist/chunk-KYIRXTCA.mjs +100 -0
- package/dist/chunk-LFXS6OF7.mjs +289 -0
- package/dist/chunk-LNGE7SLY.mjs +151 -0
- package/dist/chunk-M2Z5WVWW.mjs +194 -0
- package/dist/{chunk-45AVKHMJ.mjs → chunk-M3B7SGJB.mjs} +63 -50
- package/dist/chunk-M3OW2XSP.mjs +40 -0
- package/dist/chunk-MFPSQZ6P.mjs +127 -0
- package/dist/chunk-MRCJBWJZ.mjs +1292 -0
- package/dist/chunk-MSIN4NM3.mjs +25 -0
- package/dist/chunk-MW3CJVGP.mjs +219 -0
- package/dist/chunk-MYM6CAVK.mjs +76 -0
- package/dist/chunk-NJJN4FMM.mjs +84 -0
- package/dist/chunk-NM7I3BM7.mjs +59 -0
- package/dist/chunk-OIJ64LGT.mjs +19 -0
- package/dist/{chunk-K7D4ZTSW.mjs → chunk-P4F4UWLC.mjs} +1 -1
- package/dist/chunk-Q2AP2FSN.mjs +15 -0
- package/dist/chunk-R2PJKSNL.mjs +54 -0
- package/dist/{chunk-HXJBSHXF.mjs → chunk-R724DJSG.mjs} +5056 -2619
- package/dist/chunk-S2POFTLN.mjs +10 -0
- package/dist/chunk-S5QMWECL.mjs +7 -0
- package/dist/chunk-SLAC5PAB.mjs +5008 -0
- package/dist/chunk-T4HMSZCX.mjs +5 -0
- package/dist/chunk-TACP6VK6.mjs +111 -0
- package/dist/chunk-TGPKS2UM.mjs +125 -0
- package/dist/chunk-TKKXPKEO.mjs +979 -0
- package/dist/chunk-V6EUBAIT.mjs +19 -0
- package/dist/chunk-XL56L4IR.mjs +228 -0
- package/dist/chunk-XQIAMDAG.mjs +3076 -0
- package/dist/chunk-YTUZ4R22.mjs +1063 -0
- package/dist/{chunk-KV3AZFT3.mjs → chunk-ZKOQR7EA.mjs} +45 -1
- package/dist/chunk-ZPJFGGGI.mjs +638 -0
- package/dist/chunk-ZXX5GZEX.mjs +17 -0
- package/dist/{client-i9eLJrw5.d.ts → client-BKqtl0_V.d.ts} +442 -22
- package/dist/client.d.ts +11 -10
- package/dist/client.mjs +8 -898
- package/dist/config-Bnl7L-0H.d.ts +608 -0
- package/dist/{config-P__Diiy4.d.ts → config-CJ-jfI0a.d.ts} +119 -9
- package/dist/core-leaf-6JVHEVFB.mjs +8 -0
- package/dist/custom-token-results-NXHBVY7U.mjs +59 -0
- package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
- package/dist/direct-executor-V3WOYU2Y.mjs +17 -0
- package/dist/distribution/coordinator/etcd.d.ts +63 -7
- package/dist/distribution/coordinator/etcd.mjs +725 -81
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/coordinator/in-memory.mjs +65 -10
- package/dist/distribution/transport/grpc.d.ts +2 -2
- package/dist/distribution/transport/grpc.mjs +39 -10
- package/dist/distribution/transport/in-memory.d.ts +2 -2
- package/dist/distribution/transport/in-memory.mjs +9 -6
- package/dist/distribution/transport/tcp.d.ts +2 -2
- package/dist/distribution/transport/tcp.mjs +20 -15
- package/dist/distribution.d.ts +267 -56
- package/dist/distribution.mjs +23156 -11362
- package/dist/durability-config-VWS2K24E.mjs +96 -0
- package/dist/embed-4PHHKGBK.mjs +263 -0
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{memory-CUEDwr-F.d.ts → engine-qjAxJSKk.d.ts} +2254 -1123
- package/dist/geo-index-2ZMMWWSK.mjs +1484 -0
- package/dist/gzip-2UCZW2MM.mjs +31 -0
- package/dist/{index-lcdGLyJH.d.ts → index-B_vmxpgW.d.ts} +260 -102
- package/dist/index.browser.mjs +4 -4
- package/dist/index.d.ts +2133 -57
- package/dist/index.mjs +16 -32
- package/dist/index.react-native.mjs +12 -0
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +1 -2
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/languages/albanian.mjs +1 -1
- package/dist/languages/amharic.mjs +1 -1
- package/dist/languages/arabic.mjs +1 -1
- package/dist/languages/armenian.mjs +1 -1
- package/dist/languages/azerbaijani.mjs +1 -1
- package/dist/languages/bambara.mjs +1 -1
- package/dist/languages/basque.mjs +1 -1
- package/dist/languages/belarusian.mjs +1 -1
- package/dist/languages/bengali.mjs +1 -1
- package/dist/languages/bosnian.mjs +1 -1
- package/dist/languages/breton.mjs +1 -1
- package/dist/languages/bulgarian.mjs +1 -1
- package/dist/languages/burmese.mjs +1 -1
- package/dist/languages/catalan.mjs +1 -1
- package/dist/languages/chinese.mjs +1 -1
- package/dist/languages/croatian.mjs +1 -1
- package/dist/languages/czech.mjs +1 -1
- package/dist/languages/dagbani.mjs +1 -1
- package/dist/languages/danish.mjs +1 -1
- package/dist/languages/dutch.mjs +1 -1
- package/dist/languages/english.mjs +1 -1
- package/dist/languages/esperanto.mjs +1 -1
- package/dist/languages/estonian.mjs +1 -1
- package/dist/languages/ewe.mjs +1 -1
- package/dist/languages/faroese.mjs +1 -1
- package/dist/languages/fijian.mjs +1 -1
- package/dist/languages/finnish.mjs +1 -1
- package/dist/languages/french.mjs +1 -1
- package/dist/languages/ga.mjs +1 -1
- package/dist/languages/galician.mjs +1 -1
- package/dist/languages/georgian.mjs +1 -1
- package/dist/languages/german.mjs +1 -1
- package/dist/languages/greek.mjs +1 -1
- package/dist/languages/guarani.mjs +1 -1
- package/dist/languages/gujarati.mjs +1 -1
- package/dist/languages/haitian-creole.mjs +1 -1
- package/dist/languages/hausa.mjs +1 -1
- package/dist/languages/hawaiian.mjs +1 -1
- package/dist/languages/hebrew.mjs +1 -1
- package/dist/languages/hindi.mjs +1 -1
- package/dist/languages/hungarian.mjs +1 -1
- package/dist/languages/icelandic.mjs +1 -1
- package/dist/languages/igbo.mjs +1 -1
- package/dist/languages/indonesian.mjs +1 -1
- package/dist/languages/irish.mjs +1 -1
- package/dist/languages/italian.mjs +1 -1
- package/dist/languages/japanese.mjs +1 -1
- package/dist/languages/kannada.mjs +1 -1
- package/dist/languages/kazakh.mjs +1 -1
- package/dist/languages/khmer.mjs +1 -1
- package/dist/languages/kinyarwanda.mjs +1 -1
- package/dist/languages/kirundi.mjs +1 -1
- package/dist/languages/korean.mjs +1 -1
- package/dist/languages/kurmanji.mjs +1 -1
- package/dist/languages/kyrgyz.mjs +1 -1
- package/dist/languages/lao.mjs +1 -1
- package/dist/languages/latin.mjs +1 -1
- package/dist/languages/latvian.mjs +1 -1
- package/dist/languages/lingala.mjs +1 -1
- package/dist/languages/lithuanian.mjs +1 -1
- package/dist/languages/luxembourgish.mjs +1 -1
- package/dist/languages/macedonian.mjs +1 -1
- package/dist/languages/malagasy.mjs +1 -1
- package/dist/languages/malay.mjs +1 -1
- package/dist/languages/malayalam.mjs +1 -1
- package/dist/languages/maltese.mjs +1 -1
- package/dist/languages/maori.mjs +1 -1
- package/dist/languages/marathi.mjs +1 -1
- package/dist/languages/nepali.mjs +1 -1
- package/dist/languages/norwegian.mjs +1 -1
- package/dist/languages/oromo.mjs +1 -1
- package/dist/languages/persian.mjs +1 -1
- package/dist/languages/polish.mjs +1 -1
- package/dist/languages/portuguese.mjs +1 -1
- package/dist/languages/punjabi.mjs +1 -1
- package/dist/languages/romanian.mjs +1 -1
- package/dist/languages/russian.mjs +1 -1
- package/dist/languages/samoan.mjs +1 -1
- package/dist/languages/sanskrit.mjs +1 -1
- package/dist/languages/scottish-gaelic.mjs +1 -1
- package/dist/languages/serbian.mjs +1 -1
- package/dist/languages/shona.mjs +1 -1
- package/dist/languages/sinhala.mjs +1 -1
- package/dist/languages/slovak.mjs +1 -1
- package/dist/languages/slovenian.mjs +1 -1
- package/dist/languages/sorani.mjs +1 -1
- package/dist/languages/spanish.mjs +1 -1
- package/dist/languages/swahili.mjs +1 -1
- package/dist/languages/swedish.mjs +1 -1
- package/dist/languages/tagalog.mjs +1 -1
- package/dist/languages/tamil.mjs +1 -1
- package/dist/languages/tatar.mjs +1 -1
- package/dist/languages/telugu.mjs +1 -1
- package/dist/languages/thai.mjs +1 -1
- package/dist/languages/tibetan.mjs +1 -1
- package/dist/languages/tigrinya.mjs +1 -1
- package/dist/languages/tongan.mjs +1 -1
- package/dist/languages/turkish.mjs +1 -1
- package/dist/languages/twi.mjs +1 -1
- package/dist/languages/ukrainian.mjs +1 -1
- package/dist/languages/urdu.mjs +1 -1
- package/dist/languages/vietnamese.mjs +1 -1
- package/dist/languages/welsh.mjs +1 -1
- package/dist/languages/wolof.mjs +1 -1
- package/dist/languages/xhosa.mjs +1 -1
- package/dist/languages/yoruba.mjs +1 -1
- package/dist/languages/zulu.mjs +1 -1
- package/dist/long-query-thread-UCRK7MSI.mjs +154 -0
- package/dist/module-5ZSLUQII.mjs +3729 -0
- package/dist/msgpack-leaf-H5ZYW7S7.mjs +9 -0
- package/dist/optional-reads-5HFMF2QZ.mjs +3373 -0
- package/dist/optional-writes-4UOQKETU.mjs +247 -0
- package/dist/paged-partition-archive-BBRLZCIF.mjs +253 -0
- package/dist/partial-words.browser.mjs +1650 -0
- package/dist/partial-words.mjs +17 -11
- package/dist/{chunk-ASY5PHYI.mjs → pattern.browser.mjs} +253 -311
- package/dist/pattern.mjs +6 -7
- package/dist/persistence/durability/checkpoint-worker.d.ts +93 -25
- package/dist/persistence/durability/checkpoint-worker.mjs +51 -41
- package/dist/phrase-module-EFESWOCR.mjs +635 -0
- package/dist/query-actions-HMJUVWGT.mjs +119 -0
- package/dist/query-suggestions/merge-worker.d.ts +55 -0
- package/dist/query-suggestions/merge-worker.mjs +53 -0
- package/dist/query-suggestions-CBYkrQ5T.d.ts +311 -0
- package/dist/query-suggestions.browser.mjs +47 -0
- package/dist/query-suggestions.d.ts +20 -0
- package/dist/query-suggestions.mjs +19 -0
- package/dist/react-native/chunks/chunk-3OEFSHVV.mjs +970 -0
- package/dist/{browser/chunk-RELZRJNR.mjs → react-native/chunks/chunk-43R4GCM7.mjs} +49 -50
- package/dist/react-native/chunks/chunk-AKRYHAVG.mjs +6729 -0
- package/dist/react-native/chunks/chunk-CW2ZFXSE.mjs +14 -0
- package/dist/react-native/chunks/chunk-G3WCDTOF.mjs +29640 -0
- package/dist/react-native/chunks/chunk-GXXHHA2T.mjs +212 -0
- package/dist/react-native/chunks/chunk-H3MDVPBO.mjs +151 -0
- package/dist/react-native/chunks/chunk-HQEVQEDJ.mjs +52 -0
- package/dist/react-native/chunks/chunk-HRDMIQ63.mjs +131 -0
- package/dist/react-native/chunks/chunk-HTBY4GON.mjs +565 -0
- package/dist/react-native/chunks/chunk-LX62Y4B5.mjs +61 -0
- package/dist/react-native/chunks/chunk-MRH36RN3.mjs +902 -0
- package/dist/react-native/chunks/chunk-Q32DDFKX.mjs +19 -0
- package/dist/react-native/chunks/chunk-UE4ANHSX.mjs +127 -0
- package/dist/react-native/chunks/chunk-UNZPWLVL.mjs +1063 -0
- package/dist/react-native/chunks/chunk-UO44MA5M.mjs +232 -0
- package/dist/react-native/chunks/chunk-UYKIV2KT.mjs +42 -0
- package/dist/react-native/chunks/chunk-VUJCSQG5.mjs +11 -0
- package/dist/react-native/chunks/chunk-WVHF4ZAK.mjs +802 -0
- package/dist/react-native/chunks/chunk-ZUJCUPVS.mjs +54 -0
- package/dist/react-native/chunks/core-leaf-S2KNBWDY.mjs +7 -0
- package/dist/react-native/chunks/custom-token-results-3OZEMRE7.mjs +59 -0
- package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
- package/dist/react-native/chunks/durability-config-FCSD4MXY.mjs +96 -0
- package/dist/react-native/chunks/embed-HA2I7RCF.mjs +263 -0
- package/dist/react-native/chunks/geo-index-QEYKEVPH.mjs +1484 -0
- package/dist/react-native/chunks/gzip.react-native-CVM4NQG2.mjs +12 -0
- package/dist/react-native/chunks/module-FMBX75GP.mjs +5209 -0
- package/dist/react-native/chunks/msgpack-leaf-JMNGSTRW.mjs +7 -0
- package/dist/react-native/chunks/optional-reads-AFPO2FEB.mjs +3364 -0
- package/dist/react-native/chunks/optional-writes-XOH25XZI.mjs +296 -0
- package/dist/react-native/chunks/phrase-module-IGYBK7XH.mjs +636 -0
- package/dist/react-native/chunks/replace-IMZUVUOE.mjs +57 -0
- package/dist/react-native/chunks/resolve-vector-text-GE2CRJKI.mjs +84 -0
- package/dist/react-native/chunks/restore-queue-LLNMYB4Z.mjs +187 -0
- package/dist/react-native/chunks/runtime-UOHD2XUJ.mjs +615 -0
- package/dist/react-native/chunks/segment-codec-leaf-VR6O5GLC.mjs +13 -0
- package/dist/react-native/chunks/segment-merge-leaf-LLMWU4EW.mjs +14 -0
- package/dist/react-native/chunks/storage-leaf-JD7PIDO4.mjs +19633 -0
- package/dist/react-native/chunks/store-leaf-4UVCMYGN.mjs +15 -0
- package/dist/react-native/chunks/suggestions-leaf-J5VT5RHY.mjs +1321 -0
- package/dist/react-native/chunks/worker-copies-ZYHY7FKJ.mjs +2831 -0
- package/dist/react-native/partial-words.mjs +1658 -0
- package/dist/react-native/pattern.mjs +2570 -0
- package/dist/react-native/query-suggestions.mjs +55 -0
- package/dist/react-native/sync.mjs +2759 -0
- package/dist/react-native/synonyms.mjs +676 -0
- package/dist/react.d.ts +12 -8
- package/dist/react.mjs +45 -1
- package/dist/{rerank-NWTKK636.mjs → rerank-RI2PMNOD.mjs} +22 -12
- package/dist/rerankers/http.d.ts +1 -1
- package/dist/rerankers/http.mjs +2 -2
- package/dist/resolve-vector-text-OD4J3WHF.mjs +3 -0
- package/dist/restore-queue-PCKWDAKQ.mjs +192 -0
- package/dist/runtime-USQYKN3I.mjs +615 -0
- package/dist/{schema-4W_7tk1f.d.ts → schema-CzG9OUw5.d.ts} +70 -30
- package/dist/segment-codec-leaf-QJM7I6QG.mjs +18 -0
- package/dist/segment-merge-leaf-4BJGIJHY.mjs +18 -0
- package/dist/server.d.ts +348 -22
- package/dist/server.mjs +2211 -327
- package/dist/storage-leaf-GRRRI7UV.mjs +5962 -0
- package/dist/store-leaf-6VMMSVBE.mjs +20 -0
- package/dist/stored-values-BWIMpiT_.d.ts +25 -0
- package/dist/suggestions-leaf-4KPTMPTL.mjs +54 -0
- package/dist/sync/filesystem.d.ts +30 -0
- package/dist/sync/filesystem.mjs +288 -0
- package/dist/sync/indexeddb.browser.mjs +287 -0
- package/dist/sync/indexeddb.d.ts +30 -0
- package/dist/sync/indexeddb.mjs +242 -0
- package/dist/sync.browser.mjs +1271 -0
- package/dist/sync.d.ts +23 -0
- package/dist/sync.mjs +2712 -0
- package/dist/synonyms.browser.mjs +658 -0
- package/dist/synonyms.mjs +17 -7
- package/dist/tasks-65b6t6lk.d.ts +782 -0
- package/dist/thread-UJ3W5LVI.mjs +31 -0
- package/dist/{types-B3b68nfF.d.ts → types-Ck97nB3D.d.ts} +1 -1
- package/dist/types-CpCg-Gq-.d.ts +227 -0
- package/dist/{types-Cb9kiY5P.d.ts → types-DvncmvuQ.d.ts} +12 -1
- package/dist/vector/search-worker.d.ts +10 -2
- package/dist/vector/search-worker.mjs +11 -11
- package/dist/worker-copies-YSXZXIGC.mjs +2232 -0
- package/dist/workers/entry.mjs +75 -15
- package/openapi.json +6840 -0
- package/package.json +406 -19
- package/dist/browser/chunk-CN4I4FZU.mjs +0 -602
- package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
- package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
- package/dist/browser/chunk-LD55ZGU3.mjs +0 -347
- package/dist/browser/chunk-NAFT3K6X.mjs +0 -24546
- package/dist/browser/chunk-NNG3EEB6.mjs +0 -2728
- package/dist/browser/chunk-QWES44AW.mjs +0 -473
- package/dist/browser/durability-wiring-PY3L7DES.mjs +0 -3679
- package/dist/browser/module-PDXYHT75.mjs +0 -2822
- package/dist/browser/release-76MXRPGV.mjs +0 -33
- package/dist/browser/restore-queue-DVIYJ7RU.mjs +0 -35
- package/dist/browser/snapshot-J57MZK6L.mjs +0 -1207
- package/dist/browser/write-L7FAQA47.mjs +0 -208
- package/dist/chunk-37CD3OKS.mjs +0 -87
- package/dist/chunk-5XNIRLFC.mjs +0 -96
- package/dist/chunk-7X5JST5L.mjs +0 -114
- package/dist/chunk-AV4IJKD2.mjs +0 -35
- package/dist/chunk-AY3AQ3UH.mjs +0 -73
- package/dist/chunk-BKB3XTMI.mjs +0 -707
- package/dist/chunk-C7SLA6CM.mjs +0 -19
- package/dist/chunk-COVCQ73F.mjs +0 -587
- package/dist/chunk-DJHHF2L5.mjs +0 -17
- package/dist/chunk-E74YLAIG.mjs +0 -24
- package/dist/chunk-FMWRCP2C.mjs +0 -57
- package/dist/chunk-GES7U2PM.mjs +0 -68
- package/dist/chunk-HJSN7UYG.mjs +0 -10
- package/dist/chunk-JFRNNBOM.mjs +0 -35
- package/dist/chunk-K25LZA54.mjs +0 -8484
- package/dist/chunk-KEHK2O6P.mjs +0 -13
- package/dist/chunk-KOKM4PQN.mjs +0 -52
- package/dist/chunk-KZ3NX2P7.mjs +0 -21
- package/dist/chunk-L3L5YFXC.mjs +0 -614
- package/dist/chunk-L5ORED7V.mjs +0 -25
- package/dist/chunk-LH4NZNJJ.mjs +0 -1731
- package/dist/chunk-LU2CE5AE.mjs +0 -507
- package/dist/chunk-LXWDQLTW.mjs +0 -30
- package/dist/chunk-MHOSCQCQ.mjs +0 -948
- package/dist/chunk-NKRBEGJZ.mjs +0 -1705
- package/dist/chunk-NTRMFARG.mjs +0 -462
- package/dist/chunk-NW4XDSP2.mjs +0 -212
- package/dist/chunk-OOEXLUGR.mjs +0 -117
- package/dist/chunk-ORBLD3EL.mjs +0 -6
- package/dist/chunk-OWNZYMRE.mjs +0 -3591
- package/dist/chunk-PPY2GSIB.mjs +0 -44
- package/dist/chunk-QY7GC2MW.mjs +0 -33
- package/dist/chunk-R6A773WK.mjs +0 -226
- package/dist/chunk-R6PR4WYZ.mjs +0 -68
- package/dist/chunk-R7EEKAJE.mjs +0 -593
- package/dist/chunk-RONEOEON.mjs +0 -426
- package/dist/chunk-VWULPWRJ.mjs +0 -7469
- package/dist/chunk-WCJKUGHB.mjs +0 -262
- package/dist/chunk-WQBCBKY3.mjs +0 -8
- package/dist/chunk-X5CV2E2B.mjs +0 -1
- package/dist/chunk-YA7XLE2R.mjs +0 -1256
- package/dist/chunk-YTJCGKM4.mjs +0 -56
- package/dist/chunk-ZG477IPV.mjs +0 -526
- package/dist/chunk-ZYNAMIYX.mjs +0 -113
- package/dist/config-BGB_fDtq.d.ts +0 -237
- package/dist/direct-executor-CXZ66ACP.mjs +0 -22
- package/dist/durability-wiring-QTHOGFMZ.mjs +0 -3229
- package/dist/engine-BGCEm9E_.d.ts +0 -577
- package/dist/module-3NONKBZX.mjs +0 -1860
- package/dist/release-BH3DKW3T.mjs +0 -33
- package/dist/restore-queue-JPRBUYII.mjs +0 -35
- package/dist/runtime-ZKYZFJJC.mjs +0 -177
- package/dist/snapshot-HOGXNO5W.mjs +0 -793
- package/dist/tasks-HG3rlxx6.d.ts +0 -302
- package/dist/thread-B657LQXK.mjs +0 -692
- package/dist/write-XLIGTXBU.mjs +0 -238
package/dist/client.mjs
CHANGED
|
@@ -1,916 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
SEARCH_INVALID_FIELD: "SEARCH_INVALID_FIELD",
|
|
29
|
-
VECTOR_DIMENSION_MISMATCH: "VECTOR_DIMENSION_MISMATCH",
|
|
30
|
-
SEARCH_INVALID_FILTER: "SEARCH_INVALID_FILTER",
|
|
31
|
-
SEARCH_INVALID_MODE: "SEARCH_INVALID_MODE",
|
|
32
|
-
SEARCH_INVALID_CURSOR: "SEARCH_INVALID_CURSOR",
|
|
33
|
-
SEARCH_RESULT_WINDOW_EXCEEDED: "SEARCH_RESULT_WINDOW_EXCEEDED",
|
|
34
|
-
SEARCH_WORK_CAP_EXCEEDED: "SEARCH_WORK_CAP_EXCEEDED",
|
|
35
|
-
LANGUAGE_NOT_SUPPORTED: "LANGUAGE_NOT_SUPPORTED",
|
|
36
|
-
ENVELOPE_VERSION_MISMATCH: "ENVELOPE_VERSION_MISMATCH",
|
|
37
|
-
ENVELOPE_INVALID_MAGIC: "ENVELOPE_INVALID_MAGIC",
|
|
38
|
-
PARTITION_CAPACITY_EXCEEDED: "PARTITION_CAPACITY_EXCEEDED",
|
|
39
|
-
RESTORE_MEMORY_EXCEEDED: "RESTORE_MEMORY_EXCEEDED",
|
|
40
|
-
EMBEDDING_FAILED: "EMBEDDING_FAILED",
|
|
41
|
-
EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH",
|
|
42
|
-
EMBEDDING_NO_SOURCE: "EMBEDDING_NO_SOURCE",
|
|
43
|
-
EMBEDDING_CONFIG_INVALID: "EMBEDDING_CONFIG_INVALID",
|
|
44
|
-
RERANK_FAILED: "RERANK_FAILED",
|
|
45
|
-
RERANK_CONFIG_INVALID: "RERANK_CONFIG_INVALID",
|
|
46
|
-
DOC_MISSING_REQUIRED_FIELD: "DOC_MISSING_REQUIRED_FIELD",
|
|
47
|
-
CONFIG_INVALID: "CONFIG_INVALID",
|
|
48
|
-
QUERY_ROUTING_FAILED: "QUERY_ROUTING_FAILED",
|
|
49
|
-
QUERY_PARTIAL_FAILURE: "QUERY_PARTIAL_FAILURE",
|
|
50
|
-
QUERY_NODE_TIMEOUT: "QUERY_NODE_TIMEOUT",
|
|
51
|
-
QUERY_NO_ACTIVE_REPLICA: "QUERY_NO_ACTIVE_REPLICA",
|
|
52
|
-
CLUSTER_OPERATION_UNSUPPORTED: "CLUSTER_OPERATION_UNSUPPORTED",
|
|
53
|
-
CLUSTER_WRITE_BLOCKED: "CLUSTER_WRITE_BLOCKED",
|
|
54
|
-
ALLOCATION_NO_DATA_NODES: "ALLOCATION_NO_DATA_NODES",
|
|
55
|
-
ALLOCATION_INVALID_CONFIG: "ALLOCATION_INVALID_CONFIG",
|
|
56
|
-
ALLOCATION_FAILED: "ALLOCATION_FAILED",
|
|
57
|
-
CONTROLLER_METADATA_INVALID: "CONTROLLER_METADATA_INVALID",
|
|
58
|
-
NODE_BOOTSTRAP_FAILED: "NODE_BOOTSTRAP_FAILED",
|
|
59
|
-
NODE_ALREADY_JOINED: "NODE_ALREADY_JOINED",
|
|
60
|
-
NODE_NOT_JOINED: "NODE_NOT_JOINED",
|
|
61
|
-
NODE_NOT_READY: "NODE_NOT_READY",
|
|
62
|
-
NODE_NOT_CONTROLLER: "NODE_NOT_CONTROLLER",
|
|
63
|
-
COORDINATOR_DEPENDENCY_MISSING: "COORDINATOR_DEPENDENCY_MISSING",
|
|
64
|
-
TRANSPORT_DEPENDENCY_MISSING: "TRANSPORT_DEPENDENCY_MISSING",
|
|
65
|
-
REPLICATION_ENTRY_INVALID: "REPLICATION_ENTRY_INVALID",
|
|
66
|
-
REPLICATION_INSYNC_REMOVAL_FAILED: "REPLICATION_INSYNC_REMOVAL_FAILED",
|
|
67
|
-
REPLICATION_ROLLBACK_FAILED: "REPLICATION_ROLLBACK_FAILED",
|
|
68
|
-
REPLICATION_LOG_FULL: "REPLICATION_LOG_FULL",
|
|
69
|
-
REPLICATION_ENTRY_CORRUPT: "REPLICATION_ENTRY_CORRUPT",
|
|
70
|
-
REPLICATION_SNAPSHOT_CORRUPT: "REPLICATION_SNAPSHOT_CORRUPT",
|
|
71
|
-
REPLICATION_TERM_MISMATCH: "REPLICATION_TERM_MISMATCH",
|
|
72
|
-
REPLICATION_SYNC_FAILED: "REPLICATION_SYNC_FAILED",
|
|
73
|
-
PARTITION_NOT_PRIMARY: "PARTITION_NOT_PRIMARY",
|
|
74
|
-
PARTITION_UNASSIGNED: "PARTITION_UNASSIGNED",
|
|
75
|
-
INSUFFICIENT_REPLICAS: "INSUFFICIENT_REPLICAS",
|
|
76
|
-
SNAPSHOT_SYNC_UNAUTHORIZED: "SNAPSHOT_SYNC_UNAUTHORIZED",
|
|
77
|
-
SNAPSHOT_SYNC_REQUEST_INVALID: "SNAPSHOT_SYNC_REQUEST_INVALID",
|
|
78
|
-
SNAPSHOT_SYNC_INDEX_NOT_FOUND: "SNAPSHOT_SYNC_INDEX_NOT_FOUND",
|
|
79
|
-
SNAPSHOT_SYNC_CAPACITY_EXHAUSTED: "SNAPSHOT_SYNC_CAPACITY_EXHAUSTED",
|
|
80
|
-
SNAPSHOT_SYNC_SNAPSHOT_FAILED: "SNAPSHOT_SYNC_SNAPSHOT_FAILED",
|
|
81
|
-
SNAPSHOT_SYNC_DECODE_FAILED: "SNAPSHOT_SYNC_DECODE_FAILED",
|
|
82
|
-
SNAPSHOT_SYNC_FRAME_INVALID: "SNAPSHOT_SYNC_FRAME_INVALID",
|
|
83
|
-
SNAPSHOT_SYNC_HEADER_INVALID: "SNAPSHOT_SYNC_HEADER_INVALID",
|
|
84
|
-
SNAPSHOT_SYNC_HEADER_MISMATCH: "SNAPSHOT_SYNC_HEADER_MISMATCH",
|
|
85
|
-
SNAPSHOT_SYNC_CHUNK_OUT_OF_ORDER: "SNAPSHOT_SYNC_CHUNK_OUT_OF_ORDER",
|
|
86
|
-
SNAPSHOT_SYNC_CHUNK_OVERFLOW: "SNAPSHOT_SYNC_CHUNK_OVERFLOW",
|
|
87
|
-
SNAPSHOT_SYNC_CHUNK_SIZE_EXCEEDED: "SNAPSHOT_SYNC_CHUNK_SIZE_EXCEEDED",
|
|
88
|
-
SNAPSHOT_SYNC_CHUNK_MISSING: "SNAPSHOT_SYNC_CHUNK_MISSING",
|
|
89
|
-
SNAPSHOT_SYNC_END_MISSING: "SNAPSHOT_SYNC_END_MISSING",
|
|
90
|
-
SNAPSHOT_SYNC_CHECKSUM_MISMATCH: "SNAPSHOT_SYNC_CHECKSUM_MISMATCH",
|
|
91
|
-
SNAPSHOT_SYNC_PRIMARY_ERROR: "SNAPSHOT_SYNC_PRIMARY_ERROR",
|
|
92
|
-
SNAPSHOT_SYNC_NO_TARGETS: "SNAPSHOT_SYNC_NO_TARGETS",
|
|
93
|
-
SNAPSHOT_SYNC_TRANSPORT_FAILED: "SNAPSHOT_SYNC_TRANSPORT_FAILED",
|
|
94
|
-
SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE: "SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE",
|
|
95
|
-
SNAPSHOT_SYNC_RESTORE_FAILED: "SNAPSHOT_SYNC_RESTORE_FAILED",
|
|
96
|
-
SNAPSHOT_SYNC_RESTORE_CLEANUP_FAILED: "SNAPSHOT_SYNC_RESTORE_CLEANUP_FAILED",
|
|
97
|
-
SNAPSHOT_SYNC_TIMEOUT: "SNAPSHOT_SYNC_TIMEOUT",
|
|
98
|
-
SNAPSHOT_SYNC_ALLOCATION_UNAVAILABLE: "SNAPSHOT_SYNC_ALLOCATION_UNAVAILABLE",
|
|
99
|
-
SNAPSHOT_SYNC_NOT_ASSIGNED: "SNAPSHOT_SYNC_NOT_ASSIGNED",
|
|
100
|
-
SNAPSHOT_SYNC_ABORTED: "SNAPSHOT_SYNC_ABORTED"
|
|
101
|
-
};
|
|
102
|
-
var ServerErrorCodes = {
|
|
103
|
-
INVALID_REQUEST: "INVALID_REQUEST",
|
|
104
|
-
INVALID_JSON: "INVALID_JSON",
|
|
105
|
-
EMPTY_BODY: "EMPTY_BODY",
|
|
106
|
-
PAYLOAD_TOO_LARGE: "PAYLOAD_TOO_LARGE",
|
|
107
|
-
NOT_FOUND: "NOT_FOUND",
|
|
108
|
-
TASK_NOT_FOUND: "TASK_NOT_FOUND",
|
|
109
|
-
TASK_NOT_CANCELLABLE: "TASK_NOT_CANCELLABLE",
|
|
110
|
-
TASK_OWNED_BY_ANOTHER_INSTANCE: "TASK_OWNED_BY_ANOTHER_INSTANCE",
|
|
111
|
-
TASK_INTERRUPTED: "TASK_INTERRUPTED",
|
|
112
|
-
TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS",
|
|
113
|
-
HOOK_ERROR: "HOOK_ERROR",
|
|
114
|
-
INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
115
|
-
};
|
|
116
|
-
var ClientErrorCodes = {
|
|
117
|
-
CLIENT_CONNECTION_FAILED: "CLIENT_CONNECTION_FAILED",
|
|
118
|
-
CLIENT_REQUEST_TIMEOUT: "CLIENT_REQUEST_TIMEOUT",
|
|
119
|
-
CLIENT_REQUEST_ABORTED: "CLIENT_REQUEST_ABORTED",
|
|
120
|
-
CLIENT_INVALID_RESPONSE: "CLIENT_INVALID_RESPONSE",
|
|
121
|
-
CLIENT_TASK_TIMEOUT: "CLIENT_TASK_TIMEOUT",
|
|
122
|
-
CLIENT_UNEXPECTED_ERROR: "CLIENT_UNEXPECTED_ERROR"
|
|
123
|
-
};
|
|
124
|
-
var NarsilError = class extends Error {
|
|
125
|
-
/** This says which failure it is. */
|
|
126
|
-
code;
|
|
127
|
-
/** This carries the values behind the failure, such as the field, index, or limit involved. It is empty when the code says everything. */
|
|
128
|
-
details;
|
|
129
|
-
/**
|
|
130
|
-
* Builds an error carrying a code the caller can branch on.
|
|
131
|
-
*
|
|
132
|
-
* @param code - The failure this error reports, from {@link ErrorCodes} for
|
|
133
|
-
* an engine failure, {@link ServerErrorCodes} for one the HTTP layer raised,
|
|
134
|
-
* or {@link ClientErrorCodes} for one that stopped a request from reaching a
|
|
135
|
-
* server.
|
|
136
|
-
* @param message - Plain description, for a log or a person.
|
|
137
|
-
* @param details - Values behind the failure, which reach
|
|
138
|
-
* {@link NarsilError.details}.
|
|
139
|
-
*/
|
|
140
|
-
constructor(code, message, details) {
|
|
141
|
-
super(message);
|
|
142
|
-
this.name = "NarsilError";
|
|
143
|
-
this.code = code;
|
|
144
|
-
this.details = details ?? {};
|
|
145
|
-
Object.defineProperty(this, NARSIL_ERROR_MARKER, { value: true });
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
function isNarsilError(value) {
|
|
149
|
-
return typeof value === "object" && value !== null && NARSIL_ERROR_MARKER in value;
|
|
150
|
-
}
|
|
151
|
-
function describeError(error) {
|
|
152
|
-
return error instanceof Error ? error.message : String(error);
|
|
153
|
-
}
|
|
1
|
+
export { createNarsilClient } from './browser/chunk-4E5APHTM.mjs';
|
|
2
|
+
export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes, isNarsilError } from './browser/chunk-YINZFPLT.mjs';
|
|
154
3
|
|
|
155
4
|
// src/server/capabilities.ts
|
|
156
5
|
var ASYNC_IMPORT_CAPABILITY = "documents.import.async";
|
|
157
6
|
var TASK_CANCEL_CAPABILITY = "tasks.cancel";
|
|
158
7
|
var TASK_FILTER_CAPABILITY = "tasks.filter";
|
|
159
8
|
var REBUILD_ANALYSIS_CAPABILITY = "indexes.rebuildAnalysis";
|
|
9
|
+
var CHANGE_ANALYSIS_CAPABILITY = "indexes.changeAnalysis";
|
|
160
10
|
var INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
|
|
161
11
|
var DOCUMENT_EXPORT_CAPABILITY = "indexes.documentExport";
|
|
162
12
|
var SYNONYMS_CAPABILITY = "indexes.synonyms";
|
|
13
|
+
var BM25_TUNING_CAPABILITY = "indexes.bm25";
|
|
163
14
|
var SERVER_CAPABILITIES = [
|
|
164
15
|
ASYNC_IMPORT_CAPABILITY,
|
|
165
16
|
TASK_CANCEL_CAPABILITY,
|
|
166
17
|
TASK_FILTER_CAPABILITY,
|
|
167
18
|
REBUILD_ANALYSIS_CAPABILITY,
|
|
19
|
+
CHANGE_ANALYSIS_CAPABILITY,
|
|
168
20
|
INDEX_LIFECYCLE_CAPABILITY,
|
|
169
21
|
DOCUMENT_EXPORT_CAPABILITY,
|
|
170
|
-
SYNONYMS_CAPABILITY
|
|
22
|
+
SYNONYMS_CAPABILITY,
|
|
23
|
+
BM25_TUNING_CAPABILITY
|
|
171
24
|
];
|
|
172
25
|
|
|
173
|
-
|
|
174
|
-
function toPlainNumbers(key, value) {
|
|
175
|
-
if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
|
|
176
|
-
return Array.from(value);
|
|
177
|
-
}
|
|
178
|
-
return value;
|
|
179
|
-
}
|
|
180
|
-
function encodeJson(value) {
|
|
181
|
-
return JSON.stringify(value, toPlainNumbers);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/client/constants.ts
|
|
185
|
-
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
186
|
-
var NO_TIMEOUT = 0;
|
|
187
|
-
var DEFAULT_TASK_POLL_INTERVAL_MS = 250;
|
|
188
|
-
|
|
189
|
-
// src/client/paths.ts
|
|
190
|
-
function indexPath(indexName) {
|
|
191
|
-
return `/indexes/${encodeURIComponent(indexName)}`;
|
|
192
|
-
}
|
|
193
|
-
function documentPath(indexName, docId) {
|
|
194
|
-
return `${indexPath(indexName)}/documents/${encodeURIComponent(docId)}`;
|
|
195
|
-
}
|
|
196
|
-
function taskPath(taskId) {
|
|
197
|
-
return `/tasks/${encodeURIComponent(taskId)}`;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/client/response-shape.ts
|
|
201
|
-
function isRecord(value) {
|
|
202
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
203
|
-
}
|
|
204
|
-
function malformed(path, expected) {
|
|
205
|
-
return new NarsilError(ClientErrorCodes.CLIENT_INVALID_RESPONSE, `The answer from ${path} holds no ${expected}`, {
|
|
206
|
-
route: path
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function readArray(payload, key, path) {
|
|
210
|
-
if (!isRecord(payload) || !Array.isArray(payload[key])) throw malformed(path, `"${key}" array`);
|
|
211
|
-
return payload[key];
|
|
212
|
-
}
|
|
213
|
-
function readNumber(payload, key, path) {
|
|
214
|
-
if (!isRecord(payload) || typeof payload[key] !== "number") throw malformed(path, `"${key}" number`);
|
|
215
|
-
return payload[key];
|
|
216
|
-
}
|
|
217
|
-
function readBoolean(payload, key, path) {
|
|
218
|
-
if (!isRecord(payload) || typeof payload[key] !== "boolean") throw malformed(path, `"${key}" flag`);
|
|
219
|
-
return payload[key];
|
|
220
|
-
}
|
|
221
|
-
function readString(payload, key, path) {
|
|
222
|
-
if (!isRecord(payload) || typeof payload[key] !== "string") throw malformed(path, `"${key}" string`);
|
|
223
|
-
return payload[key];
|
|
224
|
-
}
|
|
225
|
-
function readObject(payload, key, path) {
|
|
226
|
-
if (!isRecord(payload) || !isRecord(payload[key])) throw malformed(path, `"${key}" object`);
|
|
227
|
-
return payload[key];
|
|
228
|
-
}
|
|
229
|
-
function readBody(payload, path) {
|
|
230
|
-
if (!isRecord(payload)) throw malformed(path, "JSON object");
|
|
231
|
-
return payload;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// src/client/admin.ts
|
|
235
|
-
function createAdminOperations(transport) {
|
|
236
|
-
async function postJson(path, body, options) {
|
|
237
|
-
const payload = await transport.json({
|
|
238
|
-
method: "POST",
|
|
239
|
-
path,
|
|
240
|
-
body: encodeJson(body),
|
|
241
|
-
contentType: "application/json",
|
|
242
|
-
options
|
|
243
|
-
});
|
|
244
|
-
return readBody(payload, path);
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
247
|
-
async checkpoint(indexName, options) {
|
|
248
|
-
await transport.json({ method: "POST", path: `${indexPath(indexName)}/_checkpoint`, options });
|
|
249
|
-
},
|
|
250
|
-
snapshot(indexName, options) {
|
|
251
|
-
return transport.stream({
|
|
252
|
-
method: "GET",
|
|
253
|
-
path: `${indexPath(indexName)}/snapshot`,
|
|
254
|
-
defaultTimeoutMs: NO_TIMEOUT,
|
|
255
|
-
options
|
|
256
|
-
});
|
|
257
|
-
},
|
|
258
|
-
async restore(indexName, data, options) {
|
|
259
|
-
const path = `${indexPath(indexName)}/restore`;
|
|
260
|
-
const payload = await transport.json({
|
|
261
|
-
method: "POST",
|
|
262
|
-
path,
|
|
263
|
-
body: data,
|
|
264
|
-
contentType: "application/octet-stream",
|
|
265
|
-
defaultTimeoutMs: NO_TIMEOUT,
|
|
266
|
-
options
|
|
267
|
-
});
|
|
268
|
-
return readBody(payload, path);
|
|
269
|
-
},
|
|
270
|
-
exportDocuments(indexName, options) {
|
|
271
|
-
return transport.stream({
|
|
272
|
-
method: "GET",
|
|
273
|
-
path: `${indexPath(indexName)}/export`,
|
|
274
|
-
defaultTimeoutMs: NO_TIMEOUT,
|
|
275
|
-
options
|
|
276
|
-
});
|
|
277
|
-
},
|
|
278
|
-
async importDocumentExport(indexName, data, options) {
|
|
279
|
-
const path = `${indexPath(indexName)}/import`;
|
|
280
|
-
const payload = await transport.json({
|
|
281
|
-
method: "POST",
|
|
282
|
-
path,
|
|
283
|
-
body: data,
|
|
284
|
-
contentType: "application/x-ndjson",
|
|
285
|
-
defaultTimeoutMs: NO_TIMEOUT,
|
|
286
|
-
options
|
|
287
|
-
});
|
|
288
|
-
return readBody(payload, path);
|
|
289
|
-
},
|
|
290
|
-
async vectorMaintenanceStatus(indexName, options) {
|
|
291
|
-
const path = `${indexPath(indexName)}/vector-maintenance`;
|
|
292
|
-
const payload = await transport.json({ method: "GET", path, options });
|
|
293
|
-
return readArray(payload, "fields", path);
|
|
294
|
-
},
|
|
295
|
-
async compactVectors(indexName, fieldName, options) {
|
|
296
|
-
await postJson(
|
|
297
|
-
`${indexPath(indexName)}/vectors/_compact`,
|
|
298
|
-
fieldName === void 0 ? {} : { field: fieldName },
|
|
299
|
-
options
|
|
300
|
-
);
|
|
301
|
-
},
|
|
302
|
-
optimizeVectors(indexName, fieldName, options) {
|
|
303
|
-
return postJson(
|
|
304
|
-
`${indexPath(indexName)}/vectors/_optimize`,
|
|
305
|
-
fieldName === void 0 ? {} : { field: fieldName },
|
|
306
|
-
options
|
|
307
|
-
);
|
|
308
|
-
},
|
|
309
|
-
rebalance(indexName, targetPartitionCount, options) {
|
|
310
|
-
return postJson(`${indexPath(indexName)}/_rebalance`, { targetPartitionCount }, options);
|
|
311
|
-
},
|
|
312
|
-
async updatePartitionConfig(indexName, partitionConfig, options) {
|
|
313
|
-
await postJson(`${indexPath(indexName)}/partition-config`, partitionConfig, options);
|
|
314
|
-
},
|
|
315
|
-
async updateSynonyms(indexName, synonyms, options) {
|
|
316
|
-
await postJson(`${indexPath(indexName)}/synonyms`, { synonyms }, options);
|
|
317
|
-
},
|
|
318
|
-
async getSynonyms(indexName, options) {
|
|
319
|
-
const path = `${indexPath(indexName)}/synonyms`;
|
|
320
|
-
const body = await readBody(
|
|
321
|
-
await transport.json({ method: "GET", path, options }),
|
|
322
|
-
path
|
|
323
|
-
);
|
|
324
|
-
return body.synonyms;
|
|
325
|
-
},
|
|
326
|
-
async rebuildAnalysis(indexName, options) {
|
|
327
|
-
const path = `${indexPath(indexName)}/_rebuild-analysis`;
|
|
328
|
-
return readBody(await transport.json({ method: "POST", path, options }), path);
|
|
329
|
-
},
|
|
330
|
-
async getMemoryStats(options) {
|
|
331
|
-
const path = "/stats/memory";
|
|
332
|
-
return readBody(await transport.json({ method: "GET", path, options }), path);
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// src/client/bulk.ts
|
|
338
|
-
function toNdjson(source) {
|
|
339
|
-
if (typeof source === "string") return source;
|
|
340
|
-
if (Array.isArray(source)) return source.map((document) => encodeJson(document)).join("\n");
|
|
341
|
-
return source;
|
|
342
|
-
}
|
|
343
|
-
function toBatchResult(payload, path) {
|
|
344
|
-
const failed = readArray(payload, "failed", path);
|
|
345
|
-
return {
|
|
346
|
-
succeeded: readArray(payload, "succeeded", path),
|
|
347
|
-
failed: failed.map((entry) => {
|
|
348
|
-
const record = readBody(entry, path);
|
|
349
|
-
const docId = typeof record.docId === "string" ? record.docId : "";
|
|
350
|
-
const error = readBody(record.error, path);
|
|
351
|
-
const code = typeof error.code === "string" ? error.code : ServerErrorCodes.INTERNAL_ERROR;
|
|
352
|
-
const message = typeof error.message === "string" ? error.message : "The server refused the document";
|
|
353
|
-
const details = typeof error.details === "object" && error.details !== null ? error.details : void 0;
|
|
354
|
-
return { docId, error: new NarsilError(code, message, details) };
|
|
355
|
-
})
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function createBulkOperations(transport) {
|
|
359
|
-
function batch(indexName, body, options) {
|
|
360
|
-
const path = `${indexPath(indexName)}/documents/_batch`;
|
|
361
|
-
return transport.json({ method: "POST", path, body: encodeJson(body), contentType: "application/json", options }).then((payload) => toBatchResult(payload, path));
|
|
362
|
-
}
|
|
363
|
-
function importBody(indexName, source, asynchronous, options) {
|
|
364
|
-
return {
|
|
365
|
-
method: "POST",
|
|
366
|
-
path: `${indexPath(indexName)}/documents/_import`,
|
|
367
|
-
...asynchronous ? { query: { async: "true" } } : {},
|
|
368
|
-
body: toNdjson(source),
|
|
369
|
-
contentType: "application/x-ndjson",
|
|
370
|
-
defaultTimeoutMs: NO_TIMEOUT,
|
|
371
|
-
options
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
return {
|
|
375
|
-
insertBatch(indexName, documents, insertOptions, options) {
|
|
376
|
-
return batch(
|
|
377
|
-
indexName,
|
|
378
|
-
{ action: "insert", documents, ...insertOptions === void 0 ? {} : { options: insertOptions } },
|
|
379
|
-
options
|
|
380
|
-
);
|
|
381
|
-
},
|
|
382
|
-
updateBatch(indexName, updates, writeOptions, options) {
|
|
383
|
-
return batch(
|
|
384
|
-
indexName,
|
|
385
|
-
{ action: "update", updates, ...writeOptions === void 0 ? {} : { options: writeOptions } },
|
|
386
|
-
options
|
|
387
|
-
);
|
|
388
|
-
},
|
|
389
|
-
removeBatch(indexName, docIds, writeOptions, options) {
|
|
390
|
-
return batch(
|
|
391
|
-
indexName,
|
|
392
|
-
{ action: "delete", docIds, ...writeOptions === void 0 ? {} : { options: writeOptions } },
|
|
393
|
-
options
|
|
394
|
-
);
|
|
395
|
-
},
|
|
396
|
-
async getMultiple(indexName, docIds, options) {
|
|
397
|
-
const path = `${indexPath(indexName)}/documents/_multi-get`;
|
|
398
|
-
const payload = await transport.json({
|
|
399
|
-
method: "POST",
|
|
400
|
-
path,
|
|
401
|
-
body: encodeJson({ docIds }),
|
|
402
|
-
contentType: "application/json",
|
|
403
|
-
options
|
|
404
|
-
});
|
|
405
|
-
const documents = readObject(payload, "documents", path);
|
|
406
|
-
return new Map(Object.entries(documents));
|
|
407
|
-
},
|
|
408
|
-
async listDocuments(indexName, params, options) {
|
|
409
|
-
const path = `${indexPath(indexName)}/documents/_list`;
|
|
410
|
-
const payload = await transport.json({
|
|
411
|
-
method: "POST",
|
|
412
|
-
path,
|
|
413
|
-
body: encodeJson(params ?? {}),
|
|
414
|
-
contentType: "application/json",
|
|
415
|
-
options
|
|
416
|
-
});
|
|
417
|
-
return readBody(payload, path);
|
|
418
|
-
},
|
|
419
|
-
async importDocuments(indexName, source, options) {
|
|
420
|
-
const spec = importBody(indexName, source, false, options);
|
|
421
|
-
return readBody(await transport.json(spec), spec.path);
|
|
422
|
-
},
|
|
423
|
-
async startImport(indexName, source, options) {
|
|
424
|
-
const spec = importBody(indexName, source, true, options);
|
|
425
|
-
return readBody(await transport.json(spec), spec.path);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// src/client/documents.ts
|
|
431
|
-
function createDocumentOperations(transport) {
|
|
432
|
-
return {
|
|
433
|
-
async insert(indexName, document, docId, insertOptions, options) {
|
|
434
|
-
const path = `${indexPath(indexName)}/documents`;
|
|
435
|
-
const payload = await transport.json({
|
|
436
|
-
method: "POST",
|
|
437
|
-
path,
|
|
438
|
-
body: encodeJson({
|
|
439
|
-
document,
|
|
440
|
-
...docId === void 0 ? {} : { id: docId },
|
|
441
|
-
...insertOptions === void 0 ? {} : { options: insertOptions }
|
|
442
|
-
}),
|
|
443
|
-
contentType: "application/json",
|
|
444
|
-
options
|
|
445
|
-
});
|
|
446
|
-
return readString(payload, "id", path);
|
|
447
|
-
},
|
|
448
|
-
async get(indexName, docId, options) {
|
|
449
|
-
const path = documentPath(indexName, docId);
|
|
450
|
-
const payload = await transport.jsonOrNull({ method: "GET", path, options }, ErrorCodes.DOC_NOT_FOUND);
|
|
451
|
-
if (payload === null) return void 0;
|
|
452
|
-
return readObject(payload, "document", path);
|
|
453
|
-
},
|
|
454
|
-
async has(indexName, docId, options) {
|
|
455
|
-
const path = `${documentPath(indexName, docId)}/_exists`;
|
|
456
|
-
return readBoolean(await transport.json({ method: "GET", path, options }), "exists", path);
|
|
457
|
-
},
|
|
458
|
-
async put(indexName, docId, document, writeOptions, options) {
|
|
459
|
-
const path = documentPath(indexName, docId);
|
|
460
|
-
const payload = await transport.json({
|
|
461
|
-
method: "PUT",
|
|
462
|
-
path,
|
|
463
|
-
body: encodeJson({ document, ...writeOptions === void 0 ? {} : { options: writeOptions } }),
|
|
464
|
-
contentType: "application/json",
|
|
465
|
-
options
|
|
466
|
-
});
|
|
467
|
-
return { id: readString(payload, "id", path), created: readBoolean(payload, "created", path) };
|
|
468
|
-
},
|
|
469
|
-
async update(indexName, docId, document, writeOptions, options) {
|
|
470
|
-
await transport.json({
|
|
471
|
-
method: "PATCH",
|
|
472
|
-
path: documentPath(indexName, docId),
|
|
473
|
-
body: encodeJson({ document, ...writeOptions === void 0 ? {} : { options: writeOptions } }),
|
|
474
|
-
contentType: "application/json",
|
|
475
|
-
options
|
|
476
|
-
});
|
|
477
|
-
},
|
|
478
|
-
async remove(indexName, docId, writeOptions, options) {
|
|
479
|
-
await transport.json({
|
|
480
|
-
method: "DELETE",
|
|
481
|
-
path: documentPath(indexName, docId),
|
|
482
|
-
...writeOptions?.wait === true ? { query: { wait: "true" } } : {},
|
|
483
|
-
options
|
|
484
|
-
});
|
|
485
|
-
},
|
|
486
|
-
async waitForWrites(indexName, options) {
|
|
487
|
-
await transport.json({ method: "POST", path: `${indexPath(indexName)}/_wait-for-writes`, options });
|
|
488
|
-
},
|
|
489
|
-
async countDocuments(indexName, options) {
|
|
490
|
-
const path = `${indexPath(indexName)}/count`;
|
|
491
|
-
return readNumber(await transport.json({ method: "GET", path, options }), "count", path);
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// src/client/http.ts
|
|
497
|
-
function isRecord2(value) {
|
|
498
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
499
|
-
}
|
|
500
|
-
function unrefTimer(timer) {
|
|
501
|
-
const unrefable = timer;
|
|
502
|
-
unrefable.unref?.();
|
|
503
|
-
}
|
|
504
|
-
function startDeadline(timeoutMs, caller) {
|
|
505
|
-
const controller = new AbortController();
|
|
506
|
-
let expired = false;
|
|
507
|
-
const abortWithCaller = () => controller.abort();
|
|
508
|
-
if (caller?.aborted) controller.abort();
|
|
509
|
-
else caller?.addEventListener("abort", abortWithCaller);
|
|
510
|
-
let timer;
|
|
511
|
-
if (timeoutMs > 0 && !controller.signal.aborted) {
|
|
512
|
-
timer = setTimeout(() => {
|
|
513
|
-
expired = true;
|
|
514
|
-
controller.abort();
|
|
515
|
-
}, timeoutMs);
|
|
516
|
-
unrefTimer(timer);
|
|
517
|
-
}
|
|
518
|
-
return {
|
|
519
|
-
signal: controller.signal,
|
|
520
|
-
expired: () => expired,
|
|
521
|
-
release: () => {
|
|
522
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
523
|
-
caller?.removeEventListener("abort", abortWithCaller);
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
var ResponseTooLargeError = class extends Error {
|
|
528
|
-
constructor(limitBytes) {
|
|
529
|
-
super(`The answer passed the ${limitBytes} byte ceiling this client reads`);
|
|
530
|
-
this.limitBytes = limitBytes;
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
async function readStreamCapped(stream, limitBytes) {
|
|
534
|
-
const reader = stream.getReader();
|
|
535
|
-
const chunks = [];
|
|
536
|
-
let total = 0;
|
|
537
|
-
try {
|
|
538
|
-
for (; ; ) {
|
|
539
|
-
const { done, value } = await reader.read();
|
|
540
|
-
if (done) break;
|
|
541
|
-
total += value.byteLength;
|
|
542
|
-
if (total > limitBytes) throw new ResponseTooLargeError(limitBytes);
|
|
543
|
-
chunks.push(value);
|
|
544
|
-
}
|
|
545
|
-
} finally {
|
|
546
|
-
reader.releaseLock();
|
|
547
|
-
if (total > limitBytes) await stream.cancel().catch(() => void 0);
|
|
548
|
-
}
|
|
549
|
-
const body = new Uint8Array(total);
|
|
550
|
-
let offset = 0;
|
|
551
|
-
for (const chunk of chunks) {
|
|
552
|
-
body.set(chunk, offset);
|
|
553
|
-
offset += chunk.byteLength;
|
|
554
|
-
}
|
|
555
|
-
return body;
|
|
556
|
-
}
|
|
557
|
-
async function readAnswer(response, limitBytes) {
|
|
558
|
-
const stream = response.body;
|
|
559
|
-
if (limitBytes > 0 && stream !== null && stream !== void 0) {
|
|
560
|
-
return new TextDecoder().decode(await readStreamCapped(stream, limitBytes));
|
|
561
|
-
}
|
|
562
|
-
const text = await response.text();
|
|
563
|
-
if (limitBytes > 0 && text.length > limitBytes) throw new ResponseTooLargeError(limitBytes);
|
|
564
|
-
return text;
|
|
565
|
-
}
|
|
566
|
-
function invalidResponse(message, details) {
|
|
567
|
-
return new NarsilError(ClientErrorCodes.CLIENT_INVALID_RESPONSE, message, details);
|
|
568
|
-
}
|
|
569
|
-
function errorFromBody(status, payload, url) {
|
|
570
|
-
const envelope = isRecord2(payload) && isRecord2(payload.error) ? payload.error : void 0;
|
|
571
|
-
if (envelope === void 0 || typeof envelope.code !== "string" || typeof envelope.message !== "string") {
|
|
572
|
-
return invalidResponse(`The server answered HTTP ${status} without a Narsil error envelope`, { url, status });
|
|
573
|
-
}
|
|
574
|
-
const details = isRecord2(envelope.details) ? envelope.details : {};
|
|
575
|
-
return new NarsilError(envelope.code, envelope.message, { ...details, status });
|
|
576
|
-
}
|
|
577
|
-
function isHttpUrl(value) {
|
|
578
|
-
try {
|
|
579
|
-
const parsed = new URL(value);
|
|
580
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
581
|
-
} catch {
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
function normaliseBase(url) {
|
|
586
|
-
const trimmed = url.trim();
|
|
587
|
-
if (trimmed.length === 0) {
|
|
588
|
-
throw new NarsilError(ErrorCodes.CONFIG_INVALID, 'The client needs a server address, and "url" is empty');
|
|
589
|
-
}
|
|
590
|
-
if (!trimmed.startsWith("/") && !isHttpUrl(trimmed)) {
|
|
591
|
-
throw new NarsilError(
|
|
592
|
-
ErrorCodes.CONFIG_INVALID,
|
|
593
|
-
`The client cannot read "${trimmed}" as a server address; pass an http or https URL, or a path starting with "/" that a browser resolves against the page`,
|
|
594
|
-
{ url: trimmed }
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
return trimmed.replace(/\/+$/, "");
|
|
598
|
-
}
|
|
599
|
-
function withQuery(path, query) {
|
|
600
|
-
if (query === void 0) return path;
|
|
601
|
-
const params = new URLSearchParams();
|
|
602
|
-
for (const [key, value] of Object.entries(query)) {
|
|
603
|
-
if (value !== void 0) params.set(key, value);
|
|
604
|
-
}
|
|
605
|
-
const encoded = params.toString();
|
|
606
|
-
return encoded.length === 0 ? path : `${path}?${encoded}`;
|
|
607
|
-
}
|
|
608
|
-
function createTransport(options) {
|
|
609
|
-
const base = normaliseBase(options.url);
|
|
610
|
-
const send = options.fetch ?? ((input, init) => fetch(input, init));
|
|
611
|
-
const baseHeaders = { ...options.headers };
|
|
612
|
-
if (options.apiKey !== void 0 && options.apiKey.length > 0) {
|
|
613
|
-
baseHeaders.authorization = `Bearer ${options.apiKey}`;
|
|
614
|
-
}
|
|
615
|
-
function resolveTimeout(spec) {
|
|
616
|
-
const perCall = spec.options?.timeoutMs;
|
|
617
|
-
if (perCall !== void 0) return perCall;
|
|
618
|
-
if (options.timeoutMs !== void 0) return options.timeoutMs;
|
|
619
|
-
return spec.defaultTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
620
|
-
}
|
|
621
|
-
function resolveResponseCeiling(spec) {
|
|
622
|
-
const perCall = spec.options?.maxResponseBytes;
|
|
623
|
-
if (perCall !== void 0) return perCall;
|
|
624
|
-
return options.maxResponseBytes ?? 0;
|
|
625
|
-
}
|
|
626
|
-
async function exchange(spec, keepsStream = false) {
|
|
627
|
-
const url = `${base}${withQuery(spec.path, spec.query)}`;
|
|
628
|
-
const headers = { ...baseHeaders, ...spec.options?.headers };
|
|
629
|
-
if (spec.contentType !== void 0) headers["content-type"] = spec.contentType;
|
|
630
|
-
const timeoutMs = resolveTimeout(spec);
|
|
631
|
-
const deadline = startDeadline(timeoutMs, spec.options?.signal);
|
|
632
|
-
let handedOver = false;
|
|
633
|
-
try {
|
|
634
|
-
const init = { method: spec.method, headers, signal: deadline.signal };
|
|
635
|
-
if (spec.body !== void 0) init.body = spec.body;
|
|
636
|
-
if (spec.body instanceof ReadableStream) init.duplex = "half";
|
|
637
|
-
const response = await send(url, init);
|
|
638
|
-
if (keepsStream && response.ok && response.body !== null) {
|
|
639
|
-
handedOver = true;
|
|
640
|
-
const stream = response.body.pipeThrough(
|
|
641
|
-
new TransformStream({ flush: () => deadline.release() })
|
|
642
|
-
);
|
|
643
|
-
return { status: response.status, url, text: "", stream };
|
|
644
|
-
}
|
|
645
|
-
const text = await readAnswer(response, resolveResponseCeiling(spec));
|
|
646
|
-
return { status: response.status, url, stream: null, text };
|
|
647
|
-
} catch (err) {
|
|
648
|
-
if (err instanceof ResponseTooLargeError) {
|
|
649
|
-
throw invalidResponse(`The server at ${url} answered more than this client reads: ${err.message}`, {
|
|
650
|
-
url,
|
|
651
|
-
maxResponseBytes: err.limitBytes
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
if (deadline.expired()) {
|
|
655
|
-
throw new NarsilError(
|
|
656
|
-
ClientErrorCodes.CLIENT_REQUEST_TIMEOUT,
|
|
657
|
-
`The server at ${url} did not answer within ${timeoutMs} ms`,
|
|
658
|
-
{ url, timeoutMs }
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
if (spec.options?.signal?.aborted === true) {
|
|
662
|
-
throw new NarsilError(ClientErrorCodes.CLIENT_REQUEST_ABORTED, `The caller cancelled the request to ${url}`, {
|
|
663
|
-
url
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
throw new NarsilError(
|
|
667
|
-
ClientErrorCodes.CLIENT_CONNECTION_FAILED,
|
|
668
|
-
`The client could not reach ${url}: ${describeError(err)}`,
|
|
669
|
-
{ url }
|
|
670
|
-
);
|
|
671
|
-
} finally {
|
|
672
|
-
if (!handedOver) deadline.release();
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function parse(status, text, path) {
|
|
676
|
-
if (text.length === 0) return void 0;
|
|
677
|
-
try {
|
|
678
|
-
return JSON.parse(text);
|
|
679
|
-
} catch {
|
|
680
|
-
throw invalidResponse(`The server answered HTTP ${status} with a body that is not JSON`, { url: path, status });
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
async function json(spec) {
|
|
684
|
-
const { status, text, url } = await exchange(spec);
|
|
685
|
-
const payload = parse(status, text, url);
|
|
686
|
-
if (status >= 200 && status < 300) return payload;
|
|
687
|
-
throw errorFromBody(status, payload, url);
|
|
688
|
-
}
|
|
689
|
-
return {
|
|
690
|
-
json,
|
|
691
|
-
async jsonOrNull(spec, absentCode) {
|
|
692
|
-
try {
|
|
693
|
-
return await json(spec);
|
|
694
|
-
} catch (err) {
|
|
695
|
-
if (err instanceof NarsilError && err.code === absentCode) return null;
|
|
696
|
-
throw err;
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
async stream(spec) {
|
|
700
|
-
const { status, text, stream, url } = await exchange(spec, true);
|
|
701
|
-
if (stream !== null) return stream;
|
|
702
|
-
throw errorFromBody(status, parse(status, text, url), url);
|
|
703
|
-
},
|
|
704
|
-
async probe(spec) {
|
|
705
|
-
const { status } = await exchange(spec);
|
|
706
|
-
return status;
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// src/client/indexes.ts
|
|
712
|
-
function createIndexOperations(transport) {
|
|
713
|
-
return {
|
|
714
|
-
async createIndex(name, config, options) {
|
|
715
|
-
await transport.json({
|
|
716
|
-
method: "POST",
|
|
717
|
-
path: "/indexes",
|
|
718
|
-
body: encodeJson({ name, config }),
|
|
719
|
-
contentType: "application/json",
|
|
720
|
-
options
|
|
721
|
-
});
|
|
722
|
-
},
|
|
723
|
-
async listIndexes(options) {
|
|
724
|
-
const path = "/indexes";
|
|
725
|
-
return readArray(await transport.json({ method: "GET", path, options }), "indexes", path);
|
|
726
|
-
},
|
|
727
|
-
async dropIndex(name, options) {
|
|
728
|
-
await transport.json({ method: "DELETE", path: indexPath(name), options });
|
|
729
|
-
},
|
|
730
|
-
async getStats(indexName, options) {
|
|
731
|
-
const path = `${indexPath(indexName)}/stats`;
|
|
732
|
-
return readBody(await transport.json({ method: "GET", path, options }), path);
|
|
733
|
-
},
|
|
734
|
-
async getPartitionStats(indexName, options) {
|
|
735
|
-
const path = `${indexPath(indexName)}/partitions`;
|
|
736
|
-
const payload = await transport.json({ method: "GET", path, options });
|
|
737
|
-
return readArray(payload, "partitions", path);
|
|
738
|
-
},
|
|
739
|
-
async clear(indexName, options) {
|
|
740
|
-
await transport.json({ method: "POST", path: `${indexPath(indexName)}/_clear`, options });
|
|
741
|
-
},
|
|
742
|
-
async open(indexName, options) {
|
|
743
|
-
await transport.json({ method: "POST", path: `${indexPath(indexName)}/_open`, options });
|
|
744
|
-
},
|
|
745
|
-
async close(indexName, options) {
|
|
746
|
-
await transport.json({ method: "POST", path: `${indexPath(indexName)}/_close`, options });
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// src/client/search.ts
|
|
752
|
-
function createSearchOperations(transport) {
|
|
753
|
-
async function post(path, params, options) {
|
|
754
|
-
const payload = await transport.json({
|
|
755
|
-
method: "POST",
|
|
756
|
-
path,
|
|
757
|
-
body: encodeJson(params),
|
|
758
|
-
contentType: "application/json",
|
|
759
|
-
options
|
|
760
|
-
});
|
|
761
|
-
return readBody(payload, path);
|
|
762
|
-
}
|
|
763
|
-
return {
|
|
764
|
-
query(indexName, params, options) {
|
|
765
|
-
return post(`${indexPath(indexName)}/search`, params, options);
|
|
766
|
-
},
|
|
767
|
-
preflight(indexName, params, options) {
|
|
768
|
-
return post(`${indexPath(indexName)}/search/preflight`, params, options);
|
|
769
|
-
},
|
|
770
|
-
suggest(indexName, params, options) {
|
|
771
|
-
return post(`${indexPath(indexName)}/suggest`, params, options);
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// src/client/server-info.ts
|
|
777
|
-
function createServerOperations(transport) {
|
|
778
|
-
let announced = null;
|
|
779
|
-
async function readCapabilities(options) {
|
|
780
|
-
const path = "/capabilities";
|
|
781
|
-
const payload = await transport.jsonOrNull({ method: "GET", path, options }, ServerErrorCodes.NOT_FOUND);
|
|
782
|
-
if (payload === null) return /* @__PURE__ */ new Set();
|
|
783
|
-
return new Set(readArray(payload, "capabilities", path));
|
|
784
|
-
}
|
|
785
|
-
function load(options) {
|
|
786
|
-
if (announced === null) {
|
|
787
|
-
announced = readCapabilities(options).catch((err) => {
|
|
788
|
-
announced = null;
|
|
789
|
-
throw err;
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
return announced;
|
|
793
|
-
}
|
|
794
|
-
return {
|
|
795
|
-
async version(options) {
|
|
796
|
-
const path = "/version";
|
|
797
|
-
return readBody(await transport.json({ method: "GET", path, options }), path);
|
|
798
|
-
},
|
|
799
|
-
async capabilities(options) {
|
|
800
|
-
return [...await load(options)];
|
|
801
|
-
},
|
|
802
|
-
async supports(capability, options) {
|
|
803
|
-
return (await load(options)).has(capability);
|
|
804
|
-
},
|
|
805
|
-
async isAlive(options) {
|
|
806
|
-
return await transport.probe({ method: "GET", path: "/livez", options }) === 200;
|
|
807
|
-
},
|
|
808
|
-
async isReady(options) {
|
|
809
|
-
return await transport.probe({ method: "GET", path: "/readyz", options }) === 200;
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
// src/client/tasks.ts
|
|
815
|
-
function isTerminal(record) {
|
|
816
|
-
return record.status === "succeeded" || record.status === "failed" || record.status === "cancelled";
|
|
817
|
-
}
|
|
818
|
-
function progressKey(record) {
|
|
819
|
-
const progress = record.progress;
|
|
820
|
-
if (progress === void 0) return record.status;
|
|
821
|
-
return `${record.status}:${progress.bytesProcessed}:${progress.indexed}:${progress.failed}`;
|
|
822
|
-
}
|
|
823
|
-
function sleep(milliseconds, signal) {
|
|
824
|
-
return new Promise((resolve) => {
|
|
825
|
-
const timer = setTimeout(() => {
|
|
826
|
-
signal?.removeEventListener("abort", stop);
|
|
827
|
-
resolve();
|
|
828
|
-
}, milliseconds);
|
|
829
|
-
function stop() {
|
|
830
|
-
clearTimeout(timer);
|
|
831
|
-
resolve();
|
|
832
|
-
}
|
|
833
|
-
signal?.addEventListener("abort", stop, { once: true });
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
function listQuery(query) {
|
|
837
|
-
return {
|
|
838
|
-
indexName: query?.indexName,
|
|
839
|
-
type: query?.type === void 0 || query.type.length === 0 ? void 0 : query.type.join(","),
|
|
840
|
-
status: query?.status === void 0 || query.status.length === 0 ? void 0 : query.status.join(","),
|
|
841
|
-
from: query?.from === void 0 ? void 0 : String(query.from),
|
|
842
|
-
limit: query?.limit === void 0 ? void 0 : String(query.limit)
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
function createTaskOperations(transport) {
|
|
846
|
-
const operations = {
|
|
847
|
-
async getTask(taskId, options) {
|
|
848
|
-
const path = taskPath(taskId);
|
|
849
|
-
const payload = await transport.jsonOrNull({ method: "GET", path, options }, ServerErrorCodes.TASK_NOT_FOUND);
|
|
850
|
-
return payload === null ? null : readBody(payload, path);
|
|
851
|
-
},
|
|
852
|
-
async listTasks(query, options) {
|
|
853
|
-
const path = "/tasks";
|
|
854
|
-
const payload = await transport.json({ method: "GET", path, query: listQuery(query), options });
|
|
855
|
-
return readBody(payload, path);
|
|
856
|
-
},
|
|
857
|
-
async cancelTask(taskId, options) {
|
|
858
|
-
const path = `${taskPath(taskId)}/_cancel`;
|
|
859
|
-
return readBody(await transport.json({ method: "POST", path, options }), path);
|
|
860
|
-
},
|
|
861
|
-
async waitForTask(taskId, options) {
|
|
862
|
-
const interval = options?.pollIntervalMs ?? DEFAULT_TASK_POLL_INTERVAL_MS;
|
|
863
|
-
const waitTimeoutMs = options?.waitTimeoutMs ?? 0;
|
|
864
|
-
const startedAt = Date.now();
|
|
865
|
-
let reported = null;
|
|
866
|
-
for (; ; ) {
|
|
867
|
-
if (options?.signal?.aborted === true) {
|
|
868
|
-
throw new NarsilError(
|
|
869
|
-
ClientErrorCodes.CLIENT_REQUEST_ABORTED,
|
|
870
|
-
`The caller stopped waiting for task "${taskId}"`,
|
|
871
|
-
{ taskId }
|
|
872
|
-
);
|
|
873
|
-
}
|
|
874
|
-
const record = await operations.getTask(taskId, options);
|
|
875
|
-
if (record === null) {
|
|
876
|
-
throw new NarsilError(
|
|
877
|
-
ServerErrorCodes.TASK_NOT_FOUND,
|
|
878
|
-
`The server no longer holds task "${taskId}", so its outcome is unknown`,
|
|
879
|
-
{ taskId }
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
const key = progressKey(record);
|
|
883
|
-
if (key !== reported) {
|
|
884
|
-
reported = key;
|
|
885
|
-
options?.onProgress?.(record);
|
|
886
|
-
}
|
|
887
|
-
if (isTerminal(record)) return record;
|
|
888
|
-
if (waitTimeoutMs > 0 && Date.now() - startedAt >= waitTimeoutMs) {
|
|
889
|
-
throw new NarsilError(
|
|
890
|
-
ClientErrorCodes.CLIENT_TASK_TIMEOUT,
|
|
891
|
-
`Task "${taskId}" was still ${record.status} after ${waitTimeoutMs} ms, and it keeps running`,
|
|
892
|
-
{ taskId, waitTimeoutMs, status: record.status }
|
|
893
|
-
);
|
|
894
|
-
}
|
|
895
|
-
await sleep(interval, options?.signal);
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
return operations;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
// src/client/client.ts
|
|
903
|
-
function createNarsilClient(options) {
|
|
904
|
-
const transport = createTransport(options);
|
|
905
|
-
return {
|
|
906
|
-
...createIndexOperations(transport),
|
|
907
|
-
...createDocumentOperations(transport),
|
|
908
|
-
...createBulkOperations(transport),
|
|
909
|
-
...createSearchOperations(transport),
|
|
910
|
-
...createTaskOperations(transport),
|
|
911
|
-
...createAdminOperations(transport),
|
|
912
|
-
...createServerOperations(transport)
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
export { ASYNC_IMPORT_CAPABILITY, ClientErrorCodes, DOCUMENT_EXPORT_CAPABILITY, ErrorCodes, INDEX_LIFECYCLE_CAPABILITY, NarsilError, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, SYNONYMS_CAPABILITY, ServerErrorCodes, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, createNarsilClient, isNarsilError };
|
|
26
|
+
export { ASYNC_IMPORT_CAPABILITY, BM25_TUNING_CAPABILITY, CHANGE_ANALYSIS_CAPABILITY, DOCUMENT_EXPORT_CAPABILITY, INDEX_LIFECYCLE_CAPABILITY, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, SYNONYMS_CAPABILITY, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY };
|