@delali/narsil 0.3.1-next.144 → 0.3.1-next.146
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/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/analysis-change-ZCJNYBJM.mjs +39 -0
- package/dist/{browser/analysis-change-entry-7HR4LWL3.mjs → analysis-change-entry-YN3ELL6C.mjs} +1 -1
- package/dist/browser/{analysis-change-JPV775LR.mjs → analysis-change-M65AZQQG.mjs} +8 -5
- package/dist/{analysis-change-entry-TZTG4AZB.mjs → browser/analysis-change-entry-H3YIOLXZ.mjs} +1 -1
- package/dist/browser/{chunk-VFYMPCOV.mjs → chunk-2JABMB4S.mjs} +10 -6
- package/dist/{chunk-46NZOPHS.mjs → browser/chunk-4DYLCICG.mjs} +2 -2
- package/dist/browser/{chunk-MZI3TEOW.mjs → chunk-4RD3AFSB.mjs} +1 -1
- package/dist/browser/{chunk-WCFCHIBB.mjs → chunk-5V74FFZE.mjs} +2 -2
- package/dist/{chunk-NN33CZRE.mjs → browser/chunk-6OWX3OP2.mjs} +2 -2
- package/dist/browser/chunk-BRWY3JCN.mjs +678 -0
- package/dist/browser/{chunk-5DB2VDGI.mjs → chunk-BVX2MEHA.mjs} +306 -607
- package/dist/browser/{chunk-KTOK275N.mjs → chunk-D6UFGBF5.mjs} +15 -45
- package/dist/browser/{chunk-D33A5VMU.mjs → chunk-IAXZAVYL.mjs} +25 -66
- package/dist/browser/chunk-JNOAKDUM.mjs +31 -0
- package/dist/browser/{chunk-LVY2LI35.mjs → chunk-KAEVGLYN.mjs} +2 -2
- package/dist/browser/{chunk-3ZBJYAS4.mjs → chunk-LURXVCHG.mjs} +1 -1
- package/dist/browser/chunk-MPK76GVS.mjs +63 -0
- package/dist/browser/{chunk-ZEV26AQ6.mjs → chunk-NVEJJP4R.mjs} +1 -1
- package/dist/browser/{chunk-HKX2G6WH.mjs → chunk-ODQP7P3H.mjs} +455 -66
- package/dist/browser/{chunk-35B42UFM.mjs → chunk-PIS7ZAP7.mjs} +12 -25
- package/dist/browser/{chunk-TCLEOZ4P.mjs → chunk-QMNZFFD3.mjs} +4 -3
- package/dist/browser/{chunk-R4WUDZQV.mjs → chunk-SRL47USS.mjs} +2 -2
- package/dist/browser/chunk-TY7L6OXO.mjs +69 -0
- package/dist/browser/{chunk-MVM33ZUL.mjs → chunk-W643QV3L.mjs} +6 -5
- package/dist/browser/chunk-WXLBZJMT.mjs +25 -0
- package/dist/browser/{chunk-MWUK3DA5.mjs → chunk-XILIT5MT.mjs} +8 -8
- package/dist/browser/{cold-module-MJMKNUYJ.mjs → cold-module-A5S6JFDN.mjs} +20 -20
- package/dist/browser/{durability-wiring-SNOWIT6Z.mjs → durability-wiring-W5AVV3RF.mjs} +120 -80
- package/dist/browser/gzip-5S7ROJFJ.mjs +1 -0
- package/dist/browser/import-PTT63AGK.mjs +12 -0
- package/dist/browser/{module-BUFNZMEU.mjs → module-CEKA7MQH.mjs} +13 -10
- package/dist/browser/module-X5PGOE47.mjs +4288 -0
- package/dist/browser/{phrase-module-HGVBO24W.mjs → phrase-module-CNKMUY4U.mjs} +2 -1
- package/dist/browser/pool-DTYSPBMQ.mjs +296 -0
- package/dist/{restore-queue-FEYAC4SB.mjs → browser/restore-queue-DD4LWZK7.mjs} +2 -2
- package/dist/browser/{runtime-VEUH674B.mjs → runtime-D2ULZGCN.mjs} +3 -2
- package/dist/browser/{snapshot-QXBKHJAG.mjs → snapshot-DQ6A4PQP.mjs} +20 -15
- package/dist/browser/{write-WHFBDWQS.mjs → write-MAGRAIEH.mjs} +14 -11
- package/dist/{capabilities-BCdUwK_L.d.ts → capabilities-BT-HLDC8.d.ts} +3 -3
- package/dist/{chunk-O4LJQI4G.mjs → chunk-2HJWQPR6.mjs} +126 -4
- package/dist/{chunk-Z4HFMYNX.mjs → chunk-3BVGJ4JR.mjs} +36 -13
- package/dist/{chunk-ZPWS2SKJ.mjs → chunk-3HV7M5OJ.mjs} +272 -112
- package/dist/{chunk-UIKN2OTQ.mjs → chunk-3MXV3VHR.mjs} +2 -23
- package/dist/{browser/chunk-CCOAOO73.mjs → chunk-3SBJVQLL.mjs} +2 -2
- package/dist/chunk-3TVDTACC.mjs +104 -0
- package/dist/{chunk-YH5OIL7B.mjs → chunk-5QMHMELB.mjs} +6 -1
- package/dist/{chunk-SBMAWTRG.mjs → chunk-5WB2A3XU.mjs} +84 -15
- package/dist/{chunk-NPNK57CA.mjs → chunk-65WCV5JO.mjs} +1 -1
- package/dist/chunk-6BWLDLS3.mjs +58 -0
- package/dist/{chunk-UUZCQQG2.mjs → chunk-6C5EX2QR.mjs} +3 -3
- package/dist/{chunk-VEFN6X6Q.mjs → chunk-6F6USYII.mjs} +120 -13
- package/dist/{chunk-AST3SHFA.mjs → chunk-7HKWO4BJ.mjs} +7 -7
- package/dist/{chunk-W2COJ5AH.mjs → chunk-7N223GWV.mjs} +2 -2
- package/dist/{chunk-GWOS5DYC.mjs → chunk-ADBS5XRI.mjs} +11 -13
- package/dist/{chunk-TNBIK2LQ.mjs → chunk-AWNHDBKV.mjs} +430 -75
- package/dist/{chunk-ZMBFWQXN.mjs → chunk-B2FTZNNF.mjs} +2 -2
- package/dist/chunk-B7XIOAMK.mjs +100 -0
- package/dist/{chunk-W55X2BYN.mjs → chunk-BEZH7VEH.mjs} +1 -1
- package/dist/{chunk-QSK35UC2.mjs → chunk-BTPGQC6Z.mjs} +3 -11
- package/dist/{chunk-LA4WNDHL.mjs → chunk-CYYSZPVV.mjs} +12 -14
- package/dist/{chunk-SRJBFG2T.mjs → chunk-DOY6EG76.mjs} +6 -7
- package/dist/{chunk-6SNBQESJ.mjs → chunk-F22IOCR2.mjs} +10 -6
- package/dist/{chunk-J6YVB2XM.mjs → chunk-IJPK5PGM.mjs} +1 -1
- package/dist/{chunk-L76W3IZJ.mjs → chunk-IRWP524D.mjs} +1 -1
- package/dist/{chunk-XS2VM7UE.mjs → chunk-IZT3G24Q.mjs} +2 -2
- package/dist/{chunk-NOT5QOHU.mjs → chunk-J7M73VY7.mjs} +1 -1
- package/dist/chunk-K5HSUPYS.mjs +11 -0
- package/dist/chunk-KAKQ74LS.mjs +53 -0
- package/dist/{chunk-ZSWHPKGM.mjs → chunk-KYVRZAYP.mjs} +69 -2
- package/dist/{chunk-NRUXBYPH.mjs → chunk-KZ5GQE4Z.mjs} +5 -5
- package/dist/{browser/chunk-XNWPP5NS.mjs → chunk-KZQIVGW7.mjs} +2 -2
- package/dist/{chunk-KZL72VTC.mjs → chunk-L7TIAYPX.mjs} +11 -10
- package/dist/{chunk-DD2673TX.mjs → chunk-LDGGR7YT.mjs} +4 -81
- package/dist/{chunk-XZ3SRNDJ.mjs → chunk-LJ4ENXOD.mjs} +77 -16
- package/dist/chunk-LQG5G2LY.mjs +39 -0
- package/dist/{chunk-HNHCNTVG.mjs → chunk-MDF6PDIA.mjs} +11 -0
- package/dist/{chunk-74XB2SXI.mjs → chunk-NVTFQFUL.mjs} +16 -2
- package/dist/{chunk-BOJZGUS6.mjs → chunk-NYSONUB7.mjs} +1 -1
- package/dist/{chunk-WJGO5PGV.mjs → chunk-O4KUNDVF.mjs} +31 -17
- package/dist/{chunk-PWIWSUCX.mjs → chunk-POUYICOU.mjs} +1 -1
- package/dist/{chunk-EBIHRL7B.mjs → chunk-Q2UL2TPC.mjs} +1 -1
- package/dist/{chunk-NJJCPFXN.mjs → chunk-QEYF2SQ6.mjs} +2 -2
- package/dist/{chunk-7AUASRE7.mjs → chunk-QN5WVV5K.mjs} +7 -7
- package/dist/{chunk-RIIUZJQ3.mjs → chunk-QYRNLLLI.mjs} +1 -1
- package/dist/chunk-SOUZMPME.mjs +1635 -0
- package/dist/{chunk-C3YDYX6C.mjs → chunk-T4CJDBBE.mjs} +1 -1
- package/dist/{chunk-YLNSJQLX.mjs → chunk-TTCKT2RT.mjs} +5 -5
- package/dist/{chunk-KEIYVZUX.mjs → chunk-U2726TL5.mjs} +5 -5
- package/dist/{chunk-RKAVHNRW.mjs → chunk-U46IZNCW.mjs} +10 -5
- package/dist/{chunk-BRUUBXCB.mjs → chunk-U6NE6RCV.mjs} +10 -38
- package/dist/{chunk-VJEGOELZ.mjs → chunk-VP6XRMWR.mjs} +4 -4
- package/dist/{chunk-IO5F7ZBE.mjs → chunk-VQDZVWN3.mjs} +874 -413
- package/dist/{chunk-IWVEG5CX.mjs → chunk-XIHUI4KB.mjs} +2 -2
- package/dist/{chunk-YHUTF6EA.mjs → chunk-XKPNKR3V.mjs} +17 -47
- package/dist/{chunk-HJJWY6PT.mjs → chunk-YGQOPB2Z.mjs} +1 -1
- package/dist/chunk-YKEHQUSZ.mjs +248 -0
- package/dist/{chunk-GLZHNSGB.mjs → chunk-ZAYWOHVG.mjs} +1 -1
- package/dist/{chunk-ICW45TTU.mjs → chunk-ZEKDO7YX.mjs} +2 -2
- package/dist/chunk-ZXNNR73R.mjs +31 -0
- package/dist/{chunk-VJS4JFBQ.mjs → chunk-ZXX5GZEX.mjs} +3 -1
- package/dist/{chunk-RHKRTYGO.mjs → chunk-ZYKUD5NX.mjs} +9 -7
- package/dist/{client-B12YFALP.d.ts → client-Cn3gNxUU.d.ts} +62 -5
- package/dist/client.d.ts +8 -8
- package/dist/client.mjs +46 -0
- package/dist/{cold-module-4X7WJCFM.mjs → cold-module-2WWGBFJC.mjs} +43 -49
- package/dist/{config-CIG5yDyg.d.ts → config-CfhH1IWQ.d.ts} +150 -3
- package/dist/{config-BhZxIeb1.d.ts → config-aIsy7mcL.d.ts} +63 -3
- package/dist/direct-executor-QLVHMELJ.mjs +24 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/transport/grpc.mjs +4 -4
- package/dist/distribution/transport/in-memory.mjs +2 -2
- package/dist/distribution/transport/tcp.mjs +3 -3
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +16116 -14537
- package/dist/{durability-wiring-324D2DDD.mjs → durability-wiring-GNWQSZI3.mjs} +142 -109
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{engine-CtzbHOmG.d.ts → engine-CJRUHXgf.d.ts} +3 -3
- package/dist/gzip-F4HMIEEQ.mjs +1 -0
- package/dist/import-DX55PN4G.mjs +41 -0
- package/dist/{index-DsEurhSl.d.ts → index-MsF7e5hL.d.ts} +2 -2
- package/dist/index.browser.mjs +7 -4
- package/dist/index.d.ts +542 -8
- package/dist/index.mjs +29 -32
- package/dist/index.react-native.mjs +19 -0
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +1 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/{long-query-thread-4SW7RWDE.mjs → long-query-thread-SCUE62TO.mjs} +23 -25
- package/dist/{module-DXSJ5LT2.mjs → module-HW6IXUM6.mjs} +603 -112
- package/dist/module-V5K4ZP23.mjs +45 -0
- package/dist/{paged-partition-archive-HFP45PLU.mjs → paged-partition-archive-FDIIWZNR.mjs} +42 -41
- package/dist/partial-words.mjs +7 -9
- package/dist/pattern.mjs +4 -6
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +36 -39
- package/dist/{phrase-module-5QHBD2VJ.mjs → phrase-module-OUQIRUQU.mjs} +1 -1
- package/dist/pool-UPV5PVPY.mjs +298 -0
- package/dist/react-native/chunks/analysis-change-HGW3L6NY.mjs +893 -0
- package/dist/react-native/chunks/analysis-change-entry-BNRU6STO.mjs +1 -0
- package/dist/react-native/chunks/chunk-2J2727V4.mjs +495 -0
- package/dist/react-native/chunks/chunk-3CTWSQRW.mjs +1251 -0
- package/dist/react-native/chunks/chunk-5FV4ZEVA.mjs +2619 -0
- package/dist/react-native/chunks/chunk-7VWQLEFV.mjs +642 -0
- package/dist/react-native/chunks/chunk-AAAETEJK.mjs +27 -0
- package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +32 -0
- package/dist/react-native/chunks/chunk-B6OD63Z3.mjs +997 -0
- package/dist/react-native/chunks/chunk-BRNAVOKP.mjs +177 -0
- package/dist/react-native/chunks/chunk-DKJTZ625.mjs +207 -0
- package/dist/react-native/chunks/chunk-FKGG4UOF.mjs +177 -0
- package/dist/{browser/chunk-6RHTAVZX.mjs → react-native/chunks/chunk-GV5KFQ6M.mjs} +38 -15
- package/dist/react-native/chunks/chunk-HURV3ASY.mjs +4416 -0
- package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +10 -0
- package/dist/react-native/chunks/chunk-JV6VQY2S.mjs +17 -0
- package/dist/react-native/chunks/chunk-KUJOBRKS.mjs +217 -0
- package/dist/react-native/chunks/chunk-KWRW5U65.mjs +226 -0
- package/dist/react-native/chunks/chunk-L4M7QJNP.mjs +110 -0
- package/dist/react-native/chunks/chunk-LQ6Q4L5B.mjs +360 -0
- package/dist/react-native/chunks/chunk-LQAKO5QV.mjs +523 -0
- package/dist/react-native/chunks/chunk-LRGWK367.mjs +11 -0
- package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +93 -0
- package/dist/react-native/chunks/chunk-NFGBOI46.mjs +14 -0
- package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +8 -0
- package/dist/react-native/chunks/chunk-PPEPTUVV.mjs +56 -0
- package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +9 -0
- package/dist/{chunk-KGOXHLLZ.mjs → react-native/chunks/chunk-PU55IOG4.mjs} +228 -11
- package/dist/react-native/chunks/chunk-QC4ZRBSX.mjs +270 -0
- package/dist/react-native/chunks/chunk-R4EEMYM6.mjs +21 -0
- package/dist/react-native/chunks/chunk-R4OPUZQ5.mjs +86 -0
- package/dist/react-native/chunks/chunk-SLGIAD6B.mjs +2634 -0
- package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +25 -0
- package/dist/react-native/chunks/chunk-TLYD7IJ2.mjs +23 -0
- package/dist/react-native/chunks/chunk-UFNCLEQM.mjs +73 -0
- package/dist/react-native/chunks/chunk-YH7W556M.mjs +179 -0
- package/dist/react-native/chunks/chunk-YJSMEKRE.mjs +22385 -0
- package/dist/react-native/chunks/chunk-ZCKNBPQ4.mjs +79 -0
- package/dist/react-native/chunks/cold-module-TSFWLYWC.mjs +755 -0
- package/dist/react-native/chunks/durability-wiring-PZR6KOQK.mjs +4509 -0
- package/dist/react-native/chunks/gzip.react-native-7JWCLVOB.mjs +3 -0
- package/dist/react-native/chunks/import-VTODLPLO.mjs +22 -0
- package/dist/{browser/module-BVP4TKZU.mjs → react-native/chunks/module-JBBH6PZH.mjs} +671 -146
- package/dist/react-native/chunks/module-VEK2KCKU.mjs +25 -0
- package/dist/react-native/chunks/phrase-module-76UAPPSG.mjs +329 -0
- package/dist/react-native/chunks/pool-CD4ANYUI.mjs +296 -0
- package/dist/react-native/chunks/release-D7ZTIANM.mjs +33 -0
- package/dist/react-native/chunks/replace-IMZUVUOE.mjs +57 -0
- package/dist/{browser/restore-queue-ONYNYUDE.mjs → react-native/chunks/restore-queue-OI5EH7R3.mjs} +2 -2
- package/dist/react-native/chunks/runtime-3MCDLJAF.mjs +559 -0
- package/dist/react-native/chunks/snapshot-AUZMEV36.mjs +1205 -0
- package/dist/react-native/chunks/write-DDC2QBRJ.mjs +197 -0
- package/dist/{chunk-DQNKVOJ2.mjs → react-native/partial-words.mjs} +13 -228
- package/dist/react-native/pattern.mjs +2442 -0
- package/dist/react-native/synonyms.mjs +460 -0
- package/dist/react.d.ts +11 -11
- package/dist/react.mjs +11 -0
- package/dist/{rerank-KTLC3E6N.mjs → rerank-3W54N6P2.mjs} +4 -4
- package/dist/rerankers/http.d.ts +1 -1
- package/dist/rerankers/http.mjs +2 -2
- package/dist/restore-queue-BQWWNNQI.mjs +41 -0
- package/dist/{runtime-DYV75DCB.mjs → runtime-L2DZYY6N.mjs} +5 -5
- package/dist/{schema-B-Runv0n.d.ts → schema-D33CyXCy.d.ts} +1 -1
- package/dist/server.d.ts +24 -12
- package/dist/server.mjs +159 -38
- package/dist/{snapshot-CGM65VCD.mjs → snapshot-EHXTOTW5.mjs} +47 -50
- package/dist/synonyms.mjs +3 -4
- package/dist/{tasks-CjRJRGTb.d.ts → tasks-C4ElXr4P.d.ts} +59 -7
- package/dist/thread-I7DVHHW7.mjs +31 -0
- package/dist/vector/search-worker.d.ts +2 -2
- package/dist/vector/search-worker.mjs +8 -7
- package/dist/workers/entry.mjs +9 -9
- package/dist/{write-2DZPEQL2.mjs → write-SDJXXQ2G.mjs} +36 -39
- package/openapi.json +349 -2
- package/package.json +108 -8
- package/dist/analysis-change-HQUT2Z3I.mjs +0 -43
- package/dist/browser/import-TLB2A5LJ.mjs +0 -9
- package/dist/chunk-5WYVUPGD.mjs +0 -427
- package/dist/chunk-AV4IJKD2.mjs +0 -35
- package/dist/chunk-GES7U2PM.mjs +0 -68
- package/dist/chunk-N37VMC62.mjs +0 -18
- package/dist/chunk-WNBRW4Q2.mjs +0 -128
- package/dist/chunk-WQBCBKY3.mjs +0 -8
- package/dist/chunk-ZATRDAYU.mjs +0 -160
- package/dist/direct-executor-7XOQ7VQP.mjs +0 -28
- package/dist/import-OOBUW3RR.mjs +0 -44
- package/dist/module-IYPLWHGC.mjs +0 -48
- package/dist/thread-KGNAIKPD.mjs +0 -33
- /package/dist/{chunk-22YPZVMG.mjs → chunk-ZXNQEW43.mjs} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { MAX_DOCUMENT_ENCODING_DEPTH,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { compareCodePoints, holdsUnpairedSurrogate, exceedsCodePoints } from './chunk-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Encoder, encode } from '@msgpack/msgpack';
|
|
1
|
+
import { MAX_DOCUMENT_ENCODING_DEPTH, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES } from './chunk-TJMSKBEM.mjs';
|
|
2
|
+
import { DEFAULT_PATTERN_VALUE_LIMIT, isPlainObject, isWordIndexedBase, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, parseFieldType, MAX_DOCUMENT_BYTES, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS, MAX_DOCUMENT_NESTING_DEPTH, VECTOR_PATTERN } from './chunk-DKJTZ625.mjs';
|
|
3
|
+
import { visitTokens, visitSurfaceSpellings } from './chunk-2J2727V4.mjs';
|
|
4
|
+
import { compareCodePoints, holdsUnpairedSurrogate, exceedsCodePoints } from './chunk-PPEPTUVV.mjs';
|
|
5
|
+
import { NarsilError, ErrorCodes } from './chunk-YH7W556M.mjs';
|
|
6
|
+
import { Encoder } from '@msgpack/msgpack';
|
|
8
7
|
|
|
9
8
|
// src/schema/validator/schema.ts
|
|
10
9
|
function validateSchemaFields(schema, depth, prefix) {
|
|
@@ -565,9 +564,6 @@ function holdsNegativeZero(value, depth) {
|
|
|
565
564
|
}
|
|
566
565
|
return false;
|
|
567
566
|
}
|
|
568
|
-
function encodeDocumentReply(payload) {
|
|
569
|
-
return encode(payload, { forceIntegerToFloat: holdsNegativeZero(payload, 1 - DOCUMENT_REPLY_ENVELOPE_DEPTH) });
|
|
570
|
-
}
|
|
571
567
|
function encodeDocument(document) {
|
|
572
568
|
try {
|
|
573
569
|
return encodeExactly(document, holdsNegativeZero(document, 1));
|
|
@@ -690,4 +686,225 @@ function validateVectorPromotion(config) {
|
|
|
690
686
|
}
|
|
691
687
|
}
|
|
692
688
|
|
|
693
|
-
|
|
689
|
+
// src/core/partition/utils.ts
|
|
690
|
+
function getOrCreateFieldNameIndex(table, fieldName) {
|
|
691
|
+
const existing = table.indexMap.get(fieldName);
|
|
692
|
+
if (existing !== void 0) return existing;
|
|
693
|
+
const idx = table.names.length;
|
|
694
|
+
table.names.push(fieldName);
|
|
695
|
+
table.indexMap.set(fieldName, idx);
|
|
696
|
+
return idx;
|
|
697
|
+
}
|
|
698
|
+
var VECTOR_PATTERN2 = /^vector\[(\d+)]$/;
|
|
699
|
+
function getNestedValue(obj, path) {
|
|
700
|
+
const parts = path.split(".");
|
|
701
|
+
let current = obj;
|
|
702
|
+
for (let i = 0; i < parts.length; i++) {
|
|
703
|
+
if (current === null || current === void 0 || typeof current !== "object") return void 0;
|
|
704
|
+
if (!Object.hasOwn(current, parts[i])) return void 0;
|
|
705
|
+
current = current[parts[i]];
|
|
706
|
+
}
|
|
707
|
+
return current;
|
|
708
|
+
}
|
|
709
|
+
function stringArraysEqual(a, b) {
|
|
710
|
+
if (a === b) return true;
|
|
711
|
+
if (!a || !b) return false;
|
|
712
|
+
if (a.length !== b.length) return false;
|
|
713
|
+
for (let i = 0; i < a.length; i++) {
|
|
714
|
+
if (a[i] !== b[i]) return false;
|
|
715
|
+
}
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
function textFieldsChanged(oldDoc, newDoc, fields) {
|
|
719
|
+
for (const { path, base } of fields) {
|
|
720
|
+
if (!isWordIndexedBase(base)) continue;
|
|
721
|
+
const oldVal = getNestedValue(oldDoc, path);
|
|
722
|
+
const newVal = getNestedValue(newDoc, path);
|
|
723
|
+
if (base === "string") {
|
|
724
|
+
if (oldVal !== newVal) return true;
|
|
725
|
+
} else {
|
|
726
|
+
if (!stringArraysEqual(oldVal, newVal)) return true;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
function parseVectorDimension(fieldType) {
|
|
732
|
+
const match = VECTOR_PATTERN2.exec(fieldType);
|
|
733
|
+
return match ? Number.parseInt(match[1], 10) : null;
|
|
734
|
+
}
|
|
735
|
+
function tokenizeOptions(options) {
|
|
736
|
+
return {
|
|
737
|
+
stem: true,
|
|
738
|
+
removeStopWords: true,
|
|
739
|
+
collectSurfaces: options?.collectSurfaces === true,
|
|
740
|
+
stopWordOverride: options?.stopWordOverride,
|
|
741
|
+
customTokenizer: options?.customTokenizer
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function getFlatSchema(state, schema) {
|
|
745
|
+
if (state.lastSchemaRef === schema && state.flatSchemaCache) return state.flatSchemaCache;
|
|
746
|
+
state.flatSchemaCache = flattenSchema(schema);
|
|
747
|
+
state.lastSchemaRef = schema;
|
|
748
|
+
return state.flatSchemaCache;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// src/core/partition/partial-words/constants.ts
|
|
752
|
+
var PARTIAL_WORD_RUN_CODE_POINTS = 3;
|
|
753
|
+
var GROWING_PARTIAL_ENTRY_BYTES = 104;
|
|
754
|
+
var GROWING_PARTIAL_PENDING_ENTRY_BYTES = 8;
|
|
755
|
+
var GROWING_PARTIAL_PENDING_ENTRIES_PER_ENTRY = 2;
|
|
756
|
+
var GROWING_PARTIAL_RUN_BYTES = 120;
|
|
757
|
+
var GROWING_PARTIAL_RUN_MEMBER_BYTES = 24;
|
|
758
|
+
var FROZEN_PARTIAL_REMOVED_ENTRY_BYTES = 48;
|
|
759
|
+
|
|
760
|
+
// src/core/partition/partial-words/spellings.ts
|
|
761
|
+
var LAST_BASIC_PLANE_CODE_POINT = 65535;
|
|
762
|
+
function codePointCountOf(text) {
|
|
763
|
+
let count = 0;
|
|
764
|
+
for (let index = 0; index < text.length; count++) {
|
|
765
|
+
index += (text.codePointAt(index) ?? 0) > LAST_BASIC_PLANE_CODE_POINT ? 2 : 1;
|
|
766
|
+
}
|
|
767
|
+
return count;
|
|
768
|
+
}
|
|
769
|
+
function holdsRun(spelling) {
|
|
770
|
+
if (spelling.length > 2 * PARTIAL_WORD_RUN_CODE_POINTS) return true;
|
|
771
|
+
if (spelling.length <= PARTIAL_WORD_RUN_CODE_POINTS) return false;
|
|
772
|
+
return codePointCountOf(spelling) > PARTIAL_WORD_RUN_CODE_POINTS;
|
|
773
|
+
}
|
|
774
|
+
function countSpelling(counts, token, spelling, change) {
|
|
775
|
+
if (!holdsRun(spelling)) return;
|
|
776
|
+
let byToken = counts.get(token);
|
|
777
|
+
if (byToken === void 0) {
|
|
778
|
+
if (change <= 0) return;
|
|
779
|
+
byToken = /* @__PURE__ */ new Map();
|
|
780
|
+
counts.set(token, byToken);
|
|
781
|
+
}
|
|
782
|
+
const next = (byToken.get(spelling) ?? 0) + change;
|
|
783
|
+
if (next > 0) {
|
|
784
|
+
byToken.set(spelling, next);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
byToken.delete(spelling);
|
|
788
|
+
if (byToken.size === 0) counts.delete(token);
|
|
789
|
+
}
|
|
790
|
+
function textsOf(value) {
|
|
791
|
+
if (typeof value === "string") return [value];
|
|
792
|
+
if (!Array.isArray(value)) return [];
|
|
793
|
+
return value.filter((element) => typeof element === "string");
|
|
794
|
+
}
|
|
795
|
+
function visitFieldTexts(document, fields, visit) {
|
|
796
|
+
for (const field of fields) {
|
|
797
|
+
for (const text of textsOf(getNestedValue(document, field))) visit(text);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
function visitDocumentSpellings(document, analysis, visit) {
|
|
801
|
+
const tokenizing = { ...tokenizeOptions(analysis.options), collectSurfaces: true };
|
|
802
|
+
const visitOccurrence = (token, _position, surface) => {
|
|
803
|
+
visit(token, surface ?? token);
|
|
804
|
+
};
|
|
805
|
+
visitFieldTexts(document, analysis.fields, (text) => visitTokens(text, analysis.language, tokenizing, visitOccurrence));
|
|
806
|
+
}
|
|
807
|
+
function visitDocumentSurfaceSpellings(document, analysis, visit) {
|
|
808
|
+
if (analysis.options?.customTokenizer !== void 0) return;
|
|
809
|
+
visitFieldTexts(document, analysis.fields, (text) => visitSurfaceSpellings(text, analysis.language, visit));
|
|
810
|
+
}
|
|
811
|
+
function countDocumentSpellings(counts, document, analysis, direction) {
|
|
812
|
+
visitDocumentSpellings(document, analysis, (token, spelling) => countSpelling(counts, token, spelling, direction));
|
|
813
|
+
}
|
|
814
|
+
function spellingCountsOf(documents, analysis) {
|
|
815
|
+
const counts = /* @__PURE__ */ new Map();
|
|
816
|
+
for (const document of documents) countDocumentSpellings(counts, document, analysis, 1);
|
|
817
|
+
return counts;
|
|
818
|
+
}
|
|
819
|
+
function encodePartialSpellings(fields, counts) {
|
|
820
|
+
const encoded = { fields: [...fields], tokens: [], spellings: [], counts: [] };
|
|
821
|
+
for (const [token, byToken] of counts) {
|
|
822
|
+
for (const [spelling, count] of byToken) {
|
|
823
|
+
encoded.tokens.push(token);
|
|
824
|
+
encoded.spellings.push(spelling);
|
|
825
|
+
encoded.counts.push(count);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return encoded;
|
|
829
|
+
}
|
|
830
|
+
function sameFields(left, right) {
|
|
831
|
+
if (left.length !== right.length) return false;
|
|
832
|
+
for (let at = 0; at < left.length; at++) {
|
|
833
|
+
if (left[at] !== right[at]) return false;
|
|
834
|
+
}
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// src/core/partition/suggestions.ts
|
|
839
|
+
function verbatimOccurrences(state, token) {
|
|
840
|
+
const postingList = state.invertedIdx.lookup(token);
|
|
841
|
+
if (!postingList) return 0;
|
|
842
|
+
const derived = postingList.totalTermFrequency - state.surfaceRegistry.stemChangedTotalFor(token);
|
|
843
|
+
return derived > 0 ? derived : 0;
|
|
844
|
+
}
|
|
845
|
+
function suggestDisplayTerms(state, surfacePrefix, stemmedPrefix, limit) {
|
|
846
|
+
if (limit <= 0 || surfacePrefix.length === 0) return [];
|
|
847
|
+
const groups = /* @__PURE__ */ new Map();
|
|
848
|
+
for (const candidate of state.surfaceRegistry.candidatesForPrefix(surfacePrefix)) {
|
|
849
|
+
const postingList = state.invertedIdx.lookup(candidate.token);
|
|
850
|
+
if (!postingList || postingList.docIdSet.size === 0) continue;
|
|
851
|
+
let group = groups.get(candidate.token);
|
|
852
|
+
if (!group) {
|
|
853
|
+
group = { documentFrequency: postingList.docIdSet.size, surfaces: [] };
|
|
854
|
+
groups.set(candidate.token, group);
|
|
855
|
+
}
|
|
856
|
+
group.surfaces.push({ surface: candidate.surface, occurrences: candidate.occurrences });
|
|
857
|
+
}
|
|
858
|
+
const termPrefixes = state.surfaceRegistry.size() === 0 && stemmedPrefix !== surfacePrefix && stemmedPrefix.length > 0 ? [surfacePrefix, stemmedPrefix] : [surfacePrefix];
|
|
859
|
+
for (const prefix of termPrefixes) {
|
|
860
|
+
for (const suggestion of state.invertedIdx.prefixSearch(prefix, Number.MAX_SAFE_INTEGER)) {
|
|
861
|
+
const occurrences = verbatimOccurrences(state, suggestion.term);
|
|
862
|
+
if (occurrences === 0) continue;
|
|
863
|
+
let group = groups.get(suggestion.term);
|
|
864
|
+
if (!group) {
|
|
865
|
+
group = { documentFrequency: suggestion.documentFrequency, surfaces: [] };
|
|
866
|
+
groups.set(suggestion.term, group);
|
|
867
|
+
} else if (group.surfaces.some((s) => s.surface === suggestion.term)) {
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
group.surfaces.push({ surface: suggestion.term, occurrences });
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
const results = [];
|
|
874
|
+
for (const [token, group] of groups) {
|
|
875
|
+
results.push({ token, documentFrequency: group.documentFrequency, surfaces: group.surfaces });
|
|
876
|
+
}
|
|
877
|
+
results.sort((a, b) => b.documentFrequency - a.documentFrequency || compareCodePoints(a.token, b.token));
|
|
878
|
+
if (results.length > limit) results.length = limit;
|
|
879
|
+
return results;
|
|
880
|
+
}
|
|
881
|
+
function partitionDocumentFrequency(subs, token) {
|
|
882
|
+
let documents = 0;
|
|
883
|
+
for (const sub of subs) documents += sub.invertedIdx.documentFrequency(token);
|
|
884
|
+
return documents;
|
|
885
|
+
}
|
|
886
|
+
function expandTermPrefix(subs, surfacePrefix, stemmedToken, maxExpansions) {
|
|
887
|
+
if (maxExpansions <= 0 || surfacePrefix.length === 0) return [];
|
|
888
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
889
|
+
const holdsSurfaceForms = subs.some((sub) => sub.surfaceRegistry.size() > 0);
|
|
890
|
+
const termPrefixes = !holdsSurfaceForms && stemmedToken !== surfacePrefix && stemmedToken.length > 0 ? [surfacePrefix, stemmedToken] : [surfacePrefix];
|
|
891
|
+
for (const sub of subs) {
|
|
892
|
+
for (const candidate of sub.surfaceRegistry.candidatesForPrefix(surfacePrefix)) candidates.add(candidate.token);
|
|
893
|
+
for (const prefix of termPrefixes) {
|
|
894
|
+
for (const suggestion of sub.invertedIdx.prefixSearch(prefix, Number.MAX_SAFE_INTEGER)) {
|
|
895
|
+
if (candidates.has(suggestion.term)) continue;
|
|
896
|
+
if (verbatimOccurrences(sub, suggestion.term) > 0) candidates.add(suggestion.term);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
const ranked = [];
|
|
901
|
+
for (const token of candidates) {
|
|
902
|
+
const documents = partitionDocumentFrequency(subs, token);
|
|
903
|
+
if (documents > 0) ranked.push({ token, documents });
|
|
904
|
+
}
|
|
905
|
+
ranked.sort((a, b) => b.documents - a.documents || compareCodePoints(a.token, b.token));
|
|
906
|
+
if (ranked.length > maxExpansions) ranked.length = maxExpansions;
|
|
907
|
+
return ranked.map((entry) => entry.token);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export { ANTIMERIDIAN_SPAN_DEGREES, DEG_TO_RAD, EARTH_RADIUS_METERS, FROZEN_PARTIAL_REMOVED_ENTRY_BYTES, FULL_TURN_DEGREES, GROWING_PARTIAL_ENTRY_BYTES, GROWING_PARTIAL_PENDING_ENTRIES_PER_ENTRY, GROWING_PARTIAL_PENDING_ENTRY_BYTES, GROWING_PARTIAL_RUN_BYTES, GROWING_PARTIAL_RUN_MEMBER_BYTES, LOCATION_CODE_BITS_PER_AXIS, MAX_COVERING_CELLS, MAX_LATITUDE_DEGREES, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, PARTIAL_WORD_RUN_CODE_POINTS, RADIUS_BOX_MARGIN_RADIANS, RADIUS_BOX_MARGIN_RATIO, VINCENTY_CONVERGENCE_THRESHOLD, VINCENTY_MAX_ITERATIONS, codePointCountOf, countDocumentSpellings, countSpelling, encodeDocument, encodePartialSpellings, expandTermPrefix, extractVectorFieldsFromSchema, flattenSchema, getFlatSchema, getNestedValue, getOrCreateFieldNameIndex, isLatitude, isLongitude, isQuantizationMode, isStorageMode, messagePackUpperBoundBytes, parseVectorDimension, partialFieldsOf, partitionDocumentFrequency, raiseEarlierReleaseGraphSetting, requireCreatableSchema, requireDocumentWithinSizeLimit, requireValidFieldTypes, sameFields, schemaFieldsOf, spellingCountsOf, suggestDisplayTerms, textFieldsChanged, tokenizeOptions, validateDocument, validateDocumentStrict, validateRequiredFields, validateSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, visitDocumentSpellings, visitDocumentSurfaceSpellings };
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { NarsilError, ErrorCodes } from './chunk-YH7W556M.mjs';
|
|
2
|
+
|
|
3
|
+
// src/persistence/archive/byte-reader.ts
|
|
4
|
+
async function* chunksOf(source) {
|
|
5
|
+
if (source instanceof Uint8Array) {
|
|
6
|
+
yield source;
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (typeof source.getReader === "function") {
|
|
10
|
+
const reader = source.getReader();
|
|
11
|
+
try {
|
|
12
|
+
for (; ; ) {
|
|
13
|
+
const step = await reader.read();
|
|
14
|
+
if (step.done) return;
|
|
15
|
+
yield step.value;
|
|
16
|
+
}
|
|
17
|
+
} finally {
|
|
18
|
+
reader.releaseLock();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
yield* source;
|
|
22
|
+
}
|
|
23
|
+
function createByteReader(source) {
|
|
24
|
+
const iterator = chunksOf(source);
|
|
25
|
+
const pending = [];
|
|
26
|
+
let pendingBytes = 0;
|
|
27
|
+
let ended = false;
|
|
28
|
+
async function fill(length) {
|
|
29
|
+
while (pendingBytes < length && !ended) {
|
|
30
|
+
const step = await iterator.next();
|
|
31
|
+
if (step.done) {
|
|
32
|
+
ended = true;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (step.value.byteLength === 0) continue;
|
|
36
|
+
pending.push(step.value);
|
|
37
|
+
pendingBytes += step.value.byteLength;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function take(length) {
|
|
41
|
+
const out = new Uint8Array(length);
|
|
42
|
+
let filled = 0;
|
|
43
|
+
while (filled < length) {
|
|
44
|
+
const head = pending[0];
|
|
45
|
+
const needed = length - filled;
|
|
46
|
+
if (head.byteLength <= needed) {
|
|
47
|
+
out.set(head, filled);
|
|
48
|
+
filled += head.byteLength;
|
|
49
|
+
pending.shift();
|
|
50
|
+
} else {
|
|
51
|
+
out.set(head.subarray(0, needed), filled);
|
|
52
|
+
pending[0] = head.subarray(needed);
|
|
53
|
+
filled += needed;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
pendingBytes -= length;
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
async readExactly(length) {
|
|
61
|
+
await fill(length);
|
|
62
|
+
if (pendingBytes === 0 && length > 0) return null;
|
|
63
|
+
if (pendingBytes < length) return take(pendingBytes);
|
|
64
|
+
return take(length);
|
|
65
|
+
},
|
|
66
|
+
async peek(length) {
|
|
67
|
+
await fill(length);
|
|
68
|
+
const available = Math.min(length, pendingBytes);
|
|
69
|
+
const copy = take(available);
|
|
70
|
+
pending.unshift(copy);
|
|
71
|
+
pendingBytes += copy.byteLength;
|
|
72
|
+
return copy;
|
|
73
|
+
},
|
|
74
|
+
async close() {
|
|
75
|
+
await iterator.return(void 0);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/engine/snapshot/restore-config.ts
|
|
81
|
+
function rejectSnapshot(message) {
|
|
82
|
+
throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Invalid snapshot: ${message}`);
|
|
83
|
+
}
|
|
84
|
+
function isPlainObject(value) {
|
|
85
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
86
|
+
}
|
|
87
|
+
function restoredBm25(raw, reject) {
|
|
88
|
+
if (raw === void 0) {
|
|
89
|
+
return void 0;
|
|
90
|
+
}
|
|
91
|
+
if (!isPlainObject(raw)) {
|
|
92
|
+
reject("bm25 must be an object");
|
|
93
|
+
}
|
|
94
|
+
const fields = restoredBm25Fields(raw.fields, reject);
|
|
95
|
+
return {
|
|
96
|
+
...restoredBm25Pair(raw, "bm25", reject),
|
|
97
|
+
...fields !== void 0 ? { fields } : {}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function restoredBm25Pair(raw, label, reject) {
|
|
101
|
+
const { k1, b } = raw;
|
|
102
|
+
if (k1 !== void 0 && (typeof k1 !== "number" || !Number.isFinite(k1))) {
|
|
103
|
+
reject(`${label} k1 must be a finite number`);
|
|
104
|
+
}
|
|
105
|
+
if (b !== void 0 && (typeof b !== "number" || !Number.isFinite(b))) {
|
|
106
|
+
reject(`${label} b must be a finite number`);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
...k1 !== void 0 ? { k1 } : {},
|
|
110
|
+
...b !== void 0 ? { b } : {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function restoredBm25Fields(raw, reject) {
|
|
114
|
+
if (raw === void 0) return void 0;
|
|
115
|
+
if (!isPlainObject(raw)) reject("bm25 fields must be an object");
|
|
116
|
+
const source = raw;
|
|
117
|
+
const fields = /* @__PURE__ */ Object.create(null);
|
|
118
|
+
for (const name of Object.keys(source)) {
|
|
119
|
+
const pair = source[name];
|
|
120
|
+
if (!isPlainObject(pair)) reject("bm25 fields must map each field to an object");
|
|
121
|
+
fields[name] = restoredBm25Pair(pair, "bm25 field", reject);
|
|
122
|
+
}
|
|
123
|
+
return fields;
|
|
124
|
+
}
|
|
125
|
+
function restoredStopWords(name, list, reject) {
|
|
126
|
+
if (name !== void 0 && typeof name !== "string") {
|
|
127
|
+
reject("stopWords must be a name");
|
|
128
|
+
}
|
|
129
|
+
if (list !== void 0 && (!Array.isArray(list) || !list.every((word) => typeof word === "string"))) {
|
|
130
|
+
reject("stopWordList must be a list of words");
|
|
131
|
+
}
|
|
132
|
+
if (typeof name === "string" && Array.isArray(list)) {
|
|
133
|
+
reject("stopWords and stopWordList cannot both be present");
|
|
134
|
+
}
|
|
135
|
+
if (typeof name === "string") {
|
|
136
|
+
return name;
|
|
137
|
+
}
|
|
138
|
+
if (Array.isArray(list)) {
|
|
139
|
+
return new Set(list);
|
|
140
|
+
}
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
function restoredPartitionConfig(raw, reject = rejectSnapshot) {
|
|
144
|
+
if (raw === void 0) {
|
|
145
|
+
return void 0;
|
|
146
|
+
}
|
|
147
|
+
if (!isPlainObject(raw)) {
|
|
148
|
+
reject("partitionConfig must be an object");
|
|
149
|
+
}
|
|
150
|
+
const { maxDocsPerPartition, maxPartitions, watermark } = raw;
|
|
151
|
+
if (maxDocsPerPartition !== void 0 && (typeof maxDocsPerPartition !== "number" || !Number.isInteger(maxDocsPerPartition) || maxDocsPerPartition < 1)) {
|
|
152
|
+
reject("partitionConfig maxDocsPerPartition must be a positive integer");
|
|
153
|
+
}
|
|
154
|
+
if (maxPartitions !== void 0 && (typeof maxPartitions !== "number" || !Number.isInteger(maxPartitions) || maxPartitions < 1)) {
|
|
155
|
+
reject("partitionConfig maxPartitions must be a positive integer");
|
|
156
|
+
}
|
|
157
|
+
if (watermark !== void 0 && (typeof watermark !== "number" || !(watermark > 0) || watermark > 1)) {
|
|
158
|
+
reject("partitionConfig watermark must be above 0 and at most 1");
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
...typeof maxDocsPerPartition === "number" ? { maxDocsPerPartition } : {},
|
|
162
|
+
...typeof maxPartitions === "number" ? { maxPartitions } : {},
|
|
163
|
+
...typeof watermark === "number" ? { watermark } : {}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function restoredScoring(raw, reject) {
|
|
167
|
+
if (raw === void 0) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
if (raw !== "local" && raw !== "dfs" && raw !== "broadcast") {
|
|
171
|
+
reject("defaultScoring must be 'local', 'dfs', or 'broadcast'");
|
|
172
|
+
}
|
|
173
|
+
return raw;
|
|
174
|
+
}
|
|
175
|
+
function restoredBoolean(raw, field, reject) {
|
|
176
|
+
if (raw === void 0) {
|
|
177
|
+
return void 0;
|
|
178
|
+
}
|
|
179
|
+
if (typeof raw !== "boolean") {
|
|
180
|
+
reject(`${field} must be a boolean`);
|
|
181
|
+
}
|
|
182
|
+
return raw;
|
|
183
|
+
}
|
|
184
|
+
function restoredRequired(raw, reject) {
|
|
185
|
+
if (raw === void 0) {
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
if (!Array.isArray(raw) || !raw.every((field) => typeof field === "string")) {
|
|
189
|
+
reject("required must be a list of field paths");
|
|
190
|
+
}
|
|
191
|
+
return raw;
|
|
192
|
+
}
|
|
193
|
+
function restoredVectorPromotion(raw, reject) {
|
|
194
|
+
if (raw === void 0) {
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
if (!isPlainObject(raw) || raw.hnswConfig !== void 0 && !isPlainObject(raw.hnswConfig)) {
|
|
198
|
+
reject("vectorPromotion must be an object");
|
|
199
|
+
}
|
|
200
|
+
return raw;
|
|
201
|
+
}
|
|
202
|
+
function restoredEmbedding(raw, reject = rejectSnapshot) {
|
|
203
|
+
if (raw === void 0) {
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
if (!isPlainObject(raw)) {
|
|
207
|
+
reject("embedding must be an object");
|
|
208
|
+
}
|
|
209
|
+
const { fields, adapter } = raw;
|
|
210
|
+
if (adapter !== void 0 && typeof adapter !== "string") {
|
|
211
|
+
reject("embedding adapter must be a name");
|
|
212
|
+
}
|
|
213
|
+
if (!isPlainObject(fields)) {
|
|
214
|
+
reject("embedding fields must be an object");
|
|
215
|
+
}
|
|
216
|
+
for (const value of Object.values(fields)) {
|
|
217
|
+
const isPath = typeof value === "string";
|
|
218
|
+
const isPathList = Array.isArray(value) && value.every((path) => typeof path === "string");
|
|
219
|
+
if (!isPath && !isPathList) {
|
|
220
|
+
reject("embedding fields must map vector fields to source paths");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
fields,
|
|
225
|
+
...adapter !== void 0 ? { adapter } : {}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function readSharedConfigFields(source, reject) {
|
|
229
|
+
if (source.tokenizer !== void 0 && typeof source.tokenizer !== "string") {
|
|
230
|
+
reject("tokenizer must be a name");
|
|
231
|
+
}
|
|
232
|
+
const stopWords = restoredStopWords(source.stopWords, source.stopWordList, reject);
|
|
233
|
+
const bm25 = restoredBm25(source.bm25, reject);
|
|
234
|
+
const surfaceForms = restoredBoolean(source.surfaceForms, "surfaceForms", reject);
|
|
235
|
+
const defaultScoring = restoredScoring(source.defaultScoring, reject);
|
|
236
|
+
const trackPositions = restoredBoolean(source.trackPositions, "trackPositions", reject);
|
|
237
|
+
const { textStorage } = source;
|
|
238
|
+
if (textStorage !== void 0 && textStorage !== "memory" && textStorage !== "disk") {
|
|
239
|
+
reject("textStorage must be 'memory' or 'disk'");
|
|
240
|
+
}
|
|
241
|
+
const strict = restoredBoolean(source.strict, "strict", reject);
|
|
242
|
+
const required = restoredRequired(source.required, reject);
|
|
243
|
+
const vectorPromotion = restoredVectorPromotion(source.vectorPromotion, reject);
|
|
244
|
+
if (source.patternValueLimit !== void 0 && typeof source.patternValueLimit !== "number") {
|
|
245
|
+
reject("patternValueLimit must be a number");
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
...typeof source.tokenizer === "string" ? { tokenizer: source.tokenizer } : {},
|
|
249
|
+
...stopWords !== void 0 ? { stopWords } : {},
|
|
250
|
+
...bm25 !== void 0 ? { bm25 } : {},
|
|
251
|
+
...surfaceForms !== void 0 ? { surfaceForms } : {},
|
|
252
|
+
...defaultScoring !== void 0 ? { defaultScoring } : {},
|
|
253
|
+
...trackPositions !== void 0 ? { trackPositions } : {},
|
|
254
|
+
...textStorage === "memory" || textStorage === "disk" ? { textStorage } : {},
|
|
255
|
+
...strict !== void 0 ? { strict } : {},
|
|
256
|
+
...required !== void 0 ? { required } : {},
|
|
257
|
+
...vectorPromotion !== void 0 ? { vectorPromotion } : {},
|
|
258
|
+
...typeof source.patternValueLimit === "number" ? { patternValueLimit: source.patternValueLimit } : {}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function restoredConfigFields(envelope, reject = rejectSnapshot) {
|
|
262
|
+
const shared = readSharedConfigFields(envelope, reject);
|
|
263
|
+
const partitions = restoredPartitionConfig(envelope.partitionConfig, reject);
|
|
264
|
+
return {
|
|
265
|
+
...shared,
|
|
266
|
+
...partitions !== void 0 ? { partitions } : {}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export { chunksOf, createByteReader, rejectSnapshot, restoredConfigFields, restoredEmbedding };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/engine/analysis-change-entry.ts
|
|
2
|
+
function holdsChangeWork(entry) {
|
|
3
|
+
return entry !== void 0 && (entry.pendingAnalysis !== null || entry.durableAnalysis !== null);
|
|
4
|
+
}
|
|
5
|
+
async function abandonChangeOf(core, indexName) {
|
|
6
|
+
if (!holdsChangeWork(core.indexRegistry.get(indexName))) return;
|
|
7
|
+
const { abandonAnalysisChange } = await import('./analysis-change-HGW3L6NY.mjs');
|
|
8
|
+
await abandonAnalysisChange(core, indexName);
|
|
9
|
+
}
|
|
10
|
+
async function resumeChangeOf(core, indexName) {
|
|
11
|
+
if ((core.indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
|
|
12
|
+
if (core.mutationCtx.capacityScope === "partition") return;
|
|
13
|
+
if (core.executor.getManager(indexName) === void 0) return;
|
|
14
|
+
const { resumeAnalysisChange } = await import('./analysis-change-HGW3L6NY.mjs');
|
|
15
|
+
void resumeAnalysisChange(core, indexName).catch(() => void 0);
|
|
16
|
+
}
|
|
17
|
+
async function resumeEveryChange(core) {
|
|
18
|
+
for (const indexName of [...core.indexRegistry.keys()]) await resumeChangeOf(core, indexName);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { abandonChangeOf, resumeChangeOf, resumeEveryChange };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND } from './chunk-BRNAVOKP.mjs';
|
|
2
|
+
import { NarsilError, ErrorCodes } from './chunk-YH7W556M.mjs';
|
|
3
|
+
|
|
4
|
+
// src/engine/export/json-line.ts
|
|
5
|
+
function refuse(path, kind, docId) {
|
|
6
|
+
throw new NarsilError(
|
|
7
|
+
ErrorCodes.DOC_VALIDATION_FAILED,
|
|
8
|
+
`Document "${docId}" holds ${kind} at "${path || "(document)"}", which a document export cannot carry as JSON`,
|
|
9
|
+
{ docId, field: path }
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
function encodeNumber(value, path, target) {
|
|
13
|
+
if (Number.isFinite(value)) return Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
14
|
+
if (!target.tagged) refuse(path, String(value), target.docId);
|
|
15
|
+
return `{"${NUMBER_TAG}":"${String(value)}"}`;
|
|
16
|
+
}
|
|
17
|
+
function encodeDate(value, path, target) {
|
|
18
|
+
const milliseconds = value.getTime();
|
|
19
|
+
if (!target.tagged || Number.isNaN(milliseconds)) refuse(path, "a date", target.docId);
|
|
20
|
+
const seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND);
|
|
21
|
+
const nanoseconds = (milliseconds - seconds * MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND;
|
|
22
|
+
return `{"${DATE_TAG}":[${seconds},${nanoseconds}]}`;
|
|
23
|
+
}
|
|
24
|
+
function encodeBytes(value, path, target) {
|
|
25
|
+
if (!target.tagged) refuse(path, "bytes", target.docId);
|
|
26
|
+
return `{"${BYTES_TAG}":"${encodeBase64(value)}"}`;
|
|
27
|
+
}
|
|
28
|
+
function encodeList(value, path, target) {
|
|
29
|
+
target.parts.push("[");
|
|
30
|
+
for (let at = 0; at < value.length; at++) {
|
|
31
|
+
if (at > 0) target.parts.push(",");
|
|
32
|
+
encodeValue(value[at], `${path}[${at}]`, target);
|
|
33
|
+
}
|
|
34
|
+
target.parts.push("]");
|
|
35
|
+
}
|
|
36
|
+
function encodeMap(value, path, target) {
|
|
37
|
+
const proto = Object.getPrototypeOf(value);
|
|
38
|
+
if (proto !== Object.prototype && proto !== null) refuse(path, "a value other than a plain object", target.docId);
|
|
39
|
+
const entries = Object.entries(value).filter(([, entry]) => entry !== void 0);
|
|
40
|
+
const wrapped = target.tagged && entries.length === 1 && startsWithTagPrefix(entries[0][0]);
|
|
41
|
+
target.parts.push(wrapped ? `{"${OBJECT_TAG}":{` : "{");
|
|
42
|
+
for (let at = 0; at < entries.length; at++) {
|
|
43
|
+
const [key, entry] = entries[at];
|
|
44
|
+
if (at > 0) target.parts.push(",");
|
|
45
|
+
target.parts.push(JSON.stringify(key), ":");
|
|
46
|
+
encodeValue(entry, path === "" ? key : `${path}.${key}`, target);
|
|
47
|
+
}
|
|
48
|
+
target.parts.push(wrapped ? "}}" : "}");
|
|
49
|
+
}
|
|
50
|
+
function encodeValue(value, path, target) {
|
|
51
|
+
if (value === null) {
|
|
52
|
+
target.parts.push("null");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
switch (typeof value) {
|
|
56
|
+
case "string":
|
|
57
|
+
target.parts.push(JSON.stringify(value));
|
|
58
|
+
return;
|
|
59
|
+
case "boolean":
|
|
60
|
+
target.parts.push(value ? "true" : "false");
|
|
61
|
+
return;
|
|
62
|
+
case "number":
|
|
63
|
+
target.parts.push(encodeNumber(value, path, target));
|
|
64
|
+
return;
|
|
65
|
+
case "object":
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
refuse(path, `a ${typeof value}`, target.docId);
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(value)) encodeList(value, path, target);
|
|
71
|
+
else if (value instanceof Date) target.parts.push(encodeDate(value, path, target));
|
|
72
|
+
else if (value instanceof Uint8Array) target.parts.push(encodeBytes(value, path, target));
|
|
73
|
+
else encodeMap(value, path, target);
|
|
74
|
+
}
|
|
75
|
+
function encodeExactJson(value, docId) {
|
|
76
|
+
const target = { docId, tagged: false, parts: [] };
|
|
77
|
+
encodeValue(value, "", target);
|
|
78
|
+
return target.parts.join("");
|
|
79
|
+
}
|
|
80
|
+
function encodeDocumentJson(document, docId) {
|
|
81
|
+
const target = { docId, tagged: true, parts: [] };
|
|
82
|
+
encodeValue(document, "", target);
|
|
83
|
+
return target.parts.join("");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { encodeDocumentJson, encodeExactJson };
|