@delali/narsil 0.3.1-next.140 → 0.3.1-next.143
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-JN23AZQP.mjs → analysis-change-HQUT2Z3I.mjs} +13 -13
- package/dist/{analysis-change-entry-5JSIMEKG.mjs → analysis-change-entry-TZTG4AZB.mjs} +1 -1
- package/dist/browser/{analysis-change-57MIRJWR.mjs → analysis-change-JPV775LR.mjs} +407 -6
- package/dist/browser/{analysis-change-entry-ICGRR3IN.mjs → analysis-change-entry-7HR4LWL3.mjs} +1 -1
- package/dist/browser/chunk-3ZBJYAS4.mjs +19 -0
- package/dist/browser/{chunk-ZAIZQOTM.mjs → chunk-5DB2VDGI.mjs} +951 -1134
- package/dist/browser/chunk-6RHTAVZX.mjs +656 -0
- package/dist/browser/chunk-CCOAOO73.mjs +86 -0
- package/dist/browser/{chunk-3EYDURFD.mjs → chunk-HKX2G6WH.mjs} +1615 -2266
- package/dist/browser/{chunk-CGVBGHBX.mjs → chunk-KTOK275N.mjs} +531 -830
- package/dist/browser/{chunk-5LYWZJE2.mjs → chunk-LVY2LI35.mjs} +1 -1
- package/dist/browser/chunk-MVM33ZUL.mjs +993 -0
- package/dist/browser/chunk-MWUK3DA5.mjs +2634 -0
- package/dist/browser/{chunk-67KSBUYR.mjs → chunk-R4WUDZQV.mjs} +8 -5
- package/dist/browser/{chunk-6BSB4N6B.mjs → chunk-TCLEOZ4P.mjs} +2 -2
- package/dist/browser/chunk-VFYMPCOV.mjs +212 -0
- package/dist/browser/chunk-WCFCHIBB.mjs +177 -0
- package/dist/browser/{chunk-E5SFTOQR.mjs → chunk-XNWPP5NS.mjs} +2 -2
- package/dist/browser/{chunk-QHNNULPW.mjs → chunk-ZEV26AQ6.mjs} +5 -0
- package/dist/browser/cold-module-MJMKNUYJ.mjs +745 -0
- package/dist/browser/{durability-wiring-MTIAN6VT.mjs → durability-wiring-SNOWIT6Z.mjs} +231 -51
- package/dist/browser/{import-Q7MXD6BS.mjs → import-TLB2A5LJ.mjs} +6 -5
- package/dist/browser/module-BUFNZMEU.mjs +12 -0
- package/dist/browser/{module-5J3PEUEB.mjs → module-BVP4TKZU.mjs} +395 -108
- package/dist/{restore-queue-RYSRRFS4.mjs → browser/restore-queue-ONYNYUDE.mjs} +2 -2
- package/dist/browser/{snapshot-YBJ5MF2M.mjs → snapshot-QXBKHJAG.mjs} +108 -25
- package/dist/browser/{write-RTWI5MXL.mjs → write-WHFBDWQS.mjs} +63 -91
- package/dist/{capabilities-DXAmysqJ.d.ts → capabilities-BCdUwK_L.d.ts} +2 -2
- package/dist/{chunk-HMDT3I63.mjs → chunk-46NZOPHS.mjs} +2 -2
- package/dist/{chunk-XXKWEG53.mjs → chunk-5WYVUPGD.mjs} +1 -1
- package/dist/chunk-6SNBQESJ.mjs +214 -0
- package/dist/chunk-7AUASRE7.mjs +653 -0
- package/dist/{chunk-4GCN34JV.mjs → chunk-AST3SHFA.mjs} +26 -24
- package/dist/chunk-BOJZGUS6.mjs +177 -0
- package/dist/{chunk-IP4HJOGC.mjs → chunk-BRUUBXCB.mjs} +4 -3
- package/dist/{chunk-J3EHATEZ.mjs → chunk-DQNKVOJ2.mjs} +63 -63
- package/dist/chunk-FOCV4CBZ.mjs +87 -0
- package/dist/{chunk-FFVLPCLH.mjs → chunk-GLZHNSGB.mjs} +1 -1
- package/dist/chunk-GWOS5DYC.mjs +2637 -0
- package/dist/{chunk-W2XDK66Z.mjs → chunk-IO5F7ZBE.mjs} +112 -438
- package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
- package/dist/{chunk-LLDFIKGP.mjs → chunk-KEIYVZUX.mjs} +4 -4
- package/dist/{chunk-UBXJQJII.mjs → chunk-KGOXHLLZ.mjs} +5 -1
- package/dist/{chunk-FKARMUWH.mjs → chunk-KZL72VTC.mjs} +68 -16
- package/dist/{chunk-TCWQJL7O.mjs → chunk-L76W3IZJ.mjs} +5 -0
- package/dist/{chunk-CPCGEIOM.mjs → chunk-LA4WNDHL.mjs} +83 -799
- package/dist/{chunk-PNNVTKMT.mjs → chunk-NJJCPFXN.mjs} +2 -2
- package/dist/chunk-NN33CZRE.mjs +86 -0
- package/dist/chunk-NRUXBYPH.mjs +121 -0
- package/dist/{chunk-UJWGQIXU.mjs → chunk-QHPYS427.mjs} +1 -0
- package/dist/{chunk-VSUYTPME.mjs → chunk-RHKRTYGO.mjs} +13 -4
- package/dist/{chunk-UEV53BBO.mjs → chunk-SRJBFG2T.mjs} +406 -5
- package/dist/{chunk-K3AQOZVM.mjs → chunk-TNBIK2LQ.mjs} +1638 -1644
- package/dist/chunk-UUZCQQG2.mjs +209 -0
- package/dist/{chunk-XMQNOD5V.mjs → chunk-VEFN6X6Q.mjs} +2 -2
- package/dist/{chunk-LK3MOTXF.mjs → chunk-VJEGOELZ.mjs} +8 -5
- package/dist/chunk-W2COJ5AH.mjs +148 -0
- package/dist/{chunk-IBATGS3J.mjs → chunk-WJGO5PGV.mjs} +241 -124
- package/dist/{chunk-CCCGEPJM.mjs → chunk-XZ3SRNDJ.mjs} +24 -63
- package/dist/{chunk-MTQTX4BP.mjs → chunk-YHUTF6EA.mjs} +400 -92
- package/dist/{chunk-B5I3IL4H.mjs → chunk-YLNSJQLX.mjs} +4 -4
- package/dist/{chunk-6VHWXAOI.mjs → chunk-Z4HFMYNX.mjs} +29 -24
- package/dist/{chunk-U4X4AWKL.mjs → chunk-ZPWS2SKJ.mjs} +293 -270
- package/dist/{client-DApBeLbk.d.ts → client-B12YFALP.d.ts} +3 -3
- package/dist/client.d.ts +7 -7
- package/dist/cold-module-4X7WJCFM.mjs +783 -0
- package/dist/{config-B0H-vp4U.d.ts → config-BhZxIeb1.d.ts} +6 -1
- package/dist/{config-Brysl9NO.d.ts → config-CIG5yDyg.d.ts} +2 -2
- package/dist/{direct-executor-J5UDLPL3.mjs → direct-executor-7XOQ7VQP.mjs} +5 -5
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution.d.ts +7 -7
- package/dist/distribution.mjs +123 -42
- package/dist/{durability-wiring-AYOTAPNQ.mjs → durability-wiring-324D2DDD.mjs} +213 -40
- package/dist/{engine-CuLMbH1-.d.ts → engine-CtzbHOmG.d.ts} +2 -2
- package/dist/{import-QRZAQ5RH.mjs → import-OOBUW3RR.mjs} +14 -13
- package/dist/{index-HYnqS1SE.d.ts → index-DsEurhSl.d.ts} +1 -1
- package/dist/index.browser.mjs +3 -3
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +11 -11
- package/dist/{long-query-thread-U7K5A72G.mjs → long-query-thread-4SW7RWDE.mjs} +8 -8
- package/dist/{module-L2OZO5PQ.mjs → module-DXSJ5LT2.mjs} +374 -83
- package/dist/module-IYPLWHGC.mjs +48 -0
- package/dist/paged-partition-archive-HFP45PLU.mjs +269 -0
- package/dist/partial-words.mjs +2 -2
- package/dist/persistence/durability/checkpoint-worker.d.ts +5 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +17 -15
- package/dist/react.d.ts +9 -9
- package/dist/{browser/restore-queue-DISFECE4.mjs → restore-queue-FEYAC4SB.mjs} +2 -2
- package/dist/{schema-BTXbHCqA.d.ts → schema-B-Runv0n.d.ts} +7 -0
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +8 -7
- package/dist/{snapshot-BTRZ3MZK.mjs → snapshot-CGM65VCD.mjs} +60 -25
- package/dist/{tasks-DjGjK70Y.d.ts → tasks-CjRJRGTb.d.ts} +6 -4
- package/dist/{thread-USB3GOPY.mjs → thread-KGNAIKPD.mjs} +8 -8
- package/dist/vector/search-worker.d.ts +1 -1
- package/dist/vector/search-worker.mjs +3 -2
- package/dist/workers/entry.mjs +7 -7
- package/dist/{write-GHTA56OW.mjs → write-2DZPEQL2.mjs} +70 -98
- package/openapi.json +13 -0
- package/package.json +12 -8
- package/dist/browser/chunk-XVMOQQ34.mjs +0 -384
- package/dist/chunk-BDIDUW2B.mjs +0 -387
- package/dist/browser/{chunk-4MFH226Q.mjs → chunk-D33A5VMU.mjs} +15 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nodeThreadId } from './chunk-W55X2BYN.mjs';
|
|
2
2
|
import { getFs, getPath } from './chunk-HLPRHOSO.mjs';
|
|
3
|
-
import { DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_SETTLE_MS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS } from './chunk-
|
|
3
|
+
import { DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_SETTLE_MS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS } from './chunk-7AUASRE7.mjs';
|
|
4
4
|
import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
5
5
|
import { NarsilError, ErrorCodes } from './chunk-HNHCNTVG.mjs';
|
|
6
6
|
import { openSync, close, readFileSync } from 'fs';
|
|
@@ -302,6 +302,29 @@ async function lockDirectory(root) {
|
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
// src/persistence/durability/list-recursive.ts
|
|
306
|
+
async function listRecursive(dir, base, pathMod, fs) {
|
|
307
|
+
const results = [];
|
|
308
|
+
let entries;
|
|
309
|
+
try {
|
|
310
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
311
|
+
} catch (err) {
|
|
312
|
+
if (err.code === "ENOENT") {
|
|
313
|
+
return results;
|
|
314
|
+
}
|
|
315
|
+
throw err;
|
|
316
|
+
}
|
|
317
|
+
for (const entry of entries) {
|
|
318
|
+
const full = pathMod.join(dir, entry.name);
|
|
319
|
+
if (entry.isDirectory()) {
|
|
320
|
+
results.push(...await listRecursive(full, base, pathMod, fs));
|
|
321
|
+
} else {
|
|
322
|
+
results.push(pathMod.relative(base, full).split(pathMod.sep).join("/"));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return results;
|
|
326
|
+
}
|
|
327
|
+
|
|
305
328
|
// src/persistence/durability/durable-filesystem.ts
|
|
306
329
|
function validateRelativeKey(key) {
|
|
307
330
|
if (key.length === 0) {
|
|
@@ -599,8 +622,8 @@ function createDurableDirectory(root) {
|
|
|
599
622
|
const fs = await getFs();
|
|
600
623
|
await ensureDir(target.path, target.pathMod, fs);
|
|
601
624
|
await fs.rename(source.path, target.path);
|
|
602
|
-
|
|
603
|
-
await fsyncDirectory(
|
|
625
|
+
const directories = new Set([target.path, source.path].map((path) => target.pathMod.dirname(path)));
|
|
626
|
+
for (const movedIn of directories) await fsyncDirectory(movedIn, fs);
|
|
604
627
|
},
|
|
605
628
|
async list(prefix) {
|
|
606
629
|
const fs = await getFs();
|
|
@@ -615,26 +638,5 @@ function createDurableDirectory(root) {
|
|
|
615
638
|
}
|
|
616
639
|
};
|
|
617
640
|
}
|
|
618
|
-
async function listRecursive(dir, base, pathMod, fs) {
|
|
619
|
-
const results = [];
|
|
620
|
-
let entries;
|
|
621
|
-
try {
|
|
622
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
623
|
-
} catch (err) {
|
|
624
|
-
if (err.code === "ENOENT") {
|
|
625
|
-
return results;
|
|
626
|
-
}
|
|
627
|
-
throw err;
|
|
628
|
-
}
|
|
629
|
-
for (const entry of entries) {
|
|
630
|
-
const full = pathMod.join(dir, entry.name);
|
|
631
|
-
if (entry.isDirectory()) {
|
|
632
|
-
results.push(...await listRecursive(full, base, pathMod, fs));
|
|
633
|
-
} else {
|
|
634
|
-
results.push(pathMod.relative(base, full).split(pathMod.sep).join("/"));
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
return results;
|
|
638
|
-
}
|
|
639
641
|
|
|
640
642
|
export { createDurableDirectory };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { MAX_DOCUMENT_NESTING_DEPTH } from './chunk-L5ORED7V.mjs';
|
|
2
|
+
import { NarsilError, ErrorCodes } from './chunk-HNHCNTVG.mjs';
|
|
3
|
+
|
|
4
|
+
// src/serialization/base64.ts
|
|
5
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
6
|
+
var PAD = 61;
|
|
7
|
+
var BYTES_PER_GROUP = 3;
|
|
8
|
+
var CHARACTERS_PER_GROUP = 4;
|
|
9
|
+
var ASCII_LIMIT = 128;
|
|
10
|
+
var ENCODE = new Uint8Array(ALPHABET.length);
|
|
11
|
+
var DECODE = new Int8Array(ASCII_LIMIT).fill(-1);
|
|
12
|
+
for (let at = 0; at < ALPHABET.length; at++) {
|
|
13
|
+
ENCODE[at] = ALPHABET.charCodeAt(at);
|
|
14
|
+
DECODE[ALPHABET.charCodeAt(at)] = at;
|
|
15
|
+
}
|
|
16
|
+
var asciiDecoder = new TextDecoder();
|
|
17
|
+
function encodeBase64(bytes) {
|
|
18
|
+
const out = new Uint8Array(Math.ceil(bytes.byteLength / BYTES_PER_GROUP) * CHARACTERS_PER_GROUP);
|
|
19
|
+
let write = 0;
|
|
20
|
+
let read = 0;
|
|
21
|
+
for (; read + BYTES_PER_GROUP <= bytes.byteLength; read += BYTES_PER_GROUP) {
|
|
22
|
+
const group = bytes[read] << 16 | bytes[read + 1] << 8 | bytes[read + 2];
|
|
23
|
+
out[write++] = ENCODE[group >>> 18];
|
|
24
|
+
out[write++] = ENCODE[group >>> 12 & 63];
|
|
25
|
+
out[write++] = ENCODE[group >>> 6 & 63];
|
|
26
|
+
out[write++] = ENCODE[group & 63];
|
|
27
|
+
}
|
|
28
|
+
const left = bytes.byteLength - read;
|
|
29
|
+
if (left > 0) {
|
|
30
|
+
const group = bytes[read] << 16 | (left === 2 ? bytes[read + 1] << 8 : 0);
|
|
31
|
+
out[write++] = ENCODE[group >>> 18];
|
|
32
|
+
out[write++] = ENCODE[group >>> 12 & 63];
|
|
33
|
+
out[write++] = left === 2 ? ENCODE[group >>> 6 & 63] : PAD;
|
|
34
|
+
out[write++] = PAD;
|
|
35
|
+
}
|
|
36
|
+
return asciiDecoder.decode(out);
|
|
37
|
+
}
|
|
38
|
+
function sextetAt(text, at) {
|
|
39
|
+
const code = text.charCodeAt(at);
|
|
40
|
+
return code < ASCII_LIMIT ? DECODE[code] : -1;
|
|
41
|
+
}
|
|
42
|
+
function decodeExactBase64(text) {
|
|
43
|
+
if (text.length % CHARACTERS_PER_GROUP !== 0) return null;
|
|
44
|
+
const padding = text.endsWith("==") ? 2 : text.endsWith("=") ? 1 : 0;
|
|
45
|
+
const out = new Uint8Array(text.length / CHARACTERS_PER_GROUP * BYTES_PER_GROUP - padding);
|
|
46
|
+
const fullEnd = padding === 0 ? text.length : text.length - CHARACTERS_PER_GROUP;
|
|
47
|
+
let write = 0;
|
|
48
|
+
for (let at = 0; at < fullEnd; at += CHARACTERS_PER_GROUP) {
|
|
49
|
+
const a2 = sextetAt(text, at);
|
|
50
|
+
const b2 = sextetAt(text, at + 1);
|
|
51
|
+
const c2 = sextetAt(text, at + 2);
|
|
52
|
+
const d = sextetAt(text, at + 3);
|
|
53
|
+
if ((a2 | b2 | c2 | d) < 0) return null;
|
|
54
|
+
const group = a2 << 18 | b2 << 12 | c2 << 6 | d;
|
|
55
|
+
out[write++] = group >>> 16;
|
|
56
|
+
out[write++] = group >>> 8 & 255;
|
|
57
|
+
out[write++] = group & 255;
|
|
58
|
+
}
|
|
59
|
+
if (padding === 0) return out;
|
|
60
|
+
const a = sextetAt(text, fullEnd);
|
|
61
|
+
const b = sextetAt(text, fullEnd + 1);
|
|
62
|
+
const c = padding === 1 ? sextetAt(text, fullEnd + 2) : 0;
|
|
63
|
+
if ((a | b | c) < 0) return null;
|
|
64
|
+
if (padding === 2 && (b & 15) !== 0) return null;
|
|
65
|
+
if (padding === 1 && (c & 3) !== 0) return null;
|
|
66
|
+
out[write++] = a << 2 | b >>> 4;
|
|
67
|
+
if (padding === 1) out[write] = (b & 15) << 4 | c >>> 2;
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/engine/export/tags.ts
|
|
72
|
+
var TAG_PREFIX = "$";
|
|
73
|
+
var DATE_TAG = "$date";
|
|
74
|
+
var BYTES_TAG = "$bytes";
|
|
75
|
+
var NUMBER_TAG = "$number";
|
|
76
|
+
var OBJECT_TAG = "$object";
|
|
77
|
+
var MILLISECONDS_PER_SECOND = 1e3;
|
|
78
|
+
var NANOSECONDS_PER_MILLISECOND = 1e6;
|
|
79
|
+
var MAX_NANOSECONDS = 999999999;
|
|
80
|
+
var MAX_DATE_MILLISECONDS = 864e13;
|
|
81
|
+
var ESCAPED_TAG_PREFIX = "\\u0024";
|
|
82
|
+
var NON_FINITE_NUMBERS = /* @__PURE__ */ new Map([
|
|
83
|
+
["NaN", Number.NaN],
|
|
84
|
+
["Infinity", Number.POSITIVE_INFINITY],
|
|
85
|
+
["-Infinity", Number.NEGATIVE_INFINITY]
|
|
86
|
+
]);
|
|
87
|
+
function refuse(path, reason) {
|
|
88
|
+
throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Field "${path === "" ? "(document)" : path}" ${reason}`, {
|
|
89
|
+
field: path
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function isRecord(value) {
|
|
93
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
94
|
+
}
|
|
95
|
+
function startsWithTagPrefix(key) {
|
|
96
|
+
return key.startsWith(TAG_PREFIX);
|
|
97
|
+
}
|
|
98
|
+
function soleTagKey(record) {
|
|
99
|
+
let sole = null;
|
|
100
|
+
for (const key of Object.keys(record)) {
|
|
101
|
+
if (sole !== null) return null;
|
|
102
|
+
sole = key;
|
|
103
|
+
}
|
|
104
|
+
return sole !== null && startsWithTagPrefix(sole) ? sole : null;
|
|
105
|
+
}
|
|
106
|
+
function dateOf(value, path) {
|
|
107
|
+
if (!Array.isArray(value) || value.length !== 2)
|
|
108
|
+
refuse(path, `holds a "${DATE_TAG}" tag other than [seconds, nanoseconds]`);
|
|
109
|
+
const seconds = value[0];
|
|
110
|
+
const nanoseconds = value[1];
|
|
111
|
+
if (typeof seconds !== "number" || !Number.isSafeInteger(seconds)) {
|
|
112
|
+
refuse(
|
|
113
|
+
path,
|
|
114
|
+
`holds a "${DATE_TAG}" tag whose seconds are not an integer from -${Number.MAX_SAFE_INTEGER} to ${Number.MAX_SAFE_INTEGER}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (typeof nanoseconds !== "number" || !Number.isInteger(nanoseconds) || nanoseconds < 0 || nanoseconds > MAX_NANOSECONDS) {
|
|
118
|
+
refuse(path, `holds a "${DATE_TAG}" tag whose nanoseconds are not an integer from 0 to ${MAX_NANOSECONDS}`);
|
|
119
|
+
}
|
|
120
|
+
const milliseconds = seconds * MILLISECONDS_PER_SECOND + nanoseconds / NANOSECONDS_PER_MILLISECOND;
|
|
121
|
+
if (Math.abs(milliseconds) > MAX_DATE_MILLISECONDS)
|
|
122
|
+
refuse(path, `holds a "${DATE_TAG}" tag outside the range of a date`);
|
|
123
|
+
return new Date(milliseconds);
|
|
124
|
+
}
|
|
125
|
+
function bytesOf(value, path) {
|
|
126
|
+
const bytes = typeof value === "string" ? decodeExactBase64(value) : null;
|
|
127
|
+
if (bytes === null) refuse(path, `holds a "${BYTES_TAG}" tag whose text is not padded base64`);
|
|
128
|
+
return bytes;
|
|
129
|
+
}
|
|
130
|
+
function numberOf(value, path) {
|
|
131
|
+
const number = typeof value === "string" ? NON_FINITE_NUMBERS.get(value) : void 0;
|
|
132
|
+
if (number === void 0) refuse(path, `holds a "${NUMBER_TAG}" tag other than "NaN", "Infinity", or "-Infinity"`);
|
|
133
|
+
return number;
|
|
134
|
+
}
|
|
135
|
+
function requireDepth(path, depth) {
|
|
136
|
+
if (depth >= MAX_DOCUMENT_NESTING_DEPTH) refuse(path, `nests deeper than ${MAX_DOCUMENT_NESTING_DEPTH} levels`);
|
|
137
|
+
}
|
|
138
|
+
function untagMap(record, path, depth) {
|
|
139
|
+
requireDepth(path, depth);
|
|
140
|
+
for (const key of Object.keys(record)) {
|
|
141
|
+
record[key] = untag(record[key], path === "" ? key : `${path}.${key}`, depth + 1);
|
|
142
|
+
}
|
|
143
|
+
return record;
|
|
144
|
+
}
|
|
145
|
+
function untagList(list, path, depth) {
|
|
146
|
+
requireDepth(path, depth);
|
|
147
|
+
for (let at = 0; at < list.length; at++) list[at] = untag(list[at], `${path}[${at}]`, depth + 1);
|
|
148
|
+
return list;
|
|
149
|
+
}
|
|
150
|
+
function untagTag(tag, value, path, depth) {
|
|
151
|
+
switch (tag) {
|
|
152
|
+
case DATE_TAG:
|
|
153
|
+
return dateOf(value, path);
|
|
154
|
+
case BYTES_TAG:
|
|
155
|
+
return bytesOf(value, path);
|
|
156
|
+
case NUMBER_TAG:
|
|
157
|
+
return numberOf(value, path);
|
|
158
|
+
case OBJECT_TAG:
|
|
159
|
+
if (!isRecord(value)) refuse(path, `holds an "${OBJECT_TAG}" tag whose value is not an object`);
|
|
160
|
+
return untagMap(value, path, depth);
|
|
161
|
+
default:
|
|
162
|
+
return refuse(path, `holds an object whose only key, "${tag}", names no tag`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function untag(value, path, depth) {
|
|
166
|
+
if (typeof value !== "object" || value === null) return value;
|
|
167
|
+
if (Array.isArray(value)) return untagList(value, path, depth);
|
|
168
|
+
const record = value;
|
|
169
|
+
const tag = soleTagKey(record);
|
|
170
|
+
return tag === null ? untagMap(record, path, depth) : untagTag(tag, record[tag], path, depth);
|
|
171
|
+
}
|
|
172
|
+
function untagDocumentLine(text, parsed) {
|
|
173
|
+
if (!text.includes(`"${TAG_PREFIX}`) && !text.includes(ESCAPED_TAG_PREFIX)) return parsed;
|
|
174
|
+
return untagMap(parsed, "", 0);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export { BYTES_TAG, DATE_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, NUMBER_TAG, OBJECT_TAG, encodeBase64, startsWithTagPrefix, untagDocumentLine };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { restoredEmbedding, restoredPartitionConfig, readSharedConfigFields } from './chunk-
|
|
2
|
-
import { MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-
|
|
3
|
-
import { generateId } from './chunk-N37VMC62.mjs';
|
|
1
|
+
import { restoredEmbedding, restoredPartitionConfig, readSharedConfigFields } from './chunk-L76W3IZJ.mjs';
|
|
2
|
+
import { MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-JDDXV6UF.mjs';
|
|
4
3
|
import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-EEBCDP36.mjs';
|
|
4
|
+
import { generateId } from './chunk-N37VMC62.mjs';
|
|
5
5
|
import { getLanguage, decodeSynonymRules } from './chunk-WNBRW4Q2.mjs';
|
|
6
6
|
import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
7
7
|
import { NarsilError, ErrorCodes } from './chunk-HNHCNTVG.mjs';
|
|
@@ -237,6 +237,7 @@ function settingsFieldsOf(source) {
|
|
|
237
237
|
...source.surfaceForms !== void 0 ? { surfaceForms: source.surfaceForms } : {},
|
|
238
238
|
...source.defaultScoring !== void 0 ? { defaultScoring: source.defaultScoring } : {},
|
|
239
239
|
...source.trackPositions !== void 0 ? { trackPositions: source.trackPositions } : {},
|
|
240
|
+
...source.textStorage !== void 0 ? { textStorage: source.textStorage } : {},
|
|
240
241
|
...source.strict !== void 0 ? { strict: source.strict } : {},
|
|
241
242
|
...source.required !== void 0 ? { required: source.required } : {},
|
|
242
243
|
...source.vectorPromotion !== void 0 ? { vectorPromotion: source.vectorPromotion } : {},
|
|
@@ -1,10 +1,72 @@
|
|
|
1
|
-
import { flattenSchema } from './chunk-
|
|
1
|
+
import { flattenSchema } from './chunk-KGOXHLLZ.mjs';
|
|
2
2
|
import { PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH } from './chunk-FQBFZAWG.mjs';
|
|
3
3
|
import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
|
|
4
4
|
import { isWordIndexedBase } from './chunk-ZSWHPKGM.mjs';
|
|
5
5
|
import { encodeStringBlob, tokenize, resolveStopWords, transformToken, visitTokens, visitSurfaceSpellings } from './chunk-NPNK57CA.mjs';
|
|
6
6
|
import { compareCodePoints, codePointCount } from './chunk-YTJCGKM4.mjs';
|
|
7
7
|
|
|
8
|
+
// src/core/partition/utils.ts
|
|
9
|
+
function getOrCreateFieldNameIndex(table, fieldName) {
|
|
10
|
+
const existing = table.indexMap.get(fieldName);
|
|
11
|
+
if (existing !== void 0) return existing;
|
|
12
|
+
const idx = table.names.length;
|
|
13
|
+
table.names.push(fieldName);
|
|
14
|
+
table.indexMap.set(fieldName, idx);
|
|
15
|
+
return idx;
|
|
16
|
+
}
|
|
17
|
+
var VECTOR_PATTERN = /^vector\[(\d+)]$/;
|
|
18
|
+
function getNestedValue(obj, path) {
|
|
19
|
+
const parts = path.split(".");
|
|
20
|
+
let current = obj;
|
|
21
|
+
for (let i = 0; i < parts.length; i++) {
|
|
22
|
+
if (current === null || current === void 0 || typeof current !== "object") return void 0;
|
|
23
|
+
if (!Object.hasOwn(current, parts[i])) return void 0;
|
|
24
|
+
current = current[parts[i]];
|
|
25
|
+
}
|
|
26
|
+
return current;
|
|
27
|
+
}
|
|
28
|
+
function stringArraysEqual(a, b) {
|
|
29
|
+
if (a === b) return true;
|
|
30
|
+
if (!a || !b) return false;
|
|
31
|
+
if (a.length !== b.length) return false;
|
|
32
|
+
for (let i = 0; i < a.length; i++) {
|
|
33
|
+
if (a[i] !== b[i]) return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
function textFieldsChanged(oldDoc, newDoc, fields) {
|
|
38
|
+
for (const { path, base } of fields) {
|
|
39
|
+
if (!isWordIndexedBase(base)) continue;
|
|
40
|
+
const oldVal = getNestedValue(oldDoc, path);
|
|
41
|
+
const newVal = getNestedValue(newDoc, path);
|
|
42
|
+
if (base === "string") {
|
|
43
|
+
if (oldVal !== newVal) return true;
|
|
44
|
+
} else {
|
|
45
|
+
if (!stringArraysEqual(oldVal, newVal)) return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function parseVectorDimension(fieldType) {
|
|
51
|
+
const match = VECTOR_PATTERN.exec(fieldType);
|
|
52
|
+
return match ? Number.parseInt(match[1], 10) : null;
|
|
53
|
+
}
|
|
54
|
+
function tokenizeOptions(options) {
|
|
55
|
+
return {
|
|
56
|
+
stem: true,
|
|
57
|
+
removeStopWords: true,
|
|
58
|
+
collectSurfaces: options?.collectSurfaces === true,
|
|
59
|
+
stopWordOverride: options?.stopWordOverride,
|
|
60
|
+
customTokenizer: options?.customTokenizer
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function getFlatSchema(state, schema) {
|
|
64
|
+
if (state.lastSchemaRef === schema && state.flatSchemaCache) return state.flatSchemaCache;
|
|
65
|
+
state.flatSchemaCache = flattenSchema(schema);
|
|
66
|
+
state.lastSchemaRef = schema;
|
|
67
|
+
return state.flatSchemaCache;
|
|
68
|
+
}
|
|
69
|
+
|
|
8
70
|
// src/core/partition/suggestions.ts
|
|
9
71
|
function verbatimOccurrences(state, token) {
|
|
10
72
|
const postingList = state.invertedIdx.lookup(token);
|
|
@@ -167,68 +229,6 @@ var GROWING_PARTIAL_RUN_BYTES = 120;
|
|
|
167
229
|
var GROWING_PARTIAL_RUN_MEMBER_BYTES = 24;
|
|
168
230
|
var FROZEN_PARTIAL_REMOVED_ENTRY_BYTES = 48;
|
|
169
231
|
|
|
170
|
-
// src/core/partition/utils.ts
|
|
171
|
-
function getOrCreateFieldNameIndex(table, fieldName) {
|
|
172
|
-
const existing = table.indexMap.get(fieldName);
|
|
173
|
-
if (existing !== void 0) return existing;
|
|
174
|
-
const idx = table.names.length;
|
|
175
|
-
table.names.push(fieldName);
|
|
176
|
-
table.indexMap.set(fieldName, idx);
|
|
177
|
-
return idx;
|
|
178
|
-
}
|
|
179
|
-
var VECTOR_PATTERN = /^vector\[(\d+)]$/;
|
|
180
|
-
function getNestedValue(obj, path) {
|
|
181
|
-
const parts = path.split(".");
|
|
182
|
-
let current = obj;
|
|
183
|
-
for (let i = 0; i < parts.length; i++) {
|
|
184
|
-
if (current === null || current === void 0 || typeof current !== "object") return void 0;
|
|
185
|
-
if (!Object.hasOwn(current, parts[i])) return void 0;
|
|
186
|
-
current = current[parts[i]];
|
|
187
|
-
}
|
|
188
|
-
return current;
|
|
189
|
-
}
|
|
190
|
-
function stringArraysEqual(a, b) {
|
|
191
|
-
if (a === b) return true;
|
|
192
|
-
if (!a || !b) return false;
|
|
193
|
-
if (a.length !== b.length) return false;
|
|
194
|
-
for (let i = 0; i < a.length; i++) {
|
|
195
|
-
if (a[i] !== b[i]) return false;
|
|
196
|
-
}
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
function textFieldsChanged(oldDoc, newDoc, fields) {
|
|
200
|
-
for (const { path, base } of fields) {
|
|
201
|
-
if (!isWordIndexedBase(base)) continue;
|
|
202
|
-
const oldVal = getNestedValue(oldDoc, path);
|
|
203
|
-
const newVal = getNestedValue(newDoc, path);
|
|
204
|
-
if (base === "string") {
|
|
205
|
-
if (oldVal !== newVal) return true;
|
|
206
|
-
} else {
|
|
207
|
-
if (!stringArraysEqual(oldVal, newVal)) return true;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
function parseVectorDimension(fieldType) {
|
|
213
|
-
const match = VECTOR_PATTERN.exec(fieldType);
|
|
214
|
-
return match ? Number.parseInt(match[1], 10) : null;
|
|
215
|
-
}
|
|
216
|
-
function tokenizeOptions(options) {
|
|
217
|
-
return {
|
|
218
|
-
stem: true,
|
|
219
|
-
removeStopWords: true,
|
|
220
|
-
collectSurfaces: options?.collectSurfaces === true,
|
|
221
|
-
stopWordOverride: options?.stopWordOverride,
|
|
222
|
-
customTokenizer: options?.customTokenizer
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function getFlatSchema(state, schema) {
|
|
226
|
-
if (state.lastSchemaRef === schema && state.flatSchemaCache) return state.flatSchemaCache;
|
|
227
|
-
state.flatSchemaCache = flattenSchema(schema);
|
|
228
|
-
state.lastSchemaRef = schema;
|
|
229
|
-
return state.flatSchemaCache;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
232
|
// src/core/partition/partial-words/spellings.ts
|
|
233
233
|
var LAST_BASIC_PLANE_CODE_POINT2 = 65535;
|
|
234
234
|
function codePointCountOf(text) {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { readSync, openSync, read, closeSync } from 'fs';
|
|
2
|
+
|
|
3
|
+
// src/vector/vector-store/vector-file.ts
|
|
4
|
+
function createVectorFileReader() {
|
|
5
|
+
const descriptors = /* @__PURE__ */ new Map();
|
|
6
|
+
const readsWaiting = /* @__PURE__ */ new Map();
|
|
7
|
+
const closingAfterReads = /* @__PURE__ */ new Set();
|
|
8
|
+
function descriptorOf(path) {
|
|
9
|
+
const open = descriptors.get(path);
|
|
10
|
+
if (open !== void 0) return open;
|
|
11
|
+
try {
|
|
12
|
+
const descriptor = openSync(path, "r");
|
|
13
|
+
descriptors.set(path, descriptor);
|
|
14
|
+
return descriptor;
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function closeNow(descriptor) {
|
|
20
|
+
try {
|
|
21
|
+
closeSync(descriptor);
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function closeDescriptor(path, descriptor) {
|
|
26
|
+
descriptors.delete(path);
|
|
27
|
+
if ((readsWaiting.get(descriptor) ?? 0) > 0) closingAfterReads.add(descriptor);
|
|
28
|
+
else closeNow(descriptor);
|
|
29
|
+
}
|
|
30
|
+
function finishRead(descriptor) {
|
|
31
|
+
const waiting = (readsWaiting.get(descriptor) ?? 1) - 1;
|
|
32
|
+
if (waiting > 0) {
|
|
33
|
+
readsWaiting.set(descriptor, waiting);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
readsWaiting.delete(descriptor);
|
|
37
|
+
if (closingAfterReads.delete(descriptor)) closeNow(descriptor);
|
|
38
|
+
}
|
|
39
|
+
function readRest(descriptor, offset, target, done, finish) {
|
|
40
|
+
read(descriptor, target, done, target.byteLength - done, offset + done, (error, chunk) => {
|
|
41
|
+
if (error !== null || chunk <= 0) finish(false);
|
|
42
|
+
else if (done + chunk === target.byteLength) finish(true);
|
|
43
|
+
else readRest(descriptor, offset, target, done + chunk, finish);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
readInto(path, offset, target) {
|
|
48
|
+
const descriptor = descriptorOf(path);
|
|
49
|
+
if (descriptor === null) return false;
|
|
50
|
+
let read = 0;
|
|
51
|
+
while (read < target.byteLength) {
|
|
52
|
+
let chunk;
|
|
53
|
+
try {
|
|
54
|
+
chunk = readSync(descriptor, target, read, target.byteLength - read, offset + read);
|
|
55
|
+
} catch {
|
|
56
|
+
closeDescriptor(path, descriptor);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (chunk <= 0) return false;
|
|
60
|
+
read += chunk;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
readLater(path, offset, target) {
|
|
65
|
+
const descriptor = descriptorOf(path);
|
|
66
|
+
if (descriptor === null) return Promise.resolve(false);
|
|
67
|
+
if (target.byteLength === 0) return Promise.resolve(true);
|
|
68
|
+
readsWaiting.set(descriptor, (readsWaiting.get(descriptor) ?? 0) + 1);
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
readRest(descriptor, offset, target, 0, (whole) => {
|
|
71
|
+
finishRead(descriptor);
|
|
72
|
+
resolve(whole);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
retainOnly(paths) {
|
|
77
|
+
for (const [path, descriptor] of descriptors) {
|
|
78
|
+
if (!paths.has(path)) closeDescriptor(path, descriptor);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
close() {
|
|
82
|
+
for (const [path, descriptor] of descriptors) closeDescriptor(path, descriptor);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { createVectorFileReader };
|
|
@@ -14,7 +14,7 @@ function requireLoadedVectorCode() {
|
|
|
14
14
|
function loadVectorCode() {
|
|
15
15
|
if (loaded !== null) return Promise.resolve(loaded);
|
|
16
16
|
if (loading === null) {
|
|
17
|
-
loading = import('./module-
|
|
17
|
+
loading = import('./module-DXSJ5LT2.mjs').then(
|
|
18
18
|
(code) => {
|
|
19
19
|
loaded = code;
|
|
20
20
|
return code;
|