@delali/narsil 0.1.8 → 0.1.10

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/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { A as ArrayFilter, B as BatchResult, C as ComparisonFilter, E as ErrorCode, a as ErrorCodes, F as FacetConfig, b as FacetResult, c as FilterExpression, d as FlushConfig, G as GeoPolygonFilter, e as GeoRadiusFilter, f as GroupConfig, g as GroupReducer, h as GroupResult, H as HighlightConfig, i as HighlightMatch, j as Hit, k as HybridConfig, I as IndexContext, l as IndexInfo, m as IndexStats, n as InsertContext, M as MemoryStats, N as NarsilConfig, o as NarsilError, p as NarsilPlugin, P as PartitionContext, q as PartitionStatsResult, r as PreflightResult, s as PresenceFilter, t as ProcessMemoryReport, Q as QueryParams, u as QueryResult, R as RemoveContext, S as ScoreComponents, v as SearchContext, w as SearchMode, x as StringFilter, y as SuggestParams, z as SuggestResult, T as TermMatchPolicy, U as UpdateContext, V as VectorMaintenanceResult, D as VectorQueryConfig, W as WorkerConfig, J as WorkerContext } from './config-cQLlYR3U.js';
1
+ export { A as ArrayFilter, B as BatchResult, C as ComparisonFilter, E as ErrorCode, a as ErrorCodes, F as FacetConfig, b as FacetResult, c as FilterExpression, d as FlushConfig, G as GeoPolygonFilter, e as GeoRadiusFilter, f as GroupConfig, g as GroupReducer, h as GroupResult, H as HighlightConfig, i as HighlightMatch, j as Hit, k as HybridConfig, I as IndexContext, l as IndexInfo, m as IndexStats, n as InsertContext, M as MemoryStats, N as NarsilConfig, o as NarsilError, p as NarsilPlugin, P as PartitionContext, q as PartitionStatsResult, r as PreflightResult, s as PresenceFilter, t as ProcessMemoryReport, Q as QueryParams, u as QueryResult, R as RemoveContext, S as ScoreComponents, v as SearchContext, w as SearchMode, x as StringFilter, y as SuggestParams, z as SuggestResult, T as TermMatchPolicy, U as UpdateContext, V as VectorMaintenanceResult, D as VectorQueryConfig, W as WorkerConfig, J as WorkerContext } from './config-DX--2Owg.js';
2
2
  import { L as LanguageModule } from './language-ONQ3iVDf.js';
3
- export { N as Narsil, a as NarsilEventMap, c as createNarsil } from './narsil-ChTdkwPu.js';
3
+ export { N as Narsil, a as NarsilEventMap, c as createNarsil } from './narsil-B3jKyXCr.js';
4
4
  export { E as EmbeddingAdapter, I as InvalidationAdapter, a as InvalidationEvent, P as PartitionStatistics, b as PersistenceAdapter } from './adapters-Bo2JQg8b.js';
5
- export { A as AnyDocument, B as BM25Params, C as CustomTokenizer, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition, b as ScoringMode } from './schema-BVaw7nqz.js';
5
+ export { A as AnyDocument, B as BM25Params, C as CustomTokenizer, E as EmbeddingFieldConfig, F as FieldType, I as IndexConfig, a as InsertOptions, P as PartitionConfig, S as SchemaDefinition, b as ScoringMode } from './schema-C3VhNvfw.js';
6
6
 
7
7
  declare function configureNormalizationCache(maxSize: number): void;
8
8
  declare function clearNormalizationCache(): void;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { VERSION, createNarsil } from './chunk-GQEHCZG7.mjs';
2
- export { clearNormalizationCache, configureNormalizationCache, getLanguage, getNormalizationCacheSize, registerLanguage, resetNormalizationCache } from './chunk-FS7XLIUS.mjs';
1
+ export { VERSION, createNarsil } from './chunk-CU6BVZEU.mjs';
2
+ export { clearNormalizationCache, configureNormalizationCache, getLanguage, getNormalizationCacheSize, registerLanguage, resetNormalizationCache } from './chunk-Q4OVNESD.mjs';
3
3
  export { isSimdAvailable } from './chunk-S7RJJMHI.mjs';
4
4
  import './chunk-KMMJMDUA.mjs';
5
5
  import './chunk-TW6BXTOL.mjs';
@@ -1,5 +1,6 @@
1
- import { l as IndexInfo, m as IndexStats, q as PartitionStatsResult, B as BatchResult, Q as QueryParams, u as QueryResult, r as PreflightResult, y as SuggestParams, z as SuggestResult, M as MemoryStats, V as VectorMaintenanceResult, N as NarsilConfig } from './config-cQLlYR3U.js';
2
- import { I as IndexConfig, A as AnyDocument, a as InsertOptions, P as PartitionConfig } from './schema-BVaw7nqz.js';
1
+ import { l as IndexInfo, m as IndexStats, q as PartitionStatsResult, B as BatchResult, Q as QueryParams, u as QueryResult, r as PreflightResult, y as SuggestParams, z as SuggestResult, M as MemoryStats, V as VectorMaintenanceResult, N as NarsilConfig } from './config-DX--2Owg.js';
2
+ import { I as IndexConfig, A as AnyDocument, a as InsertOptions, P as PartitionConfig } from './schema-C3VhNvfw.js';
3
+ import { E as EmbeddingAdapter } from './adapters-Bo2JQg8b.js';
3
4
 
4
5
  type NarsilEventMap = {
5
6
  persistenceError: {
@@ -29,6 +30,9 @@ type NarsilEventMap = {
29
30
 
30
31
  interface Narsil {
31
32
  createIndex(name: string, config: IndexConfig): Promise<void>;
33
+ /** Registers an adapter under a name that index configs can reference and
34
+ * durability metadata can persist; re-registering rebinds referencing indexes. */
35
+ registerEmbeddingAdapter(name: string, adapter: EmbeddingAdapter): void;
32
36
  dropIndex(name: string): Promise<void>;
33
37
  listIndexes(): IndexInfo[];
34
38
  getStats(indexName: string): IndexStats;
@@ -14,6 +14,13 @@ interface IndexMetadata {
14
14
  metric: string;
15
15
  quantization: string;
16
16
  }>;
17
+ embedding?: IndexEmbeddingMetadata;
18
+ }
19
+ /** Persisted so recovery can restore field mappings and rebind the adapter by
20
+ * name; the name is absent when the index was configured with a bare instance. */
21
+ interface IndexEmbeddingMetadata {
22
+ adapter?: string;
23
+ fields: Record<string, string | string[]>;
17
24
  }
18
25
 
19
26
  interface PartitionCheckpoint {
@@ -1,5 +1,5 @@
1
- import { createDurableDirectory, writeSegmentedCheckpoint } from '../../chunk-GQEHCZG7.mjs';
2
- import '../../chunk-FS7XLIUS.mjs';
1
+ import { createDurableDirectory, writeSegmentedCheckpoint } from '../../chunk-CU6BVZEU.mjs';
2
+ import '../../chunk-Q4OVNESD.mjs';
3
3
  import '../../chunk-S7RJJMHI.mjs';
4
4
  import '../../chunk-KMMJMDUA.mjs';
5
5
  import '../../chunk-TW6BXTOL.mjs';
@@ -19,7 +19,9 @@ interface VectorIndexConfig {
19
19
  quantization?: VectorQuantizationMode;
20
20
  }
21
21
  interface EmbeddingFieldConfig {
22
- adapter?: EmbeddingAdapter;
22
+ /** An adapter instance, or a registered adapter name. Only a name survives
23
+ * durability recovery, since instances cannot be serialised. */
24
+ adapter?: EmbeddingAdapter | string;
23
25
  fields: Record<string, string | string[]>;
24
26
  }
25
27
  interface IndexConfig {
package/dist/server.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { N as Narsil } from './narsil-ChTdkwPu.js';
1
+ import { N as Narsil } from './narsil-B3jKyXCr.js';
2
2
  import { E as EmbeddingAdapter } from './adapters-Bo2JQg8b.js';
3
- import './config-cQLlYR3U.js';
4
- import './schema-BVaw7nqz.js';
3
+ import './config-DX--2Owg.js';
4
+ import './schema-C3VhNvfw.js';
5
5
 
6
6
  /**
7
7
  * Context handed to {@link OnRequestHook} for every inbound request, captured
package/dist/server.mjs CHANGED
@@ -573,7 +573,7 @@ function createImportHandler(deps) {
573
573
  }
574
574
 
575
575
  // src/server/config-mapping.ts
576
- function mapHttpIndexConfig(http, adapters) {
576
+ function mapHttpIndexConfig(http) {
577
577
  if (typeof http !== "object" || http === null) {
578
578
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index config must be an object");
579
579
  }
@@ -596,11 +596,11 @@ function mapHttpIndexConfig(http, adapters) {
596
596
  config.stopWords = new Set(http.stopWords);
597
597
  }
598
598
  if (http.embedding !== void 0) {
599
- config.embedding = mapEmbedding(http.embedding, adapters);
599
+ config.embedding = mapEmbedding(http.embedding);
600
600
  }
601
601
  return config;
602
602
  }
603
- function mapEmbedding(embedding, adapters) {
603
+ function mapEmbedding(embedding) {
604
604
  if (typeof embedding !== "object" || embedding === null) {
605
605
  throw new NarsilError(ErrorCodes.EMBEDDING_CONFIG_INVALID, 'Field "embedding" must be an object');
606
606
  }
@@ -609,22 +609,20 @@ function mapEmbedding(embedding, adapters) {
609
609
  }
610
610
  const mapped = { fields: embedding.fields };
611
611
  if (embedding.adapter !== void 0) {
612
- const adapter = adapters[embedding.adapter];
613
- if (!adapter) {
612
+ if (typeof embedding.adapter !== "string" || embedding.adapter.length === 0) {
614
613
  throw new NarsilError(
615
614
  ErrorCodes.EMBEDDING_CONFIG_INVALID,
616
- `Embedding adapter "${embedding.adapter}" is not registered on this server`,
617
- { available: Object.keys(adapters) }
615
+ 'Field "embedding.adapter" must be a non-empty adapter name'
618
616
  );
619
617
  }
620
- mapped.adapter = adapter;
618
+ mapped.adapter = embedding.adapter;
621
619
  }
622
620
  return mapped;
623
621
  }
624
622
 
625
623
  // src/server/handlers/indexes.ts
626
624
  function createIndexHandlers(deps) {
627
- const { engine, adapters } = deps;
625
+ const { engine } = deps;
628
626
  async function create(ctx) {
629
627
  const body = parseJson(ctx);
630
628
  if (!body) return;
@@ -637,7 +635,7 @@ function createIndexHandlers(deps) {
637
635
  return;
638
636
  }
639
637
  try {
640
- const config = mapHttpIndexConfig(body.config, adapters);
638
+ const config = mapHttpIndexConfig(body.config);
641
639
  await engine.createIndex(body.name, config);
642
640
  respondJson(ctx, { name: body.name }, 201);
643
641
  } catch (err) {
@@ -1041,13 +1039,14 @@ var NarsilHttpServer = class {
1041
1039
  this.host = options.host ?? "127.0.0.1";
1042
1040
  this.port = options.port ?? 9876;
1043
1041
  this.options = options;
1044
- const adapters = options.embeddingAdapters ?? {};
1042
+ for (const [name, adapter] of Object.entries(options.embeddingAdapters ?? {})) {
1043
+ engine.registerEmbeddingAdapter(name, adapter);
1044
+ }
1045
1045
  const taskStore = options.taskStore ?? new InMemoryTaskStore();
1046
1046
  const instanceId = options.instanceId ?? randomUUID();
1047
1047
  this.deps = {
1048
1048
  engine,
1049
1049
  tasks: new TaskRegistry(taskStore, instanceId),
1050
- adapters,
1051
1050
  limits: resolveLimits(options.limits),
1052
1051
  isReady: () => this.ready,
1053
1052
  build: resolveBuild(options.build)
@@ -1,4 +1,4 @@
1
- import { S as SchemaDefinition } from './schema-BVaw7nqz.js';
1
+ import { S as SchemaDefinition } from './schema-C3VhNvfw.js';
2
2
 
3
3
  type NodeRole = 'data' | 'coordinator' | 'controller';
4
4
  type PartitionState = 'UNASSIGNED' | 'INITIALISING' | 'ACTIVE' | 'MIGRATING' | 'DECOMMISSIONING';
@@ -15,7 +15,7 @@ async function setup() {
15
15
  } catch {
16
16
  parentPort = null;
17
17
  }
18
- const { createDirectExecutor } = await import('../direct-executor-FX56DYD3.mjs');
18
+ const { createDirectExecutor } = await import('../direct-executor-6FOKJKLD.mjs');
19
19
  const executor = createDirectExecutor();
20
20
  function buildErrorResponse(requestId, code, message) {
21
21
  return { type: "error", requestId, code, message };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delali/narsil",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "description": "A distributed full-text search engine with cross-language portable binary format.",
6
6
  "author": "Delali (https://sondelali.com)",
@@ -22,6 +22,14 @@
22
22
  "#platform/vector-promoter": {
23
23
  "browser": "./src/vector/promoter.browser.ts",
24
24
  "default": "./src/vector/promoter.ts"
25
+ },
26
+ "#platform/durable-fs": {
27
+ "browser": "./src/persistence/durability/node-fs.browser.ts",
28
+ "default": "./src/persistence/durability/node-fs.ts"
29
+ },
30
+ "#platform/node-worker": {
31
+ "browser": "./src/workers/node-worker.browser.ts",
32
+ "default": "./src/workers/node-worker.ts"
25
33
  }
26
34
  },
27
35
  "sideEffects": false,
@@ -111,6 +119,7 @@
111
119
  "@types/node": "22.15.32",
112
120
  "@vitest/coverage-v8": "4.0.18",
113
121
  "etcd3": "1.1.2",
122
+ "fflate": "0.8.3",
114
123
  "selfsigned": "5.5.0",
115
124
  "tsup": "8.5.1",
116
125
  "typescript": "5.9.3",
@@ -132,7 +141,7 @@
132
141
  }
133
142
  },
134
143
  "scripts": {
135
- "build": "tsup",
144
+ "build": "tsup && node scripts/check-browser-bundle.mjs",
136
145
  "test": "vitest run --exclude='**/vector/recall.test.ts'",
137
146
  "test:etcd": "vitest run src/__tests__/distribution/coordinator/etcd-integration/*.test.ts",
138
147
  "test:watch": "vitest",