@delali/narsil 0.2.2 → 0.2.3-next.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +12 -9
  2. package/dist/adapters/filesystem.d.ts +1 -1
  3. package/dist/adapters/filesystem.mjs +1 -1
  4. package/dist/adapters/indexeddb.d.ts +1 -1
  5. package/dist/adapters/indexeddb.mjs +1 -1
  6. package/dist/adapters/memory.d.ts +1 -1
  7. package/dist/{adapters-CVqI5NBt.d.ts → adapters-79OIa4xm.d.ts} +1 -1
  8. package/dist/brute-force-DbHYCTc3.d.ts +8 -0
  9. package/dist/chunk-BFIH7OV5.mjs +185 -0
  10. package/dist/chunk-C6VVLMRX.mjs +63 -0
  11. package/dist/{chunk-UNJZ7ZDB.mjs → chunk-EMI63EXP.mjs} +33 -2
  12. package/dist/chunk-MFFAJ2NR.mjs +135 -0
  13. package/dist/chunk-OBXS7OZM.mjs +376 -0
  14. package/dist/{chunk-ASI6AOW2.mjs → chunk-RO4EFWE6.mjs} +7833 -3524
  15. package/dist/{chunk-WLR5BFL3.mjs → chunk-TEAJO7CU.mjs} +3067 -2087
  16. package/dist/{chunk-S7RJJMHI.mjs → chunk-WDL632CN.mjs} +699 -222
  17. package/dist/{chunk-BKAI2WXI.mjs → chunk-WTONLDU3.mjs} +5 -0
  18. package/dist/client-DQHB_swQ.d.ts +793 -0
  19. package/dist/client.d.ts +6 -0
  20. package/dist/client.mjs +843 -0
  21. package/dist/{config-DXypXAfN.d.ts → config-ChZ7lfqc.d.ts} +3 -3
  22. package/dist/direct-executor-YARCDMJF.mjs +8 -0
  23. package/dist/distribution/coordinator/etcd.d.ts +3 -3
  24. package/dist/distribution/coordinator/etcd.mjs +471 -2
  25. package/dist/distribution/coordinator/in-memory.d.ts +3 -3
  26. package/dist/distribution/coordinator/in-memory.mjs +286 -1
  27. package/dist/distribution/transport/grpc.d.ts +45 -0
  28. package/dist/distribution/transport/grpc.mjs +586 -0
  29. package/dist/distribution/transport/in-memory.d.ts +118 -0
  30. package/dist/distribution/transport/in-memory.mjs +214 -0
  31. package/dist/distribution/transport/tcp.d.ts +27 -0
  32. package/dist/distribution/transport/tcp.mjs +595 -0
  33. package/dist/distribution.d.ts +241 -192
  34. package/dist/distribution.mjs +6620 -4795
  35. package/dist/embeddings/openai.d.ts +1 -1
  36. package/dist/embeddings/openai.mjs +1 -1
  37. package/dist/{engine-CO9Wnfie.d.ts → engine-DScGlT2Z.d.ts} +30 -3
  38. package/dist/index.browser.mjs +10035 -3914
  39. package/dist/index.d.ts +8 -8
  40. package/dist/index.mjs +8 -5
  41. package/dist/invalidation/broadcast-channel.d.ts +1 -1
  42. package/dist/invalidation/filesystem.d.ts +1 -1
  43. package/dist/invalidation/filesystem.mjs +3 -1
  44. package/dist/invalidation/noop.d.ts +1 -1
  45. package/dist/options-BORJg5XB.d.ts +234 -0
  46. package/dist/persistence/durability/checkpoint-worker.d.ts +4 -2
  47. package/dist/persistence/durability/checkpoint-worker.mjs +8 -5
  48. package/dist/react.d.ts +340 -0
  49. package/dist/react.mjs +687 -0
  50. package/dist/{schema-CE6S_aAr.d.ts → schema-emTQfEiX.d.ts} +21 -7
  51. package/dist/{search-DLBtiPdQ.d.ts → search-CQ-9bKxo.d.ts} +226 -14
  52. package/dist/server.d.ts +42 -356
  53. package/dist/server.mjs +493 -106
  54. package/dist/tasks-CnMLpfk-.d.ts +274 -0
  55. package/dist/types-BQDlIvfS.d.ts +34 -0
  56. package/dist/{types-BV3nAKTL.d.ts → types-Bfhhnh3G.d.ts} +23 -1
  57. package/dist/types-D5OwhtsQ.d.ts +97 -0
  58. package/dist/vector/hnsw-build-worker.d.ts +2 -7
  59. package/dist/vector/hnsw-build-worker.mjs +2 -1
  60. package/dist/vector/search-worker.d.ts +373 -0
  61. package/dist/vector/search-worker.mjs +279 -0
  62. package/dist/workers/entry.mjs +43 -25
  63. package/package.json +42 -2
  64. package/dist/chunk-FKK76OR7.mjs +0 -456
  65. package/dist/chunk-RQLXC2YS.mjs +0 -269
  66. package/dist/direct-executor-3W4QRA4E.mjs +0 -5
@@ -1,10 +1,12 @@
1
- import { N as NarsilConfig } from './config-DXypXAfN.js';
2
- import { B as BatchResult, Q as QueryParams, q as QueryResult } from './search-DLBtiPdQ.js';
3
- import { I as IndexConfig, A as AnyDocument } from './schema-CE6S_aAr.js';
4
- import { A as AllocationTable, N as NodeRole, C as ClusterCoordinator, a as NodeCapacity } from './types-BV3nAKTL.js';
5
- export { b as AllocationConstraints, c as AllocationEvent, d as NodeEvent, e as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent } from './types-BV3nAKTL.js';
6
- export { createInMemoryCoordinator } from './distribution/coordinator/in-memory.js';
7
- import './adapters-CVqI5NBt.js';
1
+ import { N as NarsilConfig } from './config-ChZ7lfqc.js';
2
+ import { A as AllocationTable, N as NodeRole, C as ClusterCoordinator, a as NodeCapacity } from './types-Bfhhnh3G.js';
3
+ export { b as AllocationConstraints, c as AllocationEvent, d as NodeEvent, e as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent } from './types-Bfhhnh3G.js';
4
+ import { N as NodeTransport } from './types-D5OwhtsQ.js';
5
+ export { L as ListenHandler, R as RespondFn, T as TransportConfig, a as TransportMessage } from './types-D5OwhtsQ.js';
6
+ import { a as NarsilEventMap, N as Narsil } from './engine-DScGlT2Z.js';
7
+ import { B as BatchResult, L as ListParams, g as ListResult, i as SuggestParams, j as SuggestResult, Q as QueryParams, h as PreflightResult, f as IndexStats, P as PartitionStatsResult, M as MemoryStats, e as QueryResult } from './search-CQ-9bKxo.js';
8
+ import { I as IndexConfig, A as AnyDocument, a as InsertOptions } from './schema-emTQfEiX.js';
9
+ import './adapters-79OIa4xm.js';
8
10
 
9
11
  /**
10
12
  * How much replication history a primary keeps, and how many replicas have to
@@ -23,83 +25,6 @@ interface ReplicationConfig {
23
25
  waitForActiveReplicas: number;
24
26
  }
25
27
 
26
- /**
27
- * One message on the wire between cluster nodes.
28
- *
29
- * The payload is opaque bytes, which is what lets a node written in another
30
- * language join the same cluster: only the header fields have to agree.
31
- *
32
- * @public
33
- */
34
- interface TransportMessage {
35
- /** This says what the message is, such as a replication entry or a search request. */
36
- type: string;
37
- /** This node sent the message. */
38
- sourceId: string;
39
- /** This correlates a reply with its request. */
40
- requestId: string;
41
- /** This carries the encoded body, and the message type tells a reader how to decode it. */
42
- payload: Uint8Array;
43
- }
44
- /**
45
- * How long a transport waits before giving up on each kind of exchange.
46
- *
47
- * Every value is in milliseconds. Replication and snapshot transfers carry
48
- * their own timeouts because they move far more than a search does.
49
- *
50
- * @public
51
- */
52
- interface TransportConfig {
53
- /** Opening a connection to a peer may take this long. */
54
- connectTimeout: number;
55
- /** An ordinary request and its reply may take this long. */
56
- requestTimeout: number;
57
- /** A replication entry may take this long to reach a replica and come back acknowledged. */
58
- replicationTimeout: number;
59
- /** A whole snapshot transfer, which moves a partition between nodes, may take this long. */
60
- snapshotTimeout: number;
61
- }
62
- /**
63
- * How one cluster node reaches the others.
64
- *
65
- * The package includes a TCP transport for real deployments and an in-process
66
- * one for tests, and this is the contract either satisfies. Write your own to
67
- * run a cluster over something else.
68
- *
69
- * @public
70
- */
71
- interface NodeTransport {
72
- /**
73
- * Sends one request to a peer and waits for its reply.
74
- *
75
- * @param target - Node id to send to.
76
- * @param message - The request.
77
- * @returns The peer's reply.
78
- * @throws A `TransportError` when the peer is unreachable, the message is
79
- * oversized, or the request times out.
80
- */
81
- send(target: string, message: TransportMessage): Promise<TransportMessage>;
82
- /**
83
- * Sends one request whose reply arrives in chunks, which is how a snapshot
84
- * moves without being held in memory whole.
85
- *
86
- * @param target - Node id to send to.
87
- * @param message - The request.
88
- * @param handler - Called once per chunk, in order.
89
- */
90
- stream(target: string, message: TransportMessage, handler: (chunk: Uint8Array) => void): Promise<void>;
91
- /**
92
- * Starts accepting requests from peers.
93
- *
94
- * @param handler - Called for each request, with the function that returns
95
- * the reply.
96
- * @returns A function that ends the listener.
97
- */
98
- listen(handler: (message: TransportMessage, respond: (response: TransportMessage) => void) => void | Promise<void>): Promise<() => void>;
99
- /** Closes every connection and releases the port or registration it held. */
100
- shutdown(): Promise<void>;
101
- }
102
-
103
28
  /**
104
29
  * Everything {@link createClusterNode} needs to join a node to a cluster.
105
30
  *
@@ -181,6 +106,31 @@ interface ClusterNodeInfo {
181
106
  /** This says where the node stands, from joining through to shut down. */
182
107
  status: string;
183
108
  }
109
+
110
+ /**
111
+ * The cluster splits an index into this many partitions when
112
+ * {@link CreateIndexOptions} names no count.
113
+ *
114
+ * @public
115
+ */
116
+ declare const DEFAULT_PARTITION_COUNT = 5;
117
+ /**
118
+ * The cluster keeps this many copies of each partition when
119
+ * {@link CreateIndexOptions} names no factor. One copy means a lost node costs
120
+ * that partition, so raise it for anything you cannot rebuild.
121
+ *
122
+ * @public
123
+ */
124
+ declare const DEFAULT_REPLICATION_FACTOR = 1;
125
+ /**
126
+ * A node claims this much capacity when {@link ClusterNodeConfig} declares
127
+ * none. Measure your own hosts and set it, because these figures are a
128
+ * placeholder rather than a reading.
129
+ *
130
+ * @public
131
+ */
132
+ declare const DEFAULT_CAPACITY: NodeCapacity;
133
+
184
134
  /**
185
135
  * One node of a cluster, which routes each write to the partition's primary
186
136
  * and gathers each search from every partition.
@@ -213,18 +163,25 @@ interface ClusterNode {
213
163
  * @param document - Its fields must match the types the schema declares.
214
164
  * @param docId - Pass an id to control it yourself, or omit it and read the
215
165
  * returned value.
166
+ * @param options - Setting `skipClone` stores the object you passed rather
167
+ * than a copy, and it applies only where this node is the partition's own
168
+ * primary, because a document sent to another node is encoded for the wire
169
+ * and decoded there.
216
170
  * @returns The id the document is stored under.
217
171
  */
218
- insert(indexName: string, document: AnyDocument, docId?: string): Promise<string>;
172
+ insert(indexName: string, document: AnyDocument, docId?: string, options?: InsertOptions): Promise<string>;
219
173
  /**
220
174
  * Adds many documents, routing each to its own partition's primary, and
221
175
  * reports each one's outcome.
222
176
  *
223
177
  * @param indexName - The index that receives the documents.
224
178
  * @param documents - The documents to write.
179
+ * @param options - Setting `skipClone` stores the objects you passed rather
180
+ * than copies, and it applies only to the documents this node is primary
181
+ * for, because the rest are encoded for the wire.
225
182
  * @returns The ids written, and each rejection with its error.
226
183
  */
227
- insertBatch(indexName: string, documents: AnyDocument[]): Promise<BatchResult>;
184
+ insertBatch(indexName: string, documents: AnyDocument[], options?: InsertOptions): Promise<BatchResult>;
228
185
  /**
229
186
  * Removes one document.
230
187
  *
@@ -240,6 +197,144 @@ interface ClusterNode {
240
197
  * @returns The ids removed, and each failure with its error.
241
198
  */
242
199
  removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
200
+ /**
201
+ * Replaces a stored document, routing the replacement to the partition's
202
+ * primary, which replicates the complete new document to every in-sync copy.
203
+ *
204
+ * @param indexName - The index holding the document.
205
+ * @param docId - The document to replace.
206
+ * @param document - The complete replacement, because the primary replicates
207
+ * whole documents rather than changed fields.
208
+ */
209
+ update(indexName: string, docId: string, document: AnyDocument): Promise<void>;
210
+ /**
211
+ * Replaces many documents, routing each to its own partition's primary, and
212
+ * reports each one's outcome. Replacements bound for one remote primary
213
+ * travel together in one message.
214
+ *
215
+ * @param indexName - The index holding the documents.
216
+ * @param updates - Each id with the complete document that replaces it.
217
+ * @returns The ids replaced, and each failure with its error.
218
+ */
219
+ updateBatch(indexName: string, updates: Array<{
220
+ docId: string;
221
+ document: AnyDocument;
222
+ }>): Promise<BatchResult>;
223
+ /**
224
+ * Removes an index from the whole cluster: its schema, its allocation, and
225
+ * every node's local copy. The documents do not come back.
226
+ *
227
+ * The controller drives the teardown, so nodes drop their partitions a
228
+ * moment after this resolves rather than atomically with it.
229
+ *
230
+ * @param name - The index to drop.
231
+ */
232
+ dropIndex(name: string): Promise<void>;
233
+ /**
234
+ * Removes every document from an index across the cluster and keeps the
235
+ * index itself, along with its schema and allocation.
236
+ *
237
+ * Each removal runs through the replication log the way a single remove
238
+ * does, so a large index takes many round trips to empty.
239
+ *
240
+ * @param indexName - The index to empty.
241
+ */
242
+ clear(indexName: string): Promise<void>;
243
+ /**
244
+ * Counts the documents an index holds across the cluster, reading each
245
+ * partition's count from one copy.
246
+ *
247
+ * The count fails with `QUERY_NO_ACTIVE_REPLICA` rather than answer with a
248
+ * partition missing, because a partial count would read as a smaller index.
249
+ *
250
+ * @param indexName - The index to count.
251
+ * @returns The document count across every partition.
252
+ */
253
+ countDocuments(indexName: string): Promise<number>;
254
+ /**
255
+ * Reads one page of stored documents from across the cluster, in
256
+ * document-id order by default and in the caller's sort order when they
257
+ * name one. Pass the returned cursor back for the next page.
258
+ *
259
+ * @typeParam T - Shape of the stored documents.
260
+ * @param indexName - The index to walk.
261
+ * @param params - These set the cursor, the page size, the filter, the
262
+ * sort, and how much of each document comes back.
263
+ * @returns The page, the cursor for the next page, and how many documents
264
+ * the listing covers in total.
265
+ */
266
+ listDocuments<T = AnyDocument>(indexName: string, params?: ListParams): Promise<ListResult<T>>;
267
+ /**
268
+ * Returns the indexed terms that complete a prefix, merged from every
269
+ * partition with their document frequencies summed.
270
+ *
271
+ * Each node reports its most frequent completions alone, so a term that
272
+ * ranks low on every node can be undercounted, exactly as distributed
273
+ * facet counts can.
274
+ *
275
+ * @param indexName - The index to draw completions from.
276
+ * @param params - The prefix typed so far, and how many completions to return.
277
+ * @returns The completions, most widely used first.
278
+ */
279
+ suggest(indexName: string, params: SuggestParams): Promise<SuggestResult>;
280
+ /**
281
+ * Counts what a query would match across the cluster without building a
282
+ * single hit.
283
+ *
284
+ * @param indexName - The index the query would run against.
285
+ * @param params - The same parameters {@link ClusterNode.query} takes.
286
+ * @returns The match count and the time the count took.
287
+ */
288
+ preflight(indexName: string, params: QueryParams): Promise<PreflightResult>;
289
+ /**
290
+ * Describes one index across the cluster: its document count and memory
291
+ * estimate summed over every partition, its partition count, its language,
292
+ * and its schema.
293
+ *
294
+ * @param indexName - The index to describe.
295
+ * @returns The index's current figures, gathered from one copy of each partition.
296
+ */
297
+ getStats(indexName: string): Promise<IndexStats>;
298
+ /**
299
+ * Returns per-partition figures for one index, each read from one copy of
300
+ * that partition.
301
+ *
302
+ * @param indexName - The index to describe.
303
+ * @returns One entry per partition, in partition order.
304
+ */
305
+ getPartitionStats(indexName: string): Promise<PartitionStatsResult[]>;
306
+ /**
307
+ * Writes this node's local engine state to its durability directory, so a
308
+ * restart of this node replays less of the log. Other nodes checkpoint
309
+ * themselves.
310
+ *
311
+ * @param indexName - The index to checkpoint on this node.
312
+ */
313
+ checkpoint(indexName: string): Promise<void>;
314
+ /**
315
+ * Reports what this node's engine and process are using. Memory is a
316
+ * per-node fact, so ask each node for its own.
317
+ *
318
+ * @returns Process heap figures and this node's engine estimate.
319
+ */
320
+ getMemoryStats(): Promise<MemoryStats>;
321
+ /**
322
+ * Starts delivering one kind of engine event from this node's local engine
323
+ * to your listener.
324
+ *
325
+ * @typeParam K - The event name, which fixes the payload the listener gets.
326
+ * @param event - Which event to listen for.
327
+ * @param handler - Called once per event on this node.
328
+ */
329
+ on<K extends keyof NarsilEventMap>(event: K, handler: (payload: NarsilEventMap[K]) => void): void;
330
+ /**
331
+ * Removes a listener {@link ClusterNode.on} registered.
332
+ *
333
+ * @typeParam K - The event name.
334
+ * @param event - The event the listener was registered for.
335
+ * @param handler - The same function reference that was registered.
336
+ */
337
+ off<K extends keyof NarsilEventMap>(event: K, handler: (payload: NarsilEventMap[K]) => void): void;
243
338
  /**
244
339
  * Runs a search across every partition and merges the results into one
245
340
  * ranking.
@@ -253,6 +348,41 @@ interface ClusterNode {
253
348
  * @returns The merged hits, the total count, and the elapsed time.
254
349
  */
255
350
  query<T = AnyDocument>(indexName: string, params: QueryParams): Promise<QueryResult<T>>;
351
+ /**
352
+ * Reads one document, from this node when it holds the partition and from a
353
+ * node that does otherwise.
354
+ *
355
+ * A read fails with `QUERY_NO_ACTIVE_REPLICA` when no reachable node serves
356
+ * the document's partition, rather than reporting the document missing.
357
+ *
358
+ * @param indexName - The index holding the document.
359
+ * @param docId - The document to read.
360
+ * @returns The document, or `undefined` when the partition holds no
361
+ * document under this id.
362
+ */
363
+ get(indexName: string, docId: string): Promise<AnyDocument | undefined>;
364
+ /**
365
+ * Reads many documents, grouping the ids by the node that serves each
366
+ * partition and fetching every group in one round trip.
367
+ *
368
+ * The read fails with `QUERY_NO_ACTIVE_REPLICA` when no reachable node
369
+ * serves some document's partition, rather than leaving that document out.
370
+ *
371
+ * @param indexName - The index holding the documents.
372
+ * @param docIds - The documents to read.
373
+ * @returns The documents found, keyed by id; an id nothing is stored under
374
+ * is absent.
375
+ */
376
+ getMultiple(indexName: string, docIds: string[]): Promise<Map<string, AnyDocument>>;
377
+ /**
378
+ * Reports whether a document exists, reading through the same routing as
379
+ * {@link ClusterNode.get}.
380
+ *
381
+ * @param indexName - The index to check.
382
+ * @param docId - The document id to check.
383
+ * @returns True when a node serving the partition holds the document.
384
+ */
385
+ has(indexName: string, docId: string): Promise<boolean>;
256
386
  /** This reaches the cluster-facing side of the node. */
257
387
  cluster: ClusterNamespace;
258
388
  /** Joins the cluster: the node registers, takes on its allocated partitions, and starts serving. */
@@ -260,29 +390,6 @@ interface ClusterNode {
260
390
  /** Leaves the cluster: the node hands its partitions on, deregisters, and closes the engine it ran. */
261
391
  shutdown(): Promise<void>;
262
392
  }
263
- /**
264
- * The cluster splits an index into this many partitions when
265
- * {@link CreateIndexOptions} names no count.
266
- *
267
- * @public
268
- */
269
- declare const DEFAULT_PARTITION_COUNT = 5;
270
- /**
271
- * The cluster keeps this many copies of each partition when
272
- * {@link CreateIndexOptions} names no factor. One copy means a lost node costs
273
- * that partition, so raise it for anything you cannot rebuild.
274
- *
275
- * @public
276
- */
277
- declare const DEFAULT_REPLICATION_FACTOR = 1;
278
- /**
279
- * A node claims this much capacity when {@link ClusterNodeConfig} declares
280
- * none. Measure your own hosts and set it, because these figures are a
281
- * placeholder rather than a reading.
282
- *
283
- * @public
284
- */
285
- declare const DEFAULT_CAPACITY: NodeCapacity;
286
393
 
287
394
  /**
288
395
  * Builds one node of a cluster, ready to join.
@@ -301,95 +408,37 @@ declare const DEFAULT_CAPACITY: NodeCapacity;
301
408
  declare function createClusterNode(config: ClusterNodeConfig): Promise<ClusterNode>;
302
409
 
303
410
  /**
304
- * Receives the chunks a streamed response carries, in order.
305
- *
306
- * @param chunks - Every chunk the responder produced.
307
- *
308
- * @public
309
- */
310
- type StreamResponder = (chunks: Uint8Array[]) => void;
311
- /**
312
- * The delivery side of an in-memory transport, which the network calls to hand
313
- * a peer its message.
314
- *
315
- * You reach this through {@link InMemoryNetwork} rather than building one, so
316
- * treat it as the connection between two in-process nodes.
317
- *
318
- * @public
319
- */
320
- interface InMemoryTransportInternal extends NodeTransport {
321
- /**
322
- * Delivers one request to this node's listener.
323
- *
324
- * @param message - The request the sender posted.
325
- * @param respond - Hands the reply back to the sender.
326
- */
327
- deliverMessage(message: TransportMessage, respond: (response: TransportMessage) => void): void;
328
- /**
329
- * Delivers one streamed request to this node's listener.
330
- *
331
- * @param message - The request the sender posted.
332
- * @param responder - Hands the chunks back to the sender.
333
- */
334
- deliverStream(message: TransportMessage, responder: StreamResponder): void;
335
- }
336
- /**
337
- * The switchboard that connects in-process cluster nodes to each other.
338
- *
339
- * Every node registers its transport under its own id, and a message addressed
340
- * to a node is handed straight to the transport registered under that id. This
341
- * runs a whole cluster inside one process, which is what tests and local
342
- * development use in place of TCP.
411
+ * How {@link clusterNodeEngine} shapes the operations it forwards.
343
412
  *
344
413
  * @public
345
414
  */
346
- interface InMemoryNetwork {
347
- /**
348
- * Makes a node reachable under its id.
349
- *
350
- * @param nodeId - The id peers address this node by.
351
- * @param transport - The transport that receives its messages.
352
- */
353
- register(nodeId: string, transport: InMemoryTransportInternal): void;
354
- /**
355
- * Makes a node unreachable, so a message addressed to it fails.
356
- *
357
- * @param nodeId - The node to remove.
358
- */
359
- unregister(nodeId: string): void;
360
- /**
361
- * Looks a node's transport up.
362
- *
363
- * @param nodeId - The node to find.
364
- * @returns Its transport, or `undefined` when no node holds that id.
365
- */
366
- getTransport(nodeId: string): InMemoryTransportInternal | undefined;
415
+ interface ClusterEngineOptions {
416
+ /** Every index created through the adapter is spread with these settings, and with the cluster defaults otherwise. */
417
+ createIndex?: CreateIndexOptions;
367
418
  }
368
419
  /**
369
- * Builds the switchboard that connects in-process cluster nodes.
370
- *
371
- * Create one network, then create a transport per node against it, which is
372
- * how a whole cluster runs inside a single process.
373
- *
374
- * @returns An empty network, ready for nodes to register against.
375
- *
376
- * @public
377
- */
378
- declare function createInMemoryNetwork(): InMemoryNetwork;
379
- /**
380
- * Builds one node's transport and registers it on an in-process network.
381
- *
382
- * The network hands each message straight to the addressed node with no socket
383
- * in between, so a cluster built this way behaves like a real one without any
384
- * ports to open.
385
- *
386
- * @param nodeId - The id peers address this node by.
387
- * @param network - The network this node joins.
388
- * @param config - The timeouts to override. Omit it to accept the defaults.
389
- * @returns The transport you pass as a cluster node's `transport`.
420
+ * Adapts a cluster node to the {@link Narsil} interface, so
421
+ * `createServer` from `@delali/narsil/server` serves the cluster the way it
422
+ * serves a single engine.
423
+ *
424
+ * Writes, updates, searches, suggestions, listings, counts, index creation,
425
+ * index removal, and document reads route through the cluster. Checkpointing,
426
+ * memory statistics, and engine events reach this node's local engine, because
427
+ * each covers a per-node fact. Every other operation fails with
428
+ * `CLUSTER_OPERATION_UNSUPPORTED`, which the HTTP server answers with status
429
+ * 501, so a caller learns the operation is missing rather than reading a
430
+ * wrong answer. That covers `getStats`, `getPartitionStats`, and
431
+ * `listIndexes` as well, because {@link Narsil} declares them synchronous and
432
+ * a cluster answer needs a round trip; call them on the
433
+ * {@link ClusterNode} itself, where they are asynchronous.
434
+ *
435
+ * @param node - The cluster node the adapter serves.
436
+ * @param options - How the forwarded operations are shaped, such as the
437
+ * partition count and replication factor of created indexes.
438
+ * @returns The node behind the {@link Narsil} interface.
390
439
  *
391
440
  * @public
392
441
  */
393
- declare function createInMemoryTransport(nodeId: string, network: InMemoryNetwork, config?: Partial<TransportConfig>): NodeTransport;
442
+ declare function clusterNodeEngine(node: ClusterNode, options?: ClusterEngineOptions): Narsil;
394
443
 
395
- export { AllocationTable, ClusterCoordinator, type ClusterNamespace, type ClusterNode, type ClusterNodeConfig, type ClusterNodeInfo, type CreateIndexOptions, DEFAULT_CAPACITY, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, type InMemoryNetwork, type InMemoryTransportInternal, NodeCapacity, NodeRole, type NodeTransport, type ReplicationConfig, type StreamResponder, type TransportConfig, type TransportMessage, createClusterNode, createInMemoryNetwork, createInMemoryTransport };
444
+ export { AllocationTable, ClusterCoordinator, type ClusterEngineOptions, type ClusterNamespace, type ClusterNode, type ClusterNodeConfig, type ClusterNodeInfo, type CreateIndexOptions, DEFAULT_CAPACITY, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, NodeCapacity, NodeRole, NodeTransport, type ReplicationConfig, clusterNodeEngine, createClusterNode };