@delali/narsil 0.3.1-next.156 → 0.3.1-next.157
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/{analysis-change-5BQOQ4BF.mjs → analysis-change-CKEMM2MC.mjs} +9 -9
- package/dist/{react-native/chunks/analysis-change-entry-SCVWK6OU.mjs → analysis-change-entry-SEDMJ6MW.mjs} +1 -1
- package/dist/browser/{analysis-change-435CUEPZ.mjs → analysis-change-ZKGJFENM.mjs} +38 -29
- package/dist/{analysis-change-entry-TXX6JSMX.mjs → browser/analysis-change-entry-5BFUVMHJ.mjs} +1 -1
- package/dist/browser/{chunk-BHFQATSC.mjs → chunk-25MTVDYD.mjs} +1 -1
- package/dist/browser/{chunk-IZXVW2ZJ.mjs → chunk-3NLMB5CC.mjs} +2 -2
- package/dist/browser/{chunk-23XRXIBW.mjs → chunk-5YWB3E2W.mjs} +8 -1
- package/dist/browser/chunk-AI5UI46D.mjs +12 -0
- package/dist/browser/{chunk-2CFI5VVV.mjs → chunk-BLT4RHCJ.mjs} +2 -2
- package/dist/browser/{chunk-4NGKC4H4.mjs → chunk-C26SPCGQ.mjs} +7 -6
- package/dist/browser/{chunk-6LWDPLTB.mjs → chunk-C4FJ3WDY.mjs} +1 -1
- package/dist/browser/{chunk-MGI4BCXC.mjs → chunk-CXNTHHA7.mjs} +2 -2
- package/dist/browser/{chunk-STOWQFT3.mjs → chunk-DUH6QUVU.mjs} +547 -2
- package/dist/browser/chunk-EKMGCRSR.mjs +61 -0
- package/dist/browser/{chunk-SSTPBZZX.mjs → chunk-GFAZPSWK.mjs} +5 -5
- package/dist/browser/{chunk-3SSRJMFN.mjs → chunk-HUCSHDTB.mjs} +1 -1
- package/dist/browser/{chunk-K4Q6KX3R.mjs → chunk-K3IPRX6D.mjs} +48 -17
- package/dist/browser/{chunk-MOG4OVDK.mjs → chunk-MY2XKH22.mjs} +1 -12
- package/dist/browser/{chunk-3V7DNNZL.mjs → chunk-N23GL72Q.mjs} +178 -801
- package/dist/browser/{chunk-NQAME3RK.mjs → chunk-UATIJ4KU.mjs} +2 -2
- package/dist/browser/{chunk-2TI4SSUP.mjs → chunk-UKOWD2K5.mjs} +3 -3
- package/dist/browser/{chunk-7U3WVJUP.mjs → chunk-UTMHUHUV.mjs} +2 -2
- package/dist/browser/{chunk-EA63E3D2.mjs → chunk-V43N6TZO.mjs} +5 -5
- package/dist/browser/{chunk-CRE3G7F3.mjs → chunk-VY5KW3HN.mjs} +3 -3
- package/dist/browser/{chunk-WI4MR75E.mjs → chunk-X7TXYUKO.mjs} +1 -1
- package/dist/browser/{chunk-KZWSX6BH.mjs → chunk-Y6IBAUNO.mjs} +2 -86
- package/dist/browser/{cold-module-2EHCIV4K.mjs → cold-module-YNUUDNOM.mjs} +12 -10
- package/dist/browser/{durability-wiring-A7BVG2DW.mjs → durability-wiring-GVZEE46O.mjs} +64 -21
- package/dist/browser/{engine-hooks-E4UD67JD.mjs → engine-hooks-HBVS6YM4.mjs} +5 -4
- package/dist/browser/{geo-index-HHWGMNIS.mjs → geo-index-OTV7VPIR.mjs} +2 -1
- package/dist/browser/{import-DXYB6756.mjs → import-5ESVMFDJ.mjs} +6 -5
- package/dist/browser/{module-NIYMEA5R.mjs → module-NDSQLPMQ.mjs} +11 -9
- package/dist/{release-BH3DKW3T.mjs → browser/release-HYXPVJVS.mjs} +0 -1
- package/dist/browser/{restore-hooks-YPN4ZFCY.mjs → restore-hooks-IE3GGYHG.mjs} +8 -7
- package/dist/browser/{restore-queue-G3RQGL3Y.mjs → restore-queue-LQBBTODR.mjs} +3 -3
- package/dist/browser/{retention-ZWVMNC3Q.mjs → retention-TY3L3BFN.mjs} +7 -6
- package/dist/browser/{snapshot-VEQNIE6C.mjs → snapshot-5FHPPCNZ.mjs} +16 -14
- package/dist/browser/{start-BM442C6R.mjs → start-2UZTOBG5.mjs} +8 -7
- package/dist/browser/{write-2EVMZWDE.mjs → write-ULXAN5B4.mjs} +10 -8
- package/dist/{capabilities-Da4ywVVl.d.ts → capabilities-D3AoBJoF.d.ts} +2 -2
- package/dist/{chunk-K5QFDYST.mjs → chunk-24FNVRKB.mjs} +1 -1
- package/dist/{chunk-DP5C7YFQ.mjs → chunk-2ROUFMQX.mjs} +2 -2
- package/dist/{chunk-PWC4VB3Q.mjs → chunk-4B7JIGQD.mjs} +2 -2
- package/dist/{chunk-FAKFUDZZ.mjs → chunk-4LMSZAK6.mjs} +14 -3
- package/dist/{chunk-6I6AYAXS.mjs → chunk-4ZTHGTVX.mjs} +2 -2
- package/dist/{chunk-QOW2JPUI.mjs → chunk-BNL5OPRV.mjs} +6 -6
- package/dist/{chunk-3HYC4JRF.mjs → chunk-C7XQYG6U.mjs} +2 -2
- package/dist/{chunk-WX4LAO6M.mjs → chunk-CQZXZ75V.mjs} +3 -97
- package/dist/{chunk-4KKXNJM6.mjs → chunk-CWS55TEX.mjs} +2 -2
- package/dist/{chunk-2UV4QBHW.mjs → chunk-EYD7K3H6.mjs} +5 -5
- package/dist/{chunk-EFBDHH5P.mjs → chunk-FEZVDOWX.mjs} +160 -245
- package/dist/{chunk-XAXKV65G.mjs → chunk-FUD5XSZ5.mjs} +1 -1
- package/dist/{chunk-JDJBQLRO.mjs → chunk-GPWMUPCA.mjs} +10 -10
- package/dist/{chunk-25KDNIZZ.mjs → chunk-IIRIG7H5.mjs} +1 -1
- package/dist/{chunk-TZTRKM33.mjs → chunk-JSV6OQ4C.mjs} +1 -1
- package/dist/{chunk-NF4DT3IH.mjs → chunk-JTYPJF3T.mjs} +8 -1
- package/dist/chunk-KCQYFO4K.mjs +62 -0
- package/dist/{chunk-CSLGFPFQ.mjs → chunk-LDNCLRZU.mjs} +1 -1
- package/dist/{chunk-MQOJIO5B.mjs → chunk-MW6BR4QP.mjs} +2 -2
- package/dist/{react-native/chunks/chunk-MUWD2H2S.mjs → chunk-MWD5VPN7.mjs} +2 -2
- package/dist/{chunk-XXHN7J46.mjs → chunk-ODYKO5TO.mjs} +1 -1
- package/dist/{chunk-RDXO6JST.mjs → chunk-OG7UGJ6F.mjs} +2 -2
- package/dist/{chunk-FYOVBEMM.mjs → chunk-OQLD2BSW.mjs} +2 -2
- package/dist/{chunk-I53G4JAU.mjs → chunk-OYABFKTW.mjs} +2 -2
- package/dist/{chunk-TZ3355VS.mjs → chunk-P5LANSH6.mjs} +1 -1
- package/dist/{chunk-P5ZI2P2W.mjs → chunk-PIH5SJ4N.mjs} +3 -3
- package/dist/{chunk-HFPMMRQT.mjs → chunk-PSZI4O24.mjs} +51 -4
- package/dist/{chunk-L6V6BST3.mjs → chunk-PV2CG7EJ.mjs} +3 -552
- package/dist/{chunk-SA5LOGO3.mjs → chunk-PWGYQXML.mjs} +1 -1
- package/dist/{chunk-BWZ3P4MU.mjs → chunk-QLDABJZM.mjs} +3 -3
- package/dist/{chunk-JWRUUCWD.mjs → chunk-RCX4WNLC.mjs} +2 -2
- package/dist/{chunk-DWEPMFJE.mjs → chunk-RIHIVFIQ.mjs} +5 -5
- package/dist/{chunk-FNGAM5B7.mjs → chunk-RWURUDSP.mjs} +8 -8
- package/dist/{chunk-I2KPOLOZ.mjs → chunk-SMOOSIAW.mjs} +3 -3
- package/dist/{chunk-TGS5UXBE.mjs → chunk-SOI6LTHM.mjs} +3 -3
- package/dist/{chunk-YTWZVGCB.mjs → chunk-UD5HIS4U.mjs} +1 -1
- package/dist/{chunk-46KY2PJD.mjs → chunk-UJDJB3NE.mjs} +37 -29
- package/dist/{chunk-Z2KAFCRT.mjs → chunk-VSLSGASN.mjs} +2 -2
- package/dist/{chunk-VTTRFF2C.mjs → chunk-VZ2ONHEE.mjs} +9 -5
- package/dist/chunk-W5EB5XKI.mjs +741 -0
- package/dist/{chunk-7LXHHCXZ.mjs → chunk-W7OSSKH5.mjs} +46 -16
- package/dist/{chunk-ZKP7G7TV.mjs → chunk-XXJZMTZT.mjs} +1 -1
- package/dist/{chunk-FRBFVQFN.mjs → chunk-ZPZ3YGXV.mjs} +4 -4
- package/dist/{client-DRv7UVeY.d.ts → client-kqSMevVi.d.ts} +15 -3
- package/dist/client.d.ts +6 -6
- package/dist/client.mjs +4 -0
- package/dist/{cold-module-6MO2XJF2.mjs → cold-module-VOJXMNZB.mjs} +13 -12
- package/dist/{config-DMwffLKn.d.ts → config-B4v_Htpu.d.ts} +1 -1
- package/dist/{config-CoSig5Ox.d.ts → config-CTP01fns.d.ts} +1 -1
- package/dist/{direct-executor-FTMYY3TI.mjs → direct-executor-V5DRIECI.mjs} +5 -5
- package/dist/distribution.d.ts +4 -4
- package/dist/distribution.mjs +72 -64
- package/dist/{durability-wiring-VIF5MOSY.mjs → durability-wiring-3TD62MBI.mjs} +38 -30
- package/dist/{engine-CFxPYqEk.d.ts → engine-CkPn2PWE.d.ts} +1 -1
- package/dist/{engine-hooks-EGUGNZYE.mjs → engine-hooks-HA3SBOBR.mjs} +8 -8
- package/dist/{import-XKDPJQDP.mjs → import-GPKLTSKA.mjs} +8 -8
- package/dist/index.browser.mjs +4 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +7 -7
- package/dist/index.react-native.mjs +3 -3
- package/dist/{long-query-thread-YA4IAYSY.mjs → long-query-thread-QDFQSJD6.mjs} +13 -13
- package/dist/{module-FQ4JWNQJ.mjs → module-JYHFTVPS.mjs} +12 -11
- package/dist/{paged-partition-archive-PXW5XAYU.mjs → paged-partition-archive-RLRGOXDX.mjs} +14 -14
- package/dist/partial-words.mjs +3 -3
- package/dist/persistence/durability/checkpoint-worker.mjs +13 -12
- package/dist/query-suggestions/merge-worker.mjs +9 -9
- package/dist/query-suggestions.browser.mjs +9 -8
- package/dist/query-suggestions.d.ts +1 -1
- package/dist/query-suggestions.mjs +17 -17
- package/dist/react-native/chunks/{analysis-change-LT5QBQ3H.mjs → analysis-change-QUVDNABS.mjs} +37 -29
- package/dist/{browser/analysis-change-entry-HZXKPPGV.mjs → react-native/chunks/analysis-change-entry-OC4XASBF.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-KV46CT4D.mjs → chunk-4AV5PPH6.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-GXX3DQXP.mjs → chunk-4COWCEY7.mjs} +188 -163
- package/dist/react-native/chunks/{chunk-G43IPIDG.mjs → chunk-4NWR3NGS.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-3JWDECAZ.mjs → chunk-5MSX5FRT.mjs} +5 -5
- package/dist/react-native/chunks/{chunk-6WA3C3DV.mjs → chunk-6OFDUYVX.mjs} +8 -1
- package/dist/react-native/chunks/{chunk-NB3LP33V.mjs → chunk-6ZELFCK5.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-4JYO3JD2.mjs → chunk-BITYFZSZ.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-ZXZFN7FI.mjs → chunk-DMIFXZ3Q.mjs} +1 -1
- package/dist/{chunk-KF4EXSM4.mjs → react-native/chunks/chunk-IAENKE2D.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-ZLWVW734.mjs → chunk-KSBYEMCB.mjs} +1 -1
- package/dist/react-native/chunks/chunk-KU646XXT.mjs +164 -0
- package/dist/react-native/chunks/{chunk-MIP4SOR6.mjs → chunk-OCSLSH27.mjs} +164 -244
- package/dist/react-native/chunks/chunk-OXM66LO6.mjs +62 -0
- package/dist/react-native/chunks/{chunk-VWUDIOT6.mjs → chunk-TORU2OHQ.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-PDRWWPKV.mjs → chunk-WVWJNUMN.mjs} +48 -18
- package/dist/react-native/chunks/{chunk-UQ4OAXKU.mjs → chunk-WW2X2AEI.mjs} +4 -4
- package/dist/react-native/chunks/{chunk-QUKQNI3H.mjs → chunk-ZNZ6CPAZ.mjs} +2 -87
- package/dist/react-native/chunks/{chunk-TP6KCKER.mjs → chunk-ZVQMBF2H.mjs} +2 -2
- package/dist/react-native/chunks/{chunk-POPDAGH6.mjs → chunk-ZWAIN4GG.mjs} +6 -6
- package/dist/react-native/chunks/{cold-module-KVZYUGRY.mjs → cold-module-N6KFNNZA.mjs} +9 -8
- package/dist/react-native/chunks/{durability-wiring-34OYO32E.mjs → durability-wiring-RN64S2TL.mjs} +63 -21
- package/dist/react-native/chunks/{engine-hooks-M7JV46NH.mjs → engine-hooks-CWA5CKCA.mjs} +4 -4
- package/dist/react-native/chunks/{import-H6AQREWI.mjs → import-5UAWBRJP.mjs} +4 -4
- package/dist/react-native/chunks/{module-LBZPGOWH.mjs → module-6RP4ZCBW.mjs} +8 -7
- package/dist/react-native/chunks/{release-D7ZTIANM.mjs → release-2SIHZWDO.mjs} +0 -1
- package/dist/react-native/chunks/{restore-hooks-IBGIY3DR.mjs → restore-hooks-ENFMDTWC.mjs} +7 -7
- package/dist/react-native/chunks/{restore-queue-ZZX54AH7.mjs → restore-queue-4R6AASE5.mjs} +3 -3
- package/dist/react-native/chunks/{retention-EW4TTDFB.mjs → retention-5GTFT3GR.mjs} +6 -6
- package/dist/react-native/chunks/{snapshot-REYVIN3X.mjs → snapshot-5LGPQXFS.mjs} +15 -14
- package/dist/react-native/chunks/{start-BQK6KN3R.mjs → start-ZQJVZ5DN.mjs} +7 -7
- package/dist/react-native/chunks/{write-FQAYCZF5.mjs → write-6BRYIIZ7.mjs} +7 -6
- package/dist/react-native/partial-words.mjs +2 -2
- package/dist/react-native/query-suggestions.mjs +8 -8
- package/dist/react-native/sync.mjs +44 -10
- package/dist/react.d.ts +7 -7
- package/dist/{browser/release-76MXRPGV.mjs → release-SMR4WJD4.mjs} +0 -1
- package/dist/{restore-hooks-CDERDEF4.mjs → restore-hooks-HXLIEB4A.mjs} +12 -12
- package/dist/{restore-queue-7NNSTROA.mjs → restore-queue-LZH7LMLR.mjs} +3 -3
- package/dist/{retention-QSVBBNRM.mjs → retention-3K7ARGAG.mjs} +12 -12
- package/dist/server.d.ts +10 -8
- package/dist/server.mjs +37 -29
- package/dist/{snapshot-RH4NSKIZ.mjs → snapshot-O7ICP7NJ.mjs} +24 -23
- package/dist/{start-MCKCOGIW.mjs → start-S4PFP6RS.mjs} +14 -14
- package/dist/sync/filesystem.d.ts +2 -2
- package/dist/sync/indexeddb.d.ts +2 -2
- package/dist/sync.browser.mjs +44 -10
- package/dist/sync.d.ts +3 -3
- package/dist/sync.mjs +44 -10
- package/dist/{tasks-qrJojgST.d.ts → tasks-CoNjxbop.d.ts} +2 -2
- package/dist/{thread-O4SBJJJS.mjs → thread-YLJ3ZPQ3.mjs} +12 -12
- package/dist/{types-BZCGjfLn.d.ts → types-DPMjfOr_.d.ts} +1 -1
- package/dist/workers/entry.mjs +5 -5
- package/dist/{write-3FK7NG3Y.mjs → write-2OBJGLFS.mjs} +11 -10
- package/openapi.json +71 -0
- package/package.json +7 -7
- package/dist/chunk-BU4SAIC4.mjs +0 -196
- package/dist/react-native/chunks/chunk-DNXOMPAQ.mjs +0 -191
package/dist/workers/entry.mjs
CHANGED
|
@@ -32,9 +32,9 @@ async function importBootstrapModule(moduleUrl) {
|
|
|
32
32
|
await import(moduleUrl);
|
|
33
33
|
}
|
|
34
34
|
async function stopServingRequests() {
|
|
35
|
-
const { closeRequestThread } = await import('../thread-
|
|
35
|
+
const { closeRequestThread } = await import('../thread-YLJ3ZPQ3.mjs');
|
|
36
36
|
closeRequestThread();
|
|
37
|
-
const { closeLongQueryThread } = await import('../long-query-thread-
|
|
37
|
+
const { closeLongQueryThread } = await import('../long-query-thread-QDFQSJD6.mjs');
|
|
38
38
|
closeLongQueryThread();
|
|
39
39
|
}
|
|
40
40
|
function holdsCopies(executor) {
|
|
@@ -65,7 +65,7 @@ function createActionHandler(executor) {
|
|
|
65
65
|
if (!holdsCopies(executor)) {
|
|
66
66
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "This executor holds no copies to answer requests from");
|
|
67
67
|
}
|
|
68
|
-
const starting = import('../thread-
|
|
68
|
+
const starting = import('../thread-YLJ3ZPQ3.mjs').then(
|
|
69
69
|
({ serveRequests }) => serveRequests(executor, action.settings)
|
|
70
70
|
);
|
|
71
71
|
serving.start = starting.then(
|
|
@@ -82,7 +82,7 @@ function createActionHandler(executor) {
|
|
|
82
82
|
if (!holdsCopies(executor)) {
|
|
83
83
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "This executor holds no copies to answer long queries from");
|
|
84
84
|
}
|
|
85
|
-
const { serveLongQueries } = await import('../long-query-thread-
|
|
85
|
+
const { serveLongQueries } = await import('../long-query-thread-QDFQSJD6.mjs');
|
|
86
86
|
serveLongQueries(executor, action.settings);
|
|
87
87
|
servingRequests = true;
|
|
88
88
|
post(buildSuccessResponse(action.requestId, void 0));
|
|
@@ -129,7 +129,7 @@ async function setup() {
|
|
|
129
129
|
parentPort = null;
|
|
130
130
|
}
|
|
131
131
|
requireSearchBackendSettings();
|
|
132
|
-
const [{ createDirectExecutor }] = await Promise.all([import('../direct-executor-
|
|
132
|
+
const [{ createDirectExecutor }] = await Promise.all([import('../direct-executor-V5DRIECI.mjs'), loadVectorCode(), loadGeoCode()]);
|
|
133
133
|
const handleAction = createActionHandler(createDirectExecutor({ threadSlot }));
|
|
134
134
|
if (parentPort) {
|
|
135
135
|
const port = parentPort;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { DOCUMENT_EXPORT_VERSION, DOCUMENT_EXPORT_FORMAT } from './chunk-
|
|
1
|
+
import { DOCUMENT_EXPORT_VERSION, DOCUMENT_EXPORT_FORMAT } from './chunk-LDNCLRZU.mjs';
|
|
2
2
|
import { encodeExactJson, encodeDocumentJson } from './chunk-6RC4K46J.mjs';
|
|
3
3
|
import './chunk-TQXHPFWT.mjs';
|
|
4
4
|
import './chunk-INJYO3BU.mjs';
|
|
5
5
|
import './chunk-CZQ33DLW.mjs';
|
|
6
6
|
import { decodeVectorFilePayload, isDead, bytesToVectors } from './chunk-K4ZIGL2O.mjs';
|
|
7
7
|
import './chunk-37CD3OKS.mjs';
|
|
8
|
-
import {
|
|
9
|
-
import './chunk-
|
|
10
|
-
import './chunk-
|
|
8
|
+
import { KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment } from './chunk-CQZXZ75V.mjs';
|
|
9
|
+
import { setNestedValue } from './chunk-KCQYFO4K.mjs';
|
|
10
|
+
import './chunk-FEZVDOWX.mjs';
|
|
11
|
+
import './chunk-OYABFKTW.mjs';
|
|
11
12
|
import './chunk-HJSN7UYG.mjs';
|
|
12
13
|
import './chunk-LHKOSI2J.mjs';
|
|
13
14
|
import './chunk-XIHUI4KB.mjs';
|
|
14
15
|
import './chunk-3MXV3VHR.mjs';
|
|
15
16
|
import { EXPORT_CHUNK_BYTES } from './chunk-EEBCDP36.mjs';
|
|
16
|
-
import { decodeStoredDocument } from './chunk-
|
|
17
|
-
import './chunk-
|
|
17
|
+
import { decodeStoredDocument } from './chunk-VZ2ONHEE.mjs';
|
|
18
|
+
import './chunk-PIH5SJ4N.mjs';
|
|
18
19
|
import './chunk-GH4WQ22V.mjs';
|
|
19
20
|
import { openChecksummedEnvelope } from './chunk-3OH67G7R.mjs';
|
|
20
21
|
import './chunk-IPN7S4KX.mjs';
|
|
@@ -23,10 +24,10 @@ import './chunk-7GXJUJ24.mjs';
|
|
|
23
24
|
import './chunk-Q2UL2TPC.mjs';
|
|
24
25
|
import './chunk-CITFCZKF.mjs';
|
|
25
26
|
import './chunk-RLOES5SX.mjs';
|
|
26
|
-
import './chunk-
|
|
27
|
-
import './chunk-SQJWAIF4.mjs';
|
|
27
|
+
import './chunk-PV2CG7EJ.mjs';
|
|
28
28
|
import './chunk-FQBFZAWG.mjs';
|
|
29
|
-
import './chunk-
|
|
29
|
+
import './chunk-W5EB5XKI.mjs';
|
|
30
|
+
import './chunk-SQJWAIF4.mjs';
|
|
30
31
|
import './chunk-GES7U2PM.mjs';
|
|
31
32
|
import './chunk-I54T6CQP.mjs';
|
|
32
33
|
import './chunk-I5B7RXU7.mjs';
|
|
@@ -139,7 +140,7 @@ async function wholeFileVectorReads(checkpoint) {
|
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
async function* pagedDocumentLines(checkpoint) {
|
|
142
|
-
const { openFileVectorReads, pagedPartitionLines } = await import('./module-
|
|
143
|
+
const { openFileVectorReads, pagedPartitionLines } = await import('./module-JYHFTVPS.mjs');
|
|
143
144
|
const vectors = await openFileVectorReads(checkpoint, () => wholeFileVectorReads(checkpoint));
|
|
144
145
|
try {
|
|
145
146
|
for (const partition of checkpoint.manifest.partitions) {
|
package/openapi.json
CHANGED
|
@@ -2268,6 +2268,39 @@
|
|
|
2268
2268
|
}
|
|
2269
2269
|
},
|
|
2270
2270
|
"/indexes/{name}/sync": {
|
|
2271
|
+
"get": {
|
|
2272
|
+
"operationId": "getSync",
|
|
2273
|
+
"summary": "Report the device sync setting of an index, whether a device has downloaded it, and its epoch",
|
|
2274
|
+
"tags": [
|
|
2275
|
+
"Sync"
|
|
2276
|
+
],
|
|
2277
|
+
"parameters": [
|
|
2278
|
+
{
|
|
2279
|
+
"name": "name",
|
|
2280
|
+
"in": "path",
|
|
2281
|
+
"required": true,
|
|
2282
|
+
"description": "The name of the index.",
|
|
2283
|
+
"schema": {
|
|
2284
|
+
"type": "string"
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
],
|
|
2288
|
+
"responses": {
|
|
2289
|
+
"200": {
|
|
2290
|
+
"description": "The server answered the request.",
|
|
2291
|
+
"content": {
|
|
2292
|
+
"application/json": {
|
|
2293
|
+
"schema": {
|
|
2294
|
+
"$ref": "#/components/schemas/SyncStatus"
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
},
|
|
2299
|
+
"default": {
|
|
2300
|
+
"$ref": "#/components/responses/Error"
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
},
|
|
2271
2304
|
"put": {
|
|
2272
2305
|
"operationId": "updateSync",
|
|
2273
2306
|
"summary": "Replace the device sync setting of an index",
|
|
@@ -6062,6 +6095,44 @@
|
|
|
6062
6095
|
],
|
|
6063
6096
|
"description": "The device sync setting of one index, which SyncOperations.updateSync takes. Turn sync on only for an index whose every document belongs to one user, because every device that syncs the index receives the whole index. Create one index for each user, and leave sync off for a public index or for an index that holds the data of several users."
|
|
6064
6097
|
},
|
|
6098
|
+
"SyncStatus": {
|
|
6099
|
+
"type": "object",
|
|
6100
|
+
"properties": {
|
|
6101
|
+
"active": {
|
|
6102
|
+
"type": "boolean",
|
|
6103
|
+
"description": "This is true once a device has asked for the published snapshot, from when the server keeps history."
|
|
6104
|
+
},
|
|
6105
|
+
"epoch": {
|
|
6106
|
+
"anyOf": [
|
|
6107
|
+
{
|
|
6108
|
+
"type": "null"
|
|
6109
|
+
},
|
|
6110
|
+
{
|
|
6111
|
+
"type": "string"
|
|
6112
|
+
}
|
|
6113
|
+
],
|
|
6114
|
+
"description": "This is the index epoch, 32 lowercase hexadecimal digits, or `null` while sync is off."
|
|
6115
|
+
},
|
|
6116
|
+
"enabled": {
|
|
6117
|
+
"type": "boolean",
|
|
6118
|
+
"description": "This turns sync on or off. Turning it on gives the index a new epoch, so every synced device loads a new copy."
|
|
6119
|
+
},
|
|
6120
|
+
"historyMaxAgeMs": {
|
|
6121
|
+
"type": "number",
|
|
6122
|
+
"description": "This is the age in milliseconds after which the server deletes a log segment from history. It defaults to 30 days."
|
|
6123
|
+
},
|
|
6124
|
+
"historyMaxBytes": {
|
|
6125
|
+
"type": "number",
|
|
6126
|
+
"description": "This is the byte count above which the server deletes the oldest log segment from history. It defaults to the length of the published snapshot."
|
|
6127
|
+
}
|
|
6128
|
+
},
|
|
6129
|
+
"required": [
|
|
6130
|
+
"active",
|
|
6131
|
+
"epoch",
|
|
6132
|
+
"enabled"
|
|
6133
|
+
],
|
|
6134
|
+
"description": "The device sync state of one index, which SyncOperations.getSync returns."
|
|
6135
|
+
},
|
|
6065
6136
|
"SynonymRule": {
|
|
6066
6137
|
"anyOf": [
|
|
6067
6138
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delali/narsil",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.157",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Distributed search engine with full-text, vector, hybrid, and geosearch. One engine, embedded or on a server, with a cross-language .nrsl format.",
|
|
6
6
|
"author": "Delali (https://sondelali.com)",
|
|
@@ -427,11 +427,11 @@
|
|
|
427
427
|
}
|
|
428
428
|
},
|
|
429
429
|
"optionalDependencies": {
|
|
430
|
-
"@delali/narsil-native-darwin-arm64": "0.3.1-next.
|
|
431
|
-
"@delali/narsil-native-darwin-x64": "0.3.1-next.
|
|
432
|
-
"@delali/narsil-native-linux-arm64": "0.3.1-next.
|
|
433
|
-
"@delali/narsil-native-linux-x64": "0.3.1-next.
|
|
434
|
-
"@delali/narsil-native-win32-arm64": "0.3.1-next.
|
|
435
|
-
"@delali/narsil-native-win32-x64": "0.3.1-next.
|
|
430
|
+
"@delali/narsil-native-darwin-arm64": "0.3.1-next.157",
|
|
431
|
+
"@delali/narsil-native-darwin-x64": "0.3.1-next.157",
|
|
432
|
+
"@delali/narsil-native-linux-arm64": "0.3.1-next.157",
|
|
433
|
+
"@delali/narsil-native-linux-x64": "0.3.1-next.157",
|
|
434
|
+
"@delali/narsil-native-win32-arm64": "0.3.1-next.157",
|
|
435
|
+
"@delali/narsil-native-win32-x64": "0.3.1-next.157"
|
|
436
436
|
}
|
|
437
437
|
}
|
package/dist/chunk-BU4SAIC4.mjs
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { isWordIndexedBase, parseFieldType } from './chunk-I54T6CQP.mjs';
|
|
2
|
-
import { isPlainObject, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS } from './chunk-L5ORED7V.mjs';
|
|
3
|
-
import { MAX_DOCUMENT_ENCODING_DEPTH, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, DOCUMENT_REPLY_ENVELOPE_DEPTH } from './chunk-U476IXKQ.mjs';
|
|
4
|
-
import { NarsilError, ErrorCodes } from './chunk-MP7ABPTD.mjs';
|
|
5
|
-
import { compareCodePoints } from './chunk-TBC3XUL2.mjs';
|
|
6
|
-
import { Encoder, encode } from '@msgpack/msgpack';
|
|
7
|
-
|
|
8
|
-
var INTEGER_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH };
|
|
9
|
-
var FLOAT_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH, forceIntegerToFloat: true };
|
|
10
|
-
var integerEncoder = new Encoder(INTEGER_ENCODING);
|
|
11
|
-
var floatEncoder = new Encoder(FLOAT_ENCODING);
|
|
12
|
-
function encodeExactly(document, forceIntegerToFloat) {
|
|
13
|
-
const bytes = (forceIntegerToFloat ? floatEncoder : integerEncoder).encode(document);
|
|
14
|
-
if (bytes.byteLength > DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES) {
|
|
15
|
-
if (forceIntegerToFloat) floatEncoder = new Encoder(FLOAT_ENCODING);
|
|
16
|
-
else integerEncoder = new Encoder(INTEGER_ENCODING);
|
|
17
|
-
}
|
|
18
|
-
return bytes;
|
|
19
|
-
}
|
|
20
|
-
function holdsNegativeZero(value, depth) {
|
|
21
|
-
if (typeof value === "number") return Object.is(value, -0);
|
|
22
|
-
if (value === null || typeof value !== "object" || ArrayBuffer.isView(value) || depth > MAX_DOCUMENT_ENCODING_DEPTH) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
for (const child of Array.isArray(value) ? value : Object.values(value)) {
|
|
26
|
-
if (holdsNegativeZero(child, depth + 1)) return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
function encodeDocumentReply(payload) {
|
|
31
|
-
return encode(payload, { forceIntegerToFloat: holdsNegativeZero(payload, 1 - DOCUMENT_REPLY_ENVELOPE_DEPTH) });
|
|
32
|
-
}
|
|
33
|
-
function encodeDocument(document) {
|
|
34
|
-
try {
|
|
35
|
-
return encodeExactly(document, holdsNegativeZero(document, 1));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw new NarsilError(
|
|
38
|
-
ErrorCodes.DOC_VALIDATION_FAILED,
|
|
39
|
-
`The document cannot be encoded as MessagePack: ${error instanceof Error ? error.message : String(error)}`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/schema/validator/schema.ts
|
|
45
|
-
function validateSchemaFields(schema, depth, prefix) {
|
|
46
|
-
if (depth > MAX_NESTING_DEPTH) {
|
|
47
|
-
throw new NarsilError(
|
|
48
|
-
ErrorCodes.SCHEMA_DEPTH_EXCEEDED,
|
|
49
|
-
`Schema nesting exceeds the maximum depth of ${MAX_NESTING_DEPTH} at "${prefix}"`,
|
|
50
|
-
{ path: prefix, maxDepth: MAX_NESTING_DEPTH }
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
let canonical = null;
|
|
54
|
-
const replace = (field, value) => {
|
|
55
|
-
if (canonical === null) canonical = { ...schema };
|
|
56
|
-
canonical[field] = value;
|
|
57
|
-
};
|
|
58
|
-
for (const [field, type] of Object.entries(schema)) {
|
|
59
|
-
const path = prefix ? `${prefix}.${field}` : field;
|
|
60
|
-
if (PROTOTYPE_POLLUTION_KEYS.has(field)) {
|
|
61
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, `Field name "${field}" is not allowed in a schema`, {
|
|
62
|
-
field,
|
|
63
|
-
path
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (!FIELD_NAME_PATTERN.test(field)) {
|
|
67
|
-
throw new NarsilError(
|
|
68
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
69
|
-
`Field name "${field}" contains characters that are not allowed; use letters, digits, and underscores only`,
|
|
70
|
-
{ field, path }
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
if (depth === 1 && RESERVED_ROOT_FIELDS.has(field)) {
|
|
74
|
-
throw new NarsilError(
|
|
75
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
76
|
-
`Field "${field}" is reserved and cannot be defined in a schema`,
|
|
77
|
-
{ field, path }
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
if (isPlainObject(type)) {
|
|
81
|
-
const nested = validateSchemaFields(type, depth + 1, path);
|
|
82
|
-
if (nested !== type) replace(field, nested);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (typeof type !== "string") {
|
|
86
|
-
throw new NarsilError(
|
|
87
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
88
|
-
`Field "${path}" has an invalid type definition: ${String(type)}`,
|
|
89
|
-
{
|
|
90
|
-
field: path,
|
|
91
|
-
type: String(type)
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
const parsed = parseFieldType(type, path);
|
|
96
|
-
if (parsed.type !== type) replace(field, parsed.type);
|
|
97
|
-
}
|
|
98
|
-
return canonical ?? schema;
|
|
99
|
-
}
|
|
100
|
-
function validateSchema(schema) {
|
|
101
|
-
if (!isPlainObject(schema)) {
|
|
102
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must be a plain object", {
|
|
103
|
-
received: typeof schema
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if (Object.keys(schema).length === 0) {
|
|
107
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must define at least one field");
|
|
108
|
-
}
|
|
109
|
-
const validated = validateSchemaFields(schema, 1, "");
|
|
110
|
-
requireTextFieldCount(schemaFieldsOf(validated).filter((field) => isWordIndexedBase(field.base)).length);
|
|
111
|
-
return validated;
|
|
112
|
-
}
|
|
113
|
-
function requireTextFieldCount(count) {
|
|
114
|
-
if (count <= MAX_TEXT_FIELDS) return;
|
|
115
|
-
throw new NarsilError(
|
|
116
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
117
|
-
`The schema declares ${count} string and string[] fields, but a schema holds at most ${MAX_TEXT_FIELDS}`,
|
|
118
|
-
{ textFields: count, maximum: MAX_TEXT_FIELDS }
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
function requireCreatableSchema(schema) {
|
|
122
|
-
for (const field of schemaFieldsOf(schema)) {
|
|
123
|
-
if (field.base !== "vector" || field.dimension <= MAX_VECTOR_DIMENSION) continue;
|
|
124
|
-
throw new NarsilError(
|
|
125
|
-
ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
|
|
126
|
-
`Vector field "${field.path}" has ${field.dimension} dimensions, but a new index takes at most ${MAX_VECTOR_DIMENSION}`,
|
|
127
|
-
{ field: field.path, dimension: field.dimension, maximum: MAX_VECTOR_DIMENSION }
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function requireValidFieldTypes(flatSchema) {
|
|
132
|
-
let textFields = 0;
|
|
133
|
-
for (const [path, type] of Object.entries(flatSchema)) {
|
|
134
|
-
if (typeof type !== "string") {
|
|
135
|
-
throw new NarsilError(
|
|
136
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
137
|
-
`Field "${path}" has an invalid type definition: ${String(type)}`,
|
|
138
|
-
{ field: path, type: String(type) }
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
if (isWordIndexedBase(parseFieldType(type, path).base)) textFields += 1;
|
|
142
|
-
}
|
|
143
|
-
requireTextFieldCount(textFields);
|
|
144
|
-
}
|
|
145
|
-
function flattenRecursive(schema, prefix, result) {
|
|
146
|
-
for (const [field, type] of Object.entries(schema)) {
|
|
147
|
-
const path = prefix ? `${prefix}.${field}` : field;
|
|
148
|
-
if (isPlainObject(type)) {
|
|
149
|
-
flattenRecursive(type, path, result);
|
|
150
|
-
} else {
|
|
151
|
-
result[path] = type;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
var flattenedSchemas = /* @__PURE__ */ new WeakMap();
|
|
156
|
-
function flattenSchema(schema) {
|
|
157
|
-
const cached = flattenedSchemas.get(schema);
|
|
158
|
-
if (cached !== void 0) return cached;
|
|
159
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
160
|
-
flattenRecursive(schema, "", result);
|
|
161
|
-
flattenedSchemas.set(schema, Object.freeze(result));
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
var parsedSchemas = /* @__PURE__ */ new WeakMap();
|
|
165
|
-
function schemaFieldsOf(schema) {
|
|
166
|
-
const cached = parsedSchemas.get(schema);
|
|
167
|
-
if (cached !== void 0) return cached;
|
|
168
|
-
const fields = [];
|
|
169
|
-
for (const [path, type] of Object.entries(flattenSchema(schema))) {
|
|
170
|
-
fields.push({ ...parseFieldType(type, path), path });
|
|
171
|
-
}
|
|
172
|
-
const frozen = Object.freeze(fields);
|
|
173
|
-
parsedSchemas.set(schema, frozen);
|
|
174
|
-
return frozen;
|
|
175
|
-
}
|
|
176
|
-
var partialFieldsBySchema = /* @__PURE__ */ new WeakMap();
|
|
177
|
-
function partialFieldsOf(schema) {
|
|
178
|
-
const cached = partialFieldsBySchema.get(schema);
|
|
179
|
-
if (cached !== void 0) return cached;
|
|
180
|
-
const paths = [];
|
|
181
|
-
for (const field of schemaFieldsOf(schema)) {
|
|
182
|
-
if (field.partial) paths.push(field.path);
|
|
183
|
-
}
|
|
184
|
-
const frozen = Object.freeze(paths.sort(compareCodePoints));
|
|
185
|
-
partialFieldsBySchema.set(schema, frozen);
|
|
186
|
-
return frozen;
|
|
187
|
-
}
|
|
188
|
-
function extractVectorFieldsFromSchema(schema) {
|
|
189
|
-
const result = /* @__PURE__ */ new Map();
|
|
190
|
-
for (const field of schemaFieldsOf(schema)) {
|
|
191
|
-
if (field.base === "vector") result.set(field.path, field.dimension);
|
|
192
|
-
}
|
|
193
|
-
return result;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export { encodeDocument, encodeDocumentReply, extractVectorFieldsFromSchema, flattenSchema, partialFieldsOf, requireCreatableSchema, requireValidFieldTypes, schemaFieldsOf, validateSchema };
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { MAX_DOCUMENT_ENCODING_DEPTH, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES } from './chunk-6VBXNFLE.mjs';
|
|
2
|
-
import { isPlainObject, isWordIndexedBase, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, parseFieldType, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS } from './chunk-C5G6TJ7A.mjs';
|
|
3
|
-
import { compareCodePoints } from './chunk-EJ33LCHV.mjs';
|
|
4
|
-
import { NarsilError, ErrorCodes } from './chunk-DZ7H7D2C.mjs';
|
|
5
|
-
import { Encoder } from '@msgpack/msgpack';
|
|
6
|
-
|
|
7
|
-
// src/schema/validator/schema.ts
|
|
8
|
-
function validateSchemaFields(schema, depth, prefix) {
|
|
9
|
-
if (depth > MAX_NESTING_DEPTH) {
|
|
10
|
-
throw new NarsilError(
|
|
11
|
-
ErrorCodes.SCHEMA_DEPTH_EXCEEDED,
|
|
12
|
-
`Schema nesting exceeds the maximum depth of ${MAX_NESTING_DEPTH} at "${prefix}"`,
|
|
13
|
-
{ path: prefix, maxDepth: MAX_NESTING_DEPTH }
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
let canonical = null;
|
|
17
|
-
const replace = (field, value) => {
|
|
18
|
-
if (canonical === null) canonical = { ...schema };
|
|
19
|
-
canonical[field] = value;
|
|
20
|
-
};
|
|
21
|
-
for (const [field, type] of Object.entries(schema)) {
|
|
22
|
-
const path = prefix ? `${prefix}.${field}` : field;
|
|
23
|
-
if (PROTOTYPE_POLLUTION_KEYS.has(field)) {
|
|
24
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, `Field name "${field}" is not allowed in a schema`, {
|
|
25
|
-
field,
|
|
26
|
-
path
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (!FIELD_NAME_PATTERN.test(field)) {
|
|
30
|
-
throw new NarsilError(
|
|
31
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
32
|
-
`Field name "${field}" contains characters that are not allowed; use letters, digits, and underscores only`,
|
|
33
|
-
{ field, path }
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (depth === 1 && RESERVED_ROOT_FIELDS.has(field)) {
|
|
37
|
-
throw new NarsilError(
|
|
38
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
39
|
-
`Field "${field}" is reserved and cannot be defined in a schema`,
|
|
40
|
-
{ field, path }
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
if (isPlainObject(type)) {
|
|
44
|
-
const nested = validateSchemaFields(type, depth + 1, path);
|
|
45
|
-
if (nested !== type) replace(field, nested);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (typeof type !== "string") {
|
|
49
|
-
throw new NarsilError(
|
|
50
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
51
|
-
`Field "${path}" has an invalid type definition: ${String(type)}`,
|
|
52
|
-
{
|
|
53
|
-
field: path,
|
|
54
|
-
type: String(type)
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
const parsed = parseFieldType(type, path);
|
|
59
|
-
if (parsed.type !== type) replace(field, parsed.type);
|
|
60
|
-
}
|
|
61
|
-
return canonical ?? schema;
|
|
62
|
-
}
|
|
63
|
-
function validateSchema(schema) {
|
|
64
|
-
if (!isPlainObject(schema)) {
|
|
65
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must be a plain object", {
|
|
66
|
-
received: typeof schema
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (Object.keys(schema).length === 0) {
|
|
70
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, "Schema must define at least one field");
|
|
71
|
-
}
|
|
72
|
-
const validated = validateSchemaFields(schema, 1, "");
|
|
73
|
-
requireTextFieldCount(schemaFieldsOf(validated).filter((field) => isWordIndexedBase(field.base)).length);
|
|
74
|
-
return validated;
|
|
75
|
-
}
|
|
76
|
-
function requireTextFieldCount(count) {
|
|
77
|
-
if (count <= MAX_TEXT_FIELDS) return;
|
|
78
|
-
throw new NarsilError(
|
|
79
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
80
|
-
`The schema declares ${count} string and string[] fields, but a schema holds at most ${MAX_TEXT_FIELDS}`,
|
|
81
|
-
{ textFields: count, maximum: MAX_TEXT_FIELDS }
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
function requireCreatableSchema(schema) {
|
|
85
|
-
for (const field of schemaFieldsOf(schema)) {
|
|
86
|
-
if (field.base !== "vector" || field.dimension <= MAX_VECTOR_DIMENSION) continue;
|
|
87
|
-
throw new NarsilError(
|
|
88
|
-
ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
|
|
89
|
-
`Vector field "${field.path}" has ${field.dimension} dimensions, but a new index takes at most ${MAX_VECTOR_DIMENSION}`,
|
|
90
|
-
{ field: field.path, dimension: field.dimension, maximum: MAX_VECTOR_DIMENSION }
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function requireValidFieldTypes(flatSchema) {
|
|
95
|
-
let textFields = 0;
|
|
96
|
-
for (const [path, type] of Object.entries(flatSchema)) {
|
|
97
|
-
if (typeof type !== "string") {
|
|
98
|
-
throw new NarsilError(
|
|
99
|
-
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
100
|
-
`Field "${path}" has an invalid type definition: ${String(type)}`,
|
|
101
|
-
{ field: path, type: String(type) }
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
if (isWordIndexedBase(parseFieldType(type, path).base)) textFields += 1;
|
|
105
|
-
}
|
|
106
|
-
requireTextFieldCount(textFields);
|
|
107
|
-
}
|
|
108
|
-
function flattenRecursive(schema, prefix, result) {
|
|
109
|
-
for (const [field, type] of Object.entries(schema)) {
|
|
110
|
-
const path = prefix ? `${prefix}.${field}` : field;
|
|
111
|
-
if (isPlainObject(type)) {
|
|
112
|
-
flattenRecursive(type, path, result);
|
|
113
|
-
} else {
|
|
114
|
-
result[path] = type;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
var flattenedSchemas = /* @__PURE__ */ new WeakMap();
|
|
119
|
-
function flattenSchema(schema) {
|
|
120
|
-
const cached = flattenedSchemas.get(schema);
|
|
121
|
-
if (cached !== void 0) return cached;
|
|
122
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
123
|
-
flattenRecursive(schema, "", result);
|
|
124
|
-
flattenedSchemas.set(schema, Object.freeze(result));
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
var parsedSchemas = /* @__PURE__ */ new WeakMap();
|
|
128
|
-
function schemaFieldsOf(schema) {
|
|
129
|
-
const cached = parsedSchemas.get(schema);
|
|
130
|
-
if (cached !== void 0) return cached;
|
|
131
|
-
const fields = [];
|
|
132
|
-
for (const [path, type] of Object.entries(flattenSchema(schema))) {
|
|
133
|
-
fields.push({ ...parseFieldType(type, path), path });
|
|
134
|
-
}
|
|
135
|
-
const frozen = Object.freeze(fields);
|
|
136
|
-
parsedSchemas.set(schema, frozen);
|
|
137
|
-
return frozen;
|
|
138
|
-
}
|
|
139
|
-
var partialFieldsBySchema = /* @__PURE__ */ new WeakMap();
|
|
140
|
-
function partialFieldsOf(schema) {
|
|
141
|
-
const cached = partialFieldsBySchema.get(schema);
|
|
142
|
-
if (cached !== void 0) return cached;
|
|
143
|
-
const paths = [];
|
|
144
|
-
for (const field of schemaFieldsOf(schema)) {
|
|
145
|
-
if (field.partial) paths.push(field.path);
|
|
146
|
-
}
|
|
147
|
-
const frozen = Object.freeze(paths.sort(compareCodePoints));
|
|
148
|
-
partialFieldsBySchema.set(schema, frozen);
|
|
149
|
-
return frozen;
|
|
150
|
-
}
|
|
151
|
-
function extractVectorFieldsFromSchema(schema) {
|
|
152
|
-
const result = /* @__PURE__ */ new Map();
|
|
153
|
-
for (const field of schemaFieldsOf(schema)) {
|
|
154
|
-
if (field.base === "vector") result.set(field.path, field.dimension);
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
var INTEGER_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH };
|
|
159
|
-
var FLOAT_ENCODING = { maxDepth: MAX_DOCUMENT_ENCODING_DEPTH, forceIntegerToFloat: true };
|
|
160
|
-
var integerEncoder = new Encoder(INTEGER_ENCODING);
|
|
161
|
-
var floatEncoder = new Encoder(FLOAT_ENCODING);
|
|
162
|
-
function encodeExactly(document, forceIntegerToFloat) {
|
|
163
|
-
const bytes = (forceIntegerToFloat ? floatEncoder : integerEncoder).encode(document);
|
|
164
|
-
if (bytes.byteLength > DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES) {
|
|
165
|
-
if (forceIntegerToFloat) floatEncoder = new Encoder(FLOAT_ENCODING);
|
|
166
|
-
else integerEncoder = new Encoder(INTEGER_ENCODING);
|
|
167
|
-
}
|
|
168
|
-
return bytes;
|
|
169
|
-
}
|
|
170
|
-
function holdsNegativeZero(value, depth) {
|
|
171
|
-
if (typeof value === "number") return Object.is(value, -0);
|
|
172
|
-
if (value === null || typeof value !== "object" || ArrayBuffer.isView(value) || depth > MAX_DOCUMENT_ENCODING_DEPTH) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
for (const child of Array.isArray(value) ? value : Object.values(value)) {
|
|
176
|
-
if (holdsNegativeZero(child, depth + 1)) return true;
|
|
177
|
-
}
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
function encodeDocument(document) {
|
|
181
|
-
try {
|
|
182
|
-
return encodeExactly(document, holdsNegativeZero(document, 1));
|
|
183
|
-
} catch (error) {
|
|
184
|
-
throw new NarsilError(
|
|
185
|
-
ErrorCodes.DOC_VALIDATION_FAILED,
|
|
186
|
-
`The document cannot be encoded as MessagePack: ${error instanceof Error ? error.message : String(error)}`
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export { encodeDocument, extractVectorFieldsFromSchema, flattenSchema, partialFieldsOf, requireCreatableSchema, requireValidFieldTypes, schemaFieldsOf, validateSchema };
|