@delali/narsil 0.1.7 → 0.1.8
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 +44 -2
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +46 -2
- 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-BbRkoiu9.d.ts → adapters-Bo2JQg8b.d.ts} +2 -1
- package/dist/chunk-ALB35PRQ.mjs +98 -0
- package/dist/{chunk-KHL4RPC3.mjs → chunk-FS7XLIUS.mjs} +2536 -2284
- package/dist/chunk-GQEHCZG7.mjs +6825 -0
- package/dist/chunk-KMMJMDUA.mjs +44 -0
- package/dist/chunk-RQLXC2YS.mjs +269 -0
- package/dist/chunk-S7RJJMHI.mjs +1086 -0
- package/dist/{chunk-I24SGLFS.mjs → chunk-TW6BXTOL.mjs} +5 -1
- package/dist/chunk-WISGW24C.mjs +455 -0
- package/dist/config-cQLlYR3U.d.ts +470 -0
- package/dist/direct-executor-FX56DYD3.mjs +4 -0
- package/dist/distribution/coordinator/etcd.d.ts +16 -0
- package/dist/distribution/coordinator/etcd.mjs +2 -0
- package/dist/distribution/coordinator/in-memory.d.ts +7 -0
- package/dist/distribution/coordinator/in-memory.mjs +1 -0
- package/dist/distribution.d.ts +122 -0
- package/dist/distribution.mjs +7410 -0
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/index.browser.mjs +11469 -7481
- package/dist/index.d.ts +6 -450
- package/dist/index.mjs +7 -3236
- 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/{language-ClUGLuoC.d.ts → language-ONQ3iVDf.d.ts} +1 -0
- package/dist/languages/arabic.d.ts +1 -1
- package/dist/languages/armenian.d.ts +1 -1
- package/dist/languages/bulgarian.d.ts +1 -1
- package/dist/languages/chinese.d.ts +1 -1
- package/dist/languages/dagbani.d.ts +1 -1
- package/dist/languages/danish.d.ts +1 -1
- package/dist/languages/dutch.d.ts +1 -1
- package/dist/languages/english.d.ts +1 -1
- package/dist/languages/english.mjs +1 -1
- package/dist/languages/ewe.d.ts +1 -1
- package/dist/languages/finnish.d.ts +1 -1
- package/dist/languages/french.d.ts +1 -1
- package/dist/languages/ga.d.ts +1 -1
- package/dist/languages/german.d.ts +1 -1
- package/dist/languages/greek.d.ts +1 -1
- package/dist/languages/hausa.d.ts +1 -1
- package/dist/languages/hindi.d.ts +1 -1
- package/dist/languages/hungarian.d.ts +1 -1
- package/dist/languages/igbo.d.ts +1 -1
- package/dist/languages/indonesian.d.ts +1 -1
- package/dist/languages/irish.d.ts +1 -1
- package/dist/languages/italian.d.ts +1 -1
- package/dist/languages/japanese.d.ts +1 -1
- package/dist/languages/nepali.d.ts +1 -1
- package/dist/languages/norwegian.d.ts +1 -1
- package/dist/languages/portuguese.d.ts +1 -1
- package/dist/languages/romanian.d.ts +1 -1
- package/dist/languages/russian.d.ts +1 -1
- package/dist/languages/sanskrit.d.ts +1 -1
- package/dist/languages/serbian.d.ts +1 -1
- package/dist/languages/slovenian.d.ts +1 -1
- package/dist/languages/spanish.d.ts +1 -1
- package/dist/languages/swahili.d.ts +1 -1
- package/dist/languages/swedish.d.ts +1 -1
- package/dist/languages/tamil.d.ts +1 -1
- package/dist/languages/turkish.d.ts +1 -1
- package/dist/languages/twi.d.ts +1 -1
- package/dist/languages/ukrainian.d.ts +1 -1
- package/dist/languages/yoruba.d.ts +1 -1
- package/dist/languages/zulu.d.ts +1 -1
- package/dist/narsil-ChTdkwPu.d.ts +68 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +41 -0
- package/dist/persistence/durability/checkpoint-worker.mjs +59 -0
- package/dist/schema-BVaw7nqz.d.ts +58 -0
- package/dist/serialization/crc32-worker.d.ts +20 -0
- package/dist/serialization/crc32-worker.mjs +61 -0
- package/dist/server.d.ts +218 -0
- package/dist/server.mjs +1185 -0
- package/dist/types-Bt7c4hDF.d.ts +73 -0
- package/dist/vector/hnsw-build-worker.mjs +1 -1
- package/dist/workers/entry.mjs +1 -1
- package/package.json +37 -2
- package/dist/chunk-R2C2EQGO.mjs +0 -53
- package/dist/chunk-VVORJOXR.mjs +0 -759
- package/dist/direct-executor-LBJLGMJ2.mjs +0 -4
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { b as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter } from './adapters-Bo2JQg8b.js';
|
|
2
|
+
import { A as AnyDocument, b as ScoringMode, S as SchemaDefinition, I as IndexConfig } from './schema-BVaw7nqz.js';
|
|
3
|
+
|
|
4
|
+
declare const ErrorCodes: {
|
|
5
|
+
readonly SCHEMA_INVALID_TYPE: "SCHEMA_INVALID_TYPE";
|
|
6
|
+
readonly SCHEMA_MISSING_FIELD: "SCHEMA_MISSING_FIELD";
|
|
7
|
+
readonly SCHEMA_DEPTH_EXCEEDED: "SCHEMA_DEPTH_EXCEEDED";
|
|
8
|
+
readonly SCHEMA_INVALID_VECTOR_DIMENSION: "SCHEMA_INVALID_VECTOR_DIMENSION";
|
|
9
|
+
readonly SCHEMA_INVALID_GEOPOINT: "SCHEMA_INVALID_GEOPOINT";
|
|
10
|
+
readonly DOC_NOT_FOUND: "DOC_NOT_FOUND";
|
|
11
|
+
readonly DOC_ALREADY_EXISTS: "DOC_ALREADY_EXISTS";
|
|
12
|
+
readonly DOC_VALIDATION_FAILED: "DOC_VALIDATION_FAILED";
|
|
13
|
+
readonly INDEX_NOT_FOUND: "INDEX_NOT_FOUND";
|
|
14
|
+
readonly INDEX_ALREADY_EXISTS: "INDEX_ALREADY_EXISTS";
|
|
15
|
+
readonly PARTITION_CORRUPTED: "PARTITION_CORRUPTED";
|
|
16
|
+
readonly PARTITION_REBALANCING_BACKPRESSURE: "PARTITION_REBALANCING_BACKPRESSURE";
|
|
17
|
+
readonly WORKER_CRASHED: "WORKER_CRASHED";
|
|
18
|
+
readonly WORKER_BUSY: "WORKER_BUSY";
|
|
19
|
+
readonly WORKER_TIMEOUT: "WORKER_TIMEOUT";
|
|
20
|
+
readonly PERSISTENCE_SAVE_FAILED: "PERSISTENCE_SAVE_FAILED";
|
|
21
|
+
readonly PERSISTENCE_LOAD_FAILED: "PERSISTENCE_LOAD_FAILED";
|
|
22
|
+
readonly PERSISTENCE_DELETE_FAILED: "PERSISTENCE_DELETE_FAILED";
|
|
23
|
+
readonly PERSISTENCE_CRC_MISMATCH: "PERSISTENCE_CRC_MISMATCH";
|
|
24
|
+
readonly PERSISTENCE_WAL_CORRUPT: "PERSISTENCE_WAL_CORRUPT";
|
|
25
|
+
readonly PERSISTENCE_FSYNC_FAILED: "PERSISTENCE_FSYNC_FAILED";
|
|
26
|
+
readonly SEARCH_INVALID_FIELD: "SEARCH_INVALID_FIELD";
|
|
27
|
+
readonly SEARCH_INVALID_VECTOR_SIZE: "SEARCH_INVALID_VECTOR_SIZE";
|
|
28
|
+
readonly VECTOR_DIMENSION_MISMATCH: "VECTOR_DIMENSION_MISMATCH";
|
|
29
|
+
readonly SEARCH_INVALID_FILTER: "SEARCH_INVALID_FILTER";
|
|
30
|
+
readonly SEARCH_INVALID_MODE: "SEARCH_INVALID_MODE";
|
|
31
|
+
readonly SEARCH_INVALID_CURSOR: "SEARCH_INVALID_CURSOR";
|
|
32
|
+
readonly LANGUAGE_NOT_SUPPORTED: "LANGUAGE_NOT_SUPPORTED";
|
|
33
|
+
readonly ENVELOPE_VERSION_MISMATCH: "ENVELOPE_VERSION_MISMATCH";
|
|
34
|
+
readonly ENVELOPE_INVALID_MAGIC: "ENVELOPE_INVALID_MAGIC";
|
|
35
|
+
readonly PARTITION_CAPACITY_EXCEEDED: "PARTITION_CAPACITY_EXCEEDED";
|
|
36
|
+
readonly EMBEDDING_FAILED: "EMBEDDING_FAILED";
|
|
37
|
+
readonly EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH";
|
|
38
|
+
readonly EMBEDDING_NO_SOURCE: "EMBEDDING_NO_SOURCE";
|
|
39
|
+
readonly EMBEDDING_CONFIG_INVALID: "EMBEDDING_CONFIG_INVALID";
|
|
40
|
+
readonly DOC_MISSING_REQUIRED_FIELD: "DOC_MISSING_REQUIRED_FIELD";
|
|
41
|
+
readonly CONFIG_INVALID: "CONFIG_INVALID";
|
|
42
|
+
readonly QUERY_ROUTING_FAILED: "QUERY_ROUTING_FAILED";
|
|
43
|
+
readonly QUERY_PARTIAL_FAILURE: "QUERY_PARTIAL_FAILURE";
|
|
44
|
+
readonly QUERY_NODE_TIMEOUT: "QUERY_NODE_TIMEOUT";
|
|
45
|
+
readonly QUERY_NO_ACTIVE_REPLICA: "QUERY_NO_ACTIVE_REPLICA";
|
|
46
|
+
readonly ALLOCATION_NO_DATA_NODES: "ALLOCATION_NO_DATA_NODES";
|
|
47
|
+
readonly ALLOCATION_INVALID_CONFIG: "ALLOCATION_INVALID_CONFIG";
|
|
48
|
+
readonly ALLOCATION_FAILED: "ALLOCATION_FAILED";
|
|
49
|
+
readonly CONTROLLER_LEASE_LOST: "CONTROLLER_LEASE_LOST";
|
|
50
|
+
readonly CONTROLLER_NOT_ACTIVE: "CONTROLLER_NOT_ACTIVE";
|
|
51
|
+
readonly CONTROLLER_METADATA_INVALID: "CONTROLLER_METADATA_INVALID";
|
|
52
|
+
readonly NODE_BOOTSTRAP_FAILED: "NODE_BOOTSTRAP_FAILED";
|
|
53
|
+
readonly NODE_ALREADY_JOINED: "NODE_ALREADY_JOINED";
|
|
54
|
+
readonly NODE_NOT_JOINED: "NODE_NOT_JOINED";
|
|
55
|
+
readonly COORDINATOR_DEPENDENCY_MISSING: "COORDINATOR_DEPENDENCY_MISSING";
|
|
56
|
+
readonly REPLICATION_ENTRY_INVALID: "REPLICATION_ENTRY_INVALID";
|
|
57
|
+
readonly REPLICATION_INSYNC_REMOVAL_FAILED: "REPLICATION_INSYNC_REMOVAL_FAILED";
|
|
58
|
+
readonly REPLICATION_ROLLBACK_FAILED: "REPLICATION_ROLLBACK_FAILED";
|
|
59
|
+
readonly SNAPSHOT_SYNC_UNAUTHORIZED: "SNAPSHOT_SYNC_UNAUTHORIZED";
|
|
60
|
+
readonly SNAPSHOT_SYNC_REQUEST_INVALID: "SNAPSHOT_SYNC_REQUEST_INVALID";
|
|
61
|
+
readonly SNAPSHOT_SYNC_INDEX_NOT_FOUND: "SNAPSHOT_SYNC_INDEX_NOT_FOUND";
|
|
62
|
+
readonly SNAPSHOT_SYNC_TOO_LARGE: "SNAPSHOT_SYNC_TOO_LARGE";
|
|
63
|
+
readonly SNAPSHOT_SYNC_CAPACITY_EXHAUSTED: "SNAPSHOT_SYNC_CAPACITY_EXHAUSTED";
|
|
64
|
+
readonly SNAPSHOT_SYNC_SNAPSHOT_FAILED: "SNAPSHOT_SYNC_SNAPSHOT_FAILED";
|
|
65
|
+
readonly SNAPSHOT_SYNC_DECODE_FAILED: "SNAPSHOT_SYNC_DECODE_FAILED";
|
|
66
|
+
readonly SNAPSHOT_SYNC_FRAME_INVALID: "SNAPSHOT_SYNC_FRAME_INVALID";
|
|
67
|
+
readonly SNAPSHOT_SYNC_HEADER_INVALID: "SNAPSHOT_SYNC_HEADER_INVALID";
|
|
68
|
+
readonly SNAPSHOT_SYNC_HEADER_MISMATCH: "SNAPSHOT_SYNC_HEADER_MISMATCH";
|
|
69
|
+
readonly SNAPSHOT_SYNC_CHUNK_OUT_OF_ORDER: "SNAPSHOT_SYNC_CHUNK_OUT_OF_ORDER";
|
|
70
|
+
readonly SNAPSHOT_SYNC_CHUNK_OVERFLOW: "SNAPSHOT_SYNC_CHUNK_OVERFLOW";
|
|
71
|
+
readonly SNAPSHOT_SYNC_CHUNK_SIZE_EXCEEDED: "SNAPSHOT_SYNC_CHUNK_SIZE_EXCEEDED";
|
|
72
|
+
readonly SNAPSHOT_SYNC_CHUNK_MISSING: "SNAPSHOT_SYNC_CHUNK_MISSING";
|
|
73
|
+
readonly SNAPSHOT_SYNC_END_MISSING: "SNAPSHOT_SYNC_END_MISSING";
|
|
74
|
+
readonly SNAPSHOT_SYNC_CHECKSUM_MISMATCH: "SNAPSHOT_SYNC_CHECKSUM_MISMATCH";
|
|
75
|
+
readonly SNAPSHOT_SYNC_PRIMARY_ERROR: "SNAPSHOT_SYNC_PRIMARY_ERROR";
|
|
76
|
+
readonly SNAPSHOT_SYNC_NO_TARGETS: "SNAPSHOT_SYNC_NO_TARGETS";
|
|
77
|
+
readonly SNAPSHOT_SYNC_TRANSPORT_FAILED: "SNAPSHOT_SYNC_TRANSPORT_FAILED";
|
|
78
|
+
readonly SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE: "SNAPSHOT_SYNC_SCHEMA_UNAVAILABLE";
|
|
79
|
+
readonly SNAPSHOT_SYNC_RESTORE_FAILED: "SNAPSHOT_SYNC_RESTORE_FAILED";
|
|
80
|
+
readonly SNAPSHOT_SYNC_RESTORE_CLEANUP_FAILED: "SNAPSHOT_SYNC_RESTORE_CLEANUP_FAILED";
|
|
81
|
+
readonly SNAPSHOT_SYNC_TIMEOUT: "SNAPSHOT_SYNC_TIMEOUT";
|
|
82
|
+
readonly SNAPSHOT_SYNC_ALLOCATION_UNAVAILABLE: "SNAPSHOT_SYNC_ALLOCATION_UNAVAILABLE";
|
|
83
|
+
readonly SNAPSHOT_SYNC_NOT_ASSIGNED: "SNAPSHOT_SYNC_NOT_ASSIGNED";
|
|
84
|
+
readonly SNAPSHOT_SYNC_ABORTED: "SNAPSHOT_SYNC_ABORTED";
|
|
85
|
+
};
|
|
86
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
87
|
+
declare class NarsilError extends Error {
|
|
88
|
+
readonly code: ErrorCode;
|
|
89
|
+
readonly details: Record<string, unknown>;
|
|
90
|
+
constructor(code: ErrorCode, message: string, details?: Record<string, unknown>);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type ComparisonFilter = {
|
|
94
|
+
eq?: number | string | boolean;
|
|
95
|
+
ne?: number | string | boolean;
|
|
96
|
+
gt?: number;
|
|
97
|
+
lt?: number;
|
|
98
|
+
gte?: number;
|
|
99
|
+
lte?: number;
|
|
100
|
+
between?: [number, number];
|
|
101
|
+
};
|
|
102
|
+
type StringFilter = ComparisonFilter & {
|
|
103
|
+
in?: string[];
|
|
104
|
+
nin?: string[];
|
|
105
|
+
startsWith?: string;
|
|
106
|
+
endsWith?: string;
|
|
107
|
+
};
|
|
108
|
+
type ArrayFilter = {
|
|
109
|
+
containsAll?: (string | number | boolean)[];
|
|
110
|
+
matchesAny?: (string | number | boolean)[];
|
|
111
|
+
size?: ComparisonFilter;
|
|
112
|
+
};
|
|
113
|
+
type PresenceFilter = {
|
|
114
|
+
exists?: boolean;
|
|
115
|
+
notExists?: boolean;
|
|
116
|
+
isEmpty?: boolean;
|
|
117
|
+
isNotEmpty?: boolean;
|
|
118
|
+
};
|
|
119
|
+
type GeoRadiusFilter = {
|
|
120
|
+
radius: {
|
|
121
|
+
lat: number;
|
|
122
|
+
lon: number;
|
|
123
|
+
distance: number;
|
|
124
|
+
unit: 'km' | 'mi' | 'm';
|
|
125
|
+
inside?: boolean;
|
|
126
|
+
highPrecision?: boolean;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
type GeoPolygonFilter = {
|
|
130
|
+
polygon: {
|
|
131
|
+
points: Array<{
|
|
132
|
+
lat: number;
|
|
133
|
+
lon: number;
|
|
134
|
+
}>;
|
|
135
|
+
inside?: boolean;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
type GeoFilter = GeoRadiusFilter | GeoPolygonFilter;
|
|
139
|
+
type FieldFilter = ComparisonFilter | StringFilter | ArrayFilter | PresenceFilter | GeoFilter;
|
|
140
|
+
type FilterExpression = {
|
|
141
|
+
fields?: Record<string, FieldFilter>;
|
|
142
|
+
and?: FilterExpression[];
|
|
143
|
+
or?: FilterExpression[];
|
|
144
|
+
not?: FilterExpression;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
type SearchMode = 'fulltext' | 'vector' | 'hybrid';
|
|
148
|
+
type TermMatchPolicy = 'all' | 'any' | number;
|
|
149
|
+
interface QueryParams {
|
|
150
|
+
term?: string;
|
|
151
|
+
fields?: string[];
|
|
152
|
+
filters?: FilterExpression;
|
|
153
|
+
boost?: Record<string, number>;
|
|
154
|
+
scoring?: ScoringMode;
|
|
155
|
+
minScore?: number;
|
|
156
|
+
termMatch?: TermMatchPolicy;
|
|
157
|
+
tolerance?: number;
|
|
158
|
+
prefixLength?: number;
|
|
159
|
+
exact?: boolean;
|
|
160
|
+
facets?: FacetConfig;
|
|
161
|
+
sort?: Record<string, 'asc' | 'desc'>;
|
|
162
|
+
group?: GroupConfig;
|
|
163
|
+
limit?: number;
|
|
164
|
+
offset?: number;
|
|
165
|
+
searchAfter?: string;
|
|
166
|
+
highlight?: HighlightConfig;
|
|
167
|
+
pinned?: Array<{
|
|
168
|
+
docId: string;
|
|
169
|
+
position: number;
|
|
170
|
+
}>;
|
|
171
|
+
mode?: SearchMode;
|
|
172
|
+
vector?: VectorQueryConfig;
|
|
173
|
+
hybrid?: HybridConfig;
|
|
174
|
+
includeScoreComponents?: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Vector-search inputs passed under `QueryParams.vector`.
|
|
178
|
+
*
|
|
179
|
+
* Supply either a raw `value` array or a `text` string for auto-embedding;
|
|
180
|
+
* passing both throws `EMBEDDING_CONFIG_INVALID`. Result count is governed
|
|
181
|
+
* by the outer query's `limit`, not by any field on this object.
|
|
182
|
+
*/
|
|
183
|
+
interface VectorQueryConfig {
|
|
184
|
+
/**
|
|
185
|
+
* Name of the schema field that holds the vector to compare against.
|
|
186
|
+
* Must reference a field declared as `vector[N]` in the index schema.
|
|
187
|
+
*/
|
|
188
|
+
field: string;
|
|
189
|
+
/**
|
|
190
|
+
* Raw query vector. Length must match the indexed field's dimension or
|
|
191
|
+
* the search rejects the request with `VECTOR_DIMENSION_MISMATCH`.
|
|
192
|
+
*/
|
|
193
|
+
value?: number[];
|
|
194
|
+
/**
|
|
195
|
+
* Text to embed at query time using the index or instance embedding
|
|
196
|
+
* adapter. Mutually exclusive with `value`; requires a configured adapter.
|
|
197
|
+
*/
|
|
198
|
+
text?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Score floor applied during ranking. Hits scoring below this value
|
|
201
|
+
* are dropped before `limit` is enforced, so the returned hit count
|
|
202
|
+
* can be smaller than `limit` even when more documents exist. The
|
|
203
|
+
* floor is interpreted in score space for every metric; for
|
|
204
|
+
* `euclidean`, distance is mapped to a similarity score of
|
|
205
|
+
* `1 / (1 + distance)` first. Defaults to no floor.
|
|
206
|
+
*/
|
|
207
|
+
similarity?: number;
|
|
208
|
+
/**
|
|
209
|
+
* Similarity metric used for ranking. Defaults to `cosine`. Choose
|
|
210
|
+
* `dotProduct` for raw inner-product scoring on already-normalised
|
|
211
|
+
* vectors and `euclidean` for distance-based ordering.
|
|
212
|
+
*/
|
|
213
|
+
metric?: 'cosine' | 'dotProduct' | 'euclidean';
|
|
214
|
+
/**
|
|
215
|
+
* HNSW exploration factor for approximate search. Higher values raise
|
|
216
|
+
* recall at the cost of latency. Ignored while the field is still
|
|
217
|
+
* served by the brute-force backend. Defaults to the engine's built-in
|
|
218
|
+
* value when omitted.
|
|
219
|
+
*/
|
|
220
|
+
efSearch?: number;
|
|
221
|
+
}
|
|
222
|
+
interface HybridConfig {
|
|
223
|
+
strategy?: 'rrf' | 'linear';
|
|
224
|
+
k?: number;
|
|
225
|
+
alpha?: number;
|
|
226
|
+
}
|
|
227
|
+
interface FacetConfig {
|
|
228
|
+
[field: string]: {
|
|
229
|
+
limit?: number;
|
|
230
|
+
sort?: 'asc' | 'desc';
|
|
231
|
+
ranges?: Array<{
|
|
232
|
+
from: number;
|
|
233
|
+
to: number;
|
|
234
|
+
}>;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
interface GroupConfig {
|
|
238
|
+
fields: string[];
|
|
239
|
+
maxPerGroup?: number;
|
|
240
|
+
reduce?: GroupReducer;
|
|
241
|
+
}
|
|
242
|
+
type GroupReducer = {
|
|
243
|
+
reducer: (accumulator: unknown, doc: AnyDocument, score: number) => unknown;
|
|
244
|
+
initialValue: () => unknown;
|
|
245
|
+
};
|
|
246
|
+
interface HighlightConfig {
|
|
247
|
+
fields: string[];
|
|
248
|
+
preTag?: string;
|
|
249
|
+
postTag?: string;
|
|
250
|
+
maxSnippetLength?: number;
|
|
251
|
+
}
|
|
252
|
+
interface SuggestParams {
|
|
253
|
+
prefix: string;
|
|
254
|
+
limit?: number;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface QueryResult<T = AnyDocument> {
|
|
258
|
+
hits: Array<Hit<T>>;
|
|
259
|
+
count: number;
|
|
260
|
+
elapsed: number;
|
|
261
|
+
cursor?: string;
|
|
262
|
+
facets?: Record<string, FacetResult>;
|
|
263
|
+
groups?: GroupResult[];
|
|
264
|
+
}
|
|
265
|
+
interface Hit<T = AnyDocument> {
|
|
266
|
+
id: string;
|
|
267
|
+
score: number;
|
|
268
|
+
document: T;
|
|
269
|
+
scoreComponents?: ScoreComponents;
|
|
270
|
+
highlights?: Record<string, HighlightMatch>;
|
|
271
|
+
}
|
|
272
|
+
interface ScoreComponents {
|
|
273
|
+
termFrequencies: Record<string, number>;
|
|
274
|
+
fieldLengths: Record<string, number>;
|
|
275
|
+
idf: Record<string, number>;
|
|
276
|
+
}
|
|
277
|
+
interface HighlightMatch {
|
|
278
|
+
snippet: string;
|
|
279
|
+
positions: Array<{
|
|
280
|
+
start: number;
|
|
281
|
+
end: number;
|
|
282
|
+
}>;
|
|
283
|
+
}
|
|
284
|
+
interface FacetResult {
|
|
285
|
+
values: Record<string, number>;
|
|
286
|
+
count: number;
|
|
287
|
+
}
|
|
288
|
+
interface GroupResult {
|
|
289
|
+
values: Record<string, unknown>;
|
|
290
|
+
hits: Array<Hit>;
|
|
291
|
+
}
|
|
292
|
+
interface PreflightResult {
|
|
293
|
+
count: number;
|
|
294
|
+
elapsed: number;
|
|
295
|
+
}
|
|
296
|
+
interface BatchResult {
|
|
297
|
+
succeeded: string[];
|
|
298
|
+
failed: Array<{
|
|
299
|
+
docId: string;
|
|
300
|
+
error: NarsilError;
|
|
301
|
+
}>;
|
|
302
|
+
}
|
|
303
|
+
interface IndexStats {
|
|
304
|
+
documentCount: number;
|
|
305
|
+
partitionCount: number;
|
|
306
|
+
/**
|
|
307
|
+
* Formula-based estimate of the index's main-thread memory footprint, summed
|
|
308
|
+
* across every partition and vector index for this index. Computed from
|
|
309
|
+
* structural counters (document count, posting counts, field-index sizes),
|
|
310
|
+
* not measured. Per-object V8 overhead (hidden classes, map transitions,
|
|
311
|
+
* GC headers) is not captured here, so this number routinely undershoots
|
|
312
|
+
* the real heap by a meaningful factor. Use {@link Narsil.getMemoryStats}
|
|
313
|
+
* when sizing host memory.
|
|
314
|
+
*/
|
|
315
|
+
estimatedMemoryBytes: number;
|
|
316
|
+
language: string;
|
|
317
|
+
schema: SchemaDefinition;
|
|
318
|
+
}
|
|
319
|
+
interface IndexInfo {
|
|
320
|
+
name: string;
|
|
321
|
+
documentCount: number;
|
|
322
|
+
partitionCount: number;
|
|
323
|
+
language: string;
|
|
324
|
+
}
|
|
325
|
+
interface PartitionStatsResult {
|
|
326
|
+
partitionId: number;
|
|
327
|
+
documentCount: number;
|
|
328
|
+
/**
|
|
329
|
+
* Formula-based estimate of this partition's memory footprint. V8 has no
|
|
330
|
+
* per-object heap accounting API, so this number is derived from structural
|
|
331
|
+
* counters (document count, posting counts, field-index sizes) and does not
|
|
332
|
+
* include per-object overhead. Treat as an estimate, not a measurement.
|
|
333
|
+
*/
|
|
334
|
+
estimatedMemoryBytes: number;
|
|
335
|
+
}
|
|
336
|
+
interface SuggestResult {
|
|
337
|
+
terms: Array<{
|
|
338
|
+
term: string;
|
|
339
|
+
documentFrequency: number;
|
|
340
|
+
}>;
|
|
341
|
+
elapsed: number;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Snapshot of V8 heap usage as reported by `process.memoryUsage()`. All values
|
|
345
|
+
* are bytes. `null` in environments that do not expose `process.memoryUsage`,
|
|
346
|
+
* such as browsers.
|
|
347
|
+
*/
|
|
348
|
+
interface ProcessMemoryReport {
|
|
349
|
+
heapUsed: number;
|
|
350
|
+
heapTotal: number;
|
|
351
|
+
external: number;
|
|
352
|
+
rss: number;
|
|
353
|
+
}
|
|
354
|
+
interface MemoryStats {
|
|
355
|
+
/**
|
|
356
|
+
* V8 heap usage for the host process at the moment the call was made. This
|
|
357
|
+
* is process-wide, not engine-wide; if multiple Narsil engines are running
|
|
358
|
+
* in the same process every engine's `getMemoryStats` returns the same
|
|
359
|
+
* `process` figures. `null` in browsers and any runtime where
|
|
360
|
+
* `process.memoryUsage` is unavailable.
|
|
361
|
+
*/
|
|
362
|
+
process: ProcessMemoryReport | null;
|
|
363
|
+
/**
|
|
364
|
+
* Sum of every index's {@link IndexStats.estimatedMemoryBytes} held by this
|
|
365
|
+
* engine. Formula-based; treat as an estimate, not a measurement. Useful
|
|
366
|
+
* for cross-engine relative comparisons inside a single process where
|
|
367
|
+
* `process.heapUsed` cannot tell engines apart.
|
|
368
|
+
*/
|
|
369
|
+
estimatedIndexBytes: number;
|
|
370
|
+
/**
|
|
371
|
+
* Per-worker V8 heap usage when the engine has been promoted to a worker
|
|
372
|
+
* pool. Empty when no workers are active.
|
|
373
|
+
*/
|
|
374
|
+
workers: Array<{
|
|
375
|
+
workerId: number;
|
|
376
|
+
heapUsed: number;
|
|
377
|
+
heapTotal: number;
|
|
378
|
+
external: number;
|
|
379
|
+
}>;
|
|
380
|
+
}
|
|
381
|
+
interface VectorMaintenanceResult {
|
|
382
|
+
fieldName: string;
|
|
383
|
+
tombstoneRatio: number;
|
|
384
|
+
graphCount: number;
|
|
385
|
+
bufferSize: number;
|
|
386
|
+
building: boolean;
|
|
387
|
+
estimatedCompactMs: number;
|
|
388
|
+
estimatedOptimizeMs: number;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
interface NarsilPlugin {
|
|
392
|
+
name: string;
|
|
393
|
+
beforeInsert?(ctx: InsertContext): void | Promise<void>;
|
|
394
|
+
afterInsert?(ctx: InsertContext): void | Promise<void>;
|
|
395
|
+
beforeRemove?(ctx: RemoveContext): void | Promise<void>;
|
|
396
|
+
afterRemove?(ctx: RemoveContext): void | Promise<void>;
|
|
397
|
+
beforeUpdate?(ctx: UpdateContext): void | Promise<void>;
|
|
398
|
+
afterUpdate?(ctx: UpdateContext): void | Promise<void>;
|
|
399
|
+
beforeSearch?(ctx: SearchContext): void | Promise<void>;
|
|
400
|
+
afterSearch?(ctx: SearchContext): void | Promise<void>;
|
|
401
|
+
onIndexCreate?(ctx: IndexContext): void | Promise<void>;
|
|
402
|
+
onIndexDrop?(ctx: IndexContext): void | Promise<void>;
|
|
403
|
+
onPartitionSplit?(ctx: PartitionContext): void | Promise<void>;
|
|
404
|
+
onWorkerPromote?(ctx: WorkerContext): void | Promise<void>;
|
|
405
|
+
}
|
|
406
|
+
interface InsertContext {
|
|
407
|
+
indexName: string;
|
|
408
|
+
docId: string;
|
|
409
|
+
document: AnyDocument;
|
|
410
|
+
}
|
|
411
|
+
interface RemoveContext {
|
|
412
|
+
indexName: string;
|
|
413
|
+
docId: string;
|
|
414
|
+
}
|
|
415
|
+
interface UpdateContext {
|
|
416
|
+
indexName: string;
|
|
417
|
+
docId: string;
|
|
418
|
+
oldDocument: AnyDocument;
|
|
419
|
+
newDocument: AnyDocument;
|
|
420
|
+
}
|
|
421
|
+
interface SearchContext {
|
|
422
|
+
indexName: string;
|
|
423
|
+
params: QueryParams;
|
|
424
|
+
results?: QueryResult;
|
|
425
|
+
}
|
|
426
|
+
interface IndexContext {
|
|
427
|
+
indexName: string;
|
|
428
|
+
config: IndexConfig;
|
|
429
|
+
}
|
|
430
|
+
interface PartitionContext {
|
|
431
|
+
indexName: string;
|
|
432
|
+
oldPartitionCount: number;
|
|
433
|
+
newPartitionCount: number;
|
|
434
|
+
}
|
|
435
|
+
interface WorkerContext {
|
|
436
|
+
workerCount: number;
|
|
437
|
+
reason: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
interface NarsilConfig {
|
|
441
|
+
persistence?: PersistenceAdapter;
|
|
442
|
+
invalidation?: InvalidationAdapter;
|
|
443
|
+
plugins?: NarsilPlugin[];
|
|
444
|
+
idGenerator?: () => string;
|
|
445
|
+
workers?: WorkerConfig;
|
|
446
|
+
flush?: FlushConfig;
|
|
447
|
+
embedding?: EmbeddingAdapter;
|
|
448
|
+
durability?: DurabilityConfig;
|
|
449
|
+
}
|
|
450
|
+
interface DurabilityConfig {
|
|
451
|
+
directory?: string;
|
|
452
|
+
mode?: 'sync' | 'async';
|
|
453
|
+
flushIntervalMs?: number;
|
|
454
|
+
segmentMaxBytes?: number;
|
|
455
|
+
checkpointIntervalMs?: number;
|
|
456
|
+
checkpointMutationThreshold?: number;
|
|
457
|
+
compactionThreshold?: number;
|
|
458
|
+
}
|
|
459
|
+
interface WorkerConfig {
|
|
460
|
+
enabled?: boolean;
|
|
461
|
+
count?: number;
|
|
462
|
+
promotionThreshold?: number;
|
|
463
|
+
totalPromotionThreshold?: number;
|
|
464
|
+
}
|
|
465
|
+
interface FlushConfig {
|
|
466
|
+
interval?: number;
|
|
467
|
+
mutationThreshold?: number;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export { type ArrayFilter as A, type BatchResult as B, type ComparisonFilter as C, type VectorQueryConfig as D, type ErrorCode as E, type FacetConfig as F, type GeoPolygonFilter as G, type HighlightConfig as H, type IndexContext as I, type WorkerContext as J, type MemoryStats as M, type NarsilConfig as N, type PartitionContext as P, type QueryParams as Q, type RemoveContext as R, type ScoreComponents as S, type TermMatchPolicy as T, type UpdateContext as U, type VectorMaintenanceResult as V, type WorkerConfig as W, ErrorCodes as a, type FacetResult as b, type FilterExpression as c, type FlushConfig as d, type GeoRadiusFilter as e, type GroupConfig as f, type GroupReducer as g, type GroupResult as h, type HighlightMatch as i, type Hit as j, type HybridConfig as k, type IndexInfo as l, type IndexStats as m, type InsertContext as n, NarsilError as o, type NarsilPlugin as p, type PartitionStatsResult as q, type PreflightResult as r, type PresenceFilter as s, type ProcessMemoryReport as t, type QueryResult as u, type SearchContext as v, type SearchMode as w, type StringFilter as x, type SuggestParams as y, type SuggestResult as z };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { C as ClusterCoordinator } from '../../types-Bt7c4hDF.js';
|
|
2
|
+
import '../../schema-BVaw7nqz.js';
|
|
3
|
+
import '../../adapters-Bo2JQg8b.js';
|
|
4
|
+
|
|
5
|
+
interface EtcdCoordinatorConfig {
|
|
6
|
+
endpoints: string[];
|
|
7
|
+
keyPrefix: string;
|
|
8
|
+
nodeHeartbeatTtlSeconds: number;
|
|
9
|
+
leaseTtlSeconds: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare function validateNodeId(nodeId: string): void;
|
|
13
|
+
|
|
14
|
+
declare function createEtcdCoordinator(config?: Partial<EtcdCoordinatorConfig>): Promise<ClusterCoordinator>;
|
|
15
|
+
|
|
16
|
+
export { type EtcdCoordinatorConfig, createEtcdCoordinator, validateNodeId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createInMemoryCoordinator } from '../../chunk-RQLXC2YS.mjs';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { C as ClusterCoordinator, N as NodeRegistration, A as AllocationTable, a as NodeRole, b as NodeCapacity } from './types-Bt7c4hDF.js';
|
|
2
|
+
export { c as AllocationConstraints, d as AllocationEvent, e as NodeEvent, P as PartitionAssignment, f as PartitionState, S as SchemaEvent } from './types-Bt7c4hDF.js';
|
|
3
|
+
import { B as BatchResult, Q as QueryParams, u as QueryResult, N as NarsilConfig } from './config-cQLlYR3U.js';
|
|
4
|
+
import { I as IndexConfig, A as AnyDocument } from './schema-BVaw7nqz.js';
|
|
5
|
+
export { createInMemoryCoordinator } from './distribution/coordinator/in-memory.js';
|
|
6
|
+
import './adapters-Bo2JQg8b.js';
|
|
7
|
+
|
|
8
|
+
interface TransportMessage {
|
|
9
|
+
type: string;
|
|
10
|
+
sourceId: string;
|
|
11
|
+
requestId: string;
|
|
12
|
+
payload: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
interface TransportConfig {
|
|
15
|
+
connectTimeout: number;
|
|
16
|
+
requestTimeout: number;
|
|
17
|
+
replicationTimeout: number;
|
|
18
|
+
snapshotTimeout: number;
|
|
19
|
+
}
|
|
20
|
+
interface NodeTransport {
|
|
21
|
+
send(target: string, message: TransportMessage): Promise<TransportMessage>;
|
|
22
|
+
stream(target: string, message: TransportMessage, handler: (chunk: Uint8Array) => void): Promise<void>;
|
|
23
|
+
listen(handler: (message: TransportMessage, respond: (response: TransportMessage) => void) => void | Promise<void>): Promise<() => void>;
|
|
24
|
+
shutdown(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ControllerConfig {
|
|
28
|
+
nodeId: string;
|
|
29
|
+
coordinator: ClusterCoordinator;
|
|
30
|
+
transport: NodeTransport;
|
|
31
|
+
leaseTtlMs: number;
|
|
32
|
+
standbyRetryMs: number;
|
|
33
|
+
knownIndexNames: string[];
|
|
34
|
+
onError?: (indexName: string, error: unknown) => void;
|
|
35
|
+
}
|
|
36
|
+
interface ControllerNode {
|
|
37
|
+
readonly isActive: boolean;
|
|
38
|
+
start(): Promise<void>;
|
|
39
|
+
stop(): Promise<void>;
|
|
40
|
+
shutdown(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type DataNodeLifecycleStatus = 'stopped' | 'joining' | 'active' | 'leaving' | 'shutdown';
|
|
44
|
+
interface NodeLifecycleConfig {
|
|
45
|
+
registration: NodeRegistration;
|
|
46
|
+
coordinator: ClusterCoordinator;
|
|
47
|
+
transport: NodeTransport;
|
|
48
|
+
knownIndexNames: string[];
|
|
49
|
+
bootstrapRetryBaseMs: number;
|
|
50
|
+
bootstrapRetryMaxMs: number;
|
|
51
|
+
bootstrapMaxRetries: number;
|
|
52
|
+
allocationDebounceMs: number;
|
|
53
|
+
onBootstrapPartition: (indexName: string, partitionId: number, primaryNodeId: string) => Promise<boolean>;
|
|
54
|
+
onRemovePartition?: (indexName: string, partitionId: number) => void;
|
|
55
|
+
onPrimaryDemotion?: (indexName: string, partitionId: number, newPrimaryNodeId: string) => void;
|
|
56
|
+
onError?: (error: unknown) => void;
|
|
57
|
+
}
|
|
58
|
+
interface DataNodeHandle {
|
|
59
|
+
readonly status: DataNodeLifecycleStatus;
|
|
60
|
+
readonly nodeId: string;
|
|
61
|
+
join(): Promise<void>;
|
|
62
|
+
leave(): Promise<void>;
|
|
63
|
+
shutdown(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface ClusterNodeConfig {
|
|
67
|
+
coordinator: ClusterCoordinator;
|
|
68
|
+
transport: NodeTransport;
|
|
69
|
+
address: string;
|
|
70
|
+
roles?: NodeRole[];
|
|
71
|
+
nodeId?: string;
|
|
72
|
+
capacity?: NodeCapacity;
|
|
73
|
+
engine?: NarsilConfig;
|
|
74
|
+
onError?: (error: Error) => void;
|
|
75
|
+
}
|
|
76
|
+
interface CreateIndexOptions {
|
|
77
|
+
partitionCount?: number;
|
|
78
|
+
replicationFactor?: number;
|
|
79
|
+
}
|
|
80
|
+
interface ClusterNamespace {
|
|
81
|
+
getAllocation(indexName: string): Promise<AllocationTable | null>;
|
|
82
|
+
getNodeInfo(): ClusterNodeInfo;
|
|
83
|
+
isControllerActive(): boolean;
|
|
84
|
+
}
|
|
85
|
+
interface ClusterNodeInfo {
|
|
86
|
+
nodeId: string;
|
|
87
|
+
roles: ReadonlyArray<NodeRole>;
|
|
88
|
+
status: string;
|
|
89
|
+
}
|
|
90
|
+
interface ClusterNode {
|
|
91
|
+
readonly nodeId: string;
|
|
92
|
+
readonly roles: ReadonlyArray<NodeRole>;
|
|
93
|
+
createIndex(name: string, config: IndexConfig, options?: CreateIndexOptions): Promise<void>;
|
|
94
|
+
insert(indexName: string, document: AnyDocument, docId?: string): Promise<string>;
|
|
95
|
+
insertBatch(indexName: string, documents: AnyDocument[]): Promise<BatchResult>;
|
|
96
|
+
remove(indexName: string, docId: string): Promise<void>;
|
|
97
|
+
removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
|
|
98
|
+
query<T = AnyDocument>(indexName: string, params: QueryParams): Promise<QueryResult<T>>;
|
|
99
|
+
cluster: ClusterNamespace;
|
|
100
|
+
start(): Promise<void>;
|
|
101
|
+
shutdown(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
declare const DEFAULT_PARTITION_COUNT = 5;
|
|
104
|
+
declare const DEFAULT_REPLICATION_FACTOR = 1;
|
|
105
|
+
declare const DEFAULT_CAPACITY: NodeCapacity;
|
|
106
|
+
|
|
107
|
+
declare function createClusterNode(config: ClusterNodeConfig): Promise<ClusterNode>;
|
|
108
|
+
|
|
109
|
+
type StreamResponder = (chunks: Uint8Array[]) => void;
|
|
110
|
+
interface InMemoryTransportInternal extends NodeTransport {
|
|
111
|
+
deliverMessage(message: TransportMessage, respond: (response: TransportMessage) => void): void;
|
|
112
|
+
deliverStream(message: TransportMessage, responder: StreamResponder): void;
|
|
113
|
+
}
|
|
114
|
+
interface InMemoryNetwork {
|
|
115
|
+
register(nodeId: string, transport: InMemoryTransportInternal): void;
|
|
116
|
+
unregister(nodeId: string): void;
|
|
117
|
+
getTransport(nodeId: string): InMemoryTransportInternal | undefined;
|
|
118
|
+
}
|
|
119
|
+
declare function createInMemoryNetwork(): InMemoryNetwork;
|
|
120
|
+
declare function createInMemoryTransport(nodeId: string, network: InMemoryNetwork, config?: Partial<TransportConfig>): NodeTransport;
|
|
121
|
+
|
|
122
|
+
export { AllocationTable, ClusterCoordinator, type ClusterNamespace, type ClusterNode, type ClusterNodeConfig, type ClusterNodeInfo, type ControllerConfig, type ControllerNode, type CreateIndexOptions, DEFAULT_CAPACITY, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, type DataNodeHandle, type InMemoryNetwork, type InMemoryTransportInternal, NodeCapacity, type NodeLifecycleConfig, NodeRegistration, NodeRole, type NodeTransport, type TransportConfig, createClusterNode, createInMemoryNetwork, createInMemoryTransport };
|