@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
package/dist/server.d.ts
CHANGED
|
@@ -1,340 +1,11 @@
|
|
|
1
|
-
import { N as
|
|
2
|
-
|
|
3
|
-
import './
|
|
4
|
-
import './
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* decoded from the socket; behind a proxy it is the proxy's address, so trust
|
|
10
|
-
* forwarded headers only when the proxy is trusted.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
interface RequestContext {
|
|
15
|
-
/** The request used this HTTP method, in upper case. */
|
|
16
|
-
method: string;
|
|
17
|
-
/** The request asked for this path, without the query string. */
|
|
18
|
-
path: string;
|
|
19
|
-
/** These are the request headers, keyed by lower-case name. */
|
|
20
|
-
headers: Record<string, string>;
|
|
21
|
-
/** The server decoded this peer address from the socket. */
|
|
22
|
-
remoteAddress: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Returned by an {@link OnRequestHook} to reject a request. The `status` is sent
|
|
26
|
-
* verbatim as the HTTP status; `code` and `message` populate the error envelope.
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
interface RequestDenial {
|
|
31
|
-
/** The server answers with this status. */
|
|
32
|
-
status: number;
|
|
33
|
-
/** The error envelope carries this machine-readable code. */
|
|
34
|
-
code: string;
|
|
35
|
-
/** The error envelope carries this description. */
|
|
36
|
-
message: string;
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
57
|
-
interface CorsOptions {
|
|
58
|
-
/** The server allows these origins, given as one origin or a list. */
|
|
59
|
-
origin?: string | string[];
|
|
60
|
-
/** The server allows these methods on a cross-origin request. */
|
|
61
|
-
methods?: string[];
|
|
62
|
-
/** A browser may send these request headers cross-origin. */
|
|
63
|
-
headers?: string[];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Byte and batch ceilings the server enforces before handing work to the
|
|
67
|
-
* engine. Every field has a safe default; override only to fit a deployment.
|
|
68
|
-
*
|
|
69
|
-
* @public
|
|
70
|
-
*/
|
|
71
|
-
interface ServerLimits {
|
|
72
|
-
/** Cap for JSON request bodies (single doc, batch, search). Excess → 413. */
|
|
73
|
-
maxBodyBytes?: number;
|
|
74
|
-
/** Cap for the NDJSON import stream and binary restore body. Excess → 413. */
|
|
75
|
-
maxImportBytes?: number;
|
|
76
|
-
/** Cap for a single NDJSON line, so one unterminated line cannot exhaust memory. Excess → 413. */
|
|
77
|
-
maxLineBytes?: number;
|
|
78
|
-
/** Documents handed to the engine per batch during NDJSON import; the loop yields between batches. */
|
|
79
|
-
importBatchSize?: number;
|
|
80
|
-
/** Maximum requests executing engine work at once; excess is shed with 503. Omit or 0 to disable. */
|
|
81
|
-
maxConcurrentRequests?: number;
|
|
82
|
-
/** Ceiling for a search's `limit`, `offset`, and `group.maxPerGroup`, so one
|
|
83
|
-
* request cannot ask for an unbounded result set. Excess → 400. Defaults to
|
|
84
|
-
* 10000, matching the cluster query result window. */
|
|
85
|
-
maxResultWindow?: number;
|
|
86
|
-
/** Ceiling for the number of document ids in one multi-get request, so one
|
|
87
|
-
* request cannot pull an unbounded number of documents. Excess → 400.
|
|
88
|
-
* Defaults to 10000. */
|
|
89
|
-
maxFetchDocuments?: number;
|
|
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
|
-
*/
|
|
99
|
-
interface ServerOptions {
|
|
100
|
-
/** The server binds to this address, and to loopback by default. Any other address needs an authentication hook. */
|
|
101
|
-
host?: string;
|
|
102
|
-
/** The server binds to this port. Pass 0 to let the operating system choose one, then read {@link NarsilServer.listeningPort}. */
|
|
103
|
-
port?: number;
|
|
104
|
-
/** These settings control which cross-origin requests the server accepts, and `true` accepts any origin. */
|
|
105
|
-
cors?: boolean | CorsOptions;
|
|
106
|
-
/** Authentication or admission gate run before every routed request. */
|
|
107
|
-
onRequest?: OnRequestHook;
|
|
108
|
-
/**
|
|
109
|
-
* Build identity reported verbatim at `/version`: the package version and the
|
|
110
|
-
* git commit the server was built from, with a dirty-tree flag. Supply it from
|
|
111
|
-
* the build (a stamped env var or build arg); omit it and `/version` reports
|
|
112
|
-
* nulls. The values are descriptive only and never gate a request.
|
|
113
|
-
*/
|
|
114
|
-
build?: {
|
|
115
|
-
version?: string;
|
|
116
|
-
gitSha?: string;
|
|
117
|
-
dirty?: boolean;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Named embedding adapters a JSON `createIndex` request can reference by name.
|
|
121
|
-
* Embedding adapters are functions and cannot cross JSON, so an index that
|
|
122
|
-
* needs query-time or ingest-time embedding names a server-registered adapter.
|
|
123
|
-
*/
|
|
124
|
-
embeddingAdapters?: Record<string, EmbeddingAdapter>;
|
|
125
|
-
/** These ceilings apply before the server hands any work to the engine. */
|
|
126
|
-
limits?: ServerLimits;
|
|
127
|
-
/**
|
|
128
|
-
* Backing store for long-running task records. Defaults to an in-memory store
|
|
129
|
-
* that is lost on restart and not shared across instances. Supply any store
|
|
130
|
-
* that satisfies {@link TaskStore} (Redis, Upstash over HTTP, DynamoDB, a
|
|
131
|
-
* database) to survive restarts and share task status across instances.
|
|
132
|
-
*/
|
|
133
|
-
taskStore?: TaskStore;
|
|
134
|
-
/**
|
|
135
|
-
* Stable identifier for this server instance, stamped on every task it owns.
|
|
136
|
-
* Supply a stable value (a pod or container name) so that after a restart the
|
|
137
|
-
* instance can mark its own previously-running tasks as failed instead of
|
|
138
|
-
* leaving them stuck. Defaults to a random id, which disables that recovery.
|
|
139
|
-
*/
|
|
140
|
-
instanceId?: string;
|
|
141
|
-
/**
|
|
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.
|
|
147
|
-
*/
|
|
148
|
-
allowInsecure?: boolean;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Pluggable backing store for task records. Every method is async so any
|
|
152
|
-
* backend works: an in-memory map, Redis, an HTTP key-value service, or a
|
|
153
|
-
* database. `set` upserts by `record.id`; `get` returns null for an unknown id.
|
|
154
|
-
* `ttlMs`, when honored by the backend, expires the record so terminal tasks do
|
|
155
|
-
* not accumulate. The server never calls a method that mutates a record it did
|
|
156
|
-
* not construct, so a backend may treat records as immutable snapshots.
|
|
157
|
-
*
|
|
158
|
-
* @public
|
|
159
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
188
|
-
delete(id: string): Promise<void>;
|
|
189
|
-
/** Releases whatever the backend holds open, such as a connection pool. */
|
|
190
|
-
shutdown?(): Promise<void>;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* The running HTTP server, as {@link createServer} returns it.
|
|
194
|
-
*
|
|
195
|
-
* @public
|
|
196
|
-
*/
|
|
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
|
-
*/
|
|
204
|
-
listen(): Promise<void>;
|
|
205
|
-
/** Closes the socket and ends the server. The engine keeps running. */
|
|
206
|
-
close(): Promise<void>;
|
|
207
|
-
/** The server bound to this port, which is what you read after binding to port 0. */
|
|
208
|
-
readonly listeningPort: number;
|
|
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
|
-
*/
|
|
216
|
-
interface ErrorEnvelope {
|
|
217
|
-
/** This describes the failure. */
|
|
218
|
-
error: {
|
|
219
|
-
/** This code comes from either {@link ServerErrorCodes} or {@link ErrorCodes}. */
|
|
220
|
-
code: string;
|
|
221
|
-
/** This describes the failure, for a log or a person. */
|
|
222
|
-
message: string;
|
|
223
|
-
/** These values are behind the failure, such as the field or limit involved. */
|
|
224
|
-
details?: Record<string, unknown>;
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Which long-running operation a task record tracks.
|
|
229
|
-
*
|
|
230
|
-
* @public
|
|
231
|
-
*/
|
|
232
|
-
type TaskType = 'optimizeVectors' | 'rebalance' | 'restore';
|
|
233
|
-
/**
|
|
234
|
-
* Where a long-running operation stands.
|
|
235
|
-
*
|
|
236
|
-
* @public
|
|
237
|
-
*/
|
|
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
|
-
*/
|
|
245
|
-
interface TaskRecord {
|
|
246
|
-
/** This identifies the task, and is what you poll by. */
|
|
247
|
-
id: string;
|
|
248
|
-
/** This says which operation the task runs. */
|
|
249
|
-
type: TaskType;
|
|
250
|
-
/** The operation runs against this index. */
|
|
251
|
-
indexName: string;
|
|
252
|
-
/** This says where the operation stands. */
|
|
253
|
-
status: TaskStatus;
|
|
254
|
-
/** Identifier of the server instance running this task; see ServerOptions.instanceId. */
|
|
255
|
-
owner: string;
|
|
256
|
-
/** The server accepted the task at this many milliseconds since the epoch. */
|
|
257
|
-
createdAt: number;
|
|
258
|
-
/** Work started at this many milliseconds since the epoch, and a queued task omits it. */
|
|
259
|
-
startedAt?: number;
|
|
260
|
-
/** Work ended at this many milliseconds since the epoch, and a task omits it until it succeeds or fails. */
|
|
261
|
-
completedAt?: number;
|
|
262
|
-
/** This says why the task failed, and a failed task alone carries it. */
|
|
263
|
-
error?: {
|
|
264
|
-
code: string;
|
|
265
|
-
message: string;
|
|
266
|
-
details?: Record<string, unknown>;
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
/** Declarative index configuration accepted over HTTP. Function-valued engine
|
|
270
|
-
* options (custom tokenizer, stopWords-as-function, group reducer, embedding
|
|
271
|
-
* adapter object) are not representable here; the embedding adapter is named
|
|
272
|
-
* instead via {@link CreateIndexEmbedding}.
|
|
273
|
-
*
|
|
274
|
-
* @public */
|
|
275
|
-
interface CreateIndexRequest {
|
|
276
|
-
/** The server creates the index under this name. */
|
|
277
|
-
name: string;
|
|
278
|
-
/** This carries the schema and settings, in the subset JSON can express. */
|
|
279
|
-
config: HttpIndexConfig;
|
|
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
|
-
*/
|
|
289
|
-
interface CreateIndexEmbedding {
|
|
290
|
-
/** This names an adapter the server registered under `embeddingAdapters`. */
|
|
291
|
-
adapter?: string;
|
|
292
|
-
/** This maps each vector field to the text field, or fields, the server embeds into it. */
|
|
293
|
-
fields: Record<string, string | string[]>;
|
|
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
|
-
*/
|
|
305
|
-
interface HttpIndexConfig {
|
|
306
|
-
/** This layout gives each value as either a field type or a nested schema. */
|
|
307
|
-
schema: Record<string, unknown>;
|
|
308
|
-
/** The server tokenises and stems text fields with the language module registered under this name. */
|
|
309
|
-
language?: string;
|
|
310
|
-
/** These settings control how the index splits documents across partitions as it grows. */
|
|
311
|
-
partitions?: {
|
|
312
|
-
maxDocsPerPartition?: number;
|
|
313
|
-
maxPartitions?: number;
|
|
314
|
-
watermark?: number;
|
|
315
|
-
};
|
|
316
|
-
/** A query scores this way unless it asks for another mode. */
|
|
317
|
-
defaultScoring?: 'local' | 'dfs' | 'broadcast';
|
|
318
|
-
/** These parameters tune BM25 for this index. */
|
|
319
|
-
bm25?: {
|
|
320
|
-
k1?: number;
|
|
321
|
-
b?: number;
|
|
322
|
-
};
|
|
323
|
-
/** This list replaces the language's stop words. */
|
|
324
|
-
stopWords?: string[];
|
|
325
|
-
/** Setting this records term positions, which phrase queries and highlighting need. */
|
|
326
|
-
trackPositions?: boolean;
|
|
327
|
-
/** Setting this returns the words users typed from suggestions and prefix expansion, instead of index stems. */
|
|
328
|
-
surfaceForms?: boolean;
|
|
329
|
-
/** These settings control when vector fields move to an HNSW graph, and how that graph is built. */
|
|
330
|
-
vectorPromotion?: Record<string, unknown>;
|
|
331
|
-
/** Setting this rejects a document carrying a field the schema does not declare. */
|
|
332
|
-
strict?: boolean;
|
|
333
|
-
/** This names a server-registered embedding adapter and the fields it embeds. */
|
|
334
|
-
embedding?: CreateIndexEmbedding;
|
|
335
|
-
/** The server rejects a document that omits any of these fields. */
|
|
336
|
-
required?: string[];
|
|
337
|
-
}
|
|
1
|
+
import { b as ServerOptions, N as NarsilServer } from './options-BORJg5XB.js';
|
|
2
|
+
export { A as ASYNC_IMPORT_CAPABILITY, C as CorsOptions, E as ErrorEnvelope, O as OnRequestHook, R as REBUILD_ANALYSIS_CAPABILITY, c as RequestContext, d as RequestDenial, S as SERVER_CAPABILITIES, e as ServerLimits, T as TASK_CANCEL_CAPABILITY, a as TASK_FILTER_CAPABILITY } from './options-BORJg5XB.js';
|
|
3
|
+
import { N as Narsil } from './engine-DScGlT2Z.js';
|
|
4
|
+
import { h as TaskStore, e as TaskRecord, d as TaskProgress, b as ImportResult } from './tasks-CnMLpfk-.js';
|
|
5
|
+
export { C as CapabilitiesResponse, a as CreateIndexEmbedding, i as CreateIndexRequest, H as HttpIndexConfig, I as ImportError, T as TaskListPage, c as TaskListQuery, f as TaskStatus, g as TaskType } from './tasks-CnMLpfk-.js';
|
|
6
|
+
export { d as ServerErrorCodes } from './search-CQ-9bKxo.js';
|
|
7
|
+
import './adapters-79OIa4xm.js';
|
|
8
|
+
import './schema-emTQfEiX.js';
|
|
338
9
|
|
|
339
10
|
/**
|
|
340
11
|
* Wraps a Narsil engine in an HTTP server. The caller builds and owns the engine
|
|
@@ -351,24 +22,6 @@ interface HttpIndexConfig {
|
|
|
351
22
|
*/
|
|
352
23
|
declare function createServer(engine: Narsil, options?: ServerOptions): NarsilServer;
|
|
353
24
|
|
|
354
|
-
/** HTTP-layer error codes for failures that arise before or around the engine
|
|
355
|
-
* call (parsing, limits, routing). Engine failures carry their own
|
|
356
|
-
* {@link NarsilError} codes, mapped by {@link httpStatusForNarsilError}.
|
|
357
|
-
*
|
|
358
|
-
* @public */
|
|
359
|
-
declare const ServerErrorCodes: {
|
|
360
|
-
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
361
|
-
readonly INVALID_JSON: "INVALID_JSON";
|
|
362
|
-
readonly EMPTY_BODY: "EMPTY_BODY";
|
|
363
|
-
readonly PAYLOAD_TOO_LARGE: "PAYLOAD_TOO_LARGE";
|
|
364
|
-
readonly UNSUPPORTED_MEDIA_TYPE: "UNSUPPORTED_MEDIA_TYPE";
|
|
365
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
366
|
-
readonly TASK_NOT_FOUND: "TASK_NOT_FOUND";
|
|
367
|
-
readonly TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS";
|
|
368
|
-
readonly HOOK_ERROR: "HOOK_ERROR";
|
|
369
|
-
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
370
|
-
readonly REQUEST_ABORTED: "REQUEST_ABORTED";
|
|
371
|
-
};
|
|
372
25
|
/** Maps a {@link NarsilError} code to an HTTP status. Unknown or cluster-only
|
|
373
26
|
* codes fall through to 500 so an internal fault never leaks as a client error.
|
|
374
27
|
*
|
|
@@ -426,4 +79,37 @@ declare class InMemoryTaskStore implements TaskStore {
|
|
|
426
79
|
private prune;
|
|
427
80
|
}
|
|
428
81
|
|
|
429
|
-
|
|
82
|
+
/**
|
|
83
|
+
* What a running task reports back while it works, and how it learns that a
|
|
84
|
+
* cancel arrived.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
interface TaskContext {
|
|
89
|
+
/** Aborts once a cancel arrives, so long-running work can stop between units. */
|
|
90
|
+
readonly signal: AbortSignal;
|
|
91
|
+
/**
|
|
92
|
+
* Records how far the work has gone, which `GET /tasks/{id}` then reports.
|
|
93
|
+
*
|
|
94
|
+
* @param progress - The counters as they stand now.
|
|
95
|
+
*/
|
|
96
|
+
reportProgress(progress: TaskProgress): void;
|
|
97
|
+
/**
|
|
98
|
+
* Records what the work produced, which the finished task then carries.
|
|
99
|
+
*
|
|
100
|
+
* @param result - What the work produced.
|
|
101
|
+
*/
|
|
102
|
+
reportResult(result: ImportResult): void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The work one task runs.
|
|
106
|
+
*
|
|
107
|
+
* Resolving marks the task succeeded. Rejecting marks it failed, unless a
|
|
108
|
+
* cancel had already arrived, which marks it cancelled instead. Work that
|
|
109
|
+
* cannot stop early ignores the signal and still finishes.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
type TaskOperation = (ctx: TaskContext) => Promise<void>;
|
|
114
|
+
|
|
115
|
+
export { ImportResult, InMemoryTaskStore, NarsilServer, ServerOptions, type TaskContext, type TaskOperation, TaskProgress, TaskRecord, TaskStore, createServer, httpStatusForNarsilError };
|