@delali/narsil 0.2.2 → 0.2.3-next.32
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 +12 -9
- 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-CVqI5NBt.d.ts → adapters-79OIa4xm.d.ts} +1 -1
- package/dist/brute-force-DbHYCTc3.d.ts +8 -0
- package/dist/chunk-BFIH7OV5.mjs +185 -0
- package/dist/chunk-C6VVLMRX.mjs +63 -0
- package/dist/{chunk-UNJZ7ZDB.mjs → chunk-EMI63EXP.mjs} +33 -2
- package/dist/chunk-MFFAJ2NR.mjs +135 -0
- package/dist/chunk-OBXS7OZM.mjs +376 -0
- package/dist/{chunk-ASI6AOW2.mjs → chunk-RO4EFWE6.mjs} +7833 -3524
- package/dist/{chunk-WLR5BFL3.mjs → chunk-TEAJO7CU.mjs} +3067 -2087
- package/dist/{chunk-S7RJJMHI.mjs → chunk-WDL632CN.mjs} +699 -222
- package/dist/{chunk-BKAI2WXI.mjs → chunk-WTONLDU3.mjs} +5 -0
- package/dist/client-DQHB_swQ.d.ts +793 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.mjs +843 -0
- package/dist/{config-DXypXAfN.d.ts → config-ChZ7lfqc.d.ts} +3 -3
- package/dist/direct-executor-YARCDMJF.mjs +8 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +471 -2
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/coordinator/in-memory.mjs +286 -1
- package/dist/distribution/transport/grpc.d.ts +45 -0
- package/dist/distribution/transport/grpc.mjs +586 -0
- package/dist/distribution/transport/in-memory.d.ts +118 -0
- package/dist/distribution/transport/in-memory.mjs +214 -0
- package/dist/distribution/transport/tcp.d.ts +27 -0
- package/dist/distribution/transport/tcp.mjs +595 -0
- package/dist/distribution.d.ts +241 -192
- package/dist/distribution.mjs +6620 -4795
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/{engine-CO9Wnfie.d.ts → engine-DScGlT2Z.d.ts} +30 -3
- package/dist/index.browser.mjs +10035 -3914
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +8 -5
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +3 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/options-BORJg5XB.d.ts +234 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +4 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +8 -5
- package/dist/react.d.ts +340 -0
- package/dist/react.mjs +687 -0
- package/dist/{schema-CE6S_aAr.d.ts → schema-emTQfEiX.d.ts} +21 -7
- package/dist/{search-DLBtiPdQ.d.ts → search-CQ-9bKxo.d.ts} +226 -14
- package/dist/server.d.ts +42 -356
- package/dist/server.mjs +493 -106
- package/dist/tasks-CnMLpfk-.d.ts +274 -0
- package/dist/types-BQDlIvfS.d.ts +34 -0
- package/dist/{types-BV3nAKTL.d.ts → types-Bfhhnh3G.d.ts} +23 -1
- package/dist/types-D5OwhtsQ.d.ts +97 -0
- package/dist/vector/hnsw-build-worker.d.ts +2 -7
- package/dist/vector/hnsw-build-worker.mjs +2 -1
- package/dist/vector/search-worker.d.ts +373 -0
- package/dist/vector/search-worker.mjs +279 -0
- package/dist/workers/entry.mjs +43 -25
- package/package.json +42 -2
- package/dist/chunk-FKK76OR7.mjs +0 -456
- package/dist/chunk-RQLXC2YS.mjs +0 -269
- package/dist/direct-executor-3W4QRA4E.mjs +0 -5
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/** Declarative index configuration accepted over HTTP. Function-valued engine
|
|
2
|
+
* options (custom tokenizer, stopWords-as-function, group reducer, embedding
|
|
3
|
+
* adapter object) are not representable here; the embedding adapter is named
|
|
4
|
+
* instead via {@link CreateIndexEmbedding}.
|
|
5
|
+
*
|
|
6
|
+
* @public */
|
|
7
|
+
interface CreateIndexRequest {
|
|
8
|
+
/** The server creates the index under this name. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** This carries the schema and settings, in the subset JSON can express. */
|
|
11
|
+
config: HttpIndexConfig;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* How a JSON `createIndex` request connects an index to an embedding adapter.
|
|
15
|
+
*
|
|
16
|
+
* An adapter is a function and cannot cross JSON, so the request names one the
|
|
17
|
+
* server registered instead of carrying it.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
interface CreateIndexEmbedding {
|
|
22
|
+
/** This names an adapter the server registered under `embeddingAdapters`. */
|
|
23
|
+
adapter?: string;
|
|
24
|
+
/** This maps each vector field to the text field, or fields, the server embeds into it. */
|
|
25
|
+
fields: Record<string, string | string[]>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The index settings a JSON request can carry, which is {@link IndexConfig}
|
|
29
|
+
* minus everything that is a function.
|
|
30
|
+
*
|
|
31
|
+
* A custom tokeniser, a stop-word function, and an embedding adapter object
|
|
32
|
+
* have no JSON form, so an HTTP client names a registered one or supplies a
|
|
33
|
+
* plain list instead.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
interface HttpIndexConfig {
|
|
38
|
+
/** This layout gives each value as either a field type or a nested schema. */
|
|
39
|
+
schema: Record<string, unknown>;
|
|
40
|
+
/** The server tokenises and stems text fields with the language module registered under this name. */
|
|
41
|
+
language?: string;
|
|
42
|
+
/** These settings control how the index splits documents across partitions as it grows. */
|
|
43
|
+
partitions?: {
|
|
44
|
+
maxDocsPerPartition?: number;
|
|
45
|
+
maxPartitions?: number;
|
|
46
|
+
watermark?: number;
|
|
47
|
+
};
|
|
48
|
+
/** A query scores this way unless it asks for another mode. */
|
|
49
|
+
defaultScoring?: 'local' | 'dfs' | 'broadcast';
|
|
50
|
+
/** These parameters tune BM25 for this index. */
|
|
51
|
+
bm25?: {
|
|
52
|
+
k1?: number;
|
|
53
|
+
b?: number;
|
|
54
|
+
};
|
|
55
|
+
/** This list replaces the language's stop words. */
|
|
56
|
+
stopWords?: string[];
|
|
57
|
+
/** Setting this records term positions, which phrase queries and highlighting need. */
|
|
58
|
+
trackPositions?: boolean;
|
|
59
|
+
/** Setting this to false returns index stems from suggestions and prefix expansion, instead of the words users typed. */
|
|
60
|
+
surfaceForms?: boolean;
|
|
61
|
+
/** These settings control when vector fields move to an HNSW graph, and how that graph is built. */
|
|
62
|
+
vectorPromotion?: Record<string, unknown>;
|
|
63
|
+
/** Setting this rejects a document carrying a field the schema does not declare. */
|
|
64
|
+
strict?: boolean;
|
|
65
|
+
/** This names a server-registered embedding adapter and the fields it embeds. */
|
|
66
|
+
embedding?: CreateIndexEmbedding;
|
|
67
|
+
/** The server rejects a document that omits any of these fields. */
|
|
68
|
+
required?: string[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One record an import refused, naming the line it came from and why the
|
|
72
|
+
* server rejected it.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
interface ImportError {
|
|
77
|
+
/** The failing record sat on this line of the body, counting from one. */
|
|
78
|
+
line?: number;
|
|
79
|
+
/** The engine rejected the document stored under this id. */
|
|
80
|
+
docId?: string;
|
|
81
|
+
/** This says which failure it is. */
|
|
82
|
+
code: string;
|
|
83
|
+
/** This describes the failure, for a log or a person. */
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* What one import produced.
|
|
88
|
+
*
|
|
89
|
+
* `errors` is capped by the server's `maxImportErrors` limit while `failed`
|
|
90
|
+
* counts every refusal, so a run that trips the cap reports the true total and
|
|
91
|
+
* sets `errorsTruncated`.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
interface ImportResult {
|
|
96
|
+
/** The engine accepted this many documents. */
|
|
97
|
+
indexed: number;
|
|
98
|
+
/** The server refused this many records in total. */
|
|
99
|
+
failed: number;
|
|
100
|
+
/** The first refusals, up to the server's reporting cap. */
|
|
101
|
+
errors: ImportError[];
|
|
102
|
+
/** Setting this says more records failed than `errors` lists. */
|
|
103
|
+
errorsTruncated: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* What a server announces at `/capabilities`, which is how a client finds out
|
|
107
|
+
* whether an optional route or mode is available before it sends a request.
|
|
108
|
+
*
|
|
109
|
+
* A server that answers 404 here predates the endpoint, so treat every optional
|
|
110
|
+
* capability as absent.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
interface CapabilitiesResponse {
|
|
115
|
+
/** Each name marks one capability this server serves. */
|
|
116
|
+
capabilities: string[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Which long-running operation a task record tracks.
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
type TaskType = 'optimizeVectors' | 'rebalance' | 'restore' | 'import' | 'rebuildAnalysis';
|
|
125
|
+
/**
|
|
126
|
+
* Where a long-running operation stands.
|
|
127
|
+
*
|
|
128
|
+
* A task reaches `cancelled` only when the work itself stopped early, so a
|
|
129
|
+
* cancel that arrives too late leaves the task `succeeded`.
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
type TaskStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
134
|
+
/**
|
|
135
|
+
* How far a running import has gone, which is what a progress bar reads.
|
|
136
|
+
*
|
|
137
|
+
* The byte counts describe the request body, so they give an honest fraction
|
|
138
|
+
* from the first batch onwards, while the document counts only cover what the
|
|
139
|
+
* server has already handed to the engine. Task types other than `import`
|
|
140
|
+
* report no progress.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
interface TaskProgress {
|
|
145
|
+
/** The server has indexed this many documents so far. */
|
|
146
|
+
indexed: number;
|
|
147
|
+
/** The server has rejected this many documents so far. */
|
|
148
|
+
failed: number;
|
|
149
|
+
/** The server has read this many bytes of the body so far. */
|
|
150
|
+
bytesProcessed: number;
|
|
151
|
+
/** The body holds this many bytes in total. */
|
|
152
|
+
bytesTotal: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One long-running operation, which the server answers with straight away and
|
|
156
|
+
* you then poll.
|
|
157
|
+
*
|
|
158
|
+
* Every route that starts a task answers with this same record, and
|
|
159
|
+
* `GET /tasks/{id}` returns it again as the work moves on.
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
interface TaskRecord {
|
|
164
|
+
/** This identifies the task, and is what you poll by. */
|
|
165
|
+
id: string;
|
|
166
|
+
/** This says which operation the task runs. */
|
|
167
|
+
type: TaskType;
|
|
168
|
+
/** The operation runs against this index. */
|
|
169
|
+
indexName: string;
|
|
170
|
+
/** This says where the operation stands. */
|
|
171
|
+
status: TaskStatus;
|
|
172
|
+
/** Identifier of the server instance running this task; see ServerOptions.instanceId. */
|
|
173
|
+
owner: string;
|
|
174
|
+
/** The server accepted the task at this many milliseconds since the epoch. */
|
|
175
|
+
createdAt: number;
|
|
176
|
+
/** Work started at this many milliseconds since the epoch, and a queued task omits it. */
|
|
177
|
+
startedAt?: number;
|
|
178
|
+
/** Work ended at this many milliseconds since the epoch, and a task omits it until it reaches a final status. */
|
|
179
|
+
completedAt?: number;
|
|
180
|
+
/** A cancel arrived at this many milliseconds since the epoch, which is how a
|
|
181
|
+
* task still running shows that it is stopping. */
|
|
182
|
+
cancelRequestedAt?: number;
|
|
183
|
+
/** How far the work has gone, which an import reports and other task types omit. */
|
|
184
|
+
progress?: TaskProgress;
|
|
185
|
+
/** What the work produced, which an import reports once it finishes. */
|
|
186
|
+
result?: ImportResult;
|
|
187
|
+
/** This says why the task failed, and a failed task alone carries it. */
|
|
188
|
+
error?: {
|
|
189
|
+
code: string;
|
|
190
|
+
message: string;
|
|
191
|
+
details?: Record<string, unknown>;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Which task records `GET /tasks` returns, and where the page starts.
|
|
196
|
+
*
|
|
197
|
+
* Every filter is optional, and omitting all of them lists every record the
|
|
198
|
+
* store still holds, newest first.
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
interface TaskListQuery {
|
|
203
|
+
/** Keeps the tasks running against this index. */
|
|
204
|
+
indexName?: string;
|
|
205
|
+
/** Keeps the tasks of these types. */
|
|
206
|
+
type?: TaskType[];
|
|
207
|
+
/** Keeps the tasks at these statuses. */
|
|
208
|
+
status?: TaskStatus[];
|
|
209
|
+
/** Skips this many records, and starts at the newest by default. */
|
|
210
|
+
from?: number;
|
|
211
|
+
/** The page carries this many records, and 20 by default. */
|
|
212
|
+
limit?: number;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* One page of task records, ordered newest first.
|
|
216
|
+
*
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
interface TaskListPage {
|
|
220
|
+
/** The records this page carries. */
|
|
221
|
+
tasks: TaskRecord[];
|
|
222
|
+
/** How many records the filters matched in total, across every page. */
|
|
223
|
+
total: number;
|
|
224
|
+
/** This page skipped this many records. */
|
|
225
|
+
from: number;
|
|
226
|
+
/** This page asked for this many records. */
|
|
227
|
+
limit: number;
|
|
228
|
+
/** Pass this back as `from` for the next page, and it is null on the last page. */
|
|
229
|
+
next: number | null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Pluggable backing store for task records. Every method is async so any
|
|
233
|
+
* backend works: an in-memory map, Redis, an HTTP key-value service, or a
|
|
234
|
+
* database. `set` upserts by `record.id`; `get` returns null for an unknown id.
|
|
235
|
+
* `ttlMs`, when honored by the backend, expires the record so terminal tasks do
|
|
236
|
+
* not accumulate. The server never calls a method that mutates a record it did
|
|
237
|
+
* not construct, so a backend may treat records as immutable snapshots.
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
interface TaskStore {
|
|
242
|
+
/**
|
|
243
|
+
* Stores a record, replacing whatever its id already held.
|
|
244
|
+
*
|
|
245
|
+
* @param record - The record to store.
|
|
246
|
+
* @param ttlMs - Milliseconds after which the backend may drop it, which
|
|
247
|
+
* keeps finished tasks from accumulating. Ignore it in a backend without
|
|
248
|
+
* expiry.
|
|
249
|
+
*/
|
|
250
|
+
set(record: TaskRecord, ttlMs?: number): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Reads one record back.
|
|
253
|
+
*
|
|
254
|
+
* @param id - The task to read.
|
|
255
|
+
* @returns The record, or `null` when the store holds no such id.
|
|
256
|
+
*/
|
|
257
|
+
get(id: string): Promise<TaskRecord | null>;
|
|
258
|
+
/**
|
|
259
|
+
* Lists every record the store holds.
|
|
260
|
+
*
|
|
261
|
+
* @returns Each record the backend still has.
|
|
262
|
+
*/
|
|
263
|
+
list(): Promise<TaskRecord[]>;
|
|
264
|
+
/**
|
|
265
|
+
* Removes one record. An id the store never held is not an error.
|
|
266
|
+
*
|
|
267
|
+
* @param id - The task to remove.
|
|
268
|
+
*/
|
|
269
|
+
delete(id: string): Promise<void>;
|
|
270
|
+
/** Releases whatever the backend holds open, such as a connection pool. */
|
|
271
|
+
shutdown?(): Promise<void>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type { CapabilitiesResponse as C, HttpIndexConfig as H, ImportError as I, TaskListPage as T, CreateIndexEmbedding as a, ImportResult as b, TaskListQuery as c, TaskProgress as d, TaskRecord as e, TaskStatus as f, TaskType as g, TaskStore as h, CreateIndexRequest as i };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { T as TransportConfig } from './types-D5OwhtsQ.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The certificate material one node presents to its peers.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface TlsConfig {
|
|
9
|
+
/** This node presents this certificate, in PEM form. */
|
|
10
|
+
cert: Buffer | string;
|
|
11
|
+
/** The private key matching the certificate, in PEM form. */
|
|
12
|
+
key: Buffer | string;
|
|
13
|
+
/** Peers must chain to this authority. The Node.js default authorities apply when absent. */
|
|
14
|
+
ca?: Buffer | string;
|
|
15
|
+
/** Setting this to false accepts an unverified peer, for tests alone. */
|
|
16
|
+
rejectUnauthorized?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* How the TCP transport listens and dials.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
interface TcpTransportConfig extends TransportConfig {
|
|
24
|
+
/** The transport listens on this host. */
|
|
25
|
+
host: string;
|
|
26
|
+
/** The transport listens on this port, and 0 asks the system for a free one. */
|
|
27
|
+
port: number;
|
|
28
|
+
/** The connection pool holds at most this many outbound connections. */
|
|
29
|
+
maxConnections: number;
|
|
30
|
+
/** Presenting this makes every connection mutually authenticated TLS. */
|
|
31
|
+
tls?: TlsConfig;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type { TcpTransportConfig as T, TlsConfig as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as SchemaDefinition } from './schema-emTQfEiX.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* What a node does in a cluster. A node may hold several roles at once.
|
|
@@ -199,6 +199,13 @@ interface ClusterCoordinator {
|
|
|
199
199
|
* version no longer matched.
|
|
200
200
|
*/
|
|
201
201
|
putAllocation(indexName: string, table: AllocationTable, expectedVersion?: number | null): Promise<boolean>;
|
|
202
|
+
/**
|
|
203
|
+
* Removes one index's allocation, which is the last step of dropping the
|
|
204
|
+
* index. Deleting an allocation that does not exist does nothing.
|
|
205
|
+
*
|
|
206
|
+
* @param indexName - The index whose allocation goes.
|
|
207
|
+
*/
|
|
208
|
+
deleteAllocation(indexName: string): Promise<void>;
|
|
202
209
|
/**
|
|
203
210
|
* Watches allocations changing.
|
|
204
211
|
*
|
|
@@ -280,6 +287,21 @@ interface ClusterCoordinator {
|
|
|
280
287
|
* @param schema - Its field layout.
|
|
281
288
|
*/
|
|
282
289
|
putSchema(indexName: string, schema: SchemaDefinition): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Removes one index's schema and tells every watcher it was dropped, which
|
|
292
|
+
* starts the cluster-wide teardown of that index. Dropping a schema that
|
|
293
|
+
* does not exist does nothing.
|
|
294
|
+
*
|
|
295
|
+
* @param indexName - The index whose schema goes.
|
|
296
|
+
*/
|
|
297
|
+
dropSchema(indexName: string): Promise<void>;
|
|
298
|
+
/**
|
|
299
|
+
* Lists the name of every published schema, which is how a newly elected
|
|
300
|
+
* controller finds the indexes it must reconcile.
|
|
301
|
+
*
|
|
302
|
+
* @returns Every index name holding a schema, sorted by code point.
|
|
303
|
+
*/
|
|
304
|
+
listSchemas(): Promise<string[]>;
|
|
283
305
|
/**
|
|
284
306
|
* Watches schemas being published and dropped.
|
|
285
307
|
*
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One message on the wire between cluster nodes.
|
|
3
|
+
*
|
|
4
|
+
* The payload is opaque bytes, which is what lets a node written in another
|
|
5
|
+
* language join the same cluster: only the header fields have to agree.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
interface TransportMessage {
|
|
10
|
+
/** This says what the message is, such as a replication entry or a search request. */
|
|
11
|
+
type: string;
|
|
12
|
+
/** This node sent the message. */
|
|
13
|
+
sourceId: string;
|
|
14
|
+
/** This correlates a reply with its request. */
|
|
15
|
+
requestId: string;
|
|
16
|
+
/** This carries the encoded body, and the message type tells a reader how to decode it. */
|
|
17
|
+
payload: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* How long a transport waits before giving up on each kind of exchange.
|
|
21
|
+
*
|
|
22
|
+
* Every value is in milliseconds. Replication and snapshot transfers carry
|
|
23
|
+
* their own timeouts because they move far more than a search does.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
interface TransportConfig {
|
|
28
|
+
/** Opening a connection to a peer may take this long. */
|
|
29
|
+
connectTimeout: number;
|
|
30
|
+
/** An ordinary request and its reply may take this long. */
|
|
31
|
+
requestTimeout: number;
|
|
32
|
+
/** A replication entry may take this long to reach a replica and come back acknowledged. */
|
|
33
|
+
replicationTimeout: number;
|
|
34
|
+
/** A whole snapshot transfer, which moves a partition between nodes, may take this long. */
|
|
35
|
+
snapshotTimeout: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* How one cluster node reaches the others.
|
|
39
|
+
*
|
|
40
|
+
* The package includes a TCP transport for real deployments and an in-process
|
|
41
|
+
* one for tests, and this is the contract either satisfies. Write your own to
|
|
42
|
+
* run a cluster over something else.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
interface NodeTransport {
|
|
47
|
+
/**
|
|
48
|
+
* Sends one request to a peer and waits for its reply.
|
|
49
|
+
*
|
|
50
|
+
* @param target - Node id to send to.
|
|
51
|
+
* @param message - The request.
|
|
52
|
+
* @returns The peer's reply.
|
|
53
|
+
* @throws A `TransportError` when the peer is unreachable, the message is
|
|
54
|
+
* oversized, or the request times out.
|
|
55
|
+
*/
|
|
56
|
+
send(target: string, message: TransportMessage): Promise<TransportMessage>;
|
|
57
|
+
/**
|
|
58
|
+
* Sends one request whose reply arrives in chunks, which is how a snapshot
|
|
59
|
+
* moves without being held in memory whole.
|
|
60
|
+
*
|
|
61
|
+
* @param target - Node id to send to.
|
|
62
|
+
* @param message - The request.
|
|
63
|
+
* @param handler - Called once per chunk, in order.
|
|
64
|
+
*/
|
|
65
|
+
stream(target: string, message: TransportMessage, handler: (chunk: Uint8Array) => void): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Starts accepting requests from peers.
|
|
68
|
+
*
|
|
69
|
+
* @param handler - Called for each request, with the function that returns
|
|
70
|
+
* the reply.
|
|
71
|
+
* @returns A function that ends the listener.
|
|
72
|
+
*/
|
|
73
|
+
listen(handler: ListenHandler): Promise<() => void>;
|
|
74
|
+
/** Closes every connection and releases the port or registration it held. */
|
|
75
|
+
shutdown(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sends one reply back to the peer that asked.
|
|
79
|
+
*
|
|
80
|
+
* It settles once the transport has taken the reply, which a transport whose
|
|
81
|
+
* connection is full delays until the connection accepts more. A handler
|
|
82
|
+
* sending many replies awaits each one before it builds the next, so a
|
|
83
|
+
* snapshot cannot outrun a slow receiver and exhaust this node's memory.
|
|
84
|
+
*
|
|
85
|
+
* @param response - The reply to send.
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
type RespondFn = (response: TransportMessage) => Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Handles one request a peer sent, replying through `respond`.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
type ListenHandler = (message: TransportMessage, respond: RespondFn) => void | Promise<void>;
|
|
96
|
+
|
|
97
|
+
export type { ListenHandler as L, NodeTransport as N, RespondFn as R, TransportConfig as T, TransportMessage as a };
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Similarity metric a vector search ranks by.
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
type VectorMetric = 'cosine' | 'dotProduct' | 'euclidean';
|
|
1
|
+
import { V as VectorMetric } from '../brute-force-DbHYCTc3.js';
|
|
7
2
|
|
|
8
3
|
/**
|
|
9
4
|
* How an HNSW graph is built.
|
|
@@ -107,4 +102,4 @@ interface HNSWBuildError {
|
|
|
107
102
|
*/
|
|
108
103
|
type HNSWWorkerMessage = HNSWBuildResponse | HNSWBuildError;
|
|
109
104
|
|
|
110
|
-
export type
|
|
105
|
+
export { type HNSWBuildError, type HNSWBuildRequest, type HNSWBuildRequestBinary, type HNSWBuildResponse, type HNSWConfig, type HNSWWorkerMessage, type SerializedHNSWGraph, VectorMetric };
|