@delali/narsil 0.3.1-next.78 → 0.3.1-next.80
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 +3 -3
- package/dist/{capabilities-1lEYL3WK.d.ts → capabilities-CcTDWh_P.d.ts} +2 -2
- package/dist/{chunk-AMGDG4ZJ.mjs → chunk-23HJ5QXQ.mjs} +1 -1
- package/dist/{chunk-R6WBLBTC.mjs → chunk-4QDQEJDV.mjs} +9 -45
- package/dist/chunk-DQABW5UQ.mjs +140 -0
- package/dist/chunk-GG2FBGVZ.mjs +30 -0
- package/dist/{chunk-XSZTF4ZQ.mjs → chunk-HJASKX4F.mjs} +1 -1
- package/dist/{chunk-DFW3U5UW.mjs → chunk-K4FZ55Q2.mjs} +21 -192
- package/dist/{chunk-PJWG547Z.mjs → chunk-MEOOYKWL.mjs} +3 -3
- package/dist/{chunk-55WEJKWT.mjs → chunk-NSXQCE4K.mjs} +17 -63
- package/dist/{chunk-PXDQFYD5.mjs → chunk-OSF3SGJV.mjs} +23 -139
- package/dist/{chunk-RTR44V2A.mjs → chunk-P2PYEZZE.mjs} +586 -4
- package/dist/{chunk-Z3BXCZXS.mjs → chunk-QPYV22XH.mjs} +2 -1
- package/dist/{chunk-4344I4MR.mjs → chunk-R2XCJIO7.mjs} +335 -12
- package/dist/{chunk-IBR6634K.mjs → chunk-R6A773WK.mjs} +2 -69
- package/dist/chunk-WQBCBKY3.mjs +8 -0
- package/dist/{chunk-P2BEMMOD.mjs → chunk-YGLSR7BC.mjs} +150 -203
- package/dist/chunk-YTJCGKM4.mjs +56 -0
- package/dist/{client-ZXcbSViH.d.ts → client-CsybN673.d.ts} +2 -2
- package/dist/client.d.ts +6 -6
- package/dist/{config-DTe5EbWW.d.ts → config-BCNQtszf.d.ts} +1 -1
- package/dist/{config-DHL2KsfD.d.ts → config-CFonR_gY.d.ts} +1 -1
- package/dist/direct-executor-VNMQ6NIH.mjs +19 -0
- package/dist/distribution/coordinator/etcd.mjs +2 -1
- package/dist/distribution/coordinator/in-memory.mjs +2 -1
- package/dist/distribution.d.ts +5 -5
- package/dist/distribution.mjs +15 -13
- package/dist/{engine-BjPBzWkA.d.ts → engine-B0oIF1_r.d.ts} +1 -1
- package/dist/index.browser.mjs +113 -516
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +14 -12
- package/dist/invalidation/filesystem.mjs +2 -1
- package/dist/{memory-DW3OJ0im.d.ts → memory-B6SBOKlS.d.ts} +1287 -1287
- package/dist/partial-words.mjs +5 -4
- package/dist/pattern.mjs +4 -1
- package/dist/persistence/durability/checkpoint-worker.d.ts +7 -7
- package/dist/persistence/durability/checkpoint-worker.mjs +14 -12
- package/dist/react.d.ts +6 -6
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +10 -7
- package/dist/{tasks-BTbwBqar.d.ts → tasks-CYAQe6qd.d.ts} +1 -1
- package/dist/{thread-XBDVXKUE.mjs → thread-P6QJ2Q5O.mjs} +11 -8
- package/dist/vector/search-worker.mjs +3 -2
- package/dist/workers/entry.mjs +3 -3
- package/package.json +9 -7
- package/dist/chunk-IOZPBNSG.mjs +0 -55
- package/dist/chunk-WFVOBZS4.mjs +0 -485
- package/dist/direct-executor-WB2HKU4N.mjs +0 -17
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateBM25Params, validatePartitionConfig, executeQuery, queryBindingOf, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-
|
|
1
|
+
import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateBM25Params, validatePartitionConfig, executeQuery, queryBindingOf, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-4QDQEJDV.mjs';
|
|
2
2
|
import { ReplicationMessageTypes } from './chunk-GCM3JFVA.mjs';
|
|
3
|
-
import { WIRE_BATCH_BUDGET, resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, requireDocumentObject, admitInsert, asBatchInsertError, requireMatchingDocId, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-
|
|
4
|
-
import { NATIVE_CRC32_MIN_BYTES, generateId, decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays, splitWorkerBudget, resolveWorkerCount, createDirectExecutor, createPartitionRouter,
|
|
5
|
-
import { requirePatternSearchFor, collectQueryTermStats, mergePartitionStats, oversampledFacetConfig, fnv1a, availablePatternSearch, kWayMerge, mergeFacets,
|
|
3
|
+
import { WIRE_BATCH_BUDGET, resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, requireDocumentObject, admitInsert, asBatchInsertError, requireMatchingDocId, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-HJASKX4F.mjs';
|
|
4
|
+
import { NATIVE_CRC32_MIN_BYTES, generateId, decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays, splitWorkerBudget, resolveWorkerCount, createDirectExecutor, createPartitionRouter, MAX_FILE_BYTES, resolveWorkerEntry, missingWorkerEntry, readHeapStatistics, nodeThreadId, CHECKSUM_YIELD_CHUNK_BYTES, resolvePartitionInsertOptions, resolveIndexAnalysis, createPartitionManager, buildSegmentPayload, createFrozenSegment, resolveRequestThreadCount, vectorsPerFile, vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION, deadBitsWhere, NO_LIVE_VECTOR_AT_POSITION, createPartitionIndex, selectionKeeps, decodeMapWithoutFields, isCompositePartition, segmentArraysOf, mergeSegmentContents, survivorDocumentsOf, partitionStateOf, VECTOR_FILE_MAX_VECTORS, deadBytesFor, mergeFrozenSegments, workerResourceLimits, decodeVectorIndexParts, bytesToVectors, freezeSegmentShared, DEFAULT_BACKPRESSURE_LIMIT, DEFAULT_REQUEST_TIMEOUT_MS, SHUTDOWN_TIMEOUT_MS, decodeVectorFilePayload, decodeVectorGraphPartPayload, assembleGraphParts, countDead, encodeSegmentState, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH, VALID_HNSW_METRICS, spawnNodeWorker, decodeVectorGraphPayload, graphPartsOfEarlierPayload, decodeStoredDocument, isDead } from './chunk-K4FZ55Q2.mjs';
|
|
5
|
+
import { requirePatternSearchFor, requirePartialWordSearchFor, collectQueryTermStats, mergePartitionStats, oversampledFacetConfig, fnv1a, availablePatternSearch, PATTERN_HOST, kWayMerge, mergeFacets, setNestedValue } from './chunk-YGLSR7BC.mjs';
|
|
6
6
|
import { detectRuntime, getLanguage } from './chunk-4MQ5F4IL.mjs';
|
|
7
|
-
import { MAX_INDEX_CONFIGURATION_BYTES, STATISTICS_BROADCAST_INTERVAL_MS, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, FOREIGN_STATS_TTL_MS, MAX_IMPORT_REFUSALS_REPORTED, BATCH_CHUNK_SIZE, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, EXPORT_CHUNK_BYTES } from './chunk-
|
|
8
|
-
import { releaseLocksHeldBy } from './chunk-
|
|
7
|
+
import { MAX_INDEX_CONFIGURATION_BYTES, STATISTICS_BROADCAST_INTERVAL_MS, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, FOREIGN_STATS_TTL_MS, MAX_IMPORT_REFUSALS_REPORTED, BATCH_CHUNK_SIZE, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, EXPORT_CHUNK_BYTES } from './chunk-GG2FBGVZ.mjs';
|
|
8
|
+
import { releaseLocksHeldBy } from './chunk-23HJ5QXQ.mjs';
|
|
9
9
|
import { requireSearchBackendSettings } from './chunk-2E35UM3G.mjs';
|
|
10
|
-
import { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES
|
|
11
|
-
import { getNestedValue, parseVectorDimension } from './chunk-
|
|
12
|
-
import { extractVectorFieldsFromSchema, messagePackUpperBoundBytes, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, raiseEarlierReleaseGraphSetting, partialFieldsOf, flattenSchema,
|
|
10
|
+
import { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES } from './chunk-R2XCJIO7.mjs';
|
|
11
|
+
import { getNestedValue, parseVectorDimension } from './chunk-P2PYEZZE.mjs';
|
|
12
|
+
import { extractVectorFieldsFromSchema, messagePackUpperBoundBytes, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, raiseEarlierReleaseGraphSetting, partialFieldsOf, flattenSchema, requireValidFieldTypes, encodeDocument, schemaFieldsOf, isQuantizationMode, isStorageMode, validateRequiredFields, requireDocumentWithinSizeLimit, validateDocument, validateDocumentStrict } from './chunk-OSF3SGJV.mjs';
|
|
13
13
|
import { MIN_M } from './chunk-KEHK2O6P.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { isSingleStringFieldType, VECTOR_PATTERN, MAX_DOCUMENT_NESTING_DEPTH } from './chunk-DQABW5UQ.mjs';
|
|
15
|
+
import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
15
16
|
import { createRequestId, isValidWorkerResponse, threadSlotOfWorker } from './chunk-POWOTUKJ.mjs';
|
|
16
17
|
import { ErrorCodes, NarsilError } from './chunk-I64LXKO3.mjs';
|
|
17
18
|
import { encode, decode } from '@msgpack/msgpack';
|
|
@@ -10324,65 +10325,18 @@ function stopIdleSweep(state) {
|
|
|
10324
10325
|
}
|
|
10325
10326
|
|
|
10326
10327
|
// src/core/pattern-index/matcher-budget.ts
|
|
10327
|
-
var POSITIONS_PER_WORD = 32;
|
|
10328
|
-
function positionWords(positions) {
|
|
10329
|
-
return Math.max(1, Math.ceil(positions / POSITIONS_PER_WORD));
|
|
10330
|
-
}
|
|
10331
|
-
function smallestMatcherBytes(positions) {
|
|
10332
|
-
return 2 * positionWords(positions) * Uint32Array.BYTES_PER_ELEMENT + positions * MATCHER_CODE_POINT_BYTES + positions * MATCHER_SIMULATION_BYTES_PER_POSITION + MATCHER_STATE_OVERHEAD_BYTES + positions * Uint32Array.BYTES_PER_ELEMENT;
|
|
10333
|
-
}
|
|
10334
10328
|
function widestPatternSplit(footprintBytes) {
|
|
10335
10329
|
return Math.max(1, Math.floor(MATCHER_STATE_BUDGET_BYTES / Math.max(1, footprintBytes)));
|
|
10336
10330
|
}
|
|
10337
10331
|
|
|
10338
10332
|
// src/core/pattern-index/query-positions.ts
|
|
10339
|
-
function isRecord4(value) {
|
|
10340
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10341
|
-
}
|
|
10342
|
-
function literalFootprint(text, caseFold) {
|
|
10343
|
-
if (typeof text !== "string") return null;
|
|
10344
|
-
return smallestMatcherBytes(caseFold ? foldedCodePointCount(text) : codePointCount(text));
|
|
10345
|
-
}
|
|
10346
|
-
function larger(left, right) {
|
|
10347
|
-
if (left === null) return right;
|
|
10348
|
-
if (right === null) return left;
|
|
10349
|
-
return Math.max(left, right);
|
|
10350
|
-
}
|
|
10351
|
-
function largestTestOf(filter, module) {
|
|
10352
|
-
const caseFold = filter.caseFold === true;
|
|
10353
|
-
let largest = null;
|
|
10354
|
-
for (const operator of PATTERN_TEST_OPERATORS) {
|
|
10355
|
-
const operand = filter[operator];
|
|
10356
|
-
if (operand === void 0) continue;
|
|
10357
|
-
const texts = Array.isArray(operand) ? operand : [operand];
|
|
10358
|
-
for (const text of texts) largest = larger(largest, literalFootprint(text, caseFold));
|
|
10359
|
-
}
|
|
10360
|
-
for (const operator of PATTERN_EXPRESSION_OPERATORS) {
|
|
10361
|
-
const pattern = filter[operator];
|
|
10362
|
-
if (typeof pattern !== "string") continue;
|
|
10363
|
-
largest = larger(largest, module.expressionFootprint(operator, pattern, caseFold, PATTERN_HOST));
|
|
10364
|
-
}
|
|
10365
|
-
return largest;
|
|
10366
|
-
}
|
|
10367
|
-
function largestIn(expression, patternFields, module) {
|
|
10368
|
-
let largest = null;
|
|
10369
|
-
if (isRecord4(expression.fields)) {
|
|
10370
|
-
for (const [fieldPath, filter] of Object.entries(expression.fields)) {
|
|
10371
|
-
if (patternFields.has(fieldPath) && isRecord4(filter)) largest = larger(largest, largestTestOf(filter, module));
|
|
10372
|
-
}
|
|
10373
|
-
}
|
|
10374
|
-
const nested = [...expression.and ?? [], ...expression.or ?? []];
|
|
10375
|
-
if (expression.not !== void 0) nested.push(expression.not);
|
|
10376
|
-
for (const child of nested) largest = larger(largest, largestIn(child, patternFields, module));
|
|
10377
|
-
return largest;
|
|
10378
|
-
}
|
|
10379
10333
|
function largestPatternFootprint(expression, schema) {
|
|
10380
10334
|
if (expression === void 0) return null;
|
|
10381
10335
|
const module = availablePatternSearch();
|
|
10382
10336
|
if (module === null) return null;
|
|
10383
10337
|
const patternFields = /* @__PURE__ */ new Set();
|
|
10384
10338
|
for (const { path, pattern } of schemaFieldsOf(schema)) if (pattern) patternFields.add(path);
|
|
10385
|
-
return patternFields.size === 0 ? null :
|
|
10339
|
+
return patternFields.size === 0 ? null : module.largestFootprint(expression, patternFields, PATTERN_HOST);
|
|
10386
10340
|
}
|
|
10387
10341
|
|
|
10388
10342
|
// src/engine/orchestration/search.ts
|
|
@@ -13096,7 +13050,7 @@ function refuse(path, reason) {
|
|
|
13096
13050
|
field: path
|
|
13097
13051
|
});
|
|
13098
13052
|
}
|
|
13099
|
-
function
|
|
13053
|
+
function isRecord4(value) {
|
|
13100
13054
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13101
13055
|
}
|
|
13102
13056
|
function startsWithTagPrefix(key) {
|
|
@@ -13163,7 +13117,7 @@ function untagTag(tag, value, path, depth) {
|
|
|
13163
13117
|
case NUMBER_TAG:
|
|
13164
13118
|
return numberOf(value, path);
|
|
13165
13119
|
case OBJECT_TAG:
|
|
13166
|
-
if (!
|
|
13120
|
+
if (!isRecord4(value)) refuse(path, `holds an "${OBJECT_TAG}" tag whose value is not an object`);
|
|
13167
13121
|
return untagMap(value, path, depth);
|
|
13168
13122
|
default:
|
|
13169
13123
|
return refuse(path, `holds an object whose only key, "${tag}", names no tag`);
|
|
@@ -13386,7 +13340,7 @@ function documentExportStream(header2, checkpoint) {
|
|
|
13386
13340
|
function invalidHeader(message) {
|
|
13387
13341
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The document export header ${message}`);
|
|
13388
13342
|
}
|
|
13389
|
-
function
|
|
13343
|
+
function isRecord5(value) {
|
|
13390
13344
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13391
13345
|
}
|
|
13392
13346
|
function configOfHeader(line) {
|
|
@@ -13402,7 +13356,7 @@ function configOfHeader(line) {
|
|
|
13402
13356
|
} catch {
|
|
13403
13357
|
invalidHeader("is not JSON");
|
|
13404
13358
|
}
|
|
13405
|
-
if (!
|
|
13359
|
+
if (!isRecord5(raw) || raw.format !== DOCUMENT_EXPORT_FORMAT || raw.version !== DOCUMENT_EXPORT_VERSION) {
|
|
13406
13360
|
invalidHeader(`must name format "${DOCUMENT_EXPORT_FORMAT}" and version ${DOCUMENT_EXPORT_VERSION}`);
|
|
13407
13361
|
}
|
|
13408
13362
|
const configuration = requireConfigurationShape(raw.index, "document export header");
|
|
@@ -13495,7 +13449,7 @@ async function takeLine(state, entry) {
|
|
|
13495
13449
|
refuse3(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line is not JSON");
|
|
13496
13450
|
return;
|
|
13497
13451
|
}
|
|
13498
|
-
if (!
|
|
13452
|
+
if (!isRecord5(document) || typeof document.id !== "string" || document.id.length === 0) {
|
|
13499
13453
|
refuse3(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line holds no document with a string id");
|
|
13500
13454
|
return;
|
|
13501
13455
|
}
|
|
@@ -1,145 +1,9 @@
|
|
|
1
1
|
import { EARLIER_RELEASE_MIN_M, MIN_M, MAX_M } from './chunk-KEHK2O6P.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_PATTERN_VALUE_LIMIT, isPlainObject, isWordIndexedBase, MAX_TEXT_FIELDS, MAX_VECTOR_DIMENSION, parseFieldType, MAX_DOCUMENT_BYTES, MAX_NESTING_DEPTH, PROTOTYPE_POLLUTION_KEYS, FIELD_NAME_PATTERN, RESERVED_ROOT_FIELDS, MAX_DOCUMENT_NESTING_DEPTH, VECTOR_PATTERN } from './chunk-DQABW5UQ.mjs';
|
|
3
|
+
import { compareCodePoints, holdsUnpairedSurrogate, exceedsCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
3
4
|
import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
|
|
4
5
|
import { encode } from '@msgpack/msgpack';
|
|
5
6
|
|
|
6
|
-
// src/schema/constants.ts
|
|
7
|
-
var MAX_NESTING_DEPTH = 4;
|
|
8
|
-
var MAX_DOCUMENT_NESTING_DEPTH = 32;
|
|
9
|
-
var DEFAULT_PATTERN_VALUE_LIMIT = 8192;
|
|
10
|
-
var MIN_PATTERN_VALUE_LIMIT = 1;
|
|
11
|
-
var MAX_PATTERN_VALUE_LIMIT = 65536;
|
|
12
|
-
var MAX_VECTOR_DIMENSION = 4096;
|
|
13
|
-
var MAX_STORED_VECTOR_DIMENSION = 65535;
|
|
14
|
-
var MAX_TEXT_FIELDS = 65536;
|
|
15
|
-
var MAX_DOCUMENT_BYTES = 16777216;
|
|
16
|
-
var PARSED_FIELD_TYPE_CACHE_ENTRIES = 1024;
|
|
17
|
-
|
|
18
|
-
// src/schema/validator/shared.ts
|
|
19
|
-
var VECTOR_PATTERN = /^vector\[(\d+)]$/;
|
|
20
|
-
function isGeopointOrVectorType(fieldType) {
|
|
21
|
-
return fieldType === "geopoint" || fieldType !== void 0 && VECTOR_PATTERN.test(fieldType);
|
|
22
|
-
}
|
|
23
|
-
var FIELD_NAME_PATTERN = /^[A-Za-z0-9_]+$/;
|
|
24
|
-
var RESERVED_ROOT_FIELDS = /* @__PURE__ */ new Set(["id"]);
|
|
25
|
-
var PROTOTYPE_POLLUTION_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
26
|
-
function isPlainObject(value) {
|
|
27
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/schema/validator/field-type.ts
|
|
31
|
-
var FIELD_OPTION_ORDER = ["sortable", "pattern", "partial"];
|
|
32
|
-
var OPTIONS_BY_BASE = {
|
|
33
|
-
string: FIELD_OPTION_ORDER,
|
|
34
|
-
"string[]": FIELD_OPTION_ORDER,
|
|
35
|
-
verbatim: ["sortable"],
|
|
36
|
-
"verbatim[]": ["sortable"],
|
|
37
|
-
number: [],
|
|
38
|
-
"number[]": [],
|
|
39
|
-
boolean: [],
|
|
40
|
-
"boolean[]": [],
|
|
41
|
-
enum: [],
|
|
42
|
-
"enum[]": [],
|
|
43
|
-
geopoint: [],
|
|
44
|
-
vector: []
|
|
45
|
-
};
|
|
46
|
-
var TYPE_SEPARATOR = ":";
|
|
47
|
-
function isNamedBase(name) {
|
|
48
|
-
return name !== "vector" && Object.hasOwn(OPTIONS_BY_BASE, name);
|
|
49
|
-
}
|
|
50
|
-
function describeAllowedOptions(baseName, allowed) {
|
|
51
|
-
if (allowed.length === 0) return `the "${baseName}" type has no options`;
|
|
52
|
-
const quoted = allowed.map((option) => `"${option}"`);
|
|
53
|
-
if (quoted.length === 1) return `the only option of the "${baseName}" type is ${quoted[0]}`;
|
|
54
|
-
return `the options of the "${baseName}" type are ${quoted.slice(0, -1).join(", ")}, and ${quoted[quoted.length - 1]}`;
|
|
55
|
-
}
|
|
56
|
-
function invalidType(path, type, message) {
|
|
57
|
-
throw new NarsilError(ErrorCodes.SCHEMA_INVALID_TYPE, message, { field: path, type });
|
|
58
|
-
}
|
|
59
|
-
function parseBase(baseName, path, type) {
|
|
60
|
-
if (isNamedBase(baseName)) return { base: baseName, dimension: 0 };
|
|
61
|
-
const vectorMatch = VECTOR_PATTERN.exec(baseName);
|
|
62
|
-
if (vectorMatch === null) {
|
|
63
|
-
invalidType(path, type, `Field "${path}" has an unsupported type: "${type}"`);
|
|
64
|
-
}
|
|
65
|
-
const dimension = Number.parseInt(vectorMatch[1], 10);
|
|
66
|
-
if (dimension <= 0 || dimension > MAX_STORED_VECTOR_DIMENSION) {
|
|
67
|
-
throw new NarsilError(
|
|
68
|
-
ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION,
|
|
69
|
-
`Vector field "${path}" has ${dimension} dimensions, but a vector field holds from 1 to ${MAX_STORED_VECTOR_DIMENSION}`,
|
|
70
|
-
{ field: path, dimension, maximum: MAX_STORED_VECTOR_DIMENSION }
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
return { base: "vector", dimension };
|
|
74
|
-
}
|
|
75
|
-
function parseFieldType(type, path) {
|
|
76
|
-
const separatorIndex = type.indexOf(TYPE_SEPARATOR);
|
|
77
|
-
const baseName = separatorIndex === -1 ? type : type.slice(0, separatorIndex);
|
|
78
|
-
const { base, dimension } = parseBase(baseName, path, type);
|
|
79
|
-
const allowed = OPTIONS_BY_BASE[base];
|
|
80
|
-
const options = /* @__PURE__ */ new Set();
|
|
81
|
-
if (separatorIndex !== -1) {
|
|
82
|
-
for (const option of type.slice(separatorIndex + 1).split(TYPE_SEPARATOR)) {
|
|
83
|
-
if (!allowed.includes(option)) {
|
|
84
|
-
invalidType(
|
|
85
|
-
path,
|
|
86
|
-
type,
|
|
87
|
-
`Field "${path}" has type "${type}" with the option "${option}", but ${describeAllowedOptions(baseName, allowed)}`
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
if (options.has(option)) {
|
|
91
|
-
invalidType(path, type, `Field "${path}" has the "${option}" option twice in type "${type}"`);
|
|
92
|
-
}
|
|
93
|
-
options.add(option);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const ordered = FIELD_OPTION_ORDER.filter((option) => options.has(option));
|
|
97
|
-
const verbatim = base === "verbatim" || base === "verbatim[]";
|
|
98
|
-
return {
|
|
99
|
-
type: [baseName, ...ordered].join(TYPE_SEPARATOR),
|
|
100
|
-
base,
|
|
101
|
-
sortable: options.has("sortable"),
|
|
102
|
-
pattern: verbatim || options.has("pattern"),
|
|
103
|
-
partial: options.has("partial"),
|
|
104
|
-
dimension
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
var parsedTypesByName = /* @__PURE__ */ new Map();
|
|
108
|
-
function parsedTypeOf(type) {
|
|
109
|
-
if (type === void 0) return void 0;
|
|
110
|
-
const known = parsedTypesByName.get(type);
|
|
111
|
-
if (known !== void 0) return known;
|
|
112
|
-
try {
|
|
113
|
-
const parsed = Object.freeze(parseFieldType(type, ""));
|
|
114
|
-
if (parsedTypesByName.size < PARSED_FIELD_TYPE_CACHE_ENTRIES) parsedTypesByName.set(type, parsed);
|
|
115
|
-
return parsed;
|
|
116
|
-
} catch {
|
|
117
|
-
return void 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function withSortableOption(parsed) {
|
|
121
|
-
if (parsed.sortable) return parsed.type;
|
|
122
|
-
const separatorIndex = parsed.type.indexOf(TYPE_SEPARATOR);
|
|
123
|
-
const baseName = separatorIndex === -1 ? parsed.type : parsed.type.slice(0, separatorIndex);
|
|
124
|
-
return parseFieldType(`${baseName}${TYPE_SEPARATOR}sortable${parsed.type.slice(baseName.length)}`, "").type;
|
|
125
|
-
}
|
|
126
|
-
function isListBase(base) {
|
|
127
|
-
return base.endsWith("[]");
|
|
128
|
-
}
|
|
129
|
-
function isWordIndexedBase(base) {
|
|
130
|
-
return base === "string" || base === "string[]";
|
|
131
|
-
}
|
|
132
|
-
function isSingleStringFieldType(fieldType) {
|
|
133
|
-
return parsedTypeOf(fieldType)?.base === "string";
|
|
134
|
-
}
|
|
135
|
-
function isWordIndexedFieldType(fieldType) {
|
|
136
|
-
const parsed = parsedTypeOf(fieldType);
|
|
137
|
-
return parsed !== void 0 && isWordIndexedBase(parsed.base);
|
|
138
|
-
}
|
|
139
|
-
function isStringValuedBase(base) {
|
|
140
|
-
return base === "string" || base === "string[]" || base === "verbatim" || base === "verbatim[]";
|
|
141
|
-
}
|
|
142
|
-
|
|
143
7
|
// src/schema/validator/schema.ts
|
|
144
8
|
function validateSchemaFields(schema, depth, prefix) {
|
|
145
9
|
if (depth > MAX_NESTING_DEPTH) {
|
|
@@ -801,4 +665,24 @@ function validateVectorPromotion(config) {
|
|
|
801
665
|
}
|
|
802
666
|
}
|
|
803
667
|
|
|
804
|
-
|
|
668
|
+
// src/search/constants.ts
|
|
669
|
+
var RESULT_WINDOW = 1e4;
|
|
670
|
+
var DEFAULT_PAGE_SIZE = 10;
|
|
671
|
+
var MAX_CURSOR_LENGTH = 40960;
|
|
672
|
+
var MAX_SORT_FIELDS = 8;
|
|
673
|
+
var MAX_SORT_FIELD_NAME_LENGTH = 255;
|
|
674
|
+
var MAX_CURSOR_ANCHOR_CODE_POINTS = 512;
|
|
675
|
+
var PREFIX_MAX_EXPANSIONS = 50;
|
|
676
|
+
var PARTIAL_WORDS_ADDED_PER_QUERY = 50;
|
|
677
|
+
var PARTIAL_WORD_MIN_CODE_POINTS = 3;
|
|
678
|
+
var DEFAULT_FUZZY_PREFIX_LENGTH = 2;
|
|
679
|
+
var MAX_TOLERANCE = 10;
|
|
680
|
+
var MAX_PREFIX_LENGTH = 1024;
|
|
681
|
+
var DEFAULT_MAX_PER_GROUP = 1;
|
|
682
|
+
var DEFAULT_RANK_CONSTANT = 60;
|
|
683
|
+
var MIN_RANK_CONSTANT = 1;
|
|
684
|
+
var DEFAULT_LINEAR_ALPHA = 0.5;
|
|
685
|
+
var MIN_LINEAR_ALPHA = 0;
|
|
686
|
+
var MAX_LINEAR_ALPHA = 1;
|
|
687
|
+
|
|
688
|
+
export { ANTIMERIDIAN_SPAN_DEGREES, DEFAULT_FUZZY_PREFIX_LENGTH, DEFAULT_LINEAR_ALPHA, DEFAULT_MAX_PER_GROUP, DEFAULT_PAGE_SIZE, DEFAULT_RANK_CONSTANT, DEG_TO_RAD, EARTH_RADIUS_METERS, FULL_TURN_DEGREES, LOCATION_CODE_BITS_PER_AXIS, MAX_COVERING_CELLS, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_CURSOR_LENGTH, MAX_LATITUDE_DEGREES, MAX_LINEAR_ALPHA, MAX_LONGITUDE_DEGREES, MAX_PREFIX_LENGTH, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_TOLERANCE, MIN_LINEAR_ALPHA, MIN_POLYGON_POINTS, MIN_RANK_CONSTANT, PARTIAL_WORDS_ADDED_PER_QUERY, PARTIAL_WORD_MIN_CODE_POINTS, PREFIX_MAX_EXPANSIONS, RADIUS_BOX_MARGIN_RADIANS, RADIUS_BOX_MARGIN_RATIO, RESULT_WINDOW, VINCENTY_CONVERGENCE_THRESHOLD, VINCENTY_MAX_ITERATIONS, encodeDocument, extractVectorFieldsFromSchema, flattenSchema, isLatitude, isLongitude, isQuantizationMode, isStorageMode, messagePackUpperBoundBytes, partialFieldsOf, raiseEarlierReleaseGraphSetting, requireCreatableSchema, requireDocumentWithinSizeLimit, requireValidFieldTypes, schemaFieldsOf, validateDocument, validateDocumentStrict, validateRequiredFields, validateSchema, validateVectorPromotion, validateVectorStorage };
|