@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
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
import { MAX_SEGMENT_ID, MANIFEST_ENVELOPE_VERSION, EARLIER_SEGMENT_MANIFEST_VERSION, SEGMENT_MANIFEST_VERSION, MAX_SEGMENTS_PER_PARTITION, segmentKey, manifestFileRefs, graphPartKey, vectorFileKey } from './chunk-C4ZMXXTL.mjs';
|
|
2
|
+
import { VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-R724DJSG.mjs';
|
|
3
|
+
import { openChecksummedEnvelope, HEADER_SIZE, QUERY_HISTORY_ARCHIVE_PREFIX, MAX_HISTORY_FILE_BYTES } from './chunk-TKKXPKEO.mjs';
|
|
4
|
+
import { decode } from './chunk-GXCDWLQI.mjs';
|
|
5
|
+
import { requireValidFieldTypes } from './chunk-7P5YWDRQ.mjs';
|
|
6
|
+
import { MAX_FILE_BYTES } from './chunk-4PY4JYMY.mjs';
|
|
7
|
+
import { NarsilError, ErrorCodes } from './chunk-ZKOQR7EA.mjs';
|
|
8
|
+
|
|
9
|
+
// src/persistence/durability/segment/manifest-fields.ts
|
|
10
|
+
function invalidManifest(message, details) {
|
|
11
|
+
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, `Segment manifest ${message}`, details);
|
|
12
|
+
}
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Uint8Array);
|
|
15
|
+
}
|
|
16
|
+
function isId(value) {
|
|
17
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= MAX_SEGMENT_ID;
|
|
18
|
+
}
|
|
19
|
+
function isUint32(value) {
|
|
20
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 4294967295;
|
|
21
|
+
}
|
|
22
|
+
function isSequenceNumber(value) {
|
|
23
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
24
|
+
}
|
|
25
|
+
function readFileRef(raw, expectedKey, what) {
|
|
26
|
+
if (raw.key !== expectedKey) {
|
|
27
|
+
invalidManifest(`lists the ${what} under the key "${String(raw.key)}" where it belongs at "${expectedKey}"`, {
|
|
28
|
+
key: raw.key,
|
|
29
|
+
expected: expectedKey
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const bytes = raw.bytes;
|
|
33
|
+
if (typeof bytes !== "number" || !Number.isInteger(bytes) || bytes < HEADER_SIZE || bytes > MAX_FILE_BYTES) {
|
|
34
|
+
invalidManifest(`gives the ${what} "${expectedKey}" an invalid length`, { key: expectedKey, bytes });
|
|
35
|
+
}
|
|
36
|
+
if (!isUint32(raw.checksum)) invalidManifest(`gives the ${what} "${expectedKey}" an invalid checksum`);
|
|
37
|
+
if (raw.headOffset === void 0) return { key: expectedKey, bytes, checksum: raw.checksum };
|
|
38
|
+
const { headOffset, headLength, headChecksum } = raw;
|
|
39
|
+
if (!isSequenceNumber(headOffset) || !isUint32(headLength) || !isUint32(headChecksum)) {
|
|
40
|
+
invalidManifest(`gives the ${what} "${expectedKey}" an invalid head`, { key: expectedKey });
|
|
41
|
+
}
|
|
42
|
+
if (headOffset + headLength > bytes - HEADER_SIZE) {
|
|
43
|
+
invalidManifest(`ends the head of the ${what} "${expectedKey}" outside its payload`, {
|
|
44
|
+
key: expectedKey,
|
|
45
|
+
headOffset,
|
|
46
|
+
headLength,
|
|
47
|
+
bytes
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return { key: expectedKey, bytes, checksum: raw.checksum, headOffset, headLength, headChecksum };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/persistence/durability/segment/manifest-vectors-decode.ts
|
|
54
|
+
function normalizeFile(raw, indexName, fieldPath, nextFileId, seenIds) {
|
|
55
|
+
if (!isRecord(raw) || !isId(raw.id)) invalidManifest("has an invalid vector file reference", { fieldPath });
|
|
56
|
+
if (raw.id >= nextFileId || seenIds.has(raw.id)) {
|
|
57
|
+
invalidManifest(`lists vector file ${raw.id} of "${fieldPath}" twice or at its next file id`, { fieldPath });
|
|
58
|
+
}
|
|
59
|
+
seenIds.add(raw.id);
|
|
60
|
+
const count = raw.count;
|
|
61
|
+
if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > VECTOR_FILE_MAX_VECTORS) {
|
|
62
|
+
invalidManifest(`gives vector file ${raw.id} of "${fieldPath}" an invalid count`, { fieldPath, count });
|
|
63
|
+
}
|
|
64
|
+
const dead = raw.dead ?? null;
|
|
65
|
+
if (dead !== null && !(dead instanceof Uint8Array)) invalidManifest("has dead vectors that are not bytes");
|
|
66
|
+
if (dead !== null && dead.byteLength !== deadBytesFor(count)) {
|
|
67
|
+
invalidManifest(`marks the dead vectors of file ${raw.id} of "${fieldPath}" with the wrong number of bytes`);
|
|
68
|
+
}
|
|
69
|
+
const ref = readFileRef(raw, vectorFileKey(indexName, fieldPath, raw.id), "vector file");
|
|
70
|
+
return { ...ref, id: raw.id, count, dead };
|
|
71
|
+
}
|
|
72
|
+
function normalizeGraphParts(raw, indexName, fieldPath, generation) {
|
|
73
|
+
if (!Array.isArray(raw)) invalidManifest(`gives "${fieldPath}" no list of graph parts`, { fieldPath });
|
|
74
|
+
if (raw.length > 0 && generation === 0) invalidManifest(`lists graph parts of "${fieldPath}" at generation 0`);
|
|
75
|
+
return raw.map((part, at) => {
|
|
76
|
+
if (!isRecord(part)) invalidManifest(`has an invalid graph part of "${fieldPath}"`, { fieldPath });
|
|
77
|
+
return readFileRef(part, graphPartKey(indexName, fieldPath, generation, at), "graph part");
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function normalizeField(raw, indexName, seenFields) {
|
|
81
|
+
if (!isRecord(raw) || typeof raw.fieldPath !== "string") invalidManifest("has an invalid vector reference");
|
|
82
|
+
const fieldPath = raw.fieldPath;
|
|
83
|
+
if (seenFields.has(fieldPath)) invalidManifest(`lists the vector field "${fieldPath}" twice`, { fieldPath });
|
|
84
|
+
seenFields.add(fieldPath);
|
|
85
|
+
if (!isId(raw.nextFileId)) invalidManifest(`gives "${fieldPath}" an invalid next file id`, { fieldPath });
|
|
86
|
+
if (!Array.isArray(raw.files)) invalidManifest(`gives "${fieldPath}" no list of vector files`, { fieldPath });
|
|
87
|
+
if (!isId(raw.graphGeneration)) invalidManifest(`gives "${fieldPath}" an invalid graph generation`, { fieldPath });
|
|
88
|
+
const nextFileId = raw.nextFileId;
|
|
89
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
90
|
+
return {
|
|
91
|
+
fieldPath,
|
|
92
|
+
nextFileId,
|
|
93
|
+
files: raw.files.map((file) => normalizeFile(file, indexName, fieldPath, nextFileId, seenIds)),
|
|
94
|
+
graphGeneration: raw.graphGeneration,
|
|
95
|
+
graphParts: normalizeGraphParts(raw.graphParts, indexName, fieldPath, raw.graphGeneration)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function normalizeVectorFields(raw, indexName) {
|
|
99
|
+
if (!Array.isArray(raw)) invalidManifest("has malformed vector references");
|
|
100
|
+
const seenFields = /* @__PURE__ */ new Set();
|
|
101
|
+
return raw.map((field) => normalizeField(field, indexName, seenFields));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/persistence/durability/segment/manifest-decode.ts
|
|
105
|
+
async function openManifestPayload(data) {
|
|
106
|
+
const { payload } = await openChecksummedEnvelope(data, {
|
|
107
|
+
envelopeFormatVersion: MANIFEST_ENVELOPE_VERSION,
|
|
108
|
+
what: "segment manifest",
|
|
109
|
+
allowsCompression: true
|
|
110
|
+
});
|
|
111
|
+
const raw = decode(payload);
|
|
112
|
+
if (!isRecord(raw)) invalidManifest("is not a map");
|
|
113
|
+
return raw;
|
|
114
|
+
}
|
|
115
|
+
function listedKeysOf(raw) {
|
|
116
|
+
const keys = [];
|
|
117
|
+
for (const partition of Array.isArray(raw.partitions) ? raw.partitions : []) {
|
|
118
|
+
if (!isRecord(partition) || !Array.isArray(partition.segments)) continue;
|
|
119
|
+
for (const segment of partition.segments)
|
|
120
|
+
if (isRecord(segment) && typeof segment.key === "string") keys.push(segment.key);
|
|
121
|
+
}
|
|
122
|
+
for (const field of Array.isArray(raw.vectors) ? raw.vectors : []) {
|
|
123
|
+
if (!isRecord(field)) continue;
|
|
124
|
+
for (const list of [field.files, field.graphParts]) {
|
|
125
|
+
if (!Array.isArray(list)) continue;
|
|
126
|
+
for (const file of list) if (isRecord(file) && typeof file.key === "string") keys.push(file.key);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return keys;
|
|
130
|
+
}
|
|
131
|
+
async function decodeSegmentManifest(data, indexName, partitionId = null) {
|
|
132
|
+
return decodeManifestPayload(await openManifestPayload(data), indexName, partitionId);
|
|
133
|
+
}
|
|
134
|
+
function decodeManifestPayload(raw, indexName, partitionId = null) {
|
|
135
|
+
if (raw.version === EARLIER_SEGMENT_MANIFEST_VERSION) return { kind: "earlier", payload: raw };
|
|
136
|
+
if (raw.version !== SEGMENT_MANIFEST_VERSION) {
|
|
137
|
+
throw new NarsilError(
|
|
138
|
+
ErrorCodes.ENVELOPE_VERSION_MISMATCH,
|
|
139
|
+
`The segment manifest of index "${indexName}" holds layout ${String(raw.version)}, which this release cannot open. Export the index with the release that wrote it and import the export`,
|
|
140
|
+
{ indexName, version: raw.version }
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
const schema = raw.schema;
|
|
144
|
+
if (!isRecord(schema)) invalidManifest("is missing its schema");
|
|
145
|
+
requireValidFieldTypes(schema);
|
|
146
|
+
if (typeof raw.language !== "string") invalidManifest("is missing its language");
|
|
147
|
+
if (raw.analysisGeneration !== void 0 && !isSequenceNumber(raw.analysisGeneration)) {
|
|
148
|
+
invalidManifest("has an invalid analysis generation");
|
|
149
|
+
}
|
|
150
|
+
const checkpoint = normalizeCheckpoint(raw.checkpoint);
|
|
151
|
+
const partitions = normalizePartitions(raw.partitions, indexName);
|
|
152
|
+
if (checkpoint.length === 0 || (partitionId === null ? checkpoint.some((entry, index) => entry.partitionId !== index) : checkpoint.length !== 1 || checkpoint[0].partitionId !== partitionId) || partitions.length !== checkpoint.length || partitions.some(
|
|
153
|
+
(entry) => partitionId === null ? entry.partitionId >= checkpoint.length : entry.partitionId !== partitionId
|
|
154
|
+
)) {
|
|
155
|
+
invalidManifest("has an incomplete partition layout");
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
kind: "current",
|
|
159
|
+
manifest: {
|
|
160
|
+
version: SEGMENT_MANIFEST_VERSION,
|
|
161
|
+
schema,
|
|
162
|
+
language: raw.language,
|
|
163
|
+
...raw.analysisGeneration ? { analysisGeneration: raw.analysisGeneration } : {},
|
|
164
|
+
checkpoint,
|
|
165
|
+
partitions,
|
|
166
|
+
vectors: normalizeVectorFields(raw.vectors, indexName)
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function normalizeCheckpoint(raw) {
|
|
171
|
+
if (!Array.isArray(raw)) invalidManifest("is missing its checkpoint list");
|
|
172
|
+
const seen = /* @__PURE__ */ new Set();
|
|
173
|
+
return raw.map((entry) => {
|
|
174
|
+
if (!isRecord(entry) || !isUint32(entry.partitionId) || !isSequenceNumber(entry.lastSeqNo) || !isSequenceNumber(entry.primaryTerm) || seen.has(entry.partitionId)) {
|
|
175
|
+
invalidManifest("has an invalid partition checkpoint", { entry });
|
|
176
|
+
}
|
|
177
|
+
seen.add(entry.partitionId);
|
|
178
|
+
const checkpoint = {
|
|
179
|
+
partitionId: entry.partitionId,
|
|
180
|
+
lastSeqNo: entry.lastSeqNo,
|
|
181
|
+
primaryTerm: entry.primaryTerm
|
|
182
|
+
};
|
|
183
|
+
if (entry.termHistory !== void 0) {
|
|
184
|
+
checkpoint.termHistory = normalizeTermHistory(entry.termHistory, entry.partitionId, entry.lastSeqNo);
|
|
185
|
+
}
|
|
186
|
+
return checkpoint;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function normalizeTermHistory(raw, partitionId, lastSeqNo) {
|
|
190
|
+
if (!Array.isArray(raw)) invalidManifest("has a term history that is not a list", { partitionId });
|
|
191
|
+
let previous = null;
|
|
192
|
+
return raw.map((start) => {
|
|
193
|
+
if (!isRecord(start) || !isSequenceNumber(start.primaryTerm) || !isSequenceNumber(start.firstSeqNo)) {
|
|
194
|
+
invalidManifest("has an invalid term history entry", { partitionId });
|
|
195
|
+
}
|
|
196
|
+
const read = { primaryTerm: start.primaryTerm, firstSeqNo: start.firstSeqNo };
|
|
197
|
+
if (read.firstSeqNo > lastSeqNo) {
|
|
198
|
+
invalidManifest(`has a term starting at seqNo ${read.firstSeqNo}, above lastSeqNo ${lastSeqNo}`, { partitionId });
|
|
199
|
+
}
|
|
200
|
+
if (previous !== null && (read.primaryTerm <= previous.primaryTerm || read.firstSeqNo <= previous.firstSeqNo)) {
|
|
201
|
+
invalidManifest("has a term history that fails to ascend strictly", { partitionId });
|
|
202
|
+
}
|
|
203
|
+
previous = read;
|
|
204
|
+
return read;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function normalizePartitions(raw, indexName) {
|
|
208
|
+
if (!Array.isArray(raw)) invalidManifest("is missing partition entries");
|
|
209
|
+
const seen = /* @__PURE__ */ new Set();
|
|
210
|
+
return raw.map((entry) => {
|
|
211
|
+
if (!isRecord(entry) || !isUint32(entry.partitionId) || seen.has(entry.partitionId)) {
|
|
212
|
+
invalidManifest("has a partition without a valid id", { partitionId: isRecord(entry) ? entry.partitionId : null });
|
|
213
|
+
}
|
|
214
|
+
seen.add(entry.partitionId);
|
|
215
|
+
const segments = normalizeSegments(entry.segments, indexName, entry.partitionId);
|
|
216
|
+
return {
|
|
217
|
+
partitionId: entry.partitionId,
|
|
218
|
+
nextSegmentId: readNextSegmentId(entry.nextSegmentId, segments, entry.partitionId),
|
|
219
|
+
segments
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function normalizeSegments(raw, indexName, partitionId) {
|
|
224
|
+
if (!Array.isArray(raw)) invalidManifest("has malformed segment references", { partitionId });
|
|
225
|
+
if (raw.length > MAX_SEGMENTS_PER_PARTITION) {
|
|
226
|
+
invalidManifest(`lists ${raw.length} segments for partition ${partitionId}, above ${MAX_SEGMENTS_PER_PARTITION}`);
|
|
227
|
+
}
|
|
228
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
229
|
+
return raw.map((segment) => {
|
|
230
|
+
if (!isRecord(segment) || !isId(segment.id) || !isUint32(segment.docCount) || !isUint32(segment.tombstoneCount)) {
|
|
231
|
+
invalidManifest("has an invalid segment reference", { partitionId });
|
|
232
|
+
}
|
|
233
|
+
if (seenIds.has(segment.id)) invalidManifest(`reuses segment id ${segment.id} in partition ${partitionId}`);
|
|
234
|
+
seenIds.add(segment.id);
|
|
235
|
+
const ref = readFileRef(segment, segmentKey(indexName, partitionId, segment.id), "segment");
|
|
236
|
+
return { ...ref, id: segment.id, docCount: segment.docCount, tombstoneCount: segment.tombstoneCount };
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function readNextSegmentId(value, segments, partitionId) {
|
|
240
|
+
if (!isId(value)) invalidManifest("has an invalid next segment id", { partitionId });
|
|
241
|
+
for (const segment of segments) {
|
|
242
|
+
if (segment.id >= value) {
|
|
243
|
+
invalidManifest(`next segment id ${value} does not exceed segment id ${segment.id}`, { partitionId });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/persistence/archive/constants.ts
|
|
250
|
+
var MAX_PAX_HEADER_BYTES = 65536;
|
|
251
|
+
var ARCHIVE_FILE_CHUNK_BYTES = 4194304;
|
|
252
|
+
var ARCHIVE_ENTRY_ESTIMATE_BYTES = 1536;
|
|
253
|
+
|
|
254
|
+
// src/persistence/archive/tar.ts
|
|
255
|
+
var TAR_BLOCK_BYTES = 512;
|
|
256
|
+
var NAME_OFFSET = 0;
|
|
257
|
+
var NAME_BYTES = 100;
|
|
258
|
+
var MODE_OFFSET = 100;
|
|
259
|
+
var OWNER_OFFSET = 108;
|
|
260
|
+
var GROUP_OFFSET = 116;
|
|
261
|
+
var ID_FIELD_BYTES = 8;
|
|
262
|
+
var SIZE_OFFSET = 124;
|
|
263
|
+
var SIZE_FIELD_BYTES = 12;
|
|
264
|
+
var SIZE_FIELD_DIGITS = 11;
|
|
265
|
+
var MTIME_OFFSET = 136;
|
|
266
|
+
var MTIME_FIELD_BYTES = 12;
|
|
267
|
+
var CHECKSUM_FIELD_OFFSET = 148;
|
|
268
|
+
var CHECKSUM_FIELD_BYTES = 8;
|
|
269
|
+
var CHECKSUM_DIGITS = 6;
|
|
270
|
+
var TYPEFLAG_OFFSET = 156;
|
|
271
|
+
var MAGIC_OFFSET = 257;
|
|
272
|
+
var MAGIC_BYTES = 6;
|
|
273
|
+
var VERSION_OFFSET = 263;
|
|
274
|
+
var VERSION_BYTES = 2;
|
|
275
|
+
var PREFIX_OFFSET = 345;
|
|
276
|
+
var PREFIX_BYTES = 155;
|
|
277
|
+
var MODE_OCTAL = "0000644";
|
|
278
|
+
var ZERO_OCTAL_7 = "0000000";
|
|
279
|
+
var ZERO_OCTAL_11 = "00000000000";
|
|
280
|
+
var REGULAR_FILE = 48;
|
|
281
|
+
var OLD_REGULAR_FILE = 0;
|
|
282
|
+
var PAX_EXTENDED_HEADER = 120;
|
|
283
|
+
var PAX_HEADER_NAME = "PaxHeader";
|
|
284
|
+
var encoder = new TextEncoder();
|
|
285
|
+
var decoder = new TextDecoder("utf-8", { fatal: true });
|
|
286
|
+
function writeString(block, offset, length, value) {
|
|
287
|
+
const bytes = encoder.encode(value);
|
|
288
|
+
block.set(bytes.subarray(0, length), offset);
|
|
289
|
+
}
|
|
290
|
+
function writeOctal(block, offset, digits, value) {
|
|
291
|
+
writeString(block, offset, digits, value.toString(8).padStart(digits, "0"));
|
|
292
|
+
}
|
|
293
|
+
function headerChecksum(block) {
|
|
294
|
+
let sum = 0;
|
|
295
|
+
const checksumEnd = CHECKSUM_FIELD_OFFSET + CHECKSUM_FIELD_BYTES;
|
|
296
|
+
for (let at = 0; at < TAR_BLOCK_BYTES; at++) {
|
|
297
|
+
sum += at >= CHECKSUM_FIELD_OFFSET && at < checksumEnd ? 32 : block[at];
|
|
298
|
+
}
|
|
299
|
+
return sum;
|
|
300
|
+
}
|
|
301
|
+
function ustarBlock(name, prefix, size, typeflag) {
|
|
302
|
+
const block = new Uint8Array(TAR_BLOCK_BYTES);
|
|
303
|
+
writeString(block, NAME_OFFSET, NAME_BYTES, name);
|
|
304
|
+
writeString(block, MODE_OFFSET, ID_FIELD_BYTES, MODE_OCTAL);
|
|
305
|
+
writeString(block, OWNER_OFFSET, ID_FIELD_BYTES, ZERO_OCTAL_7);
|
|
306
|
+
writeString(block, GROUP_OFFSET, ID_FIELD_BYTES, ZERO_OCTAL_7);
|
|
307
|
+
writeOctal(block, SIZE_OFFSET, SIZE_FIELD_DIGITS, size);
|
|
308
|
+
writeString(block, MTIME_OFFSET, MTIME_FIELD_BYTES, ZERO_OCTAL_11);
|
|
309
|
+
block[TYPEFLAG_OFFSET] = typeflag;
|
|
310
|
+
writeString(block, MAGIC_OFFSET, MAGIC_BYTES, "ustar");
|
|
311
|
+
writeString(block, VERSION_OFFSET, VERSION_BYTES, "00");
|
|
312
|
+
writeString(block, PREFIX_OFFSET, PREFIX_BYTES, prefix);
|
|
313
|
+
const checksum = headerChecksum(block);
|
|
314
|
+
writeString(block, CHECKSUM_FIELD_OFFSET, CHECKSUM_DIGITS, checksum.toString(8).padStart(CHECKSUM_DIGITS, "0"));
|
|
315
|
+
block[CHECKSUM_FIELD_OFFSET + CHECKSUM_DIGITS] = 0;
|
|
316
|
+
block[CHECKSUM_FIELD_OFFSET + CHECKSUM_DIGITS + 1] = 32;
|
|
317
|
+
return block;
|
|
318
|
+
}
|
|
319
|
+
function splitForUstar(name) {
|
|
320
|
+
if (encoder.encode(name).byteLength <= NAME_BYTES) return { name, prefix: "" };
|
|
321
|
+
for (let slash = name.indexOf("/"); slash >= 0; slash = name.indexOf("/", slash + 1)) {
|
|
322
|
+
const prefix = name.slice(0, slash);
|
|
323
|
+
const rest = name.slice(slash + 1);
|
|
324
|
+
if (encoder.encode(prefix).byteLength <= PREFIX_BYTES && encoder.encode(rest).byteLength <= NAME_BYTES) {
|
|
325
|
+
return { name: rest, prefix };
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
function paxRecord(key, value) {
|
|
331
|
+
const body = ` ${key}=${value}
|
|
332
|
+
`;
|
|
333
|
+
const bodyBytes = encoder.encode(body).byteLength;
|
|
334
|
+
let digits = 1;
|
|
335
|
+
while (String(bodyBytes + digits).length !== digits) digits += 1;
|
|
336
|
+
return `${bodyBytes + digits}${body}`;
|
|
337
|
+
}
|
|
338
|
+
function tarPadding(size) {
|
|
339
|
+
const remainder = size % TAR_BLOCK_BYTES;
|
|
340
|
+
return new Uint8Array(remainder === 0 ? 0 : TAR_BLOCK_BYTES - remainder);
|
|
341
|
+
}
|
|
342
|
+
function tarEntryHeaders(name, size) {
|
|
343
|
+
const split = splitForUstar(name);
|
|
344
|
+
if (split !== null) return [ustarBlock(split.name, split.prefix, size, REGULAR_FILE)];
|
|
345
|
+
const record = encoder.encode(paxRecord("path", name));
|
|
346
|
+
return [
|
|
347
|
+
ustarBlock(PAX_HEADER_NAME, "", record.byteLength, PAX_EXTENDED_HEADER),
|
|
348
|
+
record,
|
|
349
|
+
tarPadding(record.byteLength),
|
|
350
|
+
ustarBlock(name.slice(-NAME_BYTES).replace(/^[^/]*\//, ""), "", size, REGULAR_FILE)
|
|
351
|
+
];
|
|
352
|
+
}
|
|
353
|
+
function tarEnd() {
|
|
354
|
+
return new Uint8Array(TAR_BLOCK_BYTES * 2);
|
|
355
|
+
}
|
|
356
|
+
function invalidArchive(message, details) {
|
|
357
|
+
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, `Invalid snapshot archive: ${message}`, details);
|
|
358
|
+
}
|
|
359
|
+
function readString(block, offset, length) {
|
|
360
|
+
let end = offset;
|
|
361
|
+
while (end < offset + length && block[end] !== 0) end++;
|
|
362
|
+
try {
|
|
363
|
+
return decoder.decode(block.subarray(offset, end));
|
|
364
|
+
} catch {
|
|
365
|
+
invalidArchive("an entry header holds a name that is not UTF-8");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function readOctal(block, offset, length, what) {
|
|
369
|
+
const text = readString(block, offset, length).trim();
|
|
370
|
+
if (!/^[0-7]+$/.test(text)) invalidArchive(`an entry header holds an invalid ${what}`);
|
|
371
|
+
const value = Number.parseInt(text, 8);
|
|
372
|
+
if (!Number.isSafeInteger(value)) invalidArchive(`an entry header holds an invalid ${what}`);
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
function isZeroBlock(block) {
|
|
376
|
+
for (let at = 0; at < block.length; at++) if (block[at] !== 0) return false;
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
function parseTarHeader(block) {
|
|
380
|
+
if (readOctal(block, CHECKSUM_FIELD_OFFSET, CHECKSUM_FIELD_BYTES, "checksum") !== headerChecksum(block)) {
|
|
381
|
+
invalidArchive("an entry header fails its checksum");
|
|
382
|
+
}
|
|
383
|
+
const typeflag = block[TYPEFLAG_OFFSET];
|
|
384
|
+
if (typeflag !== REGULAR_FILE && typeflag !== OLD_REGULAR_FILE && typeflag !== PAX_EXTENDED_HEADER) {
|
|
385
|
+
invalidArchive(`an entry has type ${String.fromCharCode(typeflag)}, while an archive holds regular files alone`);
|
|
386
|
+
}
|
|
387
|
+
const name = readString(block, NAME_OFFSET, NAME_BYTES);
|
|
388
|
+
const prefix = readString(block, PREFIX_OFFSET, PREFIX_BYTES);
|
|
389
|
+
return {
|
|
390
|
+
name: prefix.length > 0 ? `${prefix}/${name}` : name,
|
|
391
|
+
size: readOctal(block, SIZE_OFFSET, SIZE_FIELD_BYTES, "size"),
|
|
392
|
+
isPaxHeader: typeflag === PAX_EXTENDED_HEADER
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
var SPACE = 32;
|
|
396
|
+
var EQUALS = 61;
|
|
397
|
+
var NEWLINE = 10;
|
|
398
|
+
function decodeRecordText(bytes) {
|
|
399
|
+
try {
|
|
400
|
+
return decoder.decode(bytes);
|
|
401
|
+
} catch {
|
|
402
|
+
invalidArchive("a pax extended header is not UTF-8");
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function parsePaxRecords(body) {
|
|
406
|
+
const records = /* @__PURE__ */ new Map();
|
|
407
|
+
let at = 0;
|
|
408
|
+
while (at < body.length) {
|
|
409
|
+
const space = body.indexOf(SPACE, at);
|
|
410
|
+
if (space < 0) invalidArchive("a pax extended header holds a malformed record");
|
|
411
|
+
const length = Number.parseInt(decodeRecordText(body.subarray(at, space)), 10);
|
|
412
|
+
if (!Number.isSafeInteger(length) || length <= space - at || at + length > body.length) {
|
|
413
|
+
invalidArchive("a pax extended header holds a malformed record");
|
|
414
|
+
}
|
|
415
|
+
const record = body.subarray(space + 1, at + length);
|
|
416
|
+
const equals = record.indexOf(EQUALS);
|
|
417
|
+
if (equals < 0 || record[record.length - 1] !== NEWLINE) {
|
|
418
|
+
invalidArchive("a pax extended header holds a record without a value");
|
|
419
|
+
}
|
|
420
|
+
records.set(decodeRecordText(record.subarray(0, equals)), decodeRecordText(record.subarray(equals + 1, -1)));
|
|
421
|
+
at += length;
|
|
422
|
+
}
|
|
423
|
+
return records;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/persistence/archive/read.ts
|
|
427
|
+
var ARCHIVE_CONFIG_ENTRY = "config";
|
|
428
|
+
var ARCHIVE_MANIFEST_ENTRY = "manifest";
|
|
429
|
+
var SEGMENTS_MARKER = "/segments/";
|
|
430
|
+
var CHECKSUM_OFFSET = 14;
|
|
431
|
+
async function readBlock(reader) {
|
|
432
|
+
const block = await reader.readExactly(TAR_BLOCK_BYTES);
|
|
433
|
+
if (block === null) return null;
|
|
434
|
+
if (block.byteLength < TAR_BLOCK_BYTES) invalidArchive("the archive ends inside an entry header");
|
|
435
|
+
return block;
|
|
436
|
+
}
|
|
437
|
+
async function skipPadding(reader, size) {
|
|
438
|
+
const remainder = size % TAR_BLOCK_BYTES;
|
|
439
|
+
if (remainder === 0) return;
|
|
440
|
+
const padding = await reader.readExactly(TAR_BLOCK_BYTES - remainder);
|
|
441
|
+
if (padding === null || padding.byteLength < TAR_BLOCK_BYTES - remainder) {
|
|
442
|
+
invalidArchive("the archive ends inside the padding of an entry");
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async function readPadded(reader, size) {
|
|
446
|
+
const body = await reader.readExactly(size) ?? new Uint8Array(0);
|
|
447
|
+
if (body.byteLength < size) invalidArchive("the archive ends inside an entry");
|
|
448
|
+
await skipPadding(reader, size);
|
|
449
|
+
return body;
|
|
450
|
+
}
|
|
451
|
+
function entryBody(reader, size) {
|
|
452
|
+
let remaining = size;
|
|
453
|
+
async function* chunks() {
|
|
454
|
+
while (remaining > 0) {
|
|
455
|
+
const length = Math.min(ARCHIVE_FILE_CHUNK_BYTES, remaining);
|
|
456
|
+
const chunk = await reader.readExactly(length);
|
|
457
|
+
if (chunk === null || chunk.byteLength < length) invalidArchive("the archive ends inside an entry");
|
|
458
|
+
remaining -= length;
|
|
459
|
+
yield chunk;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return chunks();
|
|
463
|
+
}
|
|
464
|
+
async function nextEntryHeader(reader) {
|
|
465
|
+
const block = await readBlock(reader);
|
|
466
|
+
if (block === null || isZeroBlock(block)) return null;
|
|
467
|
+
const header = parseTarHeader(block);
|
|
468
|
+
if (!header.isPaxHeader) return { name: header.name, size: header.size };
|
|
469
|
+
if (header.size > MAX_PAX_HEADER_BYTES) invalidArchive("a pax extended header is too long");
|
|
470
|
+
const records = parsePaxRecords(await readPadded(reader, header.size));
|
|
471
|
+
const next = await readBlock(reader);
|
|
472
|
+
if (next === null || isZeroBlock(next)) invalidArchive("a pax extended header precedes no entry");
|
|
473
|
+
const entry = parseTarHeader(next);
|
|
474
|
+
if (entry.isPaxHeader) invalidArchive("a pax extended header follows another");
|
|
475
|
+
const path = records.get("path");
|
|
476
|
+
const size = records.get("size");
|
|
477
|
+
const parsedSize = size === void 0 ? entry.size : Number.parseInt(size, 10);
|
|
478
|
+
if (!Number.isSafeInteger(parsedSize) || parsedSize < 0) invalidArchive("a pax extended header holds an invalid size");
|
|
479
|
+
return { name: path ?? entry.name, size: parsedSize };
|
|
480
|
+
}
|
|
481
|
+
async function readNamedEntry(reader, expected) {
|
|
482
|
+
const header = await nextEntryHeader(reader);
|
|
483
|
+
if (header === null) invalidArchive(`the archive ends before its ${expected} entry`);
|
|
484
|
+
if (header.name !== expected) invalidArchive(`the archive holds "${header.name}" where its ${expected} entry belongs`);
|
|
485
|
+
if (header.size > MAX_FILE_BYTES) invalidArchive(`the ${expected} entry passes the file size limit`);
|
|
486
|
+
return readPadded(reader, header.size);
|
|
487
|
+
}
|
|
488
|
+
function sourceIndexNameOf(keys) {
|
|
489
|
+
const first = keys[0];
|
|
490
|
+
if (first === void 0) return "archive";
|
|
491
|
+
const at = first.indexOf(SEGMENTS_MARKER);
|
|
492
|
+
if (at <= 0) invalidArchive(`the manifest lists the key "${first}" outside any index`);
|
|
493
|
+
return first.slice(0, at);
|
|
494
|
+
}
|
|
495
|
+
function headerChecksumOf(bytes) {
|
|
496
|
+
if (bytes.byteLength < HEADER_SIZE) return -1;
|
|
497
|
+
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(CHECKSUM_OFFSET, false);
|
|
498
|
+
}
|
|
499
|
+
async function readSnapshotArchive(reader, handlers) {
|
|
500
|
+
await handlers.config(await readNamedEntry(reader, ARCHIVE_CONFIG_ENTRY));
|
|
501
|
+
const raw = await openManifestPayload(await readNamedEntry(reader, ARCHIVE_MANIFEST_ENTRY));
|
|
502
|
+
const sourceIndexName = sourceIndexNameOf(listedKeysOf(raw));
|
|
503
|
+
const decoded = decodeManifestPayload(raw, sourceIndexName, handlers.partitionId);
|
|
504
|
+
if (decoded.kind !== "current") invalidArchive("the manifest holds the layout of an earlier release");
|
|
505
|
+
const manifest = decoded.manifest;
|
|
506
|
+
await handlers.manifest(manifest, sourceIndexName);
|
|
507
|
+
const files = manifestFileRefs(manifest);
|
|
508
|
+
const prefix = `${sourceIndexName}/`;
|
|
509
|
+
const listedNames = new Set(files.map((file) => file.key.slice(prefix.length)));
|
|
510
|
+
const seen = /* @__PURE__ */ new Set();
|
|
511
|
+
for (const ref of files) {
|
|
512
|
+
const expected = ref.key.slice(prefix.length);
|
|
513
|
+
const header = await nextEntryHeader(reader);
|
|
514
|
+
if (header === null) invalidArchive(`the archive ends before it holds "${expected}"`);
|
|
515
|
+
if (header.name !== expected) {
|
|
516
|
+
const why = !listedNames.has(header.name) ? "that the manifest does not list" : seen.has(header.name) ? "twice" : "out of order";
|
|
517
|
+
invalidArchive(`the archive holds the entry "${header.name}" ${why}`, { entry: header.name });
|
|
518
|
+
}
|
|
519
|
+
if (header.size !== ref.bytes) {
|
|
520
|
+
invalidArchive(`the entry "${expected}" holds ${header.size} bytes where the manifest lists ${ref.bytes}`);
|
|
521
|
+
}
|
|
522
|
+
const start = await reader.peek(Math.min(HEADER_SIZE, header.size));
|
|
523
|
+
if (headerChecksumOf(start) !== ref.checksum) {
|
|
524
|
+
invalidArchive(`the entry "${expected}" carries a checksum other than the manifest lists`, { entry: expected });
|
|
525
|
+
}
|
|
526
|
+
seen.add(expected);
|
|
527
|
+
const entry = entryBody(reader, header.size);
|
|
528
|
+
await handlers.file(expected, ref, entry);
|
|
529
|
+
let unread = await entry.next();
|
|
530
|
+
while (unread.done !== true) unread = await entry.next();
|
|
531
|
+
await skipPadding(reader, header.size);
|
|
532
|
+
}
|
|
533
|
+
await readHistoryEntries(reader, handlers);
|
|
534
|
+
}
|
|
535
|
+
async function readHistoryEntries(reader, handlers) {
|
|
536
|
+
for (let position = 0; ; position++) {
|
|
537
|
+
const header = await nextEntryHeader(reader);
|
|
538
|
+
if (header === null) return;
|
|
539
|
+
if (header.name !== `${QUERY_HISTORY_ARCHIVE_PREFIX}${position}`) {
|
|
540
|
+
invalidArchive(`the archive holds the entry "${header.name}" that the manifest does not list`, {
|
|
541
|
+
entry: header.name
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
if (header.size > MAX_HISTORY_FILE_BYTES) {
|
|
545
|
+
invalidArchive(`the entry "${header.name}" passes the history file limit of ${MAX_HISTORY_FILE_BYTES} bytes`, {
|
|
546
|
+
entry: header.name
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
const entry = entryBody(reader, header.size);
|
|
550
|
+
await handlers.history?.(entry);
|
|
551
|
+
let unread = await entry.next();
|
|
552
|
+
while (unread.done !== true) unread = await entry.next();
|
|
553
|
+
await skipPadding(reader, header.size);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// src/sync/feed/constants.ts
|
|
558
|
+
var DEFAULT_FEED_WINDOW_BYTES = 8388608;
|
|
559
|
+
var ENTRIES_MESSAGE_LIMIT_BYTES = 1048576;
|
|
560
|
+
var DEFAULT_MAX_FEED_CONNECTIONS = 1e4;
|
|
561
|
+
var DEFAULT_MAX_FEED_CATCH_UPS = 32;
|
|
562
|
+
var DEFAULT_MAX_FEED_BUFFERED_BYTES = 268435456;
|
|
563
|
+
var FEED_HEAD_RETRY_MS = 200;
|
|
564
|
+
var TIMER_DELAY_LIMIT_MS = 2147483647;
|
|
565
|
+
var FEED_SOCKET_MAX_PAYLOAD_BYTES = 131072;
|
|
566
|
+
var FEED_SOCKET_MAX_BACKPRESSURE_BYTES = 1073741824;
|
|
567
|
+
|
|
568
|
+
// src/persistence/archive/range-layout.ts
|
|
569
|
+
function archiveLayout(config, manifestBytes, files) {
|
|
570
|
+
const parts = [];
|
|
571
|
+
let at = 0;
|
|
572
|
+
const inline = (bytes) => {
|
|
573
|
+
if (bytes.byteLength === 0) return;
|
|
574
|
+
parts.push({ start: at, length: bytes.byteLength, inline: bytes });
|
|
575
|
+
at += bytes.byteLength;
|
|
576
|
+
};
|
|
577
|
+
for (const [name, bytes] of [
|
|
578
|
+
[ARCHIVE_CONFIG_ENTRY, config],
|
|
579
|
+
[ARCHIVE_MANIFEST_ENTRY, manifestBytes]
|
|
580
|
+
]) {
|
|
581
|
+
for (const header of tarEntryHeaders(name, bytes.byteLength)) inline(header);
|
|
582
|
+
inline(bytes);
|
|
583
|
+
inline(tarPadding(bytes.byteLength));
|
|
584
|
+
}
|
|
585
|
+
for (const file of files) {
|
|
586
|
+
for (const header of tarEntryHeaders(file.name, file.bytes)) inline(header);
|
|
587
|
+
if (file.bytes > 0) {
|
|
588
|
+
parts.push({ start: at, length: file.bytes, file });
|
|
589
|
+
at += file.bytes;
|
|
590
|
+
}
|
|
591
|
+
inline(tarPadding(file.bytes));
|
|
592
|
+
}
|
|
593
|
+
inline(tarEnd());
|
|
594
|
+
return { parts, byteLength: at };
|
|
595
|
+
}
|
|
596
|
+
function estimatedArchiveBytes(files) {
|
|
597
|
+
let total = 0;
|
|
598
|
+
for (const file of files) total += file.bytes + ARCHIVE_ENTRY_ESTIMATE_BYTES;
|
|
599
|
+
return total;
|
|
600
|
+
}
|
|
601
|
+
function firstPartAt(parts, offset) {
|
|
602
|
+
let low = 0;
|
|
603
|
+
let high = parts.length - 1;
|
|
604
|
+
while (low < high) {
|
|
605
|
+
const middle = low + high + 1 >>> 1;
|
|
606
|
+
if (parts[middle].start <= offset) low = middle;
|
|
607
|
+
else high = middle - 1;
|
|
608
|
+
}
|
|
609
|
+
return low;
|
|
610
|
+
}
|
|
611
|
+
async function* archiveRange(layout, start, endExclusive) {
|
|
612
|
+
const end = Math.min(endExclusive, layout.byteLength);
|
|
613
|
+
if (start >= end) return;
|
|
614
|
+
for (let index = firstPartAt(layout.parts, start); index < layout.parts.length; index++) {
|
|
615
|
+
const part = layout.parts[index];
|
|
616
|
+
if (part.start >= end) return;
|
|
617
|
+
const from = Math.max(start, part.start) - part.start;
|
|
618
|
+
const to = Math.min(end, part.start + part.length) - part.start;
|
|
619
|
+
if ("inline" in part) {
|
|
620
|
+
yield part.inline.subarray(from, to);
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
for (let offset = from; offset < to; offset += ARCHIVE_FILE_CHUNK_BYTES) {
|
|
624
|
+
const length = Math.min(ARCHIVE_FILE_CHUNK_BYTES, to - offset);
|
|
625
|
+
const bytes = await part.file.read(offset, length);
|
|
626
|
+
if (bytes.byteLength !== length) {
|
|
627
|
+
throw new NarsilError(
|
|
628
|
+
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
629
|
+
`The archive file "${part.file.name}" ends before the bytes that its manifest lists`,
|
|
630
|
+
{ name: part.file.name, offset, length }
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
yield bytes;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
export { ARCHIVE_CONFIG_ENTRY, ARCHIVE_FILE_CHUNK_BYTES, ARCHIVE_MANIFEST_ENTRY, DEFAULT_FEED_WINDOW_BYTES, DEFAULT_MAX_FEED_BUFFERED_BYTES, DEFAULT_MAX_FEED_CATCH_UPS, DEFAULT_MAX_FEED_CONNECTIONS, ENTRIES_MESSAGE_LIMIT_BYTES, FEED_HEAD_RETRY_MS, FEED_SOCKET_MAX_BACKPRESSURE_BYTES, FEED_SOCKET_MAX_PAYLOAD_BYTES, TIMER_DELAY_LIMIT_MS, archiveLayout, archiveRange, decodeManifestPayload, decodeSegmentManifest, estimatedArchiveBytes, invalidManifest, isId, isRecord, isSequenceNumber, isUint32, listedKeysOf, openManifestPayload, readSnapshotArchive, sourceIndexNameOf, tarEnd, tarEntryHeaders, tarPadding };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/vector/hnsw/constants.ts
|
|
2
|
+
var MAX_LAYER_CAP = 32;
|
|
3
|
+
var MAX_M = 512;
|
|
4
|
+
var MIN_M = 2;
|
|
5
|
+
var EARLIER_RELEASE_MIN_M = 1;
|
|
6
|
+
var INITIAL_UPPER_SLOTS = 64;
|
|
7
|
+
var INITIAL_LIST_CAPACITY = 64;
|
|
8
|
+
var PLACEMENT_ROOM_REQUESTS = 8;
|
|
9
|
+
var FARTHEST_REJECTED_LINKS_KEPT = 1;
|
|
10
|
+
var COMPACTION_TOMBSTONE_RATIO = 0.1;
|
|
11
|
+
var COMPACTION_ABSOLUTE_THRESHOLD = 1e3;
|
|
12
|
+
var DEFAULT_EF_SEARCH = 50;
|
|
13
|
+
var NEAREST_LINK_FALLBACK_HOSTS = 4;
|
|
14
|
+
var CONNECT_STEPS_BETWEEN_CLOCK_CHECKS = 256;
|
|
15
|
+
var CONNECT_RESTARTS_BEFORE_ONE_PASS = 8;
|
|
16
|
+
|
|
17
|
+
export { COMPACTION_ABSOLUTE_THRESHOLD, COMPACTION_TOMBSTONE_RATIO, CONNECT_RESTARTS_BEFORE_ONE_PASS, CONNECT_STEPS_BETWEEN_CLOCK_CHECKS, DEFAULT_EF_SEARCH, EARLIER_RELEASE_MIN_M, FARTHEST_REJECTED_LINKS_KEPT, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, MAX_LAYER_CAP, MAX_M, MIN_M, NEAREST_LINK_FALLBACK_HOSTS, PLACEMENT_ROOM_REQUESTS };
|