@delali/narsil 0.2.0 → 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.
- package/dist/adapters/filesystem.d.ts +23 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +25 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +14 -1
- package/dist/adapters-CVqI5NBt.d.ts +149 -0
- package/dist/{chunk-S6IAXOBA.mjs → chunk-ASI6AOW2.mjs} +1 -1
- package/dist/{chunk-AUMKFYTG.mjs → chunk-FKK76OR7.mjs} +56 -55
- package/dist/{chunk-M2EDG55Y.mjs → chunk-UNJZ7ZDB.mjs} +10 -0
- package/dist/{chunk-XAKNSWIK.mjs → chunk-WLR5BFL3.mjs} +16 -14
- package/dist/config-CAjTHzkH.d.ts +256 -0
- package/dist/{direct-executor-2FV3MEDD.mjs → direct-executor-3W4QRA4E.mjs} +2 -2
- package/dist/distribution/coordinator/etcd.d.ts +44 -3
- package/dist/distribution/coordinator/etcd.mjs +2 -2
- package/dist/distribution/coordinator/in-memory.d.ts +14 -3
- package/dist/distribution.d.ts +312 -45
- package/dist/distribution.mjs +4 -4
- package/dist/embeddings/openai.d.ts +28 -1
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/engine-CCrlfLyq.d.ts +431 -0
- package/dist/index.browser.mjs +24 -12
- package/dist/index.d.ts +173 -8
- package/dist/index.mjs +3 -3
- package/dist/invalidation/broadcast-channel.d.ts +20 -1
- package/dist/invalidation/filesystem.d.ts +24 -1
- package/dist/invalidation/noop.d.ts +14 -1
- package/dist/language-DB8KG1z5.d.ts +53 -0
- package/dist/languages/albanian.d.ts +11 -1
- package/dist/languages/amharic.d.ts +11 -1
- package/dist/languages/arabic.d.ts +10 -1
- package/dist/languages/armenian.d.ts +10 -1
- package/dist/languages/azerbaijani.d.ts +11 -1
- package/dist/languages/bambara.d.ts +11 -1
- package/dist/languages/basque.d.ts +10 -1
- package/dist/languages/belarusian.d.ts +11 -1
- package/dist/languages/bengali.d.ts +11 -1
- package/dist/languages/bosnian.d.ts +11 -1
- package/dist/languages/breton.d.ts +11 -1
- package/dist/languages/bulgarian.d.ts +10 -1
- package/dist/languages/burmese.d.ts +11 -1
- package/dist/languages/catalan.d.ts +10 -1
- package/dist/languages/chinese.d.ts +11 -1
- package/dist/languages/croatian.d.ts +11 -1
- package/dist/languages/czech.d.ts +10 -1
- package/dist/languages/dagbani.d.ts +11 -1
- package/dist/languages/danish.d.ts +10 -1
- package/dist/languages/dutch.d.ts +10 -1
- package/dist/languages/english.d.ts +10 -1
- package/dist/languages/esperanto.d.ts +10 -1
- package/dist/languages/estonian.d.ts +10 -1
- package/dist/languages/ewe.d.ts +11 -1
- package/dist/languages/faroese.d.ts +11 -1
- package/dist/languages/fijian.d.ts +11 -1
- package/dist/languages/finnish.d.ts +10 -1
- package/dist/languages/french.d.ts +10 -1
- package/dist/languages/ga.d.ts +11 -1
- package/dist/languages/galician.d.ts +11 -1
- package/dist/languages/georgian.d.ts +11 -1
- package/dist/languages/german.d.ts +10 -1
- package/dist/languages/greek.d.ts +10 -1
- package/dist/languages/guarani.d.ts +11 -1
- package/dist/languages/gujarati.d.ts +11 -1
- package/dist/languages/haitian-creole.d.ts +11 -1
- package/dist/languages/hausa.d.ts +11 -1
- package/dist/languages/hawaiian.d.ts +11 -1
- package/dist/languages/hebrew.d.ts +11 -1
- package/dist/languages/hindi.d.ts +10 -1
- package/dist/languages/hungarian.d.ts +10 -1
- package/dist/languages/icelandic.d.ts +11 -1
- package/dist/languages/igbo.d.ts +11 -1
- package/dist/languages/indonesian.d.ts +10 -1
- package/dist/languages/irish.d.ts +10 -1
- package/dist/languages/italian.d.ts +10 -1
- package/dist/languages/japanese.d.ts +11 -1
- package/dist/languages/kannada.d.ts +11 -1
- package/dist/languages/kazakh.d.ts +11 -1
- package/dist/languages/khmer.d.ts +11 -1
- package/dist/languages/kinyarwanda.d.ts +11 -1
- package/dist/languages/kirundi.d.ts +11 -1
- package/dist/languages/korean.d.ts +11 -1
- package/dist/languages/kurmanji.d.ts +11 -1
- package/dist/languages/kyrgyz.d.ts +11 -1
- package/dist/languages/lao.d.ts +11 -1
- package/dist/languages/latin.d.ts +11 -1
- package/dist/languages/latvian.d.ts +11 -1
- package/dist/languages/lingala.d.ts +11 -1
- package/dist/languages/lithuanian.d.ts +10 -1
- package/dist/languages/luxembourgish.d.ts +11 -1
- package/dist/languages/macedonian.d.ts +11 -1
- package/dist/languages/malagasy.d.ts +11 -1
- package/dist/languages/malay.d.ts +11 -1
- package/dist/languages/malayalam.d.ts +11 -1
- package/dist/languages/maltese.d.ts +11 -1
- package/dist/languages/maori.d.ts +11 -1
- package/dist/languages/marathi.d.ts +11 -1
- package/dist/languages/nepali.d.ts +10 -1
- package/dist/languages/norwegian.d.ts +10 -1
- package/dist/languages/oromo.d.ts +11 -1
- package/dist/languages/persian.d.ts +10 -1
- package/dist/languages/polish.d.ts +10 -1
- package/dist/languages/portuguese.d.ts +10 -1
- package/dist/languages/punjabi.d.ts +11 -1
- package/dist/languages/romanian.d.ts +10 -1
- package/dist/languages/russian.d.ts +10 -1
- package/dist/languages/samoan.d.ts +11 -1
- package/dist/languages/sanskrit.d.ts +10 -1
- package/dist/languages/scottish-gaelic.d.ts +11 -1
- package/dist/languages/serbian.d.ts +10 -1
- package/dist/languages/shona.d.ts +11 -1
- package/dist/languages/sinhala.d.ts +11 -1
- package/dist/languages/slovak.d.ts +11 -1
- package/dist/languages/slovenian.d.ts +10 -1
- package/dist/languages/sorani.d.ts +11 -1
- package/dist/languages/spanish.d.ts +10 -1
- package/dist/languages/swahili.d.ts +10 -1
- package/dist/languages/swedish.d.ts +10 -1
- package/dist/languages/tagalog.d.ts +11 -1
- package/dist/languages/tamil.d.ts +10 -1
- package/dist/languages/tatar.d.ts +11 -1
- package/dist/languages/telugu.d.ts +11 -1
- package/dist/languages/thai.d.ts +11 -1
- package/dist/languages/tibetan.d.ts +11 -1
- package/dist/languages/tigrinya.d.ts +11 -1
- package/dist/languages/tongan.d.ts +11 -1
- package/dist/languages/turkish.d.ts +10 -1
- package/dist/languages/twi.d.ts +11 -1
- package/dist/languages/ukrainian.d.ts +10 -1
- package/dist/languages/urdu.d.ts +11 -1
- package/dist/languages/vietnamese.d.ts +11 -1
- package/dist/languages/welsh.d.ts +11 -1
- package/dist/languages/wolof.d.ts +11 -1
- package/dist/languages/xhosa.d.ts +11 -1
- package/dist/languages/yoruba.d.ts +11 -1
- package/dist/languages/zulu.d.ts +11 -1
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +3 -3
- package/dist/schema-CE6S_aAr.d.ts +208 -0
- package/dist/search-CgQQIciB.d.ts +786 -0
- package/dist/server.d.ts +213 -12
- package/dist/server.mjs +29 -1
- package/dist/types-BV3nAKTL.d.ts +302 -0
- package/dist/vector/hnsw-build-worker.d.ts +68 -2
- package/dist/vector/hnsw-build-worker.mjs +0 -2
- package/dist/workers/entry.mjs +1 -1
- package/package.json +5 -2
- package/dist/adapters-Bo2JQg8b.d.ts +0 -37
- package/dist/config-P27AtSn4.d.ts +0 -502
- package/dist/language-CmJBHf1j.d.ts +0 -17
- package/dist/narsil-CMZRPDlQ.d.ts +0 -159
- package/dist/schema-BnvLvjRp.d.ts +0 -67
- package/dist/types-BRTcBgAp.d.ts +0 -73
package/dist/server.d.ts
CHANGED
|
@@ -1,38 +1,72 @@
|
|
|
1
|
-
import { N as Narsil } from './
|
|
2
|
-
import { E as EmbeddingAdapter } from './adapters-
|
|
3
|
-
import './
|
|
4
|
-
import './
|
|
1
|
+
import { N as Narsil } from './engine-CCrlfLyq.js';
|
|
2
|
+
import { E as EmbeddingAdapter } from './adapters-CVqI5NBt.js';
|
|
3
|
+
import './search-CgQQIciB.js';
|
|
4
|
+
import './schema-CE6S_aAr.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Context handed to {@link OnRequestHook} for every inbound request, captured
|
|
8
8
|
* synchronously before any body is read. `remoteAddress` is the peer address
|
|
9
9
|
* decoded from the socket; behind a proxy it is the proxy's address, so trust
|
|
10
10
|
* forwarded headers only when the proxy is trusted.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
11
13
|
*/
|
|
12
14
|
interface RequestContext {
|
|
15
|
+
/** The request used this HTTP method, in upper case. */
|
|
13
16
|
method: string;
|
|
17
|
+
/** The request asked for this path, without the query string. */
|
|
14
18
|
path: string;
|
|
19
|
+
/** These are the request headers, keyed by lower-case name. */
|
|
15
20
|
headers: Record<string, string>;
|
|
21
|
+
/** The server decoded this peer address from the socket. */
|
|
16
22
|
remoteAddress: string;
|
|
17
23
|
}
|
|
18
24
|
/**
|
|
19
25
|
* Returned by an {@link OnRequestHook} to reject a request. The `status` is sent
|
|
20
26
|
* verbatim as the HTTP status; `code` and `message` populate the error envelope.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
21
29
|
*/
|
|
22
30
|
interface RequestDenial {
|
|
31
|
+
/** The server answers with this status. */
|
|
23
32
|
status: number;
|
|
33
|
+
/** The error envelope carries this machine-readable code. */
|
|
24
34
|
code: string;
|
|
35
|
+
/** The error envelope carries this description. */
|
|
25
36
|
message: string;
|
|
26
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Runs before every routed request, which is where authentication, rate
|
|
40
|
+
* limiting, and any other admission rule goes.
|
|
41
|
+
*
|
|
42
|
+
* @param ctx - The request's method, path, headers, and peer address.
|
|
43
|
+
* @returns A {@link RequestDenial} to reject the request, or `undefined` to
|
|
44
|
+
* let it through.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
27
48
|
type OnRequestHook = (ctx: RequestContext) => undefined | RequestDenial | Promise<undefined | RequestDenial>;
|
|
49
|
+
/**
|
|
50
|
+
* Which cross-origin requests the server accepts.
|
|
51
|
+
*
|
|
52
|
+
* Passing `true` for `cors` instead of this object accepts any origin, which
|
|
53
|
+
* suits local development and little else.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
28
57
|
interface CorsOptions {
|
|
58
|
+
/** The server allows these origins, given as one origin or a list. */
|
|
29
59
|
origin?: string | string[];
|
|
60
|
+
/** The server allows these methods on a cross-origin request. */
|
|
30
61
|
methods?: string[];
|
|
62
|
+
/** A browser may send these request headers cross-origin. */
|
|
31
63
|
headers?: string[];
|
|
32
64
|
}
|
|
33
65
|
/**
|
|
34
66
|
* Byte and batch ceilings the server enforces before handing work to the
|
|
35
67
|
* engine. Every field has a safe default; override only to fit a deployment.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
36
70
|
*/
|
|
37
71
|
interface ServerLimits {
|
|
38
72
|
/** Cap for JSON request bodies (single doc, batch, search). Excess → 413. */
|
|
@@ -54,9 +88,20 @@ interface ServerLimits {
|
|
|
54
88
|
* Defaults to 10000. */
|
|
55
89
|
maxFetchDocuments?: number;
|
|
56
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Everything {@link createServer} accepts.
|
|
93
|
+
*
|
|
94
|
+
* Every field is optional, and a server created without any of them binds to
|
|
95
|
+
* loopback with the default limits and no authentication.
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
57
99
|
interface ServerOptions {
|
|
100
|
+
/** The server binds to this address, and to loopback by default. Any other address needs an authentication hook. */
|
|
58
101
|
host?: string;
|
|
102
|
+
/** The server binds to this port. Pass 0 to let the operating system choose one, then read {@link NarsilServer.listeningPort}. */
|
|
59
103
|
port?: number;
|
|
104
|
+
/** These settings control which cross-origin requests the server accepts, and `true` accepts any origin. */
|
|
60
105
|
cors?: boolean | CorsOptions;
|
|
61
106
|
/** Authentication or admission gate run before every routed request. */
|
|
62
107
|
onRequest?: OnRequestHook;
|
|
@@ -77,6 +122,7 @@ interface ServerOptions {
|
|
|
77
122
|
* needs query-time or ingest-time embedding names a server-registered adapter.
|
|
78
123
|
*/
|
|
79
124
|
embeddingAdapters?: Record<string, EmbeddingAdapter>;
|
|
125
|
+
/** These ceilings apply before the server hands any work to the engine. */
|
|
80
126
|
limits?: ServerLimits;
|
|
81
127
|
/**
|
|
82
128
|
* Backing store for long-running task records. Defaults to an in-memory store
|
|
@@ -93,52 +139,127 @@ interface ServerOptions {
|
|
|
93
139
|
*/
|
|
94
140
|
instanceId?: string;
|
|
95
141
|
/**
|
|
96
|
-
* Allows binding to a non-loopback address without an
|
|
97
|
-
* hook. The server otherwise refuses to
|
|
98
|
-
*
|
|
99
|
-
* trusted private network where access
|
|
142
|
+
* Allows binding to a non-loopback address without an
|
|
143
|
+
* {@link ServerOptions.onRequest} auth hook. The server otherwise refuses to
|
|
144
|
+
* start in that configuration because it exposes destructive admin endpoints.
|
|
145
|
+
* Set this only when the address is on a trusted private network where access
|
|
146
|
+
* is controlled elsewhere.
|
|
100
147
|
*/
|
|
101
148
|
allowInsecure?: boolean;
|
|
102
149
|
}
|
|
103
150
|
/**
|
|
104
151
|
* Pluggable backing store for task records. Every method is async so any
|
|
105
|
-
* backend works
|
|
152
|
+
* backend works: an in-memory map, Redis, an HTTP key-value service, or a
|
|
106
153
|
* database. `set` upserts by `record.id`; `get` returns null for an unknown id.
|
|
107
154
|
* `ttlMs`, when honored by the backend, expires the record so terminal tasks do
|
|
108
155
|
* not accumulate. The server never calls a method that mutates a record it did
|
|
109
156
|
* not construct, so a backend may treat records as immutable snapshots.
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
110
159
|
*/
|
|
111
160
|
interface TaskStore {
|
|
161
|
+
/**
|
|
162
|
+
* Stores a record, replacing whatever its id already held.
|
|
163
|
+
*
|
|
164
|
+
* @param record - The record to store.
|
|
165
|
+
* @param ttlMs - Milliseconds after which the backend may drop it, which
|
|
166
|
+
* keeps finished tasks from accumulating. Ignore it in a backend without
|
|
167
|
+
* expiry.
|
|
168
|
+
*/
|
|
112
169
|
set(record: TaskRecord, ttlMs?: number): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Reads one record back.
|
|
172
|
+
*
|
|
173
|
+
* @param id - The task to read.
|
|
174
|
+
* @returns The record, or `null` when the store holds no such id.
|
|
175
|
+
*/
|
|
113
176
|
get(id: string): Promise<TaskRecord | null>;
|
|
177
|
+
/**
|
|
178
|
+
* Lists every record the store holds.
|
|
179
|
+
*
|
|
180
|
+
* @returns Each record the backend still has.
|
|
181
|
+
*/
|
|
114
182
|
list(): Promise<TaskRecord[]>;
|
|
183
|
+
/**
|
|
184
|
+
* Removes one record. An id the store never held is not an error.
|
|
185
|
+
*
|
|
186
|
+
* @param id - The task to remove.
|
|
187
|
+
*/
|
|
115
188
|
delete(id: string): Promise<void>;
|
|
189
|
+
/** Releases whatever the backend holds open, such as a connection pool. */
|
|
116
190
|
shutdown?(): Promise<void>;
|
|
117
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* The running HTTP server, as {@link createServer} returns it.
|
|
194
|
+
*
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
118
197
|
interface NarsilServer {
|
|
198
|
+
/**
|
|
199
|
+
* Binds the socket and starts answering requests.
|
|
200
|
+
*
|
|
201
|
+
* @throws An error when the address is already in use, or when a non-loopback
|
|
202
|
+
* address is configured without an authentication hook.
|
|
203
|
+
*/
|
|
119
204
|
listen(): Promise<void>;
|
|
205
|
+
/** Closes the socket and ends the server. The engine keeps running. */
|
|
120
206
|
close(): Promise<void>;
|
|
207
|
+
/** The server bound to this port, which is what you read after binding to port 0. */
|
|
121
208
|
readonly listeningPort: number;
|
|
122
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* The body every failed response carries, which is what an HTTP client parses
|
|
212
|
+
* on a non-2xx status.
|
|
213
|
+
*
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
123
216
|
interface ErrorEnvelope {
|
|
217
|
+
/** This describes the failure. */
|
|
124
218
|
error: {
|
|
219
|
+
/** This code comes from either {@link ServerErrorCodes} or {@link ErrorCodes}. */
|
|
125
220
|
code: string;
|
|
221
|
+
/** This describes the failure, for a log or a person. */
|
|
126
222
|
message: string;
|
|
223
|
+
/** These values are behind the failure, such as the field or limit involved. */
|
|
127
224
|
details?: Record<string, unknown>;
|
|
128
225
|
};
|
|
129
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Which long-running operation a task record tracks.
|
|
229
|
+
*
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
130
232
|
type TaskType = 'optimizeVectors' | 'rebalance' | 'restore';
|
|
233
|
+
/**
|
|
234
|
+
* Where a long-running operation stands.
|
|
235
|
+
*
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
131
238
|
type TaskStatus = 'queued' | 'running' | 'succeeded' | 'failed';
|
|
239
|
+
/**
|
|
240
|
+
* One long-running operation, which the server answers with straight away and
|
|
241
|
+
* you then poll.
|
|
242
|
+
*
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
132
245
|
interface TaskRecord {
|
|
246
|
+
/** This identifies the task, and is what you poll by. */
|
|
133
247
|
id: string;
|
|
248
|
+
/** This says which operation the task runs. */
|
|
134
249
|
type: TaskType;
|
|
250
|
+
/** The operation runs against this index. */
|
|
135
251
|
indexName: string;
|
|
252
|
+
/** This says where the operation stands. */
|
|
136
253
|
status: TaskStatus;
|
|
137
254
|
/** Identifier of the server instance running this task; see ServerOptions.instanceId. */
|
|
138
255
|
owner: string;
|
|
256
|
+
/** The server accepted the task at this many milliseconds since the epoch. */
|
|
139
257
|
createdAt: number;
|
|
258
|
+
/** Work started at this many milliseconds since the epoch, and a queued task omits it. */
|
|
140
259
|
startedAt?: number;
|
|
260
|
+
/** Work ended at this many milliseconds since the epoch, and a task omits it until it succeeds or fails. */
|
|
141
261
|
completedAt?: number;
|
|
262
|
+
/** This says why the task failed, and a failed task alone carries it. */
|
|
142
263
|
error?: {
|
|
143
264
|
code: string;
|
|
144
265
|
message: string;
|
|
@@ -148,34 +269,70 @@ interface TaskRecord {
|
|
|
148
269
|
/** Declarative index configuration accepted over HTTP. Function-valued engine
|
|
149
270
|
* options (custom tokenizer, stopWords-as-function, group reducer, embedding
|
|
150
271
|
* adapter object) are not representable here; the embedding adapter is named
|
|
151
|
-
* instead via {@link CreateIndexEmbedding}.
|
|
272
|
+
* instead via {@link CreateIndexEmbedding}.
|
|
273
|
+
*
|
|
274
|
+
* @public */
|
|
152
275
|
interface CreateIndexRequest {
|
|
276
|
+
/** The server creates the index under this name. */
|
|
153
277
|
name: string;
|
|
278
|
+
/** This carries the schema and settings, in the subset JSON can express. */
|
|
154
279
|
config: HttpIndexConfig;
|
|
155
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* How a JSON `createIndex` request connects an index to an embedding adapter.
|
|
283
|
+
*
|
|
284
|
+
* An adapter is a function and cannot cross JSON, so the request names one the
|
|
285
|
+
* server registered instead of carrying it.
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
156
289
|
interface CreateIndexEmbedding {
|
|
290
|
+
/** This names an adapter the server registered under `embeddingAdapters`. */
|
|
157
291
|
adapter?: string;
|
|
292
|
+
/** This maps each vector field to the text field, or fields, the server embeds into it. */
|
|
158
293
|
fields: Record<string, string | string[]>;
|
|
159
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* The index settings a JSON request can carry, which is {@link IndexConfig}
|
|
297
|
+
* minus everything that is a function.
|
|
298
|
+
*
|
|
299
|
+
* A custom tokeniser, a stop-word function, and an embedding adapter object
|
|
300
|
+
* have no JSON form, so an HTTP client names a registered one or supplies a
|
|
301
|
+
* plain list instead.
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
160
305
|
interface HttpIndexConfig {
|
|
306
|
+
/** This layout gives each value as either a field type or a nested schema. */
|
|
161
307
|
schema: Record<string, unknown>;
|
|
308
|
+
/** The server tokenises and stems text fields with the language module registered under this name. */
|
|
162
309
|
language?: string;
|
|
310
|
+
/** These settings control how the index splits documents across partitions as it grows. */
|
|
163
311
|
partitions?: {
|
|
164
312
|
maxDocsPerPartition?: number;
|
|
165
313
|
maxPartitions?: number;
|
|
166
314
|
watermark?: number;
|
|
167
315
|
};
|
|
316
|
+
/** A query scores this way unless it asks for another mode. */
|
|
168
317
|
defaultScoring?: 'local' | 'dfs' | 'broadcast';
|
|
318
|
+
/** These parameters tune BM25 for this index. */
|
|
169
319
|
bm25?: {
|
|
170
320
|
k1?: number;
|
|
171
321
|
b?: number;
|
|
172
322
|
};
|
|
323
|
+
/** This list replaces the language's stop words. */
|
|
173
324
|
stopWords?: string[];
|
|
325
|
+
/** Setting this records term positions, which phrase queries and highlighting need. */
|
|
174
326
|
trackPositions?: boolean;
|
|
327
|
+
/** Setting this returns the words users typed from suggestions and prefix expansion, instead of index stems. */
|
|
175
328
|
surfaceForms?: boolean;
|
|
329
|
+
/** These settings control when vector fields move to an HNSW graph, and how that graph is built. */
|
|
176
330
|
vectorPromotion?: Record<string, unknown>;
|
|
331
|
+
/** Setting this rejects a document carrying a field the schema does not declare. */
|
|
177
332
|
strict?: boolean;
|
|
333
|
+
/** This names a server-registered embedding adapter and the fields it embeds. */
|
|
178
334
|
embedding?: CreateIndexEmbedding;
|
|
335
|
+
/** The server rejects a document that omits any of these fields. */
|
|
179
336
|
required?: string[];
|
|
180
337
|
}
|
|
181
338
|
|
|
@@ -184,12 +341,21 @@ interface HttpIndexConfig {
|
|
|
184
341
|
* (durability, embedding, workers) and hands the live instance in; the server
|
|
185
342
|
* shares it across requests and never constructs or shuts it down. Start with
|
|
186
343
|
* `.listen()` and stop with `.close()`; the engine is shut down separately.
|
|
344
|
+
*
|
|
345
|
+
* @param engine - The live engine every request runs against.
|
|
346
|
+
* @param options - Address, CORS, request limits, the authentication hook, and
|
|
347
|
+
* the task store. Omit it to bind to loopback with the default limits.
|
|
348
|
+
* @returns The server, ready for {@link NarsilServer.listen}.
|
|
349
|
+
*
|
|
350
|
+
* @public
|
|
187
351
|
*/
|
|
188
352
|
declare function createServer(engine: Narsil, options?: ServerOptions): NarsilServer;
|
|
189
353
|
|
|
190
354
|
/** HTTP-layer error codes for failures that arise before or around the engine
|
|
191
355
|
* call (parsing, limits, routing). Engine failures carry their own
|
|
192
|
-
* {@link NarsilError} codes, mapped by {@link httpStatusForNarsilError}.
|
|
356
|
+
* {@link NarsilError} codes, mapped by {@link httpStatusForNarsilError}.
|
|
357
|
+
*
|
|
358
|
+
* @public */
|
|
193
359
|
declare const ServerErrorCodes: {
|
|
194
360
|
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
195
361
|
readonly INVALID_JSON: "INVALID_JSON";
|
|
@@ -204,7 +370,12 @@ declare const ServerErrorCodes: {
|
|
|
204
370
|
readonly REQUEST_ABORTED: "REQUEST_ABORTED";
|
|
205
371
|
};
|
|
206
372
|
/** Maps a {@link NarsilError} code to an HTTP status. Unknown or cluster-only
|
|
207
|
-
* codes fall through to 500 so an internal fault never leaks as a client error.
|
|
373
|
+
* codes fall through to 500 so an internal fault never leaks as a client error.
|
|
374
|
+
*
|
|
375
|
+
* @param code - The code a {@link NarsilError} carried.
|
|
376
|
+
* @returns The status the server answers with.
|
|
377
|
+
*
|
|
378
|
+
* @public */
|
|
208
379
|
declare function httpStatusForNarsilError(code: string): number;
|
|
209
380
|
|
|
210
381
|
/**
|
|
@@ -213,14 +384,44 @@ declare function httpStatusForNarsilError(code: string): number;
|
|
|
213
384
|
* terminal records first, so a long-lived server cannot accumulate task state
|
|
214
385
|
* without bound. `ttlMs` is ignored here; the cap plays that role. Records are
|
|
215
386
|
* copied in and out so a caller cannot mutate stored state by reference.
|
|
387
|
+
*
|
|
388
|
+
* @public
|
|
216
389
|
*/
|
|
217
390
|
declare class InMemoryTaskStore implements TaskStore {
|
|
218
391
|
private readonly maxRetained;
|
|
219
392
|
private readonly records;
|
|
393
|
+
/**
|
|
394
|
+
* Builds a store that keeps task records in this process alone.
|
|
395
|
+
*
|
|
396
|
+
* @param maxRetained - Records to keep before the oldest finished ones are
|
|
397
|
+
* dropped. Defaults to 1000.
|
|
398
|
+
*/
|
|
220
399
|
constructor(maxRetained?: number);
|
|
400
|
+
/**
|
|
401
|
+
* Stores a record, replacing whatever its id already held.
|
|
402
|
+
*
|
|
403
|
+
* @param record - The record to store. A copy is kept, so changing the
|
|
404
|
+
* object afterwards leaves the store untouched.
|
|
405
|
+
*/
|
|
221
406
|
set(record: TaskRecord): Promise<void>;
|
|
407
|
+
/**
|
|
408
|
+
* Reads one record back.
|
|
409
|
+
*
|
|
410
|
+
* @param id - The task to read.
|
|
411
|
+
* @returns A copy of the record, or `null` when the store holds no such id.
|
|
412
|
+
*/
|
|
222
413
|
get(id: string): Promise<TaskRecord | null>;
|
|
414
|
+
/**
|
|
415
|
+
* Lists every record the store holds.
|
|
416
|
+
*
|
|
417
|
+
* @returns A copy of each record, oldest first.
|
|
418
|
+
*/
|
|
223
419
|
list(): Promise<TaskRecord[]>;
|
|
420
|
+
/**
|
|
421
|
+
* Removes one record. An id the store never held is not an error.
|
|
422
|
+
*
|
|
423
|
+
* @param id - The task to remove.
|
|
424
|
+
*/
|
|
224
425
|
delete(id: string): Promise<void>;
|
|
225
426
|
private prune;
|
|
226
427
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
1
|
+
import { NarsilError, ErrorCodes } from './chunk-UNJZ7ZDB.mjs';
|
|
2
2
|
import { randomUUID } from 'crypto';
|
|
3
3
|
|
|
4
4
|
// src/server/cors.ts
|
|
@@ -1015,21 +1015,49 @@ async function loadUWebSockets() {
|
|
|
1015
1015
|
// src/server/task-store.ts
|
|
1016
1016
|
var DEFAULT_MAX_RETAINED = 1e3;
|
|
1017
1017
|
var InMemoryTaskStore = class {
|
|
1018
|
+
/**
|
|
1019
|
+
* Builds a store that keeps task records in this process alone.
|
|
1020
|
+
*
|
|
1021
|
+
* @param maxRetained - Records to keep before the oldest finished ones are
|
|
1022
|
+
* dropped. Defaults to 1000.
|
|
1023
|
+
*/
|
|
1018
1024
|
constructor(maxRetained = DEFAULT_MAX_RETAINED) {
|
|
1019
1025
|
this.maxRetained = maxRetained;
|
|
1020
1026
|
}
|
|
1021
1027
|
records = /* @__PURE__ */ new Map();
|
|
1028
|
+
/**
|
|
1029
|
+
* Stores a record, replacing whatever its id already held.
|
|
1030
|
+
*
|
|
1031
|
+
* @param record - The record to store. A copy is kept, so changing the
|
|
1032
|
+
* object afterwards leaves the store untouched.
|
|
1033
|
+
*/
|
|
1022
1034
|
async set(record) {
|
|
1023
1035
|
this.records.set(record.id, { ...record });
|
|
1024
1036
|
this.prune();
|
|
1025
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Reads one record back.
|
|
1040
|
+
*
|
|
1041
|
+
* @param id - The task to read.
|
|
1042
|
+
* @returns A copy of the record, or `null` when the store holds no such id.
|
|
1043
|
+
*/
|
|
1026
1044
|
async get(id) {
|
|
1027
1045
|
const record = this.records.get(id);
|
|
1028
1046
|
return record ? { ...record } : null;
|
|
1029
1047
|
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Lists every record the store holds.
|
|
1050
|
+
*
|
|
1051
|
+
* @returns A copy of each record, oldest first.
|
|
1052
|
+
*/
|
|
1030
1053
|
async list() {
|
|
1031
1054
|
return [...this.records.values()].map((record) => ({ ...record }));
|
|
1032
1055
|
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Removes one record. An id the store never held is not an error.
|
|
1058
|
+
*
|
|
1059
|
+
* @param id - The task to remove.
|
|
1060
|
+
*/
|
|
1033
1061
|
async delete(id) {
|
|
1034
1062
|
this.records.delete(id);
|
|
1035
1063
|
}
|