@delali/narsil 0.3.1-next.95 → 0.3.1-next.97
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 +2 -1
- 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-3U636ADD.mjs → chunk-CN4I4FZU.mjs} +2 -2
- package/dist/browser/chunk-JPTQZWJQ.mjs +10 -0
- package/dist/browser/{chunk-WKPJ4E73.mjs → chunk-LD55ZGU3.mjs} +2 -1
- package/dist/browser/{chunk-D3CC2NMZ.mjs → chunk-NAFT3K6X.mjs} +240 -135
- package/dist/browser/{chunk-LULHQXCK.mjs → chunk-NNG3EEB6.mjs} +5 -4
- package/dist/browser/{chunk-HARBSUWP.mjs → chunk-QWES44AW.mjs} +2 -197
- package/dist/browser/chunk-RELZRJNR.mjs +203 -0
- package/dist/browser/{chunk-FYFQJKFW.mjs → chunk-Z7QH2XHB.mjs} +40 -45
- package/dist/browser/{durability-wiring-3ZRKSPJD.mjs → durability-wiring-PY3L7DES.mjs} +7 -5
- package/dist/browser/{module-IEOQI5GI.mjs → module-PDXYHT75.mjs} +18 -10
- package/dist/browser/{restore-queue-RBULSOVX.mjs → restore-queue-DVIYJ7RU.mjs} +1 -1
- package/dist/browser/runtime-NYE5TB6O.mjs +557 -0
- package/dist/browser/{snapshot-Y3NGUJHX.mjs → snapshot-J57MZK6L.mjs} +115 -61
- package/dist/browser/{write-ZUBDNLCH.mjs → write-L7FAQA47.mjs} +6 -4
- package/dist/{capabilities-BvxvFzVA.d.ts → capabilities-BTTIs96E.d.ts} +19 -3
- package/dist/{chunk-GJZHU4FC.mjs → chunk-2WYMG3OZ.mjs} +4 -4
- package/dist/{chunk-7QONURHW.mjs → chunk-45AVKHMJ.mjs} +2 -2
- package/dist/{chunk-QM3VPX4Z.mjs → chunk-ASY5PHYI.mjs} +2 -2
- package/dist/{chunk-RDJKYKMQ.mjs → chunk-AY3AQ3UH.mjs} +1 -1
- package/dist/{chunk-54HYC5FT.mjs → chunk-BKB3XTMI.mjs} +6 -6
- package/dist/{chunk-MWT5WCJ5.mjs → chunk-COVCQ73F.mjs} +5 -5
- package/dist/{chunk-FGMGUDHX.mjs → chunk-E74YLAIG.mjs} +4 -1
- package/dist/chunk-FMWRCP2C.mjs +57 -0
- package/dist/{chunk-ES33L3HO.mjs → chunk-GGSH6KBQ.mjs} +1 -1
- package/dist/chunk-HJSN7UYG.mjs +10 -0
- package/dist/{chunk-ICL2AELD.mjs → chunk-HXJBSHXF.mjs} +40 -46
- package/dist/{chunk-ZHS44YKF.mjs → chunk-JFRNNBOM.mjs} +1 -1
- package/dist/{chunk-CHOGQSHK.mjs → chunk-K25LZA54.mjs} +39 -13
- package/dist/chunk-K7D4ZTSW.mjs +126 -0
- package/dist/{chunk-SYWGORQB.mjs → chunk-KV3AZFT3.mjs} +2 -0
- package/dist/chunk-KZ3NX2P7.mjs +21 -0
- package/dist/{chunk-J7SDAOTP.mjs → chunk-L3L5YFXC.mjs} +4 -4
- package/dist/{chunk-Q4UTU5ZE.mjs → chunk-LH4NZNJJ.mjs} +10 -10
- package/dist/{chunk-7KC56574.mjs → chunk-LU2CE5AE.mjs} +1 -1
- package/dist/{chunk-4ZJWRETC.mjs → chunk-LXPIXDUJ.mjs} +2 -2
- package/dist/{chunk-Q5DC6WAB.mjs → chunk-LXWDQLTW.mjs} +1 -1
- package/dist/{chunk-SBCEHIPL.mjs → chunk-MHOSCQCQ.mjs} +4 -4
- package/dist/{chunk-R36MIGBU.mjs → chunk-NKRBEGJZ.mjs} +169 -130
- package/dist/{chunk-L26LEDHO.mjs → chunk-NTRMFARG.mjs} +7 -7
- package/dist/chunk-NW4XDSP2.mjs +212 -0
- package/dist/{chunk-BB7MASRQ.mjs → chunk-OOEXLUGR.mjs} +1 -1
- package/dist/{chunk-3LYY62M6.mjs → chunk-OWNZYMRE.mjs} +10 -10
- package/dist/{chunk-HBVLF3HA.mjs → chunk-PPY2GSIB.mjs} +1 -1
- package/dist/{chunk-WLOF6HSP.mjs → chunk-R7EEKAJE.mjs} +12 -3
- package/dist/{chunk-2GZGBOQI.mjs → chunk-RONEOEON.mjs} +2 -2
- package/dist/{chunk-T2QN2FA4.mjs → chunk-UCDF35PU.mjs} +2 -2
- package/dist/{chunk-JFUE6F2Y.mjs → chunk-VWULPWRJ.mjs} +60 -21
- package/dist/{chunk-F52QGNZ2.mjs → chunk-WCJKUGHB.mjs} +1 -1
- package/dist/{chunk-RUIXODYU.mjs → chunk-YA7XLE2R.mjs} +32 -5
- package/dist/{chunk-MASE2LTJ.mjs → chunk-ZG477IPV.mjs} +7 -7
- package/dist/chunk-ZYNAMIYX.mjs +113 -0
- package/dist/{client-DKwterMb.d.ts → client-i9eLJrw5.d.ts} +3 -3
- package/dist/client.d.ts +9 -9
- package/dist/client.mjs +2 -0
- package/dist/{config-6YBtxekG.d.ts → config-BGB_fDtq.d.ts} +2 -2
- package/dist/{config-DPphZfuM.d.ts → config-P__Diiy4.d.ts} +25 -3
- package/dist/direct-executor-CXZ66ACP.mjs +22 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/transport/grpc.mjs +1 -1
- package/dist/distribution.d.ts +24 -12
- package/dist/distribution.mjs +177 -54
- package/dist/{durability-wiring-FRPV6JLZ.mjs → durability-wiring-QTHOGFMZ.mjs} +26 -25
- package/dist/embeddings/openai.d.ts +2 -2
- package/dist/embeddings/openai.mjs +22 -133
- package/dist/{engine-BGt9lI1V.d.ts → engine-BGCEm9E_.d.ts} +50 -20
- package/dist/{index-ONAEaqtx.d.ts → index-lcdGLyJH.d.ts} +1 -1
- package/dist/index.browser.mjs +4 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +19 -18
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/{memory-COdoGthn.d.ts → memory-CUEDwr-F.d.ts} +70 -2
- package/dist/{module-IUTNXWMV.mjs → module-3NONKBZX.mjs} +25 -18
- package/dist/partial-words.mjs +6 -6
- package/dist/pattern.mjs +3 -3
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +23 -22
- package/dist/react.d.ts +8 -8
- package/dist/react.mjs +2 -0
- package/dist/rerank-NWTKK636.mjs +60 -0
- package/dist/rerankers/http.d.ts +50 -0
- package/dist/rerankers/http.mjs +104 -0
- package/dist/{restore-queue-I5SI6AUQ.mjs → restore-queue-JPRBUYII.mjs} +1 -1
- package/dist/runtime-ZKYZFJJC.mjs +177 -0
- package/dist/{schema-DttzM-ln.d.ts → schema-4W_7tk1f.d.ts} +2 -2
- package/dist/server.d.ts +11 -11
- package/dist/server.mjs +63 -22
- package/dist/{snapshot-YC6TS4OP.mjs → snapshot-HOGXNO5W.mjs} +138 -83
- package/dist/synonyms.mjs +3 -3
- package/dist/{tasks-BJmamiC4.d.ts → tasks-HG3rlxx6.d.ts} +1 -1
- package/dist/{thread-U7XYJWGG.mjs → thread-B657LQXK.mjs} +49 -30
- package/dist/vector/search-worker.d.ts +6 -2
- package/dist/vector/search-worker.mjs +9 -7
- package/dist/workers/entry.mjs +5 -5
- package/dist/{write-M2OALSA4.mjs → write-XLIGTXBU.mjs} +21 -20
- package/package.json +11 -7
- package/dist/direct-executor-5KJGVQHM.mjs +0 -22
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, patternSearchModule, DEFAULT_PATTERN_WORK_CAP, bitsetHas, createBitSet, bitsetSet, bitsetIsEmpty, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, bitsetFromSet, PATTERN_WORK_FLUSH_UNITS, MATCHER_STATE_BUDGET_BYTES } from './chunk-
|
|
1
|
+
import { PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, patternSearchModule, DEFAULT_PATTERN_WORK_CAP, bitsetHas, createBitSet, bitsetSet, bitsetIsEmpty, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, bitsetFromSet, PATTERN_WORK_FLUSH_UNITS, MATCHER_STATE_BUDGET_BYTES } from './chunk-ASY5PHYI.mjs';
|
|
2
2
|
import { GEO_UNIT_METRES, MAX_FILTER_DEPTH, MAX_FILTER_TESTS, FILTER_OPERAND_COPY_DEPTH } from './chunk-WQBCBKY3.mjs';
|
|
3
|
-
import { expandTermPrefix, suggestDisplayTerms, getNestedValue, textFieldsChanged, getFlatSchema, tokenizeOptions, partialWordSearchModule, getOrCreateFieldNameIndex, partitionDocumentFrequency } from './chunk-
|
|
4
|
-
import { isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, partialFieldsOf, schemaFieldsOf, flattenSchema, validateDocument, validateDocumentStrict, ANTIMERIDIAN_SPAN_DEGREES, FULL_TURN_DEGREES, LOCATION_CODE_BITS_PER_AXIS, MAX_COVERING_CELLS, VINCENTY_CONVERGENCE_THRESHOLD, EARTH_RADIUS_METERS, RADIUS_BOX_MARGIN_RATIO, RADIUS_BOX_MARGIN_RADIANS, DEG_TO_RAD, VINCENTY_MAX_ITERATIONS } from './chunk-
|
|
5
|
-
import { MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, RESULT_WINDOW, DEFAULT_FUZZY_PREFIX_LENGTH, DEFAULT_PAGE_SIZE, PREFIX_MAX_EXPANSIONS } from './chunk-
|
|
3
|
+
import { expandTermPrefix, suggestDisplayTerms, getNestedValue, textFieldsChanged, getFlatSchema, tokenizeOptions, partialWordSearchModule, getOrCreateFieldNameIndex, partitionDocumentFrequency } from './chunk-MHOSCQCQ.mjs';
|
|
4
|
+
import { isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, partialFieldsOf, schemaFieldsOf, flattenSchema, validateDocument, validateDocumentStrict, ANTIMERIDIAN_SPAN_DEGREES, FULL_TURN_DEGREES, LOCATION_CODE_BITS_PER_AXIS, MAX_COVERING_CELLS, VINCENTY_CONVERGENCE_THRESHOLD, EARTH_RADIUS_METERS, RADIUS_BOX_MARGIN_RATIO, RADIUS_BOX_MARGIN_RADIANS, DEG_TO_RAD, VINCENTY_MAX_ITERATIONS } from './chunk-LXPIXDUJ.mjs';
|
|
5
|
+
import { MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, RESULT_WINDOW, DEFAULT_FUZZY_PREFIX_LENGTH, DEFAULT_PAGE_SIZE, PREFIX_MAX_EXPANSIONS } from './chunk-E74YLAIG.mjs';
|
|
6
6
|
import { fuzzyPrefixOf, boundedLevenshtein, fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
|
|
7
|
-
import { parsedTypeOf, isStringValuedBase, withSortableOption, isWordIndexedBase, isWordIndexedFieldType, isListBase } from './chunk-
|
|
8
|
-
import { tokenize, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, visitTokens, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, TARGET_BLOCK_ENTRIES, SORT_COLUMN_REBUILD_FRACTION_SHIFT } from './chunk-
|
|
7
|
+
import { parsedTypeOf, isStringValuedBase, withSortableOption, isWordIndexedBase, isWordIndexedFieldType, isListBase } from './chunk-OOEXLUGR.mjs';
|
|
8
|
+
import { tokenize, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, visitTokens, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, TARGET_BLOCK_ENTRIES, SORT_COLUMN_REBUILD_FRACTION_SHIFT } from './chunk-LU2CE5AE.mjs';
|
|
9
9
|
import { singleFoldTable, appendFoldedCodePoint, sortModeOf, defaultSortMode, SORT_VALUE_MAX_CODE_POINTS, toReducedSortValue, readSortField, compareComparableKeys, toComparableSortValue, isSortMode, SORT_MODES, compareSortValues, compareComparableValues, truncateSortString } from './chunk-R6A773WK.mjs';
|
|
10
10
|
import { compareCodePoints, exceedsCodePoints, codePointCount, holdsUnpairedSurrogate } from './chunk-YTJCGKM4.mjs';
|
|
11
11
|
import { isGeopointOrVectorType, PROTOTYPE_POLLUTION_KEYS } from './chunk-L5ORED7V.mjs';
|
|
12
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
12
|
+
import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
|
|
13
13
|
|
|
14
14
|
// src/core/partition/partial-words/platform.ts
|
|
15
15
|
function platformPartialWordSearch() {
|
|
@@ -6567,12 +6567,38 @@ var FNV_OFFSET_BASIS = 2166136261;
|
|
|
6567
6567
|
var FNV_PRIME = 16777619;
|
|
6568
6568
|
var encoder = new TextEncoder();
|
|
6569
6569
|
function fnv1aBytes(bytes) {
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6570
|
+
return fnv1aContinue(FNV_OFFSET_BASIS, bytes, bytes.length) >>> 0;
|
|
6571
|
+
}
|
|
6572
|
+
function fnv1aContinue(start, bytes, length) {
|
|
6573
|
+
let hash = start;
|
|
6574
|
+
for (let i = 0; i < length; i++) {
|
|
6575
|
+
hash = Math.imul(hash ^ bytes[i], FNV_PRIME);
|
|
6576
|
+
}
|
|
6577
|
+
return hash;
|
|
6578
|
+
}
|
|
6579
|
+
var scratchNumber = new Float64Array(1);
|
|
6580
|
+
var scratchBytes = new Uint8Array(scratchNumber.buffer);
|
|
6581
|
+
var HOST_IS_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
6582
|
+
function fnv1aContinueTaggedNumbers(start, tag, numbers) {
|
|
6583
|
+
let hash = start;
|
|
6584
|
+
const b = scratchBytes;
|
|
6585
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
6586
|
+
scratchNumber[0] = Math.fround(numbers[i]);
|
|
6587
|
+
hash = Math.imul(hash ^ tag, FNV_PRIME);
|
|
6588
|
+
if (HOST_IS_LITTLE_ENDIAN) {
|
|
6589
|
+
hash = Math.imul(hash ^ b[7], FNV_PRIME);
|
|
6590
|
+
hash = Math.imul(hash ^ b[6], FNV_PRIME);
|
|
6591
|
+
hash = Math.imul(hash ^ b[5], FNV_PRIME);
|
|
6592
|
+
hash = Math.imul(hash ^ b[4], FNV_PRIME);
|
|
6593
|
+
hash = Math.imul(hash ^ b[3], FNV_PRIME);
|
|
6594
|
+
hash = Math.imul(hash ^ b[2], FNV_PRIME);
|
|
6595
|
+
hash = Math.imul(hash ^ b[1], FNV_PRIME);
|
|
6596
|
+
hash = Math.imul(hash ^ b[0], FNV_PRIME);
|
|
6597
|
+
} else {
|
|
6598
|
+
for (let at = 0; at < 8; at++) hash = Math.imul(hash ^ b[at], FNV_PRIME);
|
|
6599
|
+
}
|
|
6574
6600
|
}
|
|
6575
|
-
return hash
|
|
6601
|
+
return hash;
|
|
6576
6602
|
}
|
|
6577
6603
|
function fnv1aUint32s(values) {
|
|
6578
6604
|
let hash = FNV_OFFSET_BASIS;
|
|
@@ -8455,4 +8481,4 @@ function fanOutMatchCount(manager, params, language, schema, options) {
|
|
|
8455
8481
|
return count;
|
|
8456
8482
|
}
|
|
8457
8483
|
|
|
8458
|
-
export { FIELD_FILTER_OPERATORS, FILTER_EXPRESSION_KEYS, MAX_TERM_FREQUENCY, PATTERN_HOST, ValueAffixes, applyPagination, applyPartitionFiltersBitset, applyProjection, applySorting, availablePatternSearch, buildPartialWordTableFrom, clampRowCount, cloneProjected, collectQueryTermStats, copyVectorsInto, countPartialSpelling, countsWithoutScores, createBooleanIndex, createCompositePartition, createEnumIndex, createFrozenPartialWords, createGeoIndex, createNumericIndex, createPartitionIndex, createPatternWorkMeter, createSurfaceRegistry, decodePageCursor, documentValueBytes, documentWithOwnBuffers, encodeFieldIndexes, encodePageCursor, encodePartialSpellingsOf, encodeSegmentState, everyValueFacetConfig, fanOutMatchCount, fanOutQuery, filterTestCount, fnv1a,
|
|
8484
|
+
export { FIELD_FILTER_OPERATORS, FILTER_EXPRESSION_KEYS, FNV_OFFSET_BASIS, MAX_TERM_FREQUENCY, PATTERN_HOST, ValueAffixes, applyPagination, applyPartitionFiltersBitset, applyProjection, applySorting, availablePatternSearch, buildPartialWordTableFrom, clampRowCount, cloneProjected, collectQueryTermStats, copyVectorsInto, countPartialSpelling, countsWithoutScores, createBooleanIndex, createCompositePartition, createEnumIndex, createFrozenPartialWords, createGeoIndex, createNumericIndex, createPartitionIndex, createPatternWorkMeter, createSurfaceRegistry, decodePageCursor, documentValueBytes, documentWithOwnBuffers, encodeFieldIndexes, encodePageCursor, encodePartialSpellingsOf, encodeSegmentState, everyValueFacetConfig, fanOutMatchCount, fanOutQuery, filterTestCount, fnv1a, fnv1aContinue, fnv1aContinueTaggedNumbers, fnv1aUint32s, fulltextMatches, isCompositePartition, joinPatternWorkMeter, kWayMerge, mergeFacets, mergePartitionStats, normalizeSort, oversampledFacetConfig, oversampledShardSize, partialSpellingsOfDocuments, partialWordHighlighter, partialWordsToHighlight, partitionStateOf, partitionsIn, patternIndexOf, projectIncludedPaths, projectionKeepsField, pruneStatsToQueryTerms, readProjectedPath, readSortValues, recordValueSize, registerPartialWordSearch, registerPatternSearch, requireMatchingCursor, requirePartialWordSearchFor, requirePatternSearch, requirePatternSearchFor, requireSortableFields, requireWithinResultWindow, resolveProjection, sanitizeGlobalStats, setNestedValue, sortModesOf, sortSignatureEntry, sortSignatureOf, survivorDocumentsOf, undeclaredFieldOnStrictIndex, validatedFilterOf, valueWithOwnBuffers };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { NarsilError } from './chunk-KV3AZFT3.mjs';
|
|
2
|
+
|
|
3
|
+
// src/http-retry/constants.ts
|
|
4
|
+
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
5
|
+
var MAX_BACKOFF_MS = 3e4;
|
|
6
|
+
var BASE_BACKOFF_MS = 1e3;
|
|
7
|
+
var MAX_JITTER_MS = 1e3;
|
|
8
|
+
|
|
9
|
+
// src/http-retry/index.ts
|
|
10
|
+
function computeBackoffMs(attempt, retryAfterSeconds) {
|
|
11
|
+
if (retryAfterSeconds !== null && retryAfterSeconds > 0) {
|
|
12
|
+
return Math.min(retryAfterSeconds * 1e3, MAX_BACKOFF_MS);
|
|
13
|
+
}
|
|
14
|
+
const exponential = Math.min(BASE_BACKOFF_MS * 2 ** attempt, MAX_BACKOFF_MS);
|
|
15
|
+
const jitter = Math.random() * MAX_JITTER_MS;
|
|
16
|
+
return exponential + jitter;
|
|
17
|
+
}
|
|
18
|
+
function parseRetryAfterHeader(headers) {
|
|
19
|
+
const raw = headers.get("retry-after");
|
|
20
|
+
if (raw === null) return null;
|
|
21
|
+
const seconds = Number(raw);
|
|
22
|
+
if (Number.isFinite(seconds) && seconds > 0) return seconds;
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
async function resolveApiKey(apiKey, service, invalidCode) {
|
|
26
|
+
const resolved = typeof apiKey === "function" ? await apiKey() : apiKey;
|
|
27
|
+
if (typeof resolved !== "string" || resolved.trim().length === 0) {
|
|
28
|
+
throw new NarsilError(invalidCode, `${service} apiKey resolved to an empty or non-string value`);
|
|
29
|
+
}
|
|
30
|
+
return resolved;
|
|
31
|
+
}
|
|
32
|
+
function buildSignal(callerSignal, timeoutMs) {
|
|
33
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
34
|
+
if (callerSignal === void 0) return timeoutSignal;
|
|
35
|
+
return AbortSignal.any([callerSignal, timeoutSignal]);
|
|
36
|
+
}
|
|
37
|
+
async function sleep(ms, signal) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
if (signal?.aborted) {
|
|
40
|
+
reject(signal.reason);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const onAbort = () => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
reject(signal?.reason);
|
|
46
|
+
};
|
|
47
|
+
const timer = setTimeout(() => {
|
|
48
|
+
signal?.removeEventListener("abort", onAbort);
|
|
49
|
+
resolve();
|
|
50
|
+
}, ms);
|
|
51
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function textOf(value) {
|
|
55
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
56
|
+
}
|
|
57
|
+
async function parseErrorBody(response) {
|
|
58
|
+
const fallback = `HTTP ${response.status}`;
|
|
59
|
+
try {
|
|
60
|
+
const body = await response.json();
|
|
61
|
+
const nested = typeof body?.error === "object" && body.error !== null ? body.error : null;
|
|
62
|
+
const errorType = textOf(nested?.type) ?? "unknown";
|
|
63
|
+
const errorMessage = textOf(nested?.message) ?? textOf(body?.error) ?? textOf(body?.message) ?? textOf(body?.detail) ?? fallback;
|
|
64
|
+
return { type: errorType, message: errorMessage };
|
|
65
|
+
} catch {
|
|
66
|
+
return { type: "unknown", message: fallback };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function isAbort(err) {
|
|
70
|
+
return err instanceof DOMException || err instanceof Error && err.name === "AbortError";
|
|
71
|
+
}
|
|
72
|
+
async function postJsonWithRetry(request) {
|
|
73
|
+
const { url, body, apiKey, maxRetries, signal, service, failureCode } = request;
|
|
74
|
+
const headers = { "Content-Type": "application/json" };
|
|
75
|
+
if (apiKey !== null) headers.Authorization = `Bearer ${apiKey}`;
|
|
76
|
+
let lastError = null;
|
|
77
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
78
|
+
let response;
|
|
79
|
+
try {
|
|
80
|
+
response = await fetch(url, { method: "POST", headers, body, signal });
|
|
81
|
+
} catch (err) {
|
|
82
|
+
if (isAbort(err)) throw err;
|
|
83
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
84
|
+
if (attempt < maxRetries) {
|
|
85
|
+
await sleep(computeBackoffMs(attempt, null), signal);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
throw new NarsilError(failureCode, `${service} request failed after ${maxRetries + 1} attempts: network error`, {
|
|
89
|
+
cause: lastError.message
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (response.ok) {
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = await response.json();
|
|
96
|
+
} catch {
|
|
97
|
+
lastError = new Error("invalid JSON in a 2xx response body");
|
|
98
|
+
if (attempt < maxRetries) {
|
|
99
|
+
await sleep(computeBackoffMs(attempt, null), signal);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
throw new NarsilError(failureCode, `${service} returned invalid JSON in response body`);
|
|
103
|
+
}
|
|
104
|
+
if (parsed === null || typeof parsed !== "object") {
|
|
105
|
+
throw new NarsilError(failureCode, `${service} returned non-object JSON response`);
|
|
106
|
+
}
|
|
107
|
+
return parsed;
|
|
108
|
+
}
|
|
109
|
+
const retryAfter = parseRetryAfterHeader(response.headers);
|
|
110
|
+
const errorInfo = await parseErrorBody(response);
|
|
111
|
+
if (!RETRYABLE_STATUS_CODES.has(response.status) || attempt >= maxRetries) {
|
|
112
|
+
throw new NarsilError(
|
|
113
|
+
failureCode,
|
|
114
|
+
`${service} API error (${response.status}): [${errorInfo.type}] ${errorInfo.message}`,
|
|
115
|
+
{ status: response.status, errorType: errorInfo.type }
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
lastError = new Error(`HTTP ${response.status}: ${errorInfo.type}`);
|
|
119
|
+
await sleep(computeBackoffMs(attempt, retryAfter), signal);
|
|
120
|
+
}
|
|
121
|
+
throw new NarsilError(failureCode, `${service} request failed: exhausted all retries`, {
|
|
122
|
+
cause: lastError?.message
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { buildSignal, postJsonWithRetry, resolveApiKey };
|
|
@@ -41,6 +41,8 @@ var ErrorCodes = {
|
|
|
41
41
|
EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH",
|
|
42
42
|
EMBEDDING_NO_SOURCE: "EMBEDDING_NO_SOURCE",
|
|
43
43
|
EMBEDDING_CONFIG_INVALID: "EMBEDDING_CONFIG_INVALID",
|
|
44
|
+
RERANK_FAILED: "RERANK_FAILED",
|
|
45
|
+
RERANK_CONFIG_INVALID: "RERANK_CONFIG_INVALID",
|
|
44
46
|
DOC_MISSING_REQUIRED_FIELD: "DOC_MISSING_REQUIRED_FIELD",
|
|
45
47
|
CONFIG_INVALID: "CONFIG_INVALID",
|
|
46
48
|
QUERY_ROUTING_FAILED: "QUERY_ROUTING_FAILED",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/rerank/query-text.ts
|
|
2
|
+
function nonBlank(value) {
|
|
3
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
4
|
+
}
|
|
5
|
+
function rerankQueryTextOf(params) {
|
|
6
|
+
const rerank = params.rerank;
|
|
7
|
+
if (typeof rerank === "object" && rerank !== null && "query" in rerank && rerank.query !== void 0) {
|
|
8
|
+
return nonBlank(rerank.query);
|
|
9
|
+
}
|
|
10
|
+
return nonBlank(params.term) ?? nonBlank(params.vector?.text);
|
|
11
|
+
}
|
|
12
|
+
function withRerankQueryText(params) {
|
|
13
|
+
const rerank = params.rerank;
|
|
14
|
+
if (rerank === void 0 || typeof rerank !== "object" || rerank === null || rerank.query !== void 0) {
|
|
15
|
+
return params;
|
|
16
|
+
}
|
|
17
|
+
const query = rerankQueryTextOf(params);
|
|
18
|
+
return query === void 0 ? params : { ...params, rerank: { ...rerank, query } };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { rerankQueryTextOf, withRerankQueryText };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { removeDocumentVectors, prepareDocumentVectors, insertDocumentVectors } from './chunk-
|
|
2
|
-
import { getNestedValue } from './chunk-
|
|
3
|
-
import { requireValidFieldTypes } from './chunk-
|
|
1
|
+
import { removeDocumentVectors, prepareDocumentVectors, insertDocumentVectors } from './chunk-VWULPWRJ.mjs';
|
|
2
|
+
import { getNestedValue } from './chunk-MHOSCQCQ.mjs';
|
|
3
|
+
import { requireValidFieldTypes } from './chunk-LXPIXDUJ.mjs';
|
|
4
4
|
import { VECTOR_PATTERN } from './chunk-L5ORED7V.mjs';
|
|
5
|
-
import { ErrorCodes, NarsilError } from './chunk-
|
|
5
|
+
import { ErrorCodes, NarsilError } from './chunk-KV3AZFT3.mjs';
|
|
6
6
|
import { decode } from '@msgpack/msgpack';
|
|
7
7
|
|
|
8
8
|
function validateReplicationEntry(entry, localPrimaryTerm, log) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment, restoreVectorFields, KEYWORD_SEGMENT_PAYLOAD_VERSION, littleEndianBytes } from './chunk-
|
|
2
|
-
import { ReplicationMessageTypes } from './chunk-OHP7QR33.mjs';
|
|
1
|
+
import { KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment, restoreVectorFields, KEYWORD_SEGMENT_PAYLOAD_VERSION, littleEndianBytes } from './chunk-L3L5YFXC.mjs';
|
|
3
2
|
import { WIRE_BATCH_BUDGET } from './chunk-P36MUFEJ.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import { ReplicationMessageTypes } from './chunk-OHP7QR33.mjs';
|
|
4
|
+
import { packChecksummedEnvelope, crc32, openChecksummedEnvelope, reconstructSchemaFromMetadata, HEADER_SIZE, prepareDocumentVectors } from './chunk-VWULPWRJ.mjs';
|
|
5
|
+
import { MAX_FILE_BYTES } from './chunk-AY3AQ3UH.mjs';
|
|
6
|
+
import { freezeSegmentShared, createSharedFrozenSegment, createFrozenSegment, createPartitionManager, createPartitionRouter, buildSegmentPayload, resolvePartitionInsertOptions, selectionKeeps, decodeMapWithoutFields, shareSegmentArrays, segmentArraysOf, mergeSegmentContents } from './chunk-OWNZYMRE.mjs';
|
|
7
|
+
import { fnv1a, isCompositePartition, survivorDocumentsOf, partitionStateOf } from './chunk-K25LZA54.mjs';
|
|
8
|
+
import { generateId, getLanguage } from './chunk-JFRNNBOM.mjs';
|
|
9
|
+
import { extractVectorFieldsFromSchema, partialFieldsOf, messagePackUpperBoundBytes } from './chunk-LXPIXDUJ.mjs';
|
|
10
|
+
import { resolveIndexAnalysis } from './chunk-RONEOEON.mjs';
|
|
11
|
+
import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
|
|
12
12
|
import { encode, decode } from '@msgpack/msgpack';
|
|
13
13
|
|
|
14
14
|
// src/persistence/durability/constants.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
2
|
-
import { createNarsilError, ErrorCodes } from './chunk-
|
|
2
|
+
import { createNarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
|
|
3
3
|
|
|
4
4
|
// src/core/tokenizer/constants.ts
|
|
5
5
|
var TOKEN_CACHE_SIZE_FLOOR = 5e4;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EARLIER_RELEASE_MIN_M, MIN_M, MAX_M } from './chunk-KEHK2O6P.mjs';
|
|
2
|
-
import { isWordIndexedBase, parseFieldType } from './chunk-
|
|
2
|
+
import { isWordIndexedBase, parseFieldType } from './chunk-OOEXLUGR.mjs';
|
|
3
3
|
import { compareCodePoints, holdsUnpairedSurrogate, exceedsCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
4
4
|
import { DEFAULT_PATTERN_VALUE_LIMIT, isPlainObject, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, MAX_DOCUMENT_BYTES, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS, MAX_DOCUMENT_NESTING_DEPTH, VECTOR_PATTERN } from './chunk-L5ORED7V.mjs';
|
|
5
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
5
|
+
import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
|
|
6
6
|
import { encode } from '@msgpack/msgpack';
|
|
7
7
|
|
|
8
8
|
// src/schema/validator/schema.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { flattenSchema } from './chunk-
|
|
2
|
-
import { PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH } from './chunk-
|
|
1
|
+
import { flattenSchema } from './chunk-LXPIXDUJ.mjs';
|
|
2
|
+
import { PARTIAL_WORD_MIN_CODE_POINTS, PARTIAL_WORDS_ADDED_PER_QUERY, DEFAULT_FUZZY_PREFIX_LENGTH } from './chunk-E74YLAIG.mjs';
|
|
3
3
|
import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
|
|
4
|
-
import { isWordIndexedBase } from './chunk-
|
|
5
|
-
import { encodeStringBlob, tokenize, resolveStopWords, transformToken, visitTokens, visitSurfaceSpellings } from './chunk-
|
|
4
|
+
import { isWordIndexedBase } from './chunk-OOEXLUGR.mjs';
|
|
5
|
+
import { encodeStringBlob, tokenize, resolveStopWords, transformToken, visitTokens, visitSurfaceSpellings } from './chunk-LU2CE5AE.mjs';
|
|
6
6
|
import { compareCodePoints, codePointCount } from './chunk-YTJCGKM4.mjs';
|
|
7
7
|
|
|
8
8
|
// src/core/partition/suggestions.ts
|