@delali/narsil 0.2.4-next.48 → 0.2.4-next.50

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 (60) hide show
  1. package/README.md +2 -2
  2. package/dist/adapters/indexeddb.mjs +15 -10
  3. package/dist/{options-BC68VPoE.d.ts → capabilities-JrVQOwi4.d.ts} +55 -47
  4. package/dist/{chunk-BFIH7OV5.mjs → chunk-2GWVQWGA.mjs} +3 -1
  5. package/dist/chunk-AV4IJKD2.mjs +35 -0
  6. package/dist/{chunk-EV45L35L.mjs → chunk-BEIK3EOZ.mjs} +845 -2407
  7. package/dist/chunk-CBLS46IE.mjs +10 -0
  8. package/dist/chunk-CMVG2UEF.mjs +2038 -0
  9. package/dist/chunk-CV5H7XL7.mjs +876 -0
  10. package/dist/{chunk-JQUL2T6I.mjs → chunk-GCM3JFVA.mjs} +1 -2
  11. package/dist/{chunk-XWICBGYT.mjs → chunk-MHE7YWAU.mjs} +3 -5
  12. package/dist/{chunk-UZTT2BKQ.mjs → chunk-ND34I3SV.mjs} +1202 -1881
  13. package/dist/{chunk-PM52SMBT.mjs → chunk-OOSIDHA3.mjs} +2 -1
  14. package/dist/chunk-ORBLD3EL.mjs +6 -0
  15. package/dist/chunk-PIWKZPP7.mjs +64 -0
  16. package/dist/{chunk-4COAUBLJ.mjs → chunk-PMBHH44R.mjs} +124 -8
  17. package/dist/chunk-RP23PWMV.mjs +11 -0
  18. package/dist/chunk-UNEEFTEU.mjs +7 -0
  19. package/dist/{chunk-WTONLDU3.mjs → chunk-WYJXSLER.mjs} +9 -19
  20. package/dist/{chunk-DFZDV5FV.mjs → chunk-X6YZO4MQ.mjs} +19 -15
  21. package/dist/chunk-XE6XR2OE.mjs +23 -0
  22. package/dist/chunk-YEO6G2NG.mjs +6 -0
  23. package/dist/chunk-ZHUQKZBE.mjs +1292 -0
  24. package/dist/{client-C5BkUqB8.d.ts → client-CBOVHdjp.d.ts} +31 -7
  25. package/dist/client.d.ts +7 -7
  26. package/dist/client.mjs +250 -232
  27. package/dist/{config-B-ZI-ft5.d.ts → config-Czh2YNDi.d.ts} +2 -2
  28. package/dist/{config-BZRExglL.d.ts → config-OON7IJ_B.d.ts} +50 -13
  29. package/dist/direct-executor-OREXU72C.mjs +12 -0
  30. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  31. package/dist/distribution/coordinator/etcd.mjs +2 -3
  32. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  33. package/dist/distribution/coordinator/in-memory.mjs +2 -2
  34. package/dist/distribution/transport/grpc.mjs +7 -9
  35. package/dist/distribution/transport/in-memory.mjs +2 -1
  36. package/dist/distribution/transport/tcp.mjs +3 -2
  37. package/dist/distribution.d.ts +8 -8
  38. package/dist/distribution.mjs +142 -101
  39. package/dist/embeddings/openai.mjs +5 -3
  40. package/dist/{engine-Cjr1uBLa.d.ts → engine-9PtFY50q.d.ts} +125 -69
  41. package/dist/index.browser.mjs +4689 -3330
  42. package/dist/index.d.ts +7 -7
  43. package/dist/index.mjs +14 -8
  44. package/dist/invalidation/broadcast-channel.mjs +2 -1
  45. package/dist/invalidation/filesystem.mjs +3 -4
  46. package/dist/{search-DDHjfXhJ.d.ts → memory-Bzd5xcEW.d.ts} +89 -63
  47. package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
  48. package/dist/persistence/durability/checkpoint-worker.mjs +14 -8
  49. package/dist/react.d.ts +4 -4
  50. package/dist/react.mjs +7 -5
  51. package/dist/{schema-B7juWg8Q.d.ts → schema-BqRx9t4E.d.ts} +22 -3
  52. package/dist/server.d.ts +47 -42
  53. package/dist/server.mjs +338 -821
  54. package/dist/thread-PZLEO6JL.mjs +310 -0
  55. package/dist/{types-DsSSjY4d.d.ts → types-DXPxaXPO.d.ts} +1 -1
  56. package/dist/vector/hnsw-build-worker.mjs +3 -4
  57. package/dist/vector/search-worker.mjs +4 -123
  58. package/dist/workers/entry.mjs +47 -3
  59. package/package.json +5 -1
  60. package/dist/direct-executor-EOTFGXTO.mjs +0 -8
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { c as StopWordOverride, C as CustomTokenizer } from './schema-B7juWg8Q.js';
2
- export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, b as InsertOptions, P as PartitionConfig, S as SchemaDefinition, a as ScoringMode, V as VectorIndexConfig, d as VectorQuantizationMode } from './schema-B7juWg8Q.js';
1
+ import { c as StopWordOverride, C as CustomTokenizer } from './schema-BqRx9t4E.js';
2
+ export { A as AnyDocument, B as BM25Params, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, b as InsertOptions, P as PartitionConfig, S as SchemaDefinition, a as ScoringMode, V as VectorIndexConfig, d as VectorQuantizationMode, W as WriteOptions } from './schema-BqRx9t4E.js';
3
3
  import { L as LanguageModule } from './language-DB8KG1z5.js';
4
4
  export { T as TokenizerConfig } from './language-DB8KG1z5.js';
5
- export { A as ArrayFilter, B as BatchResult, C as ClientErrorCode, a as ClientErrorCodes, k as ComparisonFilter, D as DocumentProjection, E as ErrorCode, b as ErrorCodes, F as FacetConfig, l as FacetResult, m as FieldFilter, n as FilterExpression, G as GeoFilter, o as GeoPolygonFilter, p as GeoRadiusFilter, q as GroupConfig, r as GroupReducer, s as GroupResult, H as HighlightConfig, t as HighlightMatch, u as Hit, v as HybridConfig, I as IndexInfo, f as IndexStats, L as ListParams, g as ListResult, w as ListedDocument, M as MemoryStats, N as NarsilError, c as NarsilErrorCode, P as PartitionStatsResult, h as PreflightResult, x as PresenceFilter, y as ProcessMemoryReport, z as QueryCoverage, Q as QueryParams, e as QueryResult, J as ScoreComponents, K as SearchMode, S as ServerErrorCode, d as ServerErrorCodes, O as SortField, R as SortSpec, T as StringFilter, i as SuggestParams, j as SuggestResult, U as TermMatchPolicy, V as VectorMaintenanceResult, W as VectorQueryConfig } from './search-DDHjfXhJ.js';
6
- import { N as NarsilConfig } from './config-BZRExglL.js';
7
- export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as IndexLifecycleConfig, b as InsertContext, c as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, d as StaleAnalysis, U as UpdateContext, W as WorkerConfig, e as WorkerContext } from './config-BZRExglL.js';
8
- import { a as Narsil } from './engine-Cjr1uBLa.js';
9
- export { I as IndexLifecycleOperations, N as NarsilEventMap } from './engine-Cjr1uBLa.js';
5
+ export { A as ArrayFilter, B as BatchResult, C as ClientErrorCode, a as ClientErrorCodes, k as ComparisonFilter, D as DocumentProjection, E as ErrorCode, b as ErrorCodes, F as FacetConfig, l as FacetResult, m as FieldFilter, n as FilterExpression, G as GeoFilter, o as GeoPolygonFilter, p as GeoRadiusFilter, q as GroupConfig, r as GroupReducer, s as GroupResult, H as HighlightConfig, t as HighlightMatch, u as Hit, v as HybridConfig, I as IndexInfo, f as IndexStats, L as ListParams, g as ListResult, w as ListedDocument, M as MemoryStats, N as NarsilError, c as NarsilErrorCode, P as PartitionStatsResult, h as PreflightResult, x as PresenceFilter, y as ProcessMemoryReport, z as QueryCoverage, Q as QueryParams, e as QueryResult, J as ScoreComponents, K as SearchMode, S as ServerErrorCode, d as ServerErrorCodes, O as SortField, R as SortSpec, T as StringFilter, i as SuggestParams, j as SuggestResult, U as TermMatchPolicy, V as VectorMaintenanceResult, W as VectorQueryConfig, X as WorkerCopyReport } from './memory-Bzd5xcEW.js';
6
+ import { N as NarsilConfig } from './config-OON7IJ_B.js';
7
+ export { A as AnalysisConfig, D as DurabilityConfig, I as IndexContext, a as IndexLifecycleConfig, b as InsertContext, M as MainCopyQueries, c as NarsilPlugin, P as PartitionContext, R as RemoveContext, S as SearchContext, d as StaleAnalysis, U as UpdateContext, W as WorkerConfig, e as WorkerContext } from './config-OON7IJ_B.js';
8
+ import { a as Narsil } from './engine-9PtFY50q.js';
9
+ export { D as DocumentWriteOperations, I as IndexLifecycleOperations, N as NarsilEventMap } from './engine-9PtFY50q.js';
10
10
  export { E as EmbeddingAdapter, I as InvalidationAdapter, a as InvalidationEvent, b as PartitionStatistics, P as PersistenceAdapter } from './adapters-79OIa4xm.js';
11
11
 
12
12
  /**
package/dist/index.mjs CHANGED
@@ -1,12 +1,18 @@
1
- export { VERSION, createNarsil } from './chunk-UZTT2BKQ.mjs';
2
- import './chunk-JQUL2T6I.mjs';
3
- import './chunk-XWICBGYT.mjs';
4
- export { clearNormalizationCache, configureNormalizationCache, getLanguage, getNormalizationCacheSize, getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerLanguage, registerStopWords, registerTokenizer, resetNormalizationCache } from './chunk-EV45L35L.mjs';
1
+ export { VERSION, createNarsil } from './chunk-ND34I3SV.mjs';
2
+ import './chunk-ZHUQKZBE.mjs';
3
+ import './chunk-GCM3JFVA.mjs';
4
+ import './chunk-PIWKZPP7.mjs';
5
+ import './chunk-XE6XR2OE.mjs';
6
+ export { getLanguage, getStopWords, getTokenizer, hasStopWords, hasTokenizer, registerLanguage, registerStopWords, registerTokenizer } from './chunk-BEIK3EOZ.mjs';
7
+ export { clearNormalizationCache, configureNormalizationCache, getNormalizationCacheSize, resetNormalizationCache } from './chunk-CMVG2UEF.mjs';
8
+ import './chunk-AV4IJKD2.mjs';
9
+ import './chunk-CBLS46IE.mjs';
5
10
  import './chunk-TGP5M5R7.mjs';
6
- import './chunk-4COAUBLJ.mjs';
7
- export { isSimdAvailable } from './chunk-DFZDV5FV.mjs';
11
+ import './chunk-PMBHH44R.mjs';
12
+ export { isSimdAvailable } from './chunk-X6YZO4MQ.mjs';
13
+ import './chunk-RP23PWMV.mjs';
8
14
  import './chunk-KMMJMDUA.mjs';
9
15
  import './chunk-U2BKYEC7.mjs';
10
- import './chunk-BFIH7OV5.mjs';
11
- import './chunk-WTONLDU3.mjs';
16
+ import './chunk-2GWVQWGA.mjs';
17
+ import './chunk-WYJXSLER.mjs';
12
18
  export { ClientErrorCodes, ErrorCodes, NarsilError, ServerErrorCodes } from './chunk-P4ELXVJQ.mjs';
@@ -1,5 +1,6 @@
1
+ import { DEFAULT_CHANNEL_NAME } from '../chunk-YEO6G2NG.mjs';
2
+
1
3
  // src/invalidation/broadcast-channel.ts
2
- var DEFAULT_CHANNEL_NAME = "narsil-invalidation";
3
4
  function isInvalidationEvent(data) {
4
5
  if (typeof data !== "object" || data === null) {
5
6
  return false;
@@ -1,8 +1,7 @@
1
- import { compareCodePoints } from '../chunk-BFIH7OV5.mjs';
1
+ import { compareCodePoints } from '../chunk-2GWVQWGA.mjs';
2
+ import { DEFAULT_POLL_INTERVAL_MS, MARKER_MAX_AGE_MS } from '../chunk-YEO6G2NG.mjs';
2
3
 
3
4
  // src/invalidation/filesystem.ts
4
- var MARKER_MAX_AGE_MS = 6e4;
5
- var DEFAULT_POLL_INTERVAL = 1e3;
6
5
  function generateInstanceId() {
7
6
  if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
8
7
  return globalThis.crypto.randomUUID();
@@ -28,7 +27,7 @@ function createFilesystemInvalidation(config) {
28
27
  throw new Error(`Invalid directory path: path traversal detected in "${config.directory}"`);
29
28
  }
30
29
  const directory = config.directory;
31
- const pollInterval = config.pollInterval ?? DEFAULT_POLL_INTERVAL;
30
+ const pollInterval = config.pollInterval ?? DEFAULT_POLL_INTERVAL_MS;
32
31
  const instanceId = config.instanceId ?? generateInstanceId();
33
32
  if (instanceId.includes("/") || instanceId.includes("\\") || instanceId.includes("..") || instanceId.includes("\0")) {
34
33
  throw new Error(`Invalid instanceId: "${instanceId}" contains path separator or traversal characters`);
@@ -1,4 +1,4 @@
1
- import { A as AnyDocument, S as SchemaDefinition, a as ScoringMode } from './schema-B7juWg8Q.js';
1
+ import { A as AnyDocument, S as SchemaDefinition, a as ScoringMode } from './schema-BqRx9t4E.js';
2
2
 
3
3
  /**
4
4
  * Every code a {@link NarsilError} carries, grouped by the part of the engine
@@ -450,66 +450,6 @@ interface SuggestResult {
450
450
  /** This turns true when the index's terms came from an older analysis than its language module produces now. */
451
451
  analysisStale?: boolean;
452
452
  }
453
- /**
454
- * Snapshot of V8 heap usage as reported by `process.memoryUsage()`. All values
455
- * are bytes. `null` in environments that do not expose `process.memoryUsage`,
456
- * such as browsers.
457
- *
458
- * @public
459
- */
460
- interface ProcessMemoryReport {
461
- /** The process is using this much heap. */
462
- heapUsed: number;
463
- /** V8 has reserved this much heap. */
464
- heapTotal: number;
465
- /** The process holds this much outside the heap, such as buffers. */
466
- external: number;
467
- /** The process occupies this much physical memory in total. */
468
- rss: number;
469
- }
470
- /**
471
- * What {@link Narsil.getMemoryStats} returns, which is what you size a host
472
- * from.
473
- *
474
- * @public
475
- */
476
- interface MemoryStats {
477
- /**
478
- * V8 heap usage for the host process at the moment the call was made. This
479
- * is process-wide, not engine-wide; if multiple Narsil engines are running
480
- * in the same process every engine's `getMemoryStats` returns the same
481
- * `process` figures. `null` in browsers and any runtime where
482
- * `process.memoryUsage` is unavailable.
483
- */
484
- process: ProcessMemoryReport | null;
485
- /**
486
- * Sum of every index's {@link IndexStats.estimatedMemoryBytes} held by this
487
- * engine. Formula-based; treat as an estimate, not a measurement. Useful
488
- * for cross-engine relative comparisons inside a single process where
489
- * `process.heapUsed` cannot tell engines apart.
490
- */
491
- estimatedIndexBytes: number;
492
- /** This many indexes currently occupy engine memory. */
493
- openIndexCount: number;
494
- /** This many indexes remain registered without occupying engine memory, including parked recovery failures. */
495
- closedIndexCount: number;
496
- /** This counts successful index loads since this engine started. */
497
- reopenCount: number;
498
- /**
499
- * Per-worker V8 heap usage when the engine has been promoted to a worker
500
- * pool. Empty when no workers are active.
501
- */
502
- workers: Array<{
503
- /** This identifies the worker within the pool. */
504
- workerId: number;
505
- /** That worker is using this much heap. */
506
- heapUsed: number;
507
- /** V8 has reserved this much heap in that worker. */
508
- heapTotal: number;
509
- /** That worker holds this much outside its heap. */
510
- external: number;
511
- }>;
512
- }
513
453
  /**
514
454
  * The state of one vector field, and what maintenance would cost, as
515
455
  * {@link Narsil.vectorMaintenanceStatus} reports it.
@@ -524,7 +464,7 @@ interface VectorMaintenanceResult {
524
464
  fieldName: string;
525
465
  /** Tombstones make up this share of the graph's nodes, from 0 to 1. */
526
466
  tombstoneRatio: number;
527
- /** The field's HNSW graph holds this many vectors. */
467
+ /** The field holds this many HNSW graphs: 0 before the first build and 1 once a graph exists. */
528
468
  graphCount: number;
529
469
  /** This many vectors wait outside the graph, which a search scans one by one. */
530
470
  bufferSize: number;
@@ -1047,4 +987,90 @@ interface ListParams {
1047
987
  document?: DocumentProjection;
1048
988
  }
1049
989
 
1050
- export { type ArrayFilter as A, type BatchResult as B, type ClientErrorCode as C, type DocumentProjection as D, type ErrorCode as E, type FacetConfig as F, type GeoFilter as G, type HighlightConfig as H, type IndexInfo as I, type ScoreComponents as J, type SearchMode as K, type ListParams as L, type MemoryStats as M, NarsilError as N, type SortField as O, type PartitionStatsResult as P, type QueryParams as Q, type SortSpec as R, type ServerErrorCode as S, type StringFilter as T, type TermMatchPolicy as U, type VectorMaintenanceResult as V, type VectorQueryConfig as W, ClientErrorCodes as a, ErrorCodes as b, type NarsilErrorCode as c, ServerErrorCodes as d, type QueryResult as e, type IndexStats as f, type ListResult as g, type PreflightResult as h, type SuggestParams as i, type SuggestResult as j, type ComparisonFilter as k, type FacetResult as l, type FieldFilter as m, type FilterExpression as n, type GeoPolygonFilter as o, type GeoRadiusFilter as p, type GroupConfig as q, type GroupReducer as r, type GroupResult as s, type HighlightMatch as t, type Hit as u, type HybridConfig as v, type ListedDocument as w, type PresenceFilter as x, type ProcessMemoryReport as y, type QueryCoverage as z };
990
+ /**
991
+ * Snapshot of V8 heap usage as reported by `process.memoryUsage()`, with the
992
+ * limit the heap may grow to. All values are bytes. `null` in environments
993
+ * that do not expose `process.memoryUsage`, such as browsers.
994
+ *
995
+ * @public
996
+ */
997
+ interface ProcessMemoryReport {
998
+ /** The process is using this much heap. */
999
+ heapUsed: number;
1000
+ /** V8 has reserved this much heap. */
1001
+ heapTotal: number;
1002
+ /**
1003
+ * The heap may grow to this many bytes before the runtime ends the process
1004
+ * for running out of memory. Node sets it from `--max-old-space-size`, from
1005
+ * `--max-old-space-size-percentage`, or from the memory the host or the
1006
+ * container reports. `null` where the runtime cannot report it.
1007
+ */
1008
+ heapLimit: number | null;
1009
+ /** The process holds this much outside the heap, such as buffers. */
1010
+ external: number;
1011
+ /** The process occupies this much physical memory in total. */
1012
+ rss: number;
1013
+ }
1014
+ /**
1015
+ * Whether one index holds worker copies at the moment
1016
+ * {@link Narsil.getMemoryStats} reads it, and how many times it has loaded
1017
+ * them again after giving them up while idle.
1018
+ *
1019
+ * @public
1020
+ */
1021
+ interface WorkerCopyReport {
1022
+ /** This names the index. */
1023
+ indexName: string;
1024
+ /** This is true while every worker holds a copy of the index. */
1025
+ scaledOut: boolean;
1026
+ /** The index has loaded its copies again this many times after an idle spell dropped them. */
1027
+ reloadCount: number;
1028
+ }
1029
+ /**
1030
+ * What {@link Narsil.getMemoryStats} returns, which is what you size a host
1031
+ * from.
1032
+ *
1033
+ * @public
1034
+ */
1035
+ interface MemoryStats {
1036
+ /**
1037
+ * V8 heap usage for the host process at the moment of the call. It covers
1038
+ * the whole process, so every Narsil engine in one process returns the same
1039
+ * `process` figures from `getMemoryStats`. `null` in browsers and in any
1040
+ * runtime that does not expose `process.memoryUsage`.
1041
+ */
1042
+ process: ProcessMemoryReport | null;
1043
+ /**
1044
+ * The sum of every index's {@link IndexStats.estimatedMemoryBytes} held by
1045
+ * this engine. A formula produces it, so read it as an estimate. It compares
1046
+ * engines inside one process, where `process.heapUsed` cannot tell them
1047
+ * apart.
1048
+ */
1049
+ estimatedIndexBytes: number;
1050
+ /** This many indexes currently occupy engine memory. */
1051
+ openIndexCount: number;
1052
+ /** This many indexes remain registered without occupying engine memory, including parked recovery failures. */
1053
+ closedIndexCount: number;
1054
+ /** This counts successful index loads since this engine started. */
1055
+ reopenCount: number;
1056
+ /** One entry per index, saying whether it holds worker copies now and how many times it has reloaded them. */
1057
+ workerCopies: WorkerCopyReport[];
1058
+ /**
1059
+ * Per-worker V8 heap usage once the engine has started its worker pool.
1060
+ * Empty while no worker is running.
1061
+ */
1062
+ workers: Array<{
1063
+ /** This identifies the worker within the pool. */
1064
+ workerId: number;
1065
+ /** That worker is using this much heap. */
1066
+ heapUsed: number;
1067
+ /** V8 has reserved this much heap in that worker. */
1068
+ heapTotal: number;
1069
+ /** That worker's heap may grow to this many bytes, or `null` where its runtime cannot report it. */
1070
+ heapLimit: number | null;
1071
+ /** That worker holds this much outside its heap. */
1072
+ external: number;
1073
+ }>;
1074
+ }
1075
+
1076
+ export { type ArrayFilter as A, type BatchResult as B, type ClientErrorCode as C, type DocumentProjection as D, type ErrorCode as E, type FacetConfig as F, type GeoFilter as G, type HighlightConfig as H, type IndexInfo as I, type ScoreComponents as J, type SearchMode as K, type ListParams as L, type MemoryStats as M, NarsilError as N, type SortField as O, type PartitionStatsResult as P, type QueryParams as Q, type SortSpec as R, type ServerErrorCode as S, type StringFilter as T, type TermMatchPolicy as U, type VectorMaintenanceResult as V, type VectorQueryConfig as W, type WorkerCopyReport as X, ClientErrorCodes as a, ErrorCodes as b, type NarsilErrorCode as c, ServerErrorCodes as d, type QueryResult as e, type IndexStats as f, type ListResult as g, type PreflightResult as h, type SuggestParams as i, type SuggestResult as j, type ComparisonFilter as k, type FacetResult as l, type FieldFilter as m, type FilterExpression as n, type GeoPolygonFilter as o, type GeoRadiusFilter as p, type GroupConfig as q, type GroupReducer as r, type GroupResult as s, type HighlightMatch as t, type Hit as u, type HybridConfig as v, type ListedDocument as w, type PresenceFilter as x, type ProcessMemoryReport as y, type QueryCoverage as z };
@@ -1,4 +1,4 @@
1
- import { P as PartitionConfig, a as ScoringMode, V as VectorIndexConfig } from '../../schema-B7juWg8Q.js';
1
+ import { P as PartitionConfig, a as ScoringMode, V as VectorIndexConfig } from '../../schema-BqRx9t4E.js';
2
2
  import '../../adapters-79OIa4xm.js';
3
3
 
4
4
  interface IndexMetadata {
@@ -1,14 +1,20 @@
1
- import { createDurableDirectory, writeSegmentedCheckpoint } from '../../chunk-UZTT2BKQ.mjs';
2
- import '../../chunk-JQUL2T6I.mjs';
3
- import '../../chunk-XWICBGYT.mjs';
4
- import '../../chunk-EV45L35L.mjs';
1
+ import { createDurableDirectory, writeSegmentedCheckpoint } from '../../chunk-ND34I3SV.mjs';
2
+ import '../../chunk-ZHUQKZBE.mjs';
3
+ import '../../chunk-GCM3JFVA.mjs';
4
+ import '../../chunk-PIWKZPP7.mjs';
5
+ import '../../chunk-XE6XR2OE.mjs';
6
+ import '../../chunk-BEIK3EOZ.mjs';
7
+ import '../../chunk-CMVG2UEF.mjs';
8
+ import '../../chunk-AV4IJKD2.mjs';
9
+ import '../../chunk-CBLS46IE.mjs';
5
10
  import '../../chunk-TGP5M5R7.mjs';
6
- import '../../chunk-4COAUBLJ.mjs';
7
- import '../../chunk-DFZDV5FV.mjs';
11
+ import '../../chunk-PMBHH44R.mjs';
12
+ import '../../chunk-X6YZO4MQ.mjs';
13
+ import '../../chunk-RP23PWMV.mjs';
8
14
  import '../../chunk-KMMJMDUA.mjs';
9
15
  import '../../chunk-U2BKYEC7.mjs';
10
- import '../../chunk-BFIH7OV5.mjs';
11
- import '../../chunk-WTONLDU3.mjs';
16
+ import '../../chunk-2GWVQWGA.mjs';
17
+ import '../../chunk-WYJXSLER.mjs';
12
18
  import '../../chunk-P4ELXVJQ.mjs';
13
19
 
14
20
  // src/persistence/durability/rebuild.ts
package/dist/react.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { N as NarsilError, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, Q as QueryParams, h as PreflightResult, e as QueryResult, i as SuggestParams, j as SuggestResult } from './search-DDHjfXhJ.js';
2
- export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes } from './search-DDHjfXhJ.js';
1
+ import { N as NarsilError, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, Q as QueryParams, h as PreflightResult, e as QueryResult, i as SuggestParams, j as SuggestResult } from './memory-Bzd5xcEW.js';
2
+ export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes } from './memory-Bzd5xcEW.js';
3
3
  import { e as TaskRecord, d as TaskProgress, b as ImportResult, c as TaskListQuery, T as TaskListPage } from './tasks-Bn4R1NPN.js';
4
4
  export { I as ImportError, f as TaskStatus, g as TaskType } from './tasks-Bn4R1NPN.js';
5
5
  import { ReactNode, ReactElement } from 'react';
6
- import { N as NarsilClient, I as ImportSource } from './client-C5BkUqB8.js';
7
- import { A as AnyDocument } from './schema-B7juWg8Q.js';
6
+ import { N as NarsilClient, I as ImportSource } from './client-CBOVHdjp.js';
7
+ import { A as AnyDocument } from './schema-BqRx9t4E.js';
8
8
  import './adapters-79OIa4xm.js';
9
9
 
10
10
  /**
package/dist/react.mjs CHANGED
@@ -140,6 +140,12 @@ var NarsilError = class extends Error {
140
140
  }
141
141
  };
142
142
 
143
+ // src/react/constants.ts
144
+ var DEFAULT_KEEP_ALIVE_MS = 2e3;
145
+ var DEFAULT_TASK_POLL_INTERVAL_MS = 250;
146
+ var ERROR_RETRY_INTERVAL_MS = 5e3;
147
+ var MAX_QUERY_KEY_DEPTH = 32;
148
+
143
149
  // src/react/failure.ts
144
150
  function asNarsilError(err, whatFailed) {
145
151
  if (err instanceof NarsilError) return err;
@@ -148,7 +154,6 @@ function asNarsilError(err, whatFailed) {
148
154
  }
149
155
 
150
156
  // src/react/store.ts
151
- var DEFAULT_KEEP_ALIVE_MS = 2e3;
152
157
  var LOADING_SNAPSHOT = Object.freeze({
153
158
  data: void 0,
154
159
  error: void 0,
@@ -298,7 +303,6 @@ function useNarsilClient() {
298
303
  }
299
304
 
300
305
  // src/react/key.ts
301
- var MAX_DEPTH = 32;
302
306
  function refuse(reason) {
303
307
  return new NarsilError(
304
308
  ErrorCodes.CONFIG_INVALID,
@@ -351,7 +355,7 @@ function write(value, out, depth, seen) {
351
355
  case "symbol":
352
356
  throw refuse(`is a ${typeof value}, which carries no value a request depends on`);
353
357
  }
354
- if (depth >= MAX_DEPTH) throw refuse(`nests deeper than ${MAX_DEPTH} levels`);
358
+ if (depth >= MAX_QUERY_KEY_DEPTH) throw refuse(`nests deeper than ${MAX_QUERY_KEY_DEPTH} levels`);
355
359
  const held = value;
356
360
  if (seen.includes(held)) throw refuse("holds a reference back to itself");
357
361
  seen.push(held);
@@ -516,8 +520,6 @@ function useDocuments(indexName, params, options) {
516
520
  }
517
521
 
518
522
  // src/react/task-state.ts
519
- var DEFAULT_TASK_POLL_INTERVAL_MS = 250;
520
- var ERROR_RETRY_INTERVAL_MS = 5e3;
521
523
  function pollInterval(interval, failed) {
522
524
  return failed ? Math.max(interval, ERROR_RETRY_INTERVAL_MS) : interval;
523
525
  }
@@ -217,11 +217,30 @@ interface PartitionConfig {
217
217
  */
218
218
  type ScoringMode = 'local' | 'dfs' | 'broadcast';
219
219
  /**
220
- * Per-write options for {@link Narsil.insert} and {@link Narsil.insertBatch}.
220
+ * Per-write options every write accepts.
221
+ *
222
+ * A write returns once the main copy holds it, and it reaches the worker
223
+ * copies afterwards, so a query that a copy answers may come back without a
224
+ * write that returned before it.
225
+ *
226
+ * @public
227
+ */
228
+ interface WriteOptions {
229
+ /**
230
+ * Setting this makes the write return only once every worker copy holding
231
+ * the index has applied it, so the next query sees it whichever copy
232
+ * answers. Leave it off for a load, and call
233
+ * {@link DocumentWriteOperations.waitForWrites} once at the end.
234
+ */
235
+ wait?: boolean;
236
+ }
237
+ /**
238
+ * Per-write options for {@link DocumentWriteOperations.insert} and
239
+ * {@link DocumentWriteOperations.insertBatch}.
221
240
  *
222
241
  * @public
223
242
  */
224
- interface InsertOptions {
243
+ interface InsertOptions extends WriteOptions {
225
244
  /**
226
245
  * Setting this stores the document object you passed instead of a copy,
227
246
  * which saves a clone on a large load. Changing that object afterwards
@@ -231,4 +250,4 @@ interface InsertOptions {
231
250
  skipClone?: boolean;
232
251
  }
233
252
 
234
- export type { AnyDocument as A, BM25Params as B, CustomTokenizer as C, EmbeddingFieldConfig as E, FieldType as F, IndexConfig as I, PartitionConfig as P, SchemaDefinition as S, VectorIndexConfig as V, ScoringMode as a, InsertOptions as b, StopWordOverride as c, VectorQuantizationMode as d };
253
+ export type { AnyDocument as A, BM25Params as B, CustomTokenizer as C, EmbeddingFieldConfig as E, FieldType as F, IndexConfig as I, PartitionConfig as P, SchemaDefinition as S, VectorIndexConfig as V, WriteOptions as W, ScoringMode as a, InsertOptions as b, StopWordOverride as c, VectorQuantizationMode as d };
package/dist/server.d.ts CHANGED
@@ -1,22 +1,60 @@
1
- import { b as ServerOptions, N as NarsilServer } from './options-BC68VPoE.js';
2
- export { A as ASYNC_IMPORT_CAPABILITY, C as CorsOptions, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, 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-BC68VPoE.js';
3
- import { a as Narsil } from './engine-Cjr1uBLa.js';
4
- import { h as TaskStore, e as TaskRecord, d as TaskProgress, b as ImportResult } from './tasks-Bn4R1NPN.js';
1
+ import { b as ServerOptions, N as NarsilServer } from './capabilities-JrVQOwi4.js';
2
+ export { A as ASYNC_IMPORT_CAPABILITY, C as CorsOptions, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, 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 './capabilities-JrVQOwi4.js';
3
+ import { a as Narsil } from './engine-9PtFY50q.js';
4
+ import { d as TaskProgress, b as ImportResult, h as TaskStore, e as TaskRecord } from './tasks-Bn4R1NPN.js';
5
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-Bn4R1NPN.js';
6
- export { d as ServerErrorCodes } from './search-DDHjfXhJ.js';
7
- import './config-B-ZI-ft5.js';
8
- import './config-BZRExglL.js';
6
+ export { d as ServerErrorCodes } from './memory-Bzd5xcEW.js';
9
7
  import './adapters-79OIa4xm.js';
10
- import './schema-B7juWg8Q.js';
11
- import './types-DsSSjY4d.js';
8
+ import './config-Czh2YNDi.js';
9
+ import './config-OON7IJ_B.js';
10
+ import './schema-BqRx9t4E.js';
11
+ import './types-DXPxaXPO.js';
12
12
  import './types-D5OwhtsQ.js';
13
13
 
14
+ /**
15
+ * What a running task reports back while it works, and how it learns that a
16
+ * cancel arrived.
17
+ *
18
+ * @public
19
+ */
20
+ interface TaskContext {
21
+ /** Aborts once a cancel arrives, so long-running work can stop between units. */
22
+ readonly signal: AbortSignal;
23
+ /**
24
+ * Records how far the work has gone, which `GET /tasks/{id}` then reports.
25
+ *
26
+ * @param progress - The counters as they stand now.
27
+ */
28
+ reportProgress(progress: TaskProgress): void;
29
+ /**
30
+ * Records what the work produced, which the finished task then carries.
31
+ *
32
+ * @param result - What the work produced.
33
+ */
34
+ reportResult(result: ImportResult): void;
35
+ }
36
+ /**
37
+ * The work one task runs.
38
+ *
39
+ * Resolving marks the task succeeded. Rejecting marks it failed, unless a
40
+ * cancel had already arrived, which marks it cancelled instead. Work that
41
+ * cannot stop early ignores the signal and still finishes.
42
+ *
43
+ * @public
44
+ */
45
+ type TaskOperation = (ctx: TaskContext) => Promise<void>;
46
+
14
47
  /**
15
48
  * Wraps a Narsil engine in an HTTP server. The caller builds and owns the engine
16
49
  * (durability, embedding, workers) and hands the live instance in; the server
17
50
  * shares it across requests and never constructs or shuts it down. Start with
18
51
  * `.listen()` and stop with `.close()`; the engine is shut down separately.
19
52
  *
53
+ * On Node.js the server receives requests on the engine's worker threads, which
54
+ * hold the worker copies. A query on an index that holds copies answers on the
55
+ * thread that received it, and every write goes to the main thread. Read
56
+ * {@link NarsilServer.requestThreadCount} for how many threads took requests.
57
+ *
20
58
  * @param engine - The live engine every request runs against.
21
59
  * @param options - Address, CORS, request limits, the authentication hook, and
22
60
  * the task store. Omit it to bind to loopback with the default limits.
@@ -83,37 +121,4 @@ declare class InMemoryTaskStore implements TaskStore {
83
121
  private prune;
84
122
  }
85
123
 
86
- /**
87
- * What a running task reports back while it works, and how it learns that a
88
- * cancel arrived.
89
- *
90
- * @public
91
- */
92
- interface TaskContext {
93
- /** Aborts once a cancel arrives, so long-running work can stop between units. */
94
- readonly signal: AbortSignal;
95
- /**
96
- * Records how far the work has gone, which `GET /tasks/{id}` then reports.
97
- *
98
- * @param progress - The counters as they stand now.
99
- */
100
- reportProgress(progress: TaskProgress): void;
101
- /**
102
- * Records what the work produced, which the finished task then carries.
103
- *
104
- * @param result - What the work produced.
105
- */
106
- reportResult(result: ImportResult): void;
107
- }
108
- /**
109
- * The work one task runs.
110
- *
111
- * Resolving marks the task succeeded. Rejecting marks it failed, unless a
112
- * cancel had already arrived, which marks it cancelled instead. Work that
113
- * cannot stop early ignores the signal and still finishes.
114
- *
115
- * @public
116
- */
117
- type TaskOperation = (ctx: TaskContext) => Promise<void>;
118
-
119
124
  export { ImportResult, InMemoryTaskStore, NarsilServer, ServerOptions, type TaskContext, type TaskOperation, TaskProgress, TaskRecord, TaskStore, createServer, httpStatusForNarsilError };