@delali/narsil 0.1.15 → 0.2.1-next.25

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 (267) hide show
  1. package/NOTICE +54 -0
  2. package/README.md +38 -982
  3. package/dist/adapters/filesystem.d.ts +23 -1
  4. package/dist/adapters/filesystem.mjs +1 -1
  5. package/dist/adapters/indexeddb.d.ts +25 -1
  6. package/dist/adapters/indexeddb.mjs +1 -1
  7. package/dist/adapters/memory.d.ts +14 -1
  8. package/dist/adapters-CVqI5NBt.d.ts +149 -0
  9. package/dist/{chunk-HMO6OMZ3.mjs → chunk-ASI6AOW2.mjs} +1073 -506
  10. package/dist/{chunk-HRABJLPB.mjs → chunk-BKAI2WXI.mjs} +1 -0
  11. package/dist/{chunk-WISGW24C.mjs → chunk-FKK76OR7.mjs} +56 -55
  12. package/dist/chunk-GHJWC2E5.mjs +9 -0
  13. package/dist/chunk-KH3YGMVT.mjs +15 -0
  14. package/dist/chunk-TGP5M5R7.mjs +880 -0
  15. package/dist/chunk-U2BKYEC7.mjs +254 -0
  16. package/dist/{chunk-ALB35PRQ.mjs → chunk-UNJZ7ZDB.mjs} +18 -0
  17. package/dist/{chunk-MEW7HD75.mjs → chunk-WLR5BFL3.mjs} +2557 -1166
  18. package/dist/config-CAjTHzkH.d.ts +256 -0
  19. package/dist/direct-executor-3W4QRA4E.mjs +5 -0
  20. package/dist/distribution/coordinator/etcd.d.ts +44 -3
  21. package/dist/distribution/coordinator/etcd.mjs +2 -2
  22. package/dist/distribution/coordinator/in-memory.d.ts +14 -3
  23. package/dist/distribution.d.ts +318 -45
  24. package/dist/distribution.mjs +1875 -1772
  25. package/dist/embeddings/openai.d.ts +28 -1
  26. package/dist/embeddings/openai.mjs +1 -1
  27. package/dist/engine-CCrlfLyq.d.ts +431 -0
  28. package/dist/index.browser.mjs +4571 -1776
  29. package/dist/index.d.ts +180 -6
  30. package/dist/index.mjs +6 -5
  31. package/dist/invalidation/broadcast-channel.d.ts +20 -1
  32. package/dist/invalidation/filesystem.d.ts +24 -1
  33. package/dist/invalidation/noop.d.ts +14 -1
  34. package/dist/language-DB8KG1z5.d.ts +53 -0
  35. package/dist/languages/albanian.d.ts +15 -0
  36. package/dist/languages/albanian.mjs +103 -0
  37. package/dist/languages/amharic.d.ts +15 -0
  38. package/dist/languages/amharic.mjs +240 -0
  39. package/dist/languages/arabic.d.ts +10 -1
  40. package/dist/languages/arabic.mjs +939 -154
  41. package/dist/languages/armenian.d.ts +10 -1
  42. package/dist/languages/armenian.mjs +275 -243
  43. package/dist/languages/azerbaijani.d.ts +15 -0
  44. package/dist/languages/azerbaijani.mjs +152 -0
  45. package/dist/languages/bambara.d.ts +15 -0
  46. package/dist/languages/bambara.mjs +60 -0
  47. package/dist/languages/basque.d.ts +14 -0
  48. package/dist/languages/basque.mjs +726 -0
  49. package/dist/languages/belarusian.d.ts +15 -0
  50. package/dist/languages/belarusian.mjs +100 -0
  51. package/dist/languages/bengali.d.ts +15 -0
  52. package/dist/languages/bengali.mjs +128 -0
  53. package/dist/languages/bosnian.d.ts +15 -0
  54. package/dist/languages/bosnian.mjs +197 -0
  55. package/dist/languages/breton.d.ts +15 -0
  56. package/dist/languages/breton.mjs +96 -0
  57. package/dist/languages/bulgarian.d.ts +10 -1
  58. package/dist/languages/bulgarian.mjs +11 -2
  59. package/dist/languages/burmese.d.ts +15 -0
  60. package/dist/languages/burmese.mjs +57 -0
  61. package/dist/languages/catalan.d.ts +14 -0
  62. package/dist/languages/catalan.mjs +987 -0
  63. package/dist/languages/chinese.d.ts +11 -1
  64. package/dist/languages/chinese.mjs +4 -3
  65. package/dist/languages/croatian.d.ts +15 -0
  66. package/dist/languages/croatian.mjs +191 -0
  67. package/dist/languages/czech.d.ts +14 -0
  68. package/dist/languages/czech.mjs +628 -0
  69. package/dist/languages/dagbani.d.ts +11 -1
  70. package/dist/languages/dagbani.mjs +11 -2
  71. package/dist/languages/danish.d.ts +10 -1
  72. package/dist/languages/danish.mjs +215 -110
  73. package/dist/languages/dutch.d.ts +10 -1
  74. package/dist/languages/dutch.mjs +1248 -163
  75. package/dist/languages/english.d.ts +10 -1
  76. package/dist/languages/english.mjs +2 -1
  77. package/dist/languages/esperanto.d.ts +14 -0
  78. package/dist/languages/esperanto.mjs +689 -0
  79. package/dist/languages/estonian.d.ts +14 -0
  80. package/dist/languages/estonian.mjs +2160 -0
  81. package/dist/languages/ewe.d.ts +11 -1
  82. package/dist/languages/ewe.mjs +11 -2
  83. package/dist/languages/faroese.d.ts +15 -0
  84. package/dist/languages/faroese.mjs +93 -0
  85. package/dist/languages/fijian.d.ts +15 -0
  86. package/dist/languages/fijian.mjs +55 -0
  87. package/dist/languages/finnish.d.ts +10 -1
  88. package/dist/languages/finnish.mjs +528 -263
  89. package/dist/languages/french.d.ts +10 -1
  90. package/dist/languages/french.mjs +950 -437
  91. package/dist/languages/ga.d.ts +11 -1
  92. package/dist/languages/ga.mjs +2 -1
  93. package/dist/languages/galician.d.ts +15 -0
  94. package/dist/languages/galician.mjs +172 -0
  95. package/dist/languages/georgian.d.ts +15 -0
  96. package/dist/languages/georgian.mjs +91 -0
  97. package/dist/languages/german.d.ts +10 -1
  98. package/dist/languages/german.mjs +432 -162
  99. package/dist/languages/greek.d.ts +10 -1
  100. package/dist/languages/greek.mjs +1970 -281
  101. package/dist/languages/guarani.d.ts +15 -0
  102. package/dist/languages/guarani.mjs +132 -0
  103. package/dist/languages/gujarati.d.ts +15 -0
  104. package/dist/languages/gujarati.mjs +234 -0
  105. package/dist/languages/haitian-creole.d.ts +15 -0
  106. package/dist/languages/haitian-creole.mjs +106 -0
  107. package/dist/languages/hausa.d.ts +11 -1
  108. package/dist/languages/hausa.mjs +2 -1
  109. package/dist/languages/hawaiian.d.ts +15 -0
  110. package/dist/languages/hawaiian.mjs +69 -0
  111. package/dist/languages/hebrew.d.ts +15 -0
  112. package/dist/languages/hebrew.mjs +213 -0
  113. package/dist/languages/hindi.d.ts +10 -1
  114. package/dist/languages/hindi.mjs +175 -97
  115. package/dist/languages/hungarian.d.ts +10 -1
  116. package/dist/languages/hungarian.mjs +412 -326
  117. package/dist/languages/icelandic.d.ts +15 -0
  118. package/dist/languages/icelandic.mjs +161 -0
  119. package/dist/languages/igbo.d.ts +11 -1
  120. package/dist/languages/igbo.mjs +2 -1
  121. package/dist/languages/indonesian.d.ts +10 -1
  122. package/dist/languages/indonesian.mjs +329 -137
  123. package/dist/languages/irish.d.ts +10 -1
  124. package/dist/languages/irish.mjs +223 -139
  125. package/dist/languages/italian.d.ts +10 -1
  126. package/dist/languages/italian.mjs +703 -406
  127. package/dist/languages/japanese.d.ts +11 -1
  128. package/dist/languages/japanese.mjs +5 -108
  129. package/dist/languages/kannada.d.ts +15 -0
  130. package/dist/languages/kannada.mjs +94 -0
  131. package/dist/languages/kazakh.d.ts +15 -0
  132. package/dist/languages/kazakh.mjs +90 -0
  133. package/dist/languages/khmer.d.ts +15 -0
  134. package/dist/languages/khmer.mjs +181 -0
  135. package/dist/languages/kinyarwanda.d.ts +15 -0
  136. package/dist/languages/kinyarwanda.mjs +99 -0
  137. package/dist/languages/kirundi.d.ts +15 -0
  138. package/dist/languages/kirundi.mjs +92 -0
  139. package/dist/languages/korean.d.ts +15 -0
  140. package/dist/languages/korean.mjs +252 -0
  141. package/dist/languages/kurmanji.d.ts +15 -0
  142. package/dist/languages/kurmanji.mjs +50 -0
  143. package/dist/languages/kyrgyz.d.ts +15 -0
  144. package/dist/languages/kyrgyz.mjs +108 -0
  145. package/dist/languages/lao.d.ts +15 -0
  146. package/dist/languages/lao.mjs +63 -0
  147. package/dist/languages/latin.d.ts +15 -0
  148. package/dist/languages/latin.mjs +69 -0
  149. package/dist/languages/latvian.d.ts +15 -0
  150. package/dist/languages/latvian.mjs +173 -0
  151. package/dist/languages/lingala.d.ts +15 -0
  152. package/dist/languages/lingala.mjs +61 -0
  153. package/dist/languages/lithuanian.d.ts +14 -0
  154. package/dist/languages/lithuanian.mjs +571 -0
  155. package/dist/languages/luxembourgish.d.ts +15 -0
  156. package/dist/languages/luxembourgish.mjs +214 -0
  157. package/dist/languages/macedonian.d.ts +15 -0
  158. package/dist/languages/macedonian.mjs +808 -0
  159. package/dist/languages/malagasy.d.ts +15 -0
  160. package/dist/languages/malagasy.mjs +67 -0
  161. package/dist/languages/malay.d.ts +15 -0
  162. package/dist/languages/malay.mjs +482 -0
  163. package/dist/languages/malayalam.d.ts +15 -0
  164. package/dist/languages/malayalam.mjs +122 -0
  165. package/dist/languages/maltese.d.ts +15 -0
  166. package/dist/languages/maltese.mjs +139 -0
  167. package/dist/languages/maori.d.ts +15 -0
  168. package/dist/languages/maori.mjs +79 -0
  169. package/dist/languages/marathi.d.ts +15 -0
  170. package/dist/languages/marathi.mjs +111 -0
  171. package/dist/languages/nepali.d.ts +10 -1
  172. package/dist/languages/nepali.mjs +209 -99
  173. package/dist/languages/norwegian.d.ts +10 -1
  174. package/dist/languages/norwegian.mjs +218 -85
  175. package/dist/languages/oromo.d.ts +15 -0
  176. package/dist/languages/oromo.mjs +78 -0
  177. package/dist/languages/persian.d.ts +14 -0
  178. package/dist/languages/persian.mjs +710 -0
  179. package/dist/languages/polish.d.ts +14 -0
  180. package/dist/languages/polish.mjs +614 -0
  181. package/dist/languages/portuguese.d.ts +10 -1
  182. package/dist/languages/portuguese.mjs +613 -380
  183. package/dist/languages/punjabi.d.ts +15 -0
  184. package/dist/languages/punjabi.mjs +197 -0
  185. package/dist/languages/romanian.d.ts +10 -1
  186. package/dist/languages/romanian.mjs +561 -382
  187. package/dist/languages/russian.d.ts +10 -1
  188. package/dist/languages/russian.mjs +373 -244
  189. package/dist/languages/samoan.d.ts +15 -0
  190. package/dist/languages/samoan.mjs +63 -0
  191. package/dist/languages/sanskrit.d.ts +10 -1
  192. package/dist/languages/sanskrit.mjs +2 -2
  193. package/dist/languages/scottish-gaelic.d.ts +15 -0
  194. package/dist/languages/scottish-gaelic.mjs +370 -0
  195. package/dist/languages/serbian.d.ts +10 -1
  196. package/dist/languages/serbian.mjs +3635 -155
  197. package/dist/languages/shona.d.ts +15 -0
  198. package/dist/languages/shona.mjs +91 -0
  199. package/dist/languages/sinhala.d.ts +15 -0
  200. package/dist/languages/sinhala.mjs +182 -0
  201. package/dist/languages/slovak.d.ts +15 -0
  202. package/dist/languages/slovak.mjs +430 -0
  203. package/dist/languages/slovenian.d.ts +10 -1
  204. package/dist/languages/slovenian.mjs +11 -2
  205. package/dist/languages/sorani.d.ts +15 -0
  206. package/dist/languages/sorani.mjs +156 -0
  207. package/dist/languages/spanish.d.ts +10 -1
  208. package/dist/languages/spanish.mjs +676 -374
  209. package/dist/languages/swahili.d.ts +10 -1
  210. package/dist/languages/swahili.mjs +2 -1
  211. package/dist/languages/swedish.d.ts +10 -1
  212. package/dist/languages/swedish.mjs +237 -95
  213. package/dist/languages/tagalog.d.ts +15 -0
  214. package/dist/languages/tagalog.mjs +159 -0
  215. package/dist/languages/tamil.d.ts +10 -1
  216. package/dist/languages/tamil.mjs +836 -64
  217. package/dist/languages/tatar.d.ts +15 -0
  218. package/dist/languages/tatar.mjs +1017 -0
  219. package/dist/languages/telugu.d.ts +15 -0
  220. package/dist/languages/telugu.mjs +62 -0
  221. package/dist/languages/thai.d.ts +15 -0
  222. package/dist/languages/thai.mjs +65 -0
  223. package/dist/languages/tibetan.d.ts +15 -0
  224. package/dist/languages/tibetan.mjs +119 -0
  225. package/dist/languages/tigrinya.d.ts +15 -0
  226. package/dist/languages/tigrinya.mjs +194 -0
  227. package/dist/languages/tongan.d.ts +15 -0
  228. package/dist/languages/tongan.mjs +56 -0
  229. package/dist/languages/turkish.d.ts +10 -1
  230. package/dist/languages/turkish.mjs +1246 -393
  231. package/dist/languages/twi.d.ts +11 -1
  232. package/dist/languages/twi.mjs +13 -2
  233. package/dist/languages/ukrainian.d.ts +10 -1
  234. package/dist/languages/ukrainian.mjs +125 -47
  235. package/dist/languages/urdu.d.ts +15 -0
  236. package/dist/languages/urdu.mjs +528 -0
  237. package/dist/languages/vietnamese.d.ts +15 -0
  238. package/dist/languages/vietnamese.mjs +277 -0
  239. package/dist/languages/welsh.d.ts +15 -0
  240. package/dist/languages/welsh.mjs +446 -0
  241. package/dist/languages/wolof.d.ts +15 -0
  242. package/dist/languages/wolof.mjs +79 -0
  243. package/dist/languages/xhosa.d.ts +15 -0
  244. package/dist/languages/xhosa.mjs +95 -0
  245. package/dist/languages/yoruba.d.ts +11 -1
  246. package/dist/languages/yoruba.mjs +1 -0
  247. package/dist/languages/zulu.d.ts +11 -1
  248. package/dist/languages/zulu.mjs +2 -1
  249. package/dist/persistence/durability/checkpoint-worker.d.ts +13 -0
  250. package/dist/persistence/durability/checkpoint-worker.mjs +6 -5
  251. package/dist/schema-CE6S_aAr.d.ts +208 -0
  252. package/dist/search-CgQQIciB.d.ts +786 -0
  253. package/dist/server.d.ts +214 -12
  254. package/dist/server.mjs +41 -2
  255. package/dist/types-BV3nAKTL.d.ts +302 -0
  256. package/dist/vector/hnsw-build-worker.d.ts +68 -2
  257. package/dist/vector/hnsw-build-worker.mjs +0 -2
  258. package/dist/workers/entry.mjs +2 -2
  259. package/package.json +14 -4
  260. package/dist/adapters-Bo2JQg8b.d.ts +0 -37
  261. package/dist/chunk-TW6BXTOL.mjs +0 -338
  262. package/dist/config-CojEPOgS.d.ts +0 -481
  263. package/dist/direct-executor-E52FFGDE.mjs +0 -4
  264. package/dist/language-ONQ3iVDf.d.ts +0 -14
  265. package/dist/narsil-D-84Nvm4.d.ts +0 -72
  266. package/dist/schema-DCgkO1j4.d.ts +0 -65
  267. package/dist/types-DHX6zGeD.d.ts +0 -73
@@ -1,122 +1,395 @@
1
- import { C as ClusterCoordinator, N as NodeRegistration, A as AllocationTable, a as NodeRole, b as NodeCapacity } from './types-DHX6zGeD.js';
2
- export { c as AllocationConstraints, d as AllocationEvent, e as NodeEvent, P as PartitionAssignment, f as PartitionState, S as SchemaEvent } from './types-DHX6zGeD.js';
3
- import { B as BatchResult, Q as QueryParams, u as QueryResult, N as NarsilConfig } from './config-CojEPOgS.js';
4
- import { I as IndexConfig, A as AnyDocument } from './schema-DCgkO1j4.js';
1
+ import { N as NarsilConfig } from './config-CAjTHzkH.js';
2
+ import { B as BatchResult, Q as QueryParams, q as QueryResult } from './search-CgQQIciB.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';
5
6
  export { createInMemoryCoordinator } from './distribution/coordinator/in-memory.js';
6
- import './adapters-Bo2JQg8b.js';
7
+ import './adapters-CVqI5NBt.js';
7
8
 
9
+ /**
10
+ * How much replication history a primary keeps, and how many replicas have to
11
+ * confirm a write before it is acknowledged.
12
+ *
13
+ * A replica that falls further behind than the retained log recovers from a
14
+ * whole snapshot instead of replaying entries, so a larger retention trades
15
+ * memory for cheaper recovery.
16
+ *
17
+ * @public
18
+ */
19
+ interface ReplicationConfig {
20
+ /** A primary keeps this many bytes of replication log before it drops the oldest entries. */
21
+ logRetentionBytes: number;
22
+ /** This many replicas must acknowledge a write before the primary reports it as done. */
23
+ waitForActiveReplicas: number;
24
+ }
25
+
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
+ */
8
34
  interface TransportMessage {
35
+ /** This says what the message is, such as a replication entry or a search request. */
9
36
  type: string;
37
+ /** This node sent the message. */
10
38
  sourceId: string;
39
+ /** This correlates a reply with its request. */
11
40
  requestId: string;
41
+ /** This carries the encoded body, and the message type tells a reader how to decode it. */
12
42
  payload: Uint8Array;
13
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
+ */
14
52
  interface TransportConfig {
53
+ /** Opening a connection to a peer may take this long. */
15
54
  connectTimeout: number;
55
+ /** An ordinary request and its reply may take this long. */
16
56
  requestTimeout: number;
57
+ /** A replication entry may take this long to reach a replica and come back acknowledged. */
17
58
  replicationTimeout: number;
59
+ /** A whole snapshot transfer, which moves a partition between nodes, may take this long. */
18
60
  snapshotTimeout: number;
19
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
+ */
20
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
+ */
21
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
+ */
22
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
+ */
23
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. */
24
100
  shutdown(): Promise<void>;
25
101
  }
26
102
 
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
-
103
+ /**
104
+ * Everything {@link createClusterNode} needs to join a node to a cluster.
105
+ *
106
+ * The coordinator and the transport are the two pieces you choose: the
107
+ * coordinator holds the cluster's shared state, and the transport carries
108
+ * messages between nodes.
109
+ *
110
+ * @public
111
+ */
66
112
  interface ClusterNodeConfig {
113
+ /** This node reads and writes the cluster's shared state here. Every node in a cluster must point at the same one. */
67
114
  coordinator: ClusterCoordinator;
115
+ /** This node reaches its peers through this transport. */
68
116
  transport: NodeTransport;
117
+ /** Peers reach this node at this address, as the transport writes it. */
69
118
  address: string;
119
+ /** This node holds these roles in the cluster, and holds data alone by default. */
70
120
  roles?: NodeRole[];
121
+ /** This identifies the node across the cluster. The package generates an id by default, which a restart changes. */
71
122
  nodeId?: string;
123
+ /** This node offers this much capacity, which the allocator weighs. It offers {@link DEFAULT_CAPACITY} by default. */
72
124
  capacity?: NodeCapacity;
125
+ /** These settings configure the engine this node runs locally, such as its persistence and durability. */
73
126
  engine?: NarsilConfig;
127
+ /** These replication settings override the engine's own, and anything you leave out keeps its value. */
128
+ replication?: Partial<ReplicationConfig>;
129
+ /** This receives the failures the node reports while running on its own, away from any call you made. */
74
130
  onError?: (error: Error) => void;
75
131
  }
132
+ /**
133
+ * How an index is spread across the cluster when a node creates it.
134
+ *
135
+ * @public
136
+ */
76
137
  interface CreateIndexOptions {
138
+ /** The cluster splits the index into this many partitions, and into {@link DEFAULT_PARTITION_COUNT} by default. */
77
139
  partitionCount?: number;
140
+ /** The cluster keeps this many copies of each partition, and {@link DEFAULT_REPLICATION_FACTOR} by default. */
78
141
  replicationFactor?: number;
79
142
  }
143
+ /**
144
+ * The cluster-facing side of a node, which is where you look at the cluster
145
+ * rather than at the data.
146
+ *
147
+ * @public
148
+ */
80
149
  interface ClusterNamespace {
150
+ /**
151
+ * Reads how one index is spread across the cluster.
152
+ *
153
+ * @param indexName - The index to describe.
154
+ * @returns Its allocation, or `null` when the index has none yet.
155
+ */
81
156
  getAllocation(indexName: string): Promise<AllocationTable | null>;
157
+ /**
158
+ * Describes this node.
159
+ *
160
+ * @returns Its id, its roles, and where it stands.
161
+ */
82
162
  getNodeInfo(): ClusterNodeInfo;
163
+ /**
164
+ * Reports whether this node is the cluster's active controller, which is the
165
+ * one node making allocation decisions.
166
+ *
167
+ * @returns True while this node holds the controller lease.
168
+ */
83
169
  isControllerActive(): boolean;
84
170
  }
171
+ /**
172
+ * What one node reports about itself.
173
+ *
174
+ * @public
175
+ */
85
176
  interface ClusterNodeInfo {
177
+ /** This identifies the node across the cluster. */
86
178
  nodeId: string;
179
+ /** The node holds these roles in the cluster. */
87
180
  roles: ReadonlyArray<NodeRole>;
181
+ /** This says where the node stands, from joining through to shut down. */
88
182
  status: string;
89
183
  }
184
+ /**
185
+ * One node of a cluster, which routes each write to the partition's primary
186
+ * and gathers each search from every partition.
187
+ *
188
+ * The write and search methods mirror {@link Narsil}, so code moving from a
189
+ * single engine to a cluster keeps its shape. Build one with
190
+ * {@link createClusterNode}.
191
+ *
192
+ * @public
193
+ */
90
194
  interface ClusterNode {
195
+ /** This identifies the node across the cluster. */
91
196
  readonly nodeId: string;
197
+ /** The node holds these roles in the cluster. */
92
198
  readonly roles: ReadonlyArray<NodeRole>;
199
+ /**
200
+ * Creates an index across the cluster, publishing its schema and allocating
201
+ * its partitions to nodes.
202
+ *
203
+ * @param name - Every later call uses this name to reach the index.
204
+ * @param config - The schema, and the language, scoring, and vector
205
+ * settings, exactly as a single engine takes them.
206
+ * @param options - How the index is spread across the cluster.
207
+ */
93
208
  createIndex(name: string, config: IndexConfig, options?: CreateIndexOptions): Promise<void>;
209
+ /**
210
+ * Adds one document, routing it to the partition's primary.
211
+ *
212
+ * @param indexName - The index that receives the document.
213
+ * @param document - Its fields must match the types the schema declares.
214
+ * @param docId - Pass an id to control it yourself, or omit it and read the
215
+ * returned value.
216
+ * @returns The id the document is stored under.
217
+ */
94
218
  insert(indexName: string, document: AnyDocument, docId?: string): Promise<string>;
219
+ /**
220
+ * Adds many documents, routing each to its own partition's primary, and
221
+ * reports each one's outcome.
222
+ *
223
+ * @param indexName - The index that receives the documents.
224
+ * @param documents - The documents to write.
225
+ * @returns The ids written, and each rejection with its error.
226
+ */
95
227
  insertBatch(indexName: string, documents: AnyDocument[]): Promise<BatchResult>;
228
+ /**
229
+ * Removes one document.
230
+ *
231
+ * @param indexName - The index holding the document.
232
+ * @param docId - The document to remove.
233
+ */
96
234
  remove(indexName: string, docId: string): Promise<void>;
235
+ /**
236
+ * Removes many documents and reports each one's outcome.
237
+ *
238
+ * @param indexName - The index holding the documents.
239
+ * @param docIds - The documents to remove.
240
+ * @returns The ids removed, and each failure with its error.
241
+ */
97
242
  removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
243
+ /**
244
+ * Runs a search across every partition and merges the results into one
245
+ * ranking.
246
+ *
247
+ * The search skips a partition whose nodes are all unreachable instead of
248
+ * failing, so read the result's count against what you expect.
249
+ *
250
+ * @typeParam T - Shape of the stored documents.
251
+ * @param indexName - The index the search runs against.
252
+ * @param params - The same parameters a single engine takes.
253
+ * @returns The merged hits, the total count, and the elapsed time.
254
+ */
98
255
  query<T = AnyDocument>(indexName: string, params: QueryParams): Promise<QueryResult<T>>;
256
+ /** This reaches the cluster-facing side of the node. */
99
257
  cluster: ClusterNamespace;
258
+ /** Joins the cluster: the node registers, takes on its allocated partitions, and starts serving. */
100
259
  start(): Promise<void>;
260
+ /** Leaves the cluster: the node hands its partitions on, deregisters, and closes the engine it ran. */
101
261
  shutdown(): Promise<void>;
102
262
  }
263
+ /**
264
+ * The cluster splits an index into this many partitions when
265
+ * {@link CreateIndexOptions} names no count.
266
+ *
267
+ * @public
268
+ */
103
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
+ */
104
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
+ */
105
285
  declare const DEFAULT_CAPACITY: NodeCapacity;
106
286
 
287
+ /**
288
+ * Builds one node of a cluster, ready to join.
289
+ *
290
+ * The node is idle until you call {@link ClusterNode.start}, which registers
291
+ * it, takes on the partitions the controller allocates to it, and starts
292
+ * answering. A node whose roles include `controller` stands for election and
293
+ * runs allocation for the whole cluster while it holds the lease.
294
+ *
295
+ * @param config - The coordinator, the transport, this node's address, and the
296
+ * settings for the engine it runs locally.
297
+ * @returns The node, ready for {@link ClusterNode.start}.
298
+ *
299
+ * @public
300
+ */
107
301
  declare function createClusterNode(config: ClusterNodeConfig): Promise<ClusterNode>;
108
302
 
303
+ /**
304
+ * Receives the chunks a streamed response carries, in order.
305
+ *
306
+ * @param chunks - Every chunk the responder produced.
307
+ *
308
+ * @public
309
+ */
109
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
+ */
110
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
+ */
111
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
+ */
112
334
  deliverStream(message: TransportMessage, responder: StreamResponder): void;
113
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.
343
+ *
344
+ * @public
345
+ */
114
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
+ */
115
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
+ */
116
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
+ */
117
366
  getTransport(nodeId: string): InMemoryTransportInternal | undefined;
118
367
  }
368
+ /**
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
+ */
119
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`.
390
+ *
391
+ * @public
392
+ */
120
393
  declare function createInMemoryTransport(nodeId: string, network: InMemoryNetwork, config?: Partial<TransportConfig>): NodeTransport;
121
394
 
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 };
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 };