@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.
Files changed (104) hide show
  1. package/dist/{analysis-change-JN23AZQP.mjs → analysis-change-HQUT2Z3I.mjs} +13 -13
  2. package/dist/{analysis-change-entry-5JSIMEKG.mjs → analysis-change-entry-TZTG4AZB.mjs} +1 -1
  3. package/dist/browser/{analysis-change-57MIRJWR.mjs → analysis-change-JPV775LR.mjs} +407 -6
  4. package/dist/browser/{analysis-change-entry-ICGRR3IN.mjs → analysis-change-entry-7HR4LWL3.mjs} +1 -1
  5. package/dist/browser/chunk-3ZBJYAS4.mjs +19 -0
  6. package/dist/browser/{chunk-ZAIZQOTM.mjs → chunk-5DB2VDGI.mjs} +951 -1134
  7. package/dist/browser/chunk-6RHTAVZX.mjs +656 -0
  8. package/dist/browser/chunk-CCOAOO73.mjs +86 -0
  9. package/dist/browser/{chunk-3EYDURFD.mjs → chunk-HKX2G6WH.mjs} +1615 -2266
  10. package/dist/browser/{chunk-CGVBGHBX.mjs → chunk-KTOK275N.mjs} +531 -830
  11. package/dist/browser/{chunk-5LYWZJE2.mjs → chunk-LVY2LI35.mjs} +1 -1
  12. package/dist/browser/chunk-MVM33ZUL.mjs +993 -0
  13. package/dist/browser/chunk-MWUK3DA5.mjs +2634 -0
  14. package/dist/browser/{chunk-67KSBUYR.mjs → chunk-R4WUDZQV.mjs} +8 -5
  15. package/dist/browser/{chunk-6BSB4N6B.mjs → chunk-TCLEOZ4P.mjs} +2 -2
  16. package/dist/browser/chunk-VFYMPCOV.mjs +212 -0
  17. package/dist/browser/chunk-WCFCHIBB.mjs +177 -0
  18. package/dist/browser/{chunk-E5SFTOQR.mjs → chunk-XNWPP5NS.mjs} +2 -2
  19. package/dist/browser/{chunk-QHNNULPW.mjs → chunk-ZEV26AQ6.mjs} +5 -0
  20. package/dist/browser/cold-module-MJMKNUYJ.mjs +745 -0
  21. package/dist/browser/{durability-wiring-MTIAN6VT.mjs → durability-wiring-SNOWIT6Z.mjs} +231 -51
  22. package/dist/browser/{import-Q7MXD6BS.mjs → import-TLB2A5LJ.mjs} +6 -5
  23. package/dist/browser/module-BUFNZMEU.mjs +12 -0
  24. package/dist/browser/{module-5J3PEUEB.mjs → module-BVP4TKZU.mjs} +395 -108
  25. package/dist/{restore-queue-RYSRRFS4.mjs → browser/restore-queue-ONYNYUDE.mjs} +2 -2
  26. package/dist/browser/{snapshot-YBJ5MF2M.mjs → snapshot-QXBKHJAG.mjs} +108 -25
  27. package/dist/browser/{write-RTWI5MXL.mjs → write-WHFBDWQS.mjs} +63 -91
  28. package/dist/{capabilities-DXAmysqJ.d.ts → capabilities-BCdUwK_L.d.ts} +2 -2
  29. package/dist/{chunk-HMDT3I63.mjs → chunk-46NZOPHS.mjs} +2 -2
  30. package/dist/{chunk-XXKWEG53.mjs → chunk-5WYVUPGD.mjs} +1 -1
  31. package/dist/chunk-6SNBQESJ.mjs +214 -0
  32. package/dist/chunk-7AUASRE7.mjs +653 -0
  33. package/dist/{chunk-4GCN34JV.mjs → chunk-AST3SHFA.mjs} +26 -24
  34. package/dist/chunk-BOJZGUS6.mjs +177 -0
  35. package/dist/{chunk-IP4HJOGC.mjs → chunk-BRUUBXCB.mjs} +4 -3
  36. package/dist/{chunk-J3EHATEZ.mjs → chunk-DQNKVOJ2.mjs} +63 -63
  37. package/dist/chunk-FOCV4CBZ.mjs +87 -0
  38. package/dist/{chunk-FFVLPCLH.mjs → chunk-GLZHNSGB.mjs} +1 -1
  39. package/dist/chunk-GWOS5DYC.mjs +2637 -0
  40. package/dist/{chunk-W2XDK66Z.mjs → chunk-IO5F7ZBE.mjs} +112 -438
  41. package/dist/{chunk-P36MUFEJ.mjs → chunk-JDDXV6UF.mjs} +2 -1
  42. package/dist/{chunk-LLDFIKGP.mjs → chunk-KEIYVZUX.mjs} +4 -4
  43. package/dist/{chunk-UBXJQJII.mjs → chunk-KGOXHLLZ.mjs} +5 -1
  44. package/dist/{chunk-FKARMUWH.mjs → chunk-KZL72VTC.mjs} +68 -16
  45. package/dist/{chunk-TCWQJL7O.mjs → chunk-L76W3IZJ.mjs} +5 -0
  46. package/dist/{chunk-CPCGEIOM.mjs → chunk-LA4WNDHL.mjs} +83 -799
  47. package/dist/{chunk-PNNVTKMT.mjs → chunk-NJJCPFXN.mjs} +2 -2
  48. package/dist/chunk-NN33CZRE.mjs +86 -0
  49. package/dist/chunk-NRUXBYPH.mjs +121 -0
  50. package/dist/{chunk-UJWGQIXU.mjs → chunk-QHPYS427.mjs} +1 -0
  51. package/dist/{chunk-VSUYTPME.mjs → chunk-RHKRTYGO.mjs} +13 -4
  52. package/dist/{chunk-UEV53BBO.mjs → chunk-SRJBFG2T.mjs} +406 -5
  53. package/dist/{chunk-K3AQOZVM.mjs → chunk-TNBIK2LQ.mjs} +1638 -1644
  54. package/dist/chunk-UUZCQQG2.mjs +209 -0
  55. package/dist/{chunk-XMQNOD5V.mjs → chunk-VEFN6X6Q.mjs} +2 -2
  56. package/dist/{chunk-LK3MOTXF.mjs → chunk-VJEGOELZ.mjs} +8 -5
  57. package/dist/chunk-W2COJ5AH.mjs +148 -0
  58. package/dist/{chunk-IBATGS3J.mjs → chunk-WJGO5PGV.mjs} +241 -124
  59. package/dist/{chunk-CCCGEPJM.mjs → chunk-XZ3SRNDJ.mjs} +24 -63
  60. package/dist/{chunk-MTQTX4BP.mjs → chunk-YHUTF6EA.mjs} +400 -92
  61. package/dist/{chunk-B5I3IL4H.mjs → chunk-YLNSJQLX.mjs} +4 -4
  62. package/dist/{chunk-6VHWXAOI.mjs → chunk-Z4HFMYNX.mjs} +29 -24
  63. package/dist/{chunk-U4X4AWKL.mjs → chunk-ZPWS2SKJ.mjs} +293 -270
  64. package/dist/{client-DApBeLbk.d.ts → client-B12YFALP.d.ts} +3 -3
  65. package/dist/client.d.ts +7 -7
  66. package/dist/cold-module-4X7WJCFM.mjs +783 -0
  67. package/dist/{config-B0H-vp4U.d.ts → config-BhZxIeb1.d.ts} +6 -1
  68. package/dist/{config-Brysl9NO.d.ts → config-CIG5yDyg.d.ts} +2 -2
  69. package/dist/{direct-executor-J5UDLPL3.mjs → direct-executor-7XOQ7VQP.mjs} +5 -5
  70. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  71. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  72. package/dist/distribution.d.ts +7 -7
  73. package/dist/distribution.mjs +123 -42
  74. package/dist/{durability-wiring-AYOTAPNQ.mjs → durability-wiring-324D2DDD.mjs} +213 -40
  75. package/dist/{engine-CuLMbH1-.d.ts → engine-CtzbHOmG.d.ts} +2 -2
  76. package/dist/{import-QRZAQ5RH.mjs → import-OOBUW3RR.mjs} +14 -13
  77. package/dist/{index-HYnqS1SE.d.ts → index-DsEurhSl.d.ts} +1 -1
  78. package/dist/index.browser.mjs +3 -3
  79. package/dist/index.d.ts +6 -6
  80. package/dist/index.mjs +11 -11
  81. package/dist/{long-query-thread-U7K5A72G.mjs → long-query-thread-4SW7RWDE.mjs} +8 -8
  82. package/dist/{module-L2OZO5PQ.mjs → module-DXSJ5LT2.mjs} +374 -83
  83. package/dist/module-IYPLWHGC.mjs +48 -0
  84. package/dist/paged-partition-archive-HFP45PLU.mjs +269 -0
  85. package/dist/partial-words.mjs +2 -2
  86. package/dist/persistence/durability/checkpoint-worker.d.ts +5 -1
  87. package/dist/persistence/durability/checkpoint-worker.mjs +17 -15
  88. package/dist/react.d.ts +9 -9
  89. package/dist/{browser/restore-queue-DISFECE4.mjs → restore-queue-FEYAC4SB.mjs} +2 -2
  90. package/dist/{schema-BTXbHCqA.d.ts → schema-B-Runv0n.d.ts} +7 -0
  91. package/dist/server.d.ts +10 -10
  92. package/dist/server.mjs +8 -7
  93. package/dist/{snapshot-BTRZ3MZK.mjs → snapshot-CGM65VCD.mjs} +60 -25
  94. package/dist/{tasks-DjGjK70Y.d.ts → tasks-CjRJRGTb.d.ts} +6 -4
  95. package/dist/{thread-USB3GOPY.mjs → thread-KGNAIKPD.mjs} +8 -8
  96. package/dist/vector/search-worker.d.ts +1 -1
  97. package/dist/vector/search-worker.mjs +3 -2
  98. package/dist/workers/entry.mjs +7 -7
  99. package/dist/{write-GHTA56OW.mjs → write-2DZPEQL2.mjs} +70 -98
  100. package/openapi.json +13 -0
  101. package/package.json +12 -8
  102. package/dist/browser/chunk-XVMOQQ34.mjs +0 -384
  103. package/dist/chunk-BDIDUW2B.mjs +0 -387
  104. package/dist/browser/{chunk-4MFH226Q.mjs → chunk-D33A5VMU.mjs} +15 -15
@@ -1,5 +1,5 @@
1
+ import { extractVectorFieldsFromSchema, readHeapStatistics, readResidentMemory } from './chunk-5DB2VDGI.mjs';
1
2
  import { collectAndReturnPages } from './chunk-OIZS5KIX.mjs';
2
- import { extractVectorFieldsFromSchema, readHeapStatistics, readResidentMemory } from './chunk-ZAIZQOTM.mjs';
3
3
  import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
4
4
 
5
5
  // src/engine/snapshot/constants.ts
@@ -105,11 +105,14 @@ function deadCountOf(dead) {
105
105
  }
106
106
  return count;
107
107
  }
108
- function archiveFootprint(prepared, manifest, replacesIndex) {
109
- let segmentBytes = 0;
108
+ function storedBytesOfSegments(manifest) {
109
+ let bytes = 0;
110
110
  for (const partition of manifest.partitions) {
111
- for (const segment of partition.segments) segmentBytes += segment.bytes;
111
+ for (const segment of partition.segments) bytes += segment.bytes;
112
112
  }
113
+ return bytes;
114
+ }
115
+ function archiveFootprint(prepared, manifest, replacesIndex, segmentBytes) {
113
116
  const dimensions = extractVectorFieldsFromSchema(prepared.config.schema);
114
117
  const vectors = [];
115
118
  for (const field of manifest.vectors) {
@@ -170,4 +173,4 @@ function requireRestoreMemory(indexName, footprint, replacesIndex) {
170
173
  if (shortfall !== null) refuse(indexName, replacesIndex, shortfall);
171
174
  }
172
175
 
173
- export { MAX_SNAPSHOT_ANALYSIS_ATTEMPTS, archiveFootprint, earlierSnapshotFootprint, requireAnalysisRebuildMemory, requireRestoreMemory };
176
+ export { MAX_SNAPSHOT_ANALYSIS_ATTEMPTS, archiveFootprint, earlierSnapshotFootprint, requireAnalysisRebuildMemory, requireRestoreMemory, storedBytesOfSegments };
@@ -1,4 +1,4 @@
1
- import { removeDocumentVectors, prepareDocumentVectors, insertDocumentVectors, getNestedValue, requireValidFieldTypes, VECTOR_PATTERN } from './chunk-ZAIZQOTM.mjs';
1
+ import { removeDocumentVectors, prepareDocumentVectors, insertDocumentVectors, getNestedValue, requireValidFieldTypes, VECTOR_PATTERN } from './chunk-5DB2VDGI.mjs';
2
2
  import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
3
3
  import { decode } from '@msgpack/msgpack';
4
4
 
@@ -636,4 +636,4 @@ function decodeKeywordSegment(payload, shared) {
636
636
  return writeRecords === null ? { schema, tombstones, arrays } : { schema, tombstones, arrays, writeRecords };
637
637
  }
638
638
 
639
- export { KEYWORD_SEGMENT_ENVELOPE_VERSION, KEYWORD_SEGMENT_PAYLOAD_VERSION, applyDeleteEntry, applyIndexEntry, decodeKeywordSegment, littleEndianBytes, restoreVectorFields, setNestedValue, uint64Bytes };
639
+ export { KEYWORD_SEGMENT_ENVELOPE_VERSION, KEYWORD_SEGMENT_PAYLOAD_VERSION, applyDeleteEntry, applyIndexEntry, decodeBooleanColumns, decodeEnumColumns, decodeFieldLengths, decodeGeopointColumns, decodeKeywordSegment, decodePartialWords, decodePatternColumns, decodeSurfaceForms, decodeValueColumns, littleEndianBytes, requireEntriesAscend, requireOffsets, requireUtf8Entries, restoreVectorFields, setNestedValue, uint32sFrom, uint64Bytes };
@@ -0,0 +1,212 @@
1
+ import { chunksOf, restoredConfigFields, restoredEmbedding } from './chunk-ZEV26AQ6.mjs';
2
+ import { untagDocumentLine } from './chunk-WCFCHIBB.mjs';
3
+ import { flattenSchema, requireConfigurationShape } from './chunk-5DB2VDGI.mjs';
4
+ import { MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, MAX_IMPORT_REFUSALS_REPORTED } from './chunk-MZI3TEOW.mjs';
5
+ import { NarsilError, ErrorCodes } from './chunk-35B42UFM.mjs';
6
+
7
+ // src/engine/export/lines.ts
8
+ var NEWLINE = 10;
9
+ function joined(parts, total) {
10
+ if (parts.length === 1) return parts[0];
11
+ const bytes = new Uint8Array(total);
12
+ let offset = 0;
13
+ for (const part of parts) {
14
+ bytes.set(part, offset);
15
+ offset += part.byteLength;
16
+ }
17
+ return bytes;
18
+ }
19
+ async function* exportLines(source, maxLineBytes) {
20
+ const decoder = new TextDecoder("utf-8", { fatal: true });
21
+ let parts = [];
22
+ let pending = 0;
23
+ let overflowing = false;
24
+ let line = 0;
25
+ const finishLine = () => {
26
+ line += 1;
27
+ if (overflowing) {
28
+ overflowing = false;
29
+ parts = [];
30
+ pending = 0;
31
+ return { line, refused: "too-long" };
32
+ }
33
+ const bytes = joined(parts, pending);
34
+ parts = [];
35
+ pending = 0;
36
+ try {
37
+ return { line, text: decoder.decode(bytes) };
38
+ } catch {
39
+ return { line, refused: "not-utf8" };
40
+ }
41
+ };
42
+ for await (const chunk of chunksOf(source)) {
43
+ let start = 0;
44
+ for (; ; ) {
45
+ const newline = chunk.indexOf(NEWLINE, start);
46
+ const end = newline < 0 ? chunk.byteLength : newline;
47
+ const piece = chunk.subarray(start, end);
48
+ if (!overflowing && pending + piece.byteLength <= maxLineBytes) {
49
+ if (piece.byteLength > 0) parts.push(piece.slice());
50
+ pending += piece.byteLength;
51
+ } else {
52
+ overflowing = true;
53
+ parts = [];
54
+ }
55
+ if (newline < 0) break;
56
+ yield finishLine();
57
+ start = newline + 1;
58
+ }
59
+ }
60
+ if (pending > 0 || overflowing) yield finishLine();
61
+ }
62
+
63
+ // src/engine/export/import.ts
64
+ var DOCUMENT_EXPORT_FORMAT = "narsil-export";
65
+ var DOCUMENT_EXPORT_VERSION = 1;
66
+ function invalidHeader(message) {
67
+ throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The document export header ${message}`);
68
+ }
69
+ function isRecord(value) {
70
+ return typeof value === "object" && value !== null && !Array.isArray(value);
71
+ }
72
+ function configOfHeader(line) {
73
+ if (line === void 0) invalidHeader("is missing");
74
+ if (!("text" in line)) {
75
+ invalidHeader(
76
+ line.refused === "too-long" ? `passes the line limit of ${MAX_EXPORT_LINE_BYTES} bytes` : "is not UTF-8"
77
+ );
78
+ }
79
+ let raw;
80
+ try {
81
+ raw = JSON.parse(line.text);
82
+ } catch {
83
+ invalidHeader("is not JSON");
84
+ }
85
+ if (!isRecord(raw) || raw.format !== DOCUMENT_EXPORT_FORMAT || raw.version !== DOCUMENT_EXPORT_VERSION) {
86
+ invalidHeader(`must name format "${DOCUMENT_EXPORT_FORMAT}" and version ${DOCUMENT_EXPORT_VERSION}`);
87
+ }
88
+ const configuration = requireConfigurationShape(raw.index, "document export header");
89
+ const fields = restoredConfigFields(configuration, (message) => invalidHeader(message));
90
+ const embedding = restoredEmbedding(configuration.embedding, (message) => invalidHeader(message));
91
+ return {
92
+ schema: configuration.schema,
93
+ language: configuration.language,
94
+ ...fields,
95
+ ...embedding === void 0 ? {} : {
96
+ embedding: {
97
+ fields: embedding.fields,
98
+ ...embedding.adapter === void 0 ? {} : { adapter: embedding.adapter }
99
+ }
100
+ }
101
+ };
102
+ }
103
+ async function prepareIndex(engine, indexName, config) {
104
+ if (!engine.listIndexes().some((index) => index.name === indexName)) {
105
+ await engine.createIndex(indexName, config);
106
+ return;
107
+ }
108
+ const existing = flattenSchema(engine.getStats(indexName).schema);
109
+ const exported = flattenSchema(config.schema);
110
+ const fields = /* @__PURE__ */ new Set([...Object.keys(existing), ...Object.keys(exported)]);
111
+ for (const field of fields) {
112
+ if (existing[field] === exported[field]) continue;
113
+ throw new NarsilError(
114
+ ErrorCodes.CONFIG_INVALID,
115
+ `Index "${indexName}" gives field "${field}" another type than the export does, so the import cannot write into it`,
116
+ { indexName, field }
117
+ );
118
+ }
119
+ }
120
+ function highestReportedAt(refused) {
121
+ let highest = 0;
122
+ for (let at = 1; at < refused.length; at++) {
123
+ if (refused[at].line > refused[highest].line) highest = at;
124
+ }
125
+ return highest;
126
+ }
127
+ function refuse(state, line, code, message) {
128
+ state.result.refusedCount += 1;
129
+ const refused = state.result.refused;
130
+ if (refused.length < MAX_IMPORT_REFUSALS_REPORTED) {
131
+ refused.push({ line, code, message });
132
+ if (refused.length === MAX_IMPORT_REFUSALS_REPORTED) state.highestReported = highestReportedAt(refused);
133
+ return;
134
+ }
135
+ if (line >= refused[state.highestReported].line) return;
136
+ refused[state.highestReported] = { line, code, message };
137
+ state.highestReported = highestReportedAt(refused);
138
+ }
139
+ async function flush(state) {
140
+ if (state.batch.length === 0) return;
141
+ const batch = state.batch;
142
+ state.batch = [];
143
+ state.batchIds = /* @__PURE__ */ new Set();
144
+ const lineOf = new Map(batch.map((entry) => [entry.docId, entry.line]));
145
+ const inserts = [];
146
+ const updates = [];
147
+ for (const entry of batch) {
148
+ if (await state.engine.has(state.indexName, entry.docId))
149
+ updates.push({ docId: entry.docId, document: entry.document });
150
+ else inserts.push(entry.document);
151
+ }
152
+ for (const outcome of [
153
+ inserts.length === 0 ? null : await state.engine.insertBatch(state.indexName, inserts, { skipClone: true }),
154
+ updates.length === 0 ? null : await state.engine.updateBatch(state.indexName, updates)
155
+ ]) {
156
+ if (outcome === null) continue;
157
+ state.result.imported += outcome.succeeded.length;
158
+ for (const failure of outcome.failed) {
159
+ const code = failure.error instanceof NarsilError ? failure.error.code : ErrorCodes.DOC_VALIDATION_FAILED;
160
+ refuse(state, lineOf.get(failure.docId) ?? 0, code, failure.error.message);
161
+ }
162
+ }
163
+ }
164
+ async function takeLine(state, entry) {
165
+ if (!("text" in entry)) {
166
+ const message = entry.refused === "too-long" ? `The line passes the limit of ${MAX_EXPORT_LINE_BYTES} bytes` : "The line is not UTF-8";
167
+ refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, message);
168
+ return;
169
+ }
170
+ if (entry.text.length === 0) return;
171
+ let document;
172
+ try {
173
+ document = JSON.parse(entry.text);
174
+ } catch {
175
+ refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line is not JSON");
176
+ return;
177
+ }
178
+ if (!isRecord(document) || typeof document.id !== "string" || document.id.length === 0) {
179
+ refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line holds no document with a string id");
180
+ return;
181
+ }
182
+ try {
183
+ untagDocumentLine(entry.text, document);
184
+ } catch (error) {
185
+ if (!(error instanceof NarsilError)) throw error;
186
+ refuse(state, entry.line, error.code, error.message);
187
+ return;
188
+ }
189
+ if (state.batchIds.has(document.id)) await flush(state);
190
+ state.batch.push({ line: entry.line, docId: document.id, document });
191
+ state.batchIds.add(document.id);
192
+ if (state.batch.length >= IMPORT_BATCH_DOCUMENTS) await flush(state);
193
+ }
194
+ async function readDocumentExport(engine, indexName, source) {
195
+ const lines = exportLines(source, MAX_EXPORT_LINE_BYTES);
196
+ const header = await lines.next();
197
+ await prepareIndex(engine, indexName, configOfHeader(header.done === true ? void 0 : header.value));
198
+ const state = {
199
+ engine,
200
+ indexName,
201
+ batch: [],
202
+ batchIds: /* @__PURE__ */ new Set(),
203
+ result: { imported: 0, refusedCount: 0, refused: [] },
204
+ highestReported: 0
205
+ };
206
+ for await (const entry of lines) await takeLine(state, entry);
207
+ await flush(state);
208
+ state.result.refused.sort((a, b) => a.line - b.line);
209
+ return state.result;
210
+ }
211
+
212
+ export { DOCUMENT_EXPORT_FORMAT, DOCUMENT_EXPORT_VERSION, readDocumentExport };
@@ -0,0 +1,177 @@
1
+ import { MAX_DOCUMENT_NESTING_DEPTH } from './chunk-5DB2VDGI.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-35B42UFM.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 };
@@ -4,14 +4,14 @@ function holdsChangeWork(entry) {
4
4
  }
5
5
  async function abandonChangeOf(core, indexName) {
6
6
  if (!holdsChangeWork(core.indexRegistry.get(indexName))) return;
7
- const { abandonAnalysisChange } = await import('./analysis-change-57MIRJWR.mjs');
7
+ const { abandonAnalysisChange } = await import('./analysis-change-JPV775LR.mjs');
8
8
  await abandonAnalysisChange(core, indexName);
9
9
  }
10
10
  async function resumeChangeOf(core, indexName) {
11
11
  if ((core.indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
12
12
  if (core.mutationCtx.capacityScope === "partition") return;
13
13
  if (core.executor.getManager(indexName) === void 0) return;
14
- const { resumeAnalysisChange } = await import('./analysis-change-57MIRJWR.mjs');
14
+ const { resumeAnalysisChange } = await import('./analysis-change-JPV775LR.mjs');
15
15
  void resumeAnalysisChange(core, indexName).catch(() => void 0);
16
16
  }
17
17
  async function resumeEveryChange(core) {
@@ -234,6 +234,10 @@ function readSharedConfigFields(source, reject) {
234
234
  const surfaceForms = restoredBoolean(source.surfaceForms, "surfaceForms", reject);
235
235
  const defaultScoring = restoredScoring(source.defaultScoring, reject);
236
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
+ }
237
241
  const strict = restoredBoolean(source.strict, "strict", reject);
238
242
  const required = restoredRequired(source.required, reject);
239
243
  const vectorPromotion = restoredVectorPromotion(source.vectorPromotion, reject);
@@ -247,6 +251,7 @@ function readSharedConfigFields(source, reject) {
247
251
  ...surfaceForms !== void 0 ? { surfaceForms } : {},
248
252
  ...defaultScoring !== void 0 ? { defaultScoring } : {},
249
253
  ...trackPositions !== void 0 ? { trackPositions } : {},
254
+ ...textStorage === "memory" || textStorage === "disk" ? { textStorage } : {},
250
255
  ...strict !== void 0 ? { strict } : {},
251
256
  ...required !== void 0 ? { required } : {},
252
257
  ...vectorPromotion !== void 0 ? { vectorPromotion } : {},