@delali/narsil 0.3.0 → 0.3.1-next.101
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/README.md +9 -8
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/{adapters-79OIa4xm.d.ts → adapters-BQFQ4PRz.d.ts} +27 -1
- package/dist/browser/chunk-BDOSMEEP.mjs +493 -0
- package/dist/browser/chunk-EJDUFWSO.mjs +602 -0
- package/dist/browser/chunk-HOZW3PKP.mjs +9 -0
- package/dist/browser/chunk-JOVZ6HMT.mjs +4358 -0
- package/dist/browser/chunk-JPTQZWJQ.mjs +10 -0
- package/dist/browser/chunk-KPJMDPHG.mjs +24558 -0
- package/dist/browser/chunk-PGIM3HIM.mjs +2743 -0
- package/dist/browser/chunk-RHG4O77A.mjs +206 -0
- package/dist/browser/chunk-RIJSLY2I.mjs +360 -0
- package/dist/browser/durability-wiring-SRUYT3VV.mjs +3875 -0
- package/dist/browser/module-CBB2ETYP.mjs +3111 -0
- package/dist/browser/release-76MXRPGV.mjs +33 -0
- package/dist/browser/replace-RURXTGVG.mjs +57 -0
- package/dist/browser/restore-queue-EEZQO6RF.mjs +35 -0
- package/dist/browser/runtime-7ZAHCHWR.mjs +557 -0
- package/dist/browser/snapshot-OAAA5UJ7.mjs +1210 -0
- package/dist/browser/write-7D6VIK6O.mjs +208 -0
- package/dist/{capabilities-DSsOGz6F.d.ts → capabilities-DiGlB6Sr.d.ts} +68 -7
- package/dist/chunk-2RIRGOUL.mjs +113 -0
- package/dist/chunk-37CD3OKS.mjs +87 -0
- package/dist/chunk-44W3CBNG.mjs +7 -0
- package/dist/chunk-46D6JQIG.mjs +426 -0
- package/dist/{chunk-VMRR3DQU.mjs → chunk-5JNA5SKS.mjs} +546 -35
- package/dist/chunk-747OHOUA.mjs +11 -0
- package/dist/chunk-75XIEF6H.mjs +126 -0
- package/dist/chunk-7X5JST5L.mjs +114 -0
- package/dist/chunk-BOFBLJFZ.mjs +209 -0
- package/dist/{chunk-USKFU7J5.mjs → chunk-BWJVNZPR.mjs} +8 -1
- package/dist/chunk-C7SLA6CM.mjs +19 -0
- package/dist/{chunk-POWOTUKJ.mjs → chunk-CQUMNIIG.mjs} +3 -6
- package/dist/chunk-CVXLLEQ3.mjs +1011 -0
- package/dist/chunk-DJHHF2L5.mjs +17 -0
- package/dist/chunk-E74YLAIG.mjs +24 -0
- package/dist/{chunk-UXNWQZST.mjs → chunk-EMRMGYRE.mjs} +236 -18
- package/dist/chunk-EWZLIYHV.mjs +57 -0
- package/dist/chunk-GBEEG5AN.mjs +35 -0
- package/dist/chunk-GES7U2PM.mjs +68 -0
- package/dist/chunk-HJSN7UYG.mjs +10 -0
- package/dist/chunk-HLPRHOSO.mjs +17 -0
- package/dist/chunk-HMFNFVP7.mjs +14 -0
- package/dist/chunk-J5QP52HA.mjs +1751 -0
- package/dist/{chunk-YNVIUGF5.mjs → chunk-JZVARCRZ.mjs} +3 -28
- package/dist/chunk-KOKM4PQN.mjs +52 -0
- package/dist/{chunk-B2TFROFX.mjs → chunk-KWTW6VTG.mjs} +465 -250
- package/dist/chunk-KZ3NX2P7.mjs +21 -0
- package/dist/chunk-L5ORED7V.mjs +25 -0
- package/dist/{chunk-THYRHHO2.mjs → chunk-LGAMKHA2.mjs} +2009 -2351
- package/dist/chunk-LKOB5COA.mjs +117 -0
- package/dist/chunk-LPQOEU5M.mjs +96 -0
- package/dist/{chunk-3LHGNRYE.mjs → chunk-LXWDQLTW.mjs} +7 -2
- package/dist/{chunk-L6TNPLAR.mjs → chunk-OEYI3KRB.mjs} +270 -108
- package/dist/chunk-OM362BRO.mjs +948 -0
- package/dist/chunk-OZDFA4WC.mjs +67 -0
- package/dist/chunk-P36MUFEJ.mjs +10 -0
- package/dist/chunk-PC2G76VW.mjs +2540 -0
- package/dist/{chunk-GCM3JFVA.mjs → chunk-PNEYIHA4.mjs} +11 -2
- package/dist/chunk-PNFKUCG3.mjs +1130 -0
- package/dist/chunk-Q6XWVUZX.mjs +44 -0
- package/dist/chunk-R27EMH5M.mjs +617 -0
- package/dist/{chunk-YMZCMH5M.mjs → chunk-R6A773WK.mjs} +19 -24
- package/dist/chunk-RF7PLG43.mjs +106 -0
- package/dist/chunk-RFBLQLLZ.mjs +16 -0
- package/dist/{chunk-Y3L5MDRV.mjs → chunk-RFVUDM5E.mjs} +17 -2
- package/dist/chunk-S7FL6UAH.mjs +521 -0
- package/dist/chunk-S7GNDRPS.mjs +651 -0
- package/dist/chunk-SP3NM3ZG.mjs +3537 -0
- package/dist/chunk-U476IXKQ.mjs +10 -0
- package/dist/chunk-UA3AUGNV.mjs +462 -0
- package/dist/chunk-UTG5YNXV.mjs +507 -0
- package/dist/chunk-VI4R6W25.mjs +8484 -0
- package/dist/chunk-WQBCBKY3.mjs +8 -0
- package/dist/{chunk-24RXHMEL.mjs → chunk-WVCOCKBU.mjs} +3794 -7570
- package/dist/chunk-X5CV2E2B.mjs +1 -0
- package/dist/chunk-XADZPPZI.mjs +614 -0
- package/dist/chunk-YEEQHT4V.mjs +212 -0
- package/dist/chunk-YTJCGKM4.mjs +56 -0
- package/dist/chunk-YYQIODMF.mjs +275 -0
- package/dist/chunk-ZI34TVOA.mjs +144 -0
- package/dist/{chunk-OOSIDHA3.mjs → chunk-ZKWYWW4Y.mjs} +1 -1
- package/dist/chunk-ZM7KU4YW.mjs +35 -0
- package/dist/{client-BQK6Tf6A.d.ts → client-BOStAkc5.d.ts} +160 -37
- package/dist/client.d.ts +11 -10
- package/dist/client.mjs +209 -45
- package/dist/{config-DmXULPa-.d.ts → config-Cjvzbs_j.d.ts} +51 -3
- package/dist/config-DffQlmRq.d.ts +421 -0
- package/dist/direct-executor-ZD64PPEZ.mjs +24 -0
- package/dist/distribution/coordinator/etcd.d.ts +79 -18
- package/dist/distribution/coordinator/etcd.mjs +553 -109
- package/dist/distribution/coordinator/in-memory.d.ts +4 -3
- package/dist/distribution/coordinator/in-memory.mjs +22 -3
- package/dist/distribution/transport/grpc.d.ts +2 -2
- package/dist/distribution/transport/grpc.mjs +79 -14
- package/dist/distribution/transport/in-memory.d.ts +2 -2
- package/dist/distribution/transport/in-memory.mjs +12 -7
- package/dist/distribution/transport/tcp.d.ts +2 -2
- package/dist/distribution/transport/tcp.mjs +50 -28
- package/dist/distribution.d.ts +144 -23
- package/dist/distribution.mjs +14479 -8173
- package/dist/durability-wiring-FEUBR5BT.mjs +3330 -0
- package/dist/embeddings/openai.d.ts +2 -2
- package/dist/embeddings/openai.mjs +22 -133
- package/dist/{engine-CIOyFozK.d.ts → engine-rC0vjjY-.d.ts} +165 -141
- package/dist/{memory-yFaVn2xZ.d.ts → events-DqOIg5xa.d.ts} +645 -136
- package/dist/{types-DAK7mnUZ.d.ts → index-Bkdt8nDw.d.ts} +182 -45
- package/dist/index.browser.mjs +4 -32180
- package/dist/index.d.ts +91 -20
- package/dist/index.mjs +33 -16
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +2 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/module-3S65MVCM.mjs +2151 -0
- package/dist/partial-words-DTIHO8G4.d.ts +19 -0
- package/dist/partial-words.d.ts +22 -0
- package/dist/partial-words.mjs +17 -0
- package/dist/pattern-Cledccbl.d.ts +18 -0
- package/dist/pattern.d.ts +22 -0
- package/dist/pattern.mjs +12 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +119 -72
- package/dist/persistence/durability/checkpoint-worker.mjs +51 -18
- package/dist/react.d.ts +279 -183
- package/dist/react.mjs +201 -48
- package/dist/release-BH3DKW3T.mjs +33 -0
- package/dist/replace-CEO5KJJ3.mjs +57 -0
- package/dist/rerank-K7C4WZFG.mjs +60 -0
- package/dist/rerankers/http.d.ts +50 -0
- package/dist/rerankers/http.mjs +104 -0
- package/dist/restore-queue-KQHA7ZV2.mjs +35 -0
- package/dist/runtime-6Y4ZYXOG.mjs +177 -0
- package/dist/{schema-d5Afu03A.d.ts → schema-4W_7tk1f.d.ts} +81 -11
- package/dist/server.d.ts +13 -12
- package/dist/server.mjs +611 -80
- package/dist/snapshot-QGZPODM5.mjs +799 -0
- package/dist/synonyms-CpOAHPa-.d.ts +52 -0
- package/dist/synonyms.d.ts +22 -0
- package/dist/synonyms.mjs +12 -0
- package/dist/{tasks-CH2Dod8w.d.ts → tasks-CwPTz-tP.d.ts} +10 -3
- package/dist/thread-N3IUGUS3.mjs +697 -0
- package/dist/{types-BQDlIvfS.d.ts → types-2qoitTXg.d.ts} +1 -1
- package/dist/{types-D5OwhtsQ.d.ts → types-Cz5okLml.d.ts} +2 -2
- package/dist/vector/search-worker.d.ts +46 -4
- package/dist/vector/search-worker.mjs +21 -11
- package/dist/workers/entry.mjs +9 -6
- package/dist/write-U5RI7MAX.mjs +241 -0
- package/package.json +55 -9
- package/dist/chunk-3L4U6EJQ.mjs +0 -49
- package/dist/chunk-IFBKLBGB.mjs +0 -7
- package/dist/chunk-ORBLD3EL.mjs +0 -6
- package/dist/chunk-U7KYW4BA.mjs +0 -135
- package/dist/chunk-ZJ4CSAB2.mjs +0 -13
- package/dist/chunk-ZNZBXMP5.mjs +0 -2117
- package/dist/chunk-ZZT3EAUC.mjs +0 -11168
- package/dist/config-BhldZgaK.d.ts +0 -194
- package/dist/direct-executor-ALAVE7FC.mjs +0 -12
- package/dist/serialization/crc32-worker.d.ts +0 -20
- package/dist/serialization/crc32-worker.mjs +0 -62
- package/dist/simd-DW5AtJ6B.d.ts +0 -41
- package/dist/thread-DYHEQRVY.mjs +0 -402
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { PARSED_FIELD_TYPE_CACHE_ENTRIES, VECTOR_PATTERN, MAX_STORED_VECTOR_DIMENSION } from './chunk-L5ORED7V.mjs';
|
|
2
|
+
import { NarsilError, ErrorCodes } from './chunk-BWJVNZPR.mjs';
|
|
3
|
+
|
|
4
|
+
// src/schema/validator/field-type.ts
|
|
5
|
+
var FIELD_OPTION_ORDER = ["sortable", "pattern", "partial"];
|
|
6
|
+
var OPTIONS_BY_BASE = {
|
|
7
|
+
string: FIELD_OPTION_ORDER,
|
|
8
|
+
"string[]": FIELD_OPTION_ORDER,
|
|
9
|
+
verbatim: ["sortable"],
|
|
10
|
+
"verbatim[]": ["sortable"],
|
|
11
|
+
number: [],
|
|
12
|
+
"number[]": [],
|
|
13
|
+
boolean: [],
|
|
14
|
+
"boolean[]": [],
|
|
15
|
+
enum: [],
|
|
16
|
+
"enum[]": [],
|
|
17
|
+
geopoint: [],
|
|
18
|
+
vector: []
|
|
19
|
+
};
|
|
20
|
+
var TYPE_SEPARATOR = ":";
|
|
21
|
+
function isNamedBase(name) {
|
|
22
|
+
return name !== "vector" && Object.hasOwn(OPTIONS_BY_BASE, name);
|
|
23
|
+
}
|
|
24
|
+
function describeAllowedOptions(baseName, allowed) {
|
|
25
|
+
if (allowed.length === 0) return `the "${baseName}" type has no options`;
|
|
26
|
+
const quoted = allowed.map((option) => `"${option}"`);
|
|
27
|
+
if (quoted.length === 1) return `the only option of the "${baseName}" type is ${quoted[0]}`;
|
|
28
|
+
return `the options of the "${baseName}" type are ${quoted.slice(0, -1).join(", ")}, and ${quoted[quoted.length - 1]}`;
|
|
29
|
+
}
|
|
30
|
+
function invalidType(path, type, message) {
|
|
31
|
+
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, message, { field: path, type });
|
|
32
|
+
}
|
|
33
|
+
function parseBase(baseName, path, type) {
|
|
34
|
+
if (isNamedBase(baseName)) return { base: baseName, dimension: 0 };
|
|
35
|
+
const vectorMatch = VECTOR_PATTERN.exec(baseName);
|
|
36
|
+
if (vectorMatch === null) {
|
|
37
|
+
invalidType(path, type, `Field "${path}" has an unsupported type: "${type}"`);
|
|
38
|
+
}
|
|
39
|
+
const dimension = Number.parseInt(vectorMatch[1], 10);
|
|
40
|
+
if (dimension <= 0 || dimension > MAX_STORED_VECTOR_DIMENSION) {
|
|
41
|
+
throw new NarsilError(
|
|
42
|
+
ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
|
|
43
|
+
`Vector field "${path}" has ${dimension} dimensions, but a vector field holds from 1 to ${MAX_STORED_VECTOR_DIMENSION}`,
|
|
44
|
+
{ field: path, dimension, maximum: MAX_STORED_VECTOR_DIMENSION }
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return { base: "vector", dimension };
|
|
48
|
+
}
|
|
49
|
+
function parseFieldType(type, path) {
|
|
50
|
+
const separatorIndex = type.indexOf(TYPE_SEPARATOR);
|
|
51
|
+
const baseName = separatorIndex === -1 ? type : type.slice(0, separatorIndex);
|
|
52
|
+
const { base, dimension } = parseBase(baseName, path, type);
|
|
53
|
+
const allowed = OPTIONS_BY_BASE[base];
|
|
54
|
+
const options = /* @__PURE__ */ new Set();
|
|
55
|
+
if (separatorIndex !== -1) {
|
|
56
|
+
for (const option of type.slice(separatorIndex + 1).split(TYPE_SEPARATOR)) {
|
|
57
|
+
if (!allowed.includes(option)) {
|
|
58
|
+
invalidType(
|
|
59
|
+
path,
|
|
60
|
+
type,
|
|
61
|
+
`Field "${path}" has type "${type}" with the option "${option}", but ${describeAllowedOptions(baseName, allowed)}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (options.has(option)) {
|
|
65
|
+
invalidType(path, type, `Field "${path}" has the "${option}" option twice in type "${type}"`);
|
|
66
|
+
}
|
|
67
|
+
options.add(option);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const ordered = FIELD_OPTION_ORDER.filter((option) => options.has(option));
|
|
71
|
+
const verbatim = base === "verbatim" || base === "verbatim[]";
|
|
72
|
+
return {
|
|
73
|
+
type: [baseName, ...ordered].join(TYPE_SEPARATOR),
|
|
74
|
+
base,
|
|
75
|
+
sortable: options.has("sortable"),
|
|
76
|
+
pattern: verbatim || options.has("pattern"),
|
|
77
|
+
partial: options.has("partial"),
|
|
78
|
+
dimension
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
var parsedTypesByName = /* @__PURE__ */ new Map();
|
|
82
|
+
function parsedTypeOf(type) {
|
|
83
|
+
if (type === void 0) return void 0;
|
|
84
|
+
const known = parsedTypesByName.get(type);
|
|
85
|
+
if (known !== void 0) return known;
|
|
86
|
+
try {
|
|
87
|
+
const parsed = Object.freeze(parseFieldType(type, ""));
|
|
88
|
+
if (parsedTypesByName.size < PARSED_FIELD_TYPE_CACHE_ENTRIES) parsedTypesByName.set(type, parsed);
|
|
89
|
+
return parsed;
|
|
90
|
+
} catch {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function withSortableOption(parsed) {
|
|
95
|
+
if (parsed.sortable) return parsed.type;
|
|
96
|
+
const separatorIndex = parsed.type.indexOf(TYPE_SEPARATOR);
|
|
97
|
+
const baseName = separatorIndex === -1 ? parsed.type : parsed.type.slice(0, separatorIndex);
|
|
98
|
+
return parseFieldType(`${baseName}${TYPE_SEPARATOR}sortable${parsed.type.slice(baseName.length)}`, "").type;
|
|
99
|
+
}
|
|
100
|
+
function isListBase(base) {
|
|
101
|
+
return base.endsWith("[]");
|
|
102
|
+
}
|
|
103
|
+
function isWordIndexedBase(base) {
|
|
104
|
+
return base === "string" || base === "string[]";
|
|
105
|
+
}
|
|
106
|
+
function isSingleStringFieldType(fieldType) {
|
|
107
|
+
return parsedTypeOf(fieldType)?.base === "string";
|
|
108
|
+
}
|
|
109
|
+
function isWordIndexedFieldType(fieldType) {
|
|
110
|
+
const parsed = parsedTypeOf(fieldType);
|
|
111
|
+
return parsed !== void 0 && isWordIndexedBase(parsed.base);
|
|
112
|
+
}
|
|
113
|
+
function isStringValuedBase(base) {
|
|
114
|
+
return base === "string" || base === "string[]" || base === "verbatim" || base === "verbatim[]";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { isListBase, isSingleStringFieldType, isStringValuedBase, isWordIndexedBase, isWordIndexedFieldType, parseFieldType, parsedTypeOf, withSortableOption };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { totalmem } from 'os';
|
|
2
|
+
import { getHeapSpaceStatistics, getHeapStatistics } from 'v8';
|
|
3
|
+
|
|
4
|
+
// src/runtime/heap-statistics.ts
|
|
5
|
+
var MEGABYTE_BYTES = 1048576;
|
|
6
|
+
var IN_MEGABYTES = /^--max-old-space-size=(\d+)$/;
|
|
7
|
+
var AS_PERCENTAGE = /^--max-old-space-size-percentage=(\d+(?:\.\d+)?)$/;
|
|
8
|
+
var SEMI_SPACE_IN_MEGABYTES = /^--max-semi-space-size=(\d+)$/;
|
|
9
|
+
var YOUNG_GENERATION_SPACES = /* @__PURE__ */ new Set(["new_space", "new_large_object_space"]);
|
|
10
|
+
var V8_YOUNG_GENERATION_BYTES_PER_SEMI_SPACE_BYTE = 3;
|
|
11
|
+
function flagEntries() {
|
|
12
|
+
const fromNodeOptions = (process.env.NODE_OPTIONS ?? "").split(/\s+/).filter((entry) => entry.length > 0);
|
|
13
|
+
return [...process.execArgv, ...fromNodeOptions];
|
|
14
|
+
}
|
|
15
|
+
function memoryTheHostAllows() {
|
|
16
|
+
const constrained = process.constrainedMemory?.() ?? 0;
|
|
17
|
+
return constrained > 0 ? constrained : totalmem();
|
|
18
|
+
}
|
|
19
|
+
function readConfiguredLimit() {
|
|
20
|
+
let megabytes = null;
|
|
21
|
+
let percentage = null;
|
|
22
|
+
for (const entry of flagEntries()) {
|
|
23
|
+
const inMegabytes = IN_MEGABYTES.exec(entry);
|
|
24
|
+
if (inMegabytes !== null) {
|
|
25
|
+
megabytes = Number(inMegabytes[1]);
|
|
26
|
+
percentage = null;
|
|
27
|
+
}
|
|
28
|
+
const asPercentage = AS_PERCENTAGE.exec(entry);
|
|
29
|
+
if (asPercentage !== null) {
|
|
30
|
+
percentage = Number(asPercentage[1]);
|
|
31
|
+
megabytes = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const bytes = megabytes !== null && megabytes > 0 ? megabytes * MEGABYTE_BYTES : percentage !== null && percentage > 0 && percentage <= 100 ? Math.floor(memoryTheHostAllows() * percentage / 100) : null;
|
|
35
|
+
return bytes !== null && Number.isFinite(bytes) && bytes > 0 ? bytes : null;
|
|
36
|
+
}
|
|
37
|
+
var configuredLimit;
|
|
38
|
+
function configuredLimitBytes() {
|
|
39
|
+
if (configuredLimit === void 0) configuredLimit = readConfiguredLimit();
|
|
40
|
+
return configuredLimit;
|
|
41
|
+
}
|
|
42
|
+
function readConfiguredYoungGeneration() {
|
|
43
|
+
let megabytes = 0;
|
|
44
|
+
for (const entry of flagEntries()) {
|
|
45
|
+
const semiSpace = SEMI_SPACE_IN_MEGABYTES.exec(entry);
|
|
46
|
+
if (semiSpace !== null) megabytes = Number(semiSpace[1]);
|
|
47
|
+
}
|
|
48
|
+
if (!Number.isFinite(megabytes) || megabytes <= 0) return null;
|
|
49
|
+
const semiSpaceBytes = 2 ** Math.ceil(Math.log2(megabytes)) * MEGABYTE_BYTES;
|
|
50
|
+
return semiSpaceBytes * V8_YOUNG_GENERATION_BYTES_PER_SEMI_SPACE_BYTE;
|
|
51
|
+
}
|
|
52
|
+
var configuredYoungGeneration;
|
|
53
|
+
function configuredYoungGenerationBytes() {
|
|
54
|
+
if (configuredYoungGeneration === void 0) configuredYoungGeneration = readConfiguredYoungGeneration();
|
|
55
|
+
return configuredYoungGeneration;
|
|
56
|
+
}
|
|
57
|
+
var heapSizeLimit;
|
|
58
|
+
function heapSizeLimitBytes() {
|
|
59
|
+
if (heapSizeLimit === void 0) heapSizeLimit = getHeapStatistics().heap_size_limit;
|
|
60
|
+
return heapSizeLimit;
|
|
61
|
+
}
|
|
62
|
+
function readOldGenerationStatistics() {
|
|
63
|
+
try {
|
|
64
|
+
let usedBytes = 0;
|
|
65
|
+
let youngCapacityBytes = 0;
|
|
66
|
+
let youngUsedBytes = 0;
|
|
67
|
+
for (const space of getHeapSpaceStatistics()) {
|
|
68
|
+
if (YOUNG_GENERATION_SPACES.has(space.space_name)) {
|
|
69
|
+
youngCapacityBytes += space.space_size;
|
|
70
|
+
youngUsedBytes += space.space_used_size;
|
|
71
|
+
} else {
|
|
72
|
+
usedBytes += space.space_used_size;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const limitBytes = configuredLimitBytes() ?? heapSizeLimitBytes() - (configuredYoungGenerationBytes() ?? youngCapacityBytes);
|
|
76
|
+
if (!Number.isFinite(usedBytes) || !Number.isFinite(limitBytes) || limitBytes <= 0) return null;
|
|
77
|
+
return { usedBytes, limitBytes, youngUsedBytes: Number.isFinite(youngUsedBytes) ? youngUsedBytes : 0 };
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function readHeapStatistics() {
|
|
83
|
+
try {
|
|
84
|
+
const stats = getHeapStatistics();
|
|
85
|
+
const usedBytes = stats.used_heap_size;
|
|
86
|
+
const limitBytes = stats.heap_size_limit;
|
|
87
|
+
if (!Number.isFinite(usedBytes) || !Number.isFinite(limitBytes) || limitBytes <= 0) return null;
|
|
88
|
+
const available = stats.total_available_size;
|
|
89
|
+
const availableBytes = Number.isFinite(available) && available >= 0 ? available : null;
|
|
90
|
+
return { usedBytes, limitBytes, availableBytes, configuredLimitBytes: configuredLimitBytes() };
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { readHeapStatistics, readOldGenerationStatistics };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_SIZE } from './chunk-
|
|
1
|
+
import { DEFAULT_PAGE_SIZE } from './chunk-E74YLAIG.mjs';
|
|
2
2
|
|
|
3
3
|
// src/engine/constants.ts
|
|
4
4
|
var MIN_DOCUMENTS_FOR_SEGMENTS = 64;
|
|
@@ -10,6 +10,11 @@ var ABSOLUTE_WINDOWS_PATH_PATTERN = /^[a-zA-Z]:[\\/]/;
|
|
|
10
10
|
var MODULE_URL_SCHEME_PATTERN = /^(file|https?|data|node):/;
|
|
11
11
|
var MAX_INDEX_NAME_LENGTH = 255;
|
|
12
12
|
var MAX_DOC_ID_LENGTH = 512;
|
|
13
|
+
var EXPORT_CHUNK_BYTES = 1048576;
|
|
14
|
+
var MAX_EXPORT_LINE_BYTES = 117443592;
|
|
15
|
+
var MAX_INDEX_CONFIGURATION_BYTES = 16777216;
|
|
16
|
+
var IMPORT_BATCH_DOCUMENTS = 1e3;
|
|
17
|
+
var MAX_IMPORT_REFUSALS_REPORTED = 1e3;
|
|
13
18
|
var MIN_SWEEP_INTERVAL_MS = 100;
|
|
14
19
|
var MAX_SWEEP_INTERVAL_MS = 6e4;
|
|
15
20
|
var HEAP_PRESSURE_WARNING_FRACTION = 0.9;
|
|
@@ -22,4 +27,4 @@ var SUGGEST_OVERSAMPLE_FACTOR = 1.5;
|
|
|
22
27
|
var SUGGEST_OVERSAMPLE_PADDING = 10;
|
|
23
28
|
var MAX_SUGGEST_SCATTER_LIMIT = Math.ceil(MAX_SUGGEST_LIMIT * SUGGEST_OVERSAMPLE_FACTOR) + SUGGEST_OVERSAMPLE_PADDING;
|
|
24
29
|
|
|
25
|
-
export { ABSOLUTE_WINDOWS_PATH_PATTERN, BATCH_CHUNK_SIZE, DEFAULT_LIMIT, DEFAULT_OFFSET, DEFAULT_SUGGEST_LIMIT, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_REARM_FRACTION, HEAP_PRESSURE_WARNING_FRACTION, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, MAX_INDEX_NAME_LENGTH, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_SWEEP_INTERVAL_MS, MIN_DOCUMENTS_FOR_SEGMENTS, MIN_SWEEP_INTERVAL_MS, MODULE_URL_SCHEME_PATTERN, STATISTICS_BROADCAST_INTERVAL_MS, SUGGEST_OVERSAMPLE_FACTOR, SUGGEST_OVERSAMPLE_PADDING };
|
|
30
|
+
export { ABSOLUTE_WINDOWS_PATH_PATTERN, BATCH_CHUNK_SIZE, DEFAULT_LIMIT, DEFAULT_OFFSET, DEFAULT_SUGGEST_LIMIT, EXPORT_CHUNK_BYTES, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_REARM_FRACTION, HEAP_PRESSURE_WARNING_FRACTION, IMPORT_BATCH_DOCUMENTS, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, MAX_EXPORT_LINE_BYTES, MAX_IMPORT_REFUSALS_REPORTED, MAX_INDEX_CONFIGURATION_BYTES, MAX_INDEX_NAME_LENGTH, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_SWEEP_INTERVAL_MS, MIN_DOCUMENTS_FOR_SEGMENTS, MIN_SWEEP_INTERVAL_MS, MODULE_URL_SCHEME_PATTERN, STATISTICS_BROADCAST_INTERVAL_MS, SUGGEST_OVERSAMPLE_FACTOR, SUGGEST_OVERSAMPLE_PADDING };
|