@duckedup/nidus 0.74.0 → 0.76.0

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 CHANGED
@@ -214,6 +214,19 @@ const recent = await db.search({
214
214
  limitPer: { field: "path", max: 2 },
215
215
  });
216
216
 
217
+ // Read a chunked corpus as documents: the best chunk per file, widened with its
218
+ // neighbours into `hit.context`. Payload only, so the ranking is unchanged.
219
+ const passages = await db.search({
220
+ query: [0.1, 0.2, 0.3],
221
+ limitPer: { field: "nidus.parent_id", max: 1 },
222
+ expand: { radius: 1 },
223
+ });
224
+
225
+ // On recall the same pair has one text-native spelling.
226
+ await db.recall("docs", "how does the writer lock work", {
227
+ rollup: { neighbours: 1 },
228
+ });
229
+
217
230
  // Sort a listing by an attribute instead of storage order
218
231
  await db.list({ orderBy: { field: "updated_at", descending: true } });
219
232
 
package/dist/index.cjs CHANGED
@@ -352,6 +352,7 @@ var NidusClient = class {
352
352
  rank_by: encodeRankBy(opts.rankBy),
353
353
  limit_per: opts.limitPer,
354
354
  diversity: opts.diversity,
355
+ expand: encodeExpand(opts.expand),
355
356
  rerank: encodeRerank(opts.rerank)
356
357
  });
357
358
  }
@@ -370,7 +371,8 @@ var NidusClient = class {
370
371
  exclude_attributes: opts.excludeAttributes,
371
372
  rank_by: encodeRankBy(opts.rankBy),
372
373
  limit_per: opts.limitPer,
373
- diversity: opts.diversity
374
+ diversity: opts.diversity,
375
+ expand: encodeExpand(opts.expand)
374
376
  });
375
377
  }
376
378
  /**
@@ -392,6 +394,7 @@ var NidusClient = class {
392
394
  rank_by: encodeRankBy(opts.rankBy),
393
395
  limit_per: opts.limitPer,
394
396
  diversity: opts.diversity,
397
+ expand: encodeExpand(opts.expand),
395
398
  rerank: encodeRerank(opts.rerank)
396
399
  });
397
400
  }
@@ -413,6 +416,7 @@ var NidusClient = class {
413
416
  highlight: encodeHighlight(opts.highlight),
414
417
  vector_weight: opts.vectorWeight,
415
418
  text_weight: opts.textWeight,
419
+ expand: encodeExpand(opts.expand),
416
420
  rerank: encodeRerank(opts.rerank)
417
421
  });
418
422
  }
@@ -479,7 +483,8 @@ var NidusClient = class {
479
483
  exclude_attributes: q.excludeAttributes,
480
484
  rank_by: encodeRankBy(q.rankBy),
481
485
  limit_per: q.limitPer,
482
- diversity: q.diversity
486
+ diversity: q.diversity,
487
+ expand: encodeExpand(q.expand)
483
488
  })),
484
489
  fuse: opts.fuse ? prune({
485
490
  rrf_k: opts.fuse.rrfK,
@@ -542,6 +547,7 @@ var NidusClient = class {
542
547
  min_score: opts.minScore,
543
548
  filter: opts.filter ?? [],
544
549
  diversity: opts.diversity,
550
+ rollup: encodeRollup(opts.rollup),
545
551
  rerank: encodeRerank(opts.rerank)
546
552
  });
547
553
  }
@@ -573,7 +579,8 @@ var NidusClient = class {
573
579
  score: h.score,
574
580
  attrs: decodeAttrs(h.attrs),
575
581
  // Kept absent, not `undefined`, so an unannotated hit is the shape it always was.
576
- ...h.annotations ? { annotations: decodeAnnotations(h.annotations) } : {}
582
+ ...h.annotations ? { annotations: decodeAnnotations(h.annotations) } : {},
583
+ ...h.context !== void 0 ? { context: h.context } : {}
577
584
  };
578
585
  }
579
586
  /** Issue a request and parse a JSON body, mapping a non-2xx to {@link NidusError}. */
@@ -611,6 +618,19 @@ var NidusClient = class {
611
618
  }
612
619
  }
613
620
  };
621
+ function encodeExpand(e) {
622
+ if (!e) return void 0;
623
+ return prune({
624
+ radius: e.radius,
625
+ parent_field: e.parentField,
626
+ index_field: e.indexField,
627
+ text_field: e.textField
628
+ });
629
+ }
630
+ function encodeRollup(r) {
631
+ if (!r) return void 0;
632
+ return prune({ per_parent: r.perParent, neighbours: r.neighbours });
633
+ }
614
634
  function encodeRankBy(rank) {
615
635
  if (!rank) return void 0;
616
636
  const d = rank.decay;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/annotations.ts","../src/errors.ts","../src/values.ts","../src/client.ts","../src/filter.ts"],"sourcesContent":["//! `@duckedup/nidus` — the JavaScript/TypeScript client for nidus.\n//\n// A zero-dependency, cross-runtime remote client over the `nidus serve` HTTP API.\n// Point a {@link NidusClient} at a local or remote server, then upsert and search.\n\nexport { NidusClient } from \"./client.js\";\nexport type { FetchLike, NidusClientOptions } from \"./client.js\";\nexport { NidusError } from \"./errors.js\";\nexport { f } from \"./filter.js\";\nexport { decodeAttrs, decodeValue, encodeAttrs, encodeValue, v } from \"./values.js\";\nexport type {\n AggregateOptions,\n Aggregation,\n AnnInfo,\n AnnotationOptions,\n Annotations,\n AttrInput,\n ClauseScore,\n ClusterStatus,\n Decay,\n DecodedRecord,\n DecodedValue,\n Filter,\n FilterIndexField,\n Footprint,\n Fragment,\n FtsCombine,\n FtsField,\n Highlight,\n HighlightOptions,\n Hit,\n HybridQuerySpelling,\n HybridSearchBase,\n HybridSearchOptions,\n LegScore,\n LimitPer,\n ListOptions,\n NidusRecord,\n OrderBy,\n Predicate,\n ProjectionOptions,\n RankBy,\n RankingOptions,\n Readiness,\n RecallOptions,\n RecordInput,\n RememberOptions,\n RememberResult,\n RerankOptions,\n SearchOptions,\n SimilarSearchOptions,\n Stats,\n TextClause,\n TextQuerySpelling,\n TextSearchBase,\n TextSearchOptions,\n Value,\n} from \"./types.js\";\n","//! Decoding a hit's optional annotations — the opt-in \"why did this match\".\n//\n// One rule here is JS's alone. The server reports a highlight span as a **UTF-8 byte**\n// range into the fragment text, but a JS string is indexed in UTF-16 code units, so\n// `text.slice(...span)` on a raw span is wrong for any non-ASCII excerpt. Converted here,\n// once, so a caller's obvious slice is the right one.\n\nimport type { Annotations, Fragment, Highlight } from \"./types.js\";\n\n/** A fragment as it arrives: `spans` are UTF-8 byte offsets into `text`. */\ninterface WireFragment {\n text: string;\n spans: [number, number][];\n}\n\ninterface WireHighlight {\n field: string;\n fragments: WireFragment[];\n}\n\n/** A hit's annotations as they arrive, before the span offsets are converted. */\nexport interface WireAnnotations {\n vector?: { rank: number; score: number };\n text?: { rank: number; score: number };\n clauses?: { field: string; score: number }[];\n highlights?: WireHighlight[];\n}\n\n/**\n * Decode a hit's annotations, converting every highlight span to JS string indices. The\n * parts the server omitted stay omitted rather than becoming empty arrays.\n */\nexport function decodeAnnotations(a: WireAnnotations): Annotations {\n const out: Annotations = {};\n if (a.vector) out.vector = a.vector;\n if (a.text) out.text = a.text;\n if (a.clauses) out.clauses = a.clauses;\n if (a.highlights) out.highlights = a.highlights.map(decodeHighlight);\n return out;\n}\n\nfunction decodeHighlight(h: WireHighlight): Highlight {\n return { field: h.field, fragments: h.fragments.map(decodeFragment) };\n}\n\nfunction decodeFragment(fr: WireFragment): Fragment {\n return { text: fr.text, spans: toStringIndices(fr.text, fr.spans) };\n}\n\n/**\n * Convert UTF-8 byte ranges into `text` to JS string indices (UTF-16 code units), so\n * `text.slice(...span)` yields the matched term. An all-ASCII excerpt needs no conversion\n * and is the common case, so it is detected before any table is built.\n */\nexport function toStringIndices(\n text: string,\n spans: [number, number][],\n): [number, number][] {\n if (spans.length === 0 || isAscii(text)) return spans;\n const index = byteToUnit(text);\n const at = (b: number): number =>\n index[Math.min(Math.max(b, 0), index.length - 1)]!;\n return spans.map(([start, end]): [number, number] => [at(start), at(end)]);\n}\n\n/** One entry per byte of `text` (plus its end), holding that byte's UTF-16 index. */\nfunction byteToUnit(text: string): number[] {\n const index: number[] = [];\n let unit = 0;\n // A byte *inside* a codepoint maps to that codepoint's start. Spans land on token\n // boundaries, so this only keeps a malformed offset from landing mid-surrogate.\n for (const ch of text) {\n for (let n = utf8Len(ch.codePointAt(0)!); n > 0; n--) index.push(unit);\n unit += ch.length;\n }\n index.push(unit);\n return index;\n}\n\nfunction utf8Len(codePoint: number): number {\n if (codePoint < 0x80) return 1;\n if (codePoint < 0x800) return 2;\n return codePoint < 0x10000 ? 3 : 4;\n}\n\n/** True when every code unit is ASCII, i.e. byte offsets already *are* string indices. */\nfunction isAscii(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) > 0x7f) return false;\n }\n return true;\n}\n","//! Error type carrying the HTTP status the server reported.\n//\n// The server replies to a failed request with `{ \"error\": <message> }` and a\n// meaningful status (`src/server/mod.rs#classify`): 400 dimension mismatch,\n// 403 read-only store, 409 writer-lock conflict, 507 capacity/OOM, 500 otherwise.\n// Callers branch on `.status` to tell a client fault from a server fault.\n\n/** An error returned by a `nidus` server, or a transport failure reaching it. */\nexport class NidusError extends Error {\n /** The HTTP status code, or `0` for a transport/timeout failure (no response). */\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = \"NidusError\";\n this.status = status;\n }\n\n /** A malformed request the server rejected (HTTP 400). */\n get isBadRequest(): boolean {\n return this.status === 400;\n }\n /** The store is read-only (HTTP 403). */\n get isReadOnly(): boolean {\n return this.status === 403;\n }\n /** The writer lock is held by another process (HTTP 409). */\n get isLocked(): boolean {\n return this.status === 409;\n }\n /** Out of capacity: `max_vector_bytes` exceeded or OOM (HTTP 507). */\n get isOutOfCapacity(): boolean {\n return this.status === 507;\n }\n}\n","//! Ergonomic constructors and decoders for the externally-tagged `Value` wire type.\n//\n// Callers should never hand-write `{ Str: \"x\" }`. Use `v.str(\"x\")`, `v.int(5)`,\n// etc., or just pass plain JS values into `attrs` — `encodeValue` normalizes them.\n//\n// One rule is JS's alone. The store's `Int` and `Float` are separate types compared\n// same-type only, but JS has one `number` and `1.0 === 1`, so `Number.isInteger` has to\n// decide. A whole-numbered measurement therefore lands as an `Int` in whichever records\n// it came out round, and a `Float` range filter then skips exactly those: write such a\n// field with `v.float`. Go and Python have the types JS lacks and decide from them.\n\nimport type { AttrInput, DecodedValue, Value } from \"./types.js\";\n\n/** Every tag this SDK version knows, in the order `decodeValue` tries them. */\nconst TAGS = [\"Str\", \"Int\", \"Bool\", \"List\", \"Float\", \"DateTime\"] as const;\n\n/**\n * Value constructors mirroring the `Value` variants. `v.int` requires a safe\n * integer and `v.float` a finite number — `NaN`/`Infinity` have no JSON spelling,\n * and `JSON.stringify` would quietly write `null`.\n */\nexport const v = {\n str: (s: string): Value => ({ Str: s }),\n int: (n: number): Value => {\n if (!Number.isInteger(n)) {\n throw new TypeError(`v.int expects an integer, got ${n}`);\n }\n return { Int: n };\n },\n float: (n: number): Value => {\n if (typeof n !== \"number\" || !Number.isFinite(n)) {\n throw new TypeError(`v.float expects a finite number, got ${n}`);\n }\n return { Float: n };\n },\n bool: (b: boolean): Value => ({ Bool: b }),\n list: (items: string[]): Value => ({ List: items }),\n /**\n * A UTC instant, from a `Date` or a raw epoch-millisecond count. Milliseconds is\n * the wire type, so there is no sub-millisecond precision and no timezone.\n */\n datetime: (when: Date | number): Value => {\n const ms = when instanceof Date ? when.getTime() : when;\n if (!Number.isSafeInteger(ms)) {\n throw new TypeError(\n `v.datetime expects a valid Date or epoch ms, got ${when}`,\n );\n }\n return { DateTime: ms };\n },\n /** The explicit `Null` value — set-but-empty, distinct from an absent key. */\n nil: (): Value => \"Null\",\n} as const;\n\n/** True if `x` is already a wire-tagged {@link Value}. */\nfunction isValue(x: unknown): x is Value {\n if (x === \"Null\") return true;\n if (typeof x !== \"object\" || x === null) return false;\n return TAGS.some((tag) => tag in x);\n}\n\n/**\n * Normalize a caller-supplied {@link AttrInput} into the wire {@link Value} shape.\n * Plain scalars map by type; an already-tagged `Value` passes through unchanged.\n * Throws on a non-finite number, an invalid `Date`, or a non-string list element.\n */\nexport function encodeValue(input: AttrInput): Value {\n if (isValue(input)) return input;\n if (input === null) return \"Null\";\n switch (typeof input) {\n case \"string\":\n return { Str: input };\n case \"boolean\":\n return { Bool: input };\n case \"number\":\n return Number.isInteger(input) ? v.int(input) : v.float(input);\n case \"object\":\n // Date before the array check: both are objects, only one is a list.\n if (input instanceof Date) return v.datetime(input);\n if (Array.isArray(input)) {\n if (!input.every((e) => typeof e === \"string\")) {\n throw new TypeError(\"a List attribute must contain only strings\");\n }\n return { List: input };\n }\n // falls through\n default:\n throw new TypeError(`cannot encode attribute value: ${String(input)}`);\n }\n}\n\n/** Normalize a whole `attrs` map of {@link AttrInput} into wire {@link Value}s. */\nexport function encodeAttrs(\n attrs: Record<string, AttrInput>,\n): Record<string, Value> {\n const out: Record<string, Value> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = encodeValue(val);\n }\n return out;\n}\n\n/** Decode a wire {@link Value} back to a plain JS value. */\nexport function decodeValue(value: Value): DecodedValue {\n if (value === \"Null\") return null;\n if (\"Str\" in value) return value.Str;\n if (\"Int\" in value) return value.Int;\n if (\"Bool\" in value) return value.Bool;\n if (\"List\" in value) return value.List;\n if (\"Float\" in value) return value.Float;\n // A Date, not the raw number: a number would demote every instant to an Int\n // when a decoded attrs map is written back.\n if (\"DateTime\" in value) return new Date(value.DateTime);\n // Unknown tag (forward-compat): hand it back untouched.\n return value as unknown as DecodedValue;\n}\n\n/** Decode a whole wire `attrs` map back to plain JS values. */\nexport function decodeAttrs(\n attrs: Record<string, Value>,\n): Record<string, DecodedValue> {\n const out: Record<string, DecodedValue> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = decodeValue(val);\n }\n return out;\n}\n","//! `NidusClient` — a remote client over the `nidus serve` HTTP API.\n//\n// One method per endpoint (`src/server/mod.rs`). \"Local vs remote\" is just the\n// base URL: point at a local `nidus serve` or any reachable host. Built on the\n// platform-global `fetch`, so it runs unchanged on Node 18+, Deno, Bun, Cloudflare\n// Workers, and browsers — with no runtime dependencies.\n\nimport { decodeAnnotations, type WireAnnotations } from \"./annotations.js\";\nimport { NidusError } from \"./errors.js\";\nimport type {\n AggregateOptions,\n Aggregation,\n BatchSearchOptions,\n ClusterStatus,\n DecodedRecord,\n Filter,\n FilterIndexField,\n FtsField,\n HighlightOptions,\n Hit,\n HybridSearchOptions,\n ListOptions,\n NidusRecord,\n RankBy,\n Readiness,\n RecallOptions,\n RecordInput,\n RememberOptions,\n RememberResult,\n RerankOptions,\n SearchOptions,\n SimilarSearchOptions,\n Stats,\n TextSearchOptions,\n Value,\n} from \"./types.js\";\nimport { decodeAttrs, decodeValue, encodeAttrs } from \"./values.js\";\n\n/** Minimal `fetch` signature the client needs — satisfied by the platform global. */\nexport type FetchLike = (\n input: string,\n init?: RequestInit,\n) => Promise<Response>;\n\n/** Construction options for {@link NidusClient}. */\nexport interface NidusClientOptions {\n /** Base URL of the server, e.g. `http://127.0.0.1:7700`. Trailing slash optional. */\n baseUrl: string;\n /** Bearer token, when the server was started with `--token`. */\n token?: string;\n /** Override the `fetch` implementation (defaults to `globalThis.fetch`). */\n fetch?: FetchLike;\n /** Per-request timeout in milliseconds. Omit (or `0`) to disable. */\n timeoutMs?: number;\n /** Extra headers sent on every request. */\n headers?: Record<string, string>;\n}\n\nexport class NidusClient {\n private readonly baseUrl: string;\n private readonly token?: string;\n private readonly doFetch: FetchLike;\n private readonly timeoutMs: number;\n private readonly extraHeaders: Record<string, string>;\n\n constructor(options: NidusClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError(\"NidusClient requires a baseUrl\");\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.token = options.token;\n this.timeoutMs = options.timeoutMs ?? 0;\n this.extraHeaders = options.headers ?? {};\n const f = options.fetch ?? globalThis.fetch;\n if (typeof f !== \"function\") {\n throw new TypeError(\n \"no fetch available; pass options.fetch (Node < 18, or a custom runtime)\",\n );\n }\n // Bind so a passed `globalThis.fetch` keeps its `this`.\n this.doFetch = f === globalThis.fetch ? f.bind(globalThis) : f;\n }\n\n // ── Admin / introspection ─────────────────────────────────────────────────\n\n /** Liveness check. Returns `true` when the server answers `/health`. */\n async health(): Promise<boolean> {\n try {\n const res = await this.raw(\"GET\", \"/health\");\n return res.ok;\n } catch {\n return false;\n }\n }\n\n /** Store-wide introspection: dimension, distance, ANN config, collections, footprint. */\n stats(): Promise<Stats> {\n return this.request<Stats>(\"GET\", \"/stats\");\n }\n\n /**\n * Readiness: whether this instance can serve. A `503` is the negative answer, not an\n * error, so a poll loop branches on `ready` instead of catching. Other failures throw.\n */\n async ready(): Promise<Readiness> {\n const res = await this.raw(\"GET\", \"/ready\");\n const text = await res.text();\n if (res.status === 503) return { ready: false, reason: extractError(text, 503) };\n if (!res.ok) throw new NidusError(extractError(text, res.status), res.status);\n return JSON.parse(text) as Readiness;\n }\n\n /** Cluster role, writer-handle state, fencing token, commit counter, staleness. */\n cluster(): Promise<ClusterStatus> {\n return this.request<ClusterStatus>(\"GET\", \"/cluster\");\n }\n\n /** List every collection name. */\n collections(): Promise<string[]> {\n return this.request<string[]>(\"GET\", \"/collections\");\n }\n\n /** Create a collection. Idempotent on the server side. */\n async createCollection(name: string): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}`, {});\n }\n\n /** Drop a collection and all its records. */\n async dropCollection(name: string): Promise<void> {\n await this.request(\"DELETE\", `/collections/${enc(name)}`);\n }\n\n /** Read a collection's free-form string metadata. */\n getMeta(name: string): Promise<Record<string, string>> {\n return this.request<Record<string, string>>(\n \"GET\",\n `/collections/${enc(name)}/meta`,\n );\n }\n\n /** Replace a collection's free-form string metadata. */\n async setMeta(name: string, meta: Record<string, string>): Promise<void> {\n await this.request(\"PUT\", `/collections/${enc(name)}/meta`, meta);\n }\n\n // ── Data ──────────────────────────────────────────────────────────────────\n\n /**\n * Insert or replace records (idempotent on `id` within the collection).\n * `attrs` accept plain JS values or `v.*` helpers; they are normalized for you.\n * Returns the number of records upserted.\n */\n async upsert(name: string, records: RecordInput[]): Promise<number> {\n const wire: NidusRecord[] = records.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: encodeAttrs(r.attrs),\n }));\n const res = await this.request<{ upserted: number }>(\n \"POST\",\n `/collections/${enc(name)}/upsert`,\n { records: wire },\n );\n return res.upserted;\n }\n\n /** Delete records by id. Returns the number deleted. */\n async delete(name: string, opts: { ids: string[] }): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { ids: opts.ids },\n );\n return res.deleted;\n }\n\n /** Delete every record matching `filter`. Returns the number deleted. */\n async deleteWhere(name: string, filter: Filter): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { filter },\n );\n return res.deleted;\n }\n\n /** Fetch every record in a collection (attrs decoded to plain JS values). */\n async records(name: string): Promise<DecodedRecord[]> {\n const recs = await this.request<NidusRecord[]>(\n \"GET\",\n `/collections/${enc(name)}/records`,\n );\n return recs.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: decodeAttrs(r.attrs),\n }));\n }\n\n /**\n * Declare the full-text-indexed attribute fields for a collection. A bare string\n * takes the server's BM25/analyzer defaults; an {@link FtsField} object tunes `k1`,\n * `b`, and the analyzer for that field alone.\n */\n async setFtsSchema(\n name: string,\n fields: (string | FtsField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/fts-schema`, {\n fields: fields.map(encodeFtsField),\n });\n }\n\n /**\n * Declare which attribute fields are indexed for the text predicates (`Fuzzy`,\n * `ContainsAllTokens`, `ContainsAnyToken`, `ContainsTokenSequence`, `Regex`). Fields\n * already written are indexed as part of applying the declaration.\n *\n * This changes how fast those predicates run, never what they return: the index\n * proposes candidate documents and the predicate itself still decides. The cost is\n * paid at write time and in memory. Pass an empty array to drop the declaration.\n */\n async setFilterIndex(\n name: string,\n fields: (string | FilterIndexField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/filter-index`, {\n fields: fields.map(encodeFilterIndexField),\n });\n }\n\n // ── Search ──────────────────────────────────────────────────────────────\n\n /** Vector (cosine) nearest-neighbour search. Empty `scope` searches all collections. */\n search(opts: SearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search\", {\n query: opts.query,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Records most like an existing one. The source record itself is never returned. */\n searchSimilar(opts: SimilarSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search/similar\", {\n collection: opts.collection,\n id: opts.id,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n });\n }\n\n /**\n * BM25 full-text search over one indexed field, or over a `clauses` list folded by\n * `combine` (`\"Sum\"` unless said otherwise). Naming the fields both ways is a `400`.\n */\n textSearch(opts: TextSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/text-search\", {\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, query: opts.query }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /**\n * Hybrid search: fuse a vector query and a BM25 text query via RRF. The text leg takes\n * the same single-field / `clauses` choice as {@link NidusClient.textSearch}.\n */\n hybridSearch(opts: HybridSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/hybrid-search\", {\n vector: opts.vector,\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, text: opts.text }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n filter: opts.filter ?? [],\n rrf_k: opts.rrfK,\n candidates: opts.candidates,\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n vector_weight: opts.vectorWeight,\n text_weight: opts.textWeight,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Metadata-only listing (no vector), paginated by `offset`/`limit`. */\n list(opts: ListOptions = {}): Promise<Hit[]> {\n return this.searchRequest(\"/list\", {\n scope: opts.scope ?? [],\n offset: opts.offset,\n limit: opts.limit,\n filter: opts.filter ?? [],\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n order_by: opts.orderBy,\n });\n }\n\n /**\n * Count the records matching a filter and sum the named attributes. Answered from the\n * in-RAM index alone — no record is built and no vector is read.\n */\n async aggregate(opts: AggregateOptions = {}): Promise<Aggregation> {\n const res = await this.request<RawAggregation>(\n \"POST\",\n \"/aggregate\",\n prune({\n scope: opts.scope ?? [],\n filter: opts.filter ?? [],\n sum: opts.sum ?? [],\n group_by: opts.groupBy,\n }),\n );\n // Every sum is an `Int` or a `Float`, both of which decode to a JS number.\n return {\n count: res.count,\n sums: decodeAttrs(res.sums) as Record<string, number>,\n // Kept absent, not `undefined`, so an ungrouped answer is the shape it always was.\n ...(res.groups\n ? {\n groups: res.groups.map((g) => ({\n value: g.value === null ? null : decodeValue(g.value),\n count: g.count,\n sums: decodeAttrs(g.sums) as Record<string, number>,\n })),\n }\n : {}),\n ...(res.groups_truncated ? { groupsTruncated: true } : {}),\n };\n }\n\n /**\n * Answer several vector queries in one round-trip (16 max). Returns one ranking per\n * query in request order, or — with `opts.fuse` — a single array holding the one fused\n * ranking, so the return shape is uniform either way.\n *\n * The server validates the whole batch before running any leg, so a malformed query\n * fails the call rather than returning a partial answer that cannot be told apart.\n */\n async batchSearch(opts: BatchSearchOptions): Promise<Hit[][]> {\n const body = prune({\n queries: opts.queries.map((q) => ({\n query: q.query,\n scope: q.scope ?? [],\n top_k: q.topK,\n offset: q.offset,\n min_score: q.minScore,\n filter: q.filter ?? [],\n exact: q.exact,\n include_attributes: q.includeAttributes,\n exclude_attributes: q.excludeAttributes,\n rank_by: encodeRankBy(q.rankBy),\n limit_per: q.limitPer,\n diversity: q.diversity,\n })),\n fuse: opts.fuse\n ? prune({\n rrf_k: opts.fuse.rrfK,\n weights: opts.fuse.weights,\n top_k: opts.fuse.topK,\n })\n : undefined,\n });\n const res = await this.request<RawBatchSearch>(\n \"POST\",\n \"/search/batch\",\n body,\n );\n return (res.fused ? [res.fused] : (res.results ?? [])).map((hits) =>\n hits.map((h) => this.decodeHit(h)),\n );\n }\n\n // ── Memory (text-native) ──────────────────────────────────────────────────\n //\n // Available only when `nidus serve` was started with an embedder\n // (`--embed-provider …`); otherwise these answer `400`. The server embeds the\n // text/query — the client only sends strings.\n\n /**\n * Embed `text` and upsert it under `id` in `collection` (idempotent on `id`).\n * With `opts.mode === \"summarize\"` the server summarizes first, embeds the\n * summary, and stamps a `nidus.summary` attr (requires the server to have a\n * summarizer). The raw text is always stored under `nidus.text`. `opts.attrs` accept plain JS values or `v.*`\n * helpers; they are normalized for you.\n *\n * Read `id` off the result rather than assuming the one you passed:\n * `opts.dedupeThreshold` can redirect the write onto a near-duplicate.\n */\n async remember(\n collection: string,\n id: string,\n text: string,\n opts: RememberOptions = {},\n ): Promise<RememberResult> {\n const res = await this.request<Partial<RememberResult> | undefined>(\n \"POST\",\n `/collections/${enc(collection)}/remember`,\n prune({\n id,\n text,\n mode: opts.mode,\n attrs: opts.attrs ? encodeAttrs(opts.attrs) : undefined,\n ttl_seconds: opts.ttlSeconds,\n dedupe_threshold: opts.dedupeThreshold,\n }),\n );\n // A server predating the echoed fields answers `{ok, upserted}`; falling back to the\n // requested id keeps that case honest instead of reporting `undefined` as the target.\n return {\n id: res?.id ?? id,\n upserted: res?.upserted ?? 0,\n deduped: res?.deduped ?? false,\n };\n }\n\n /**\n * Embed `query` and vector-search `collection`, best-first (attrs decoded to\n * plain JS values). Refused with a cross-model guard if the collection was\n * written with a different embedder than the server's.\n */\n recall(\n collection: string,\n query: string,\n opts: RecallOptions = {},\n ): Promise<Hit[]> {\n return this.searchRequest(`/collections/${enc(collection)}/recall`, {\n query,\n top_k: opts.topK,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n diversity: opts.diversity,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n // ── Maintenance ───────────────────────────────────────────────────────────\n\n /** Force a durability flush. */\n async flush(): Promise<void> {\n await this.request(\"POST\", \"/flush\", {});\n }\n\n /** Compact the store (reclaim space from deleted/overwritten rows). */\n async compact(): Promise<void> {\n await this.request(\"POST\", \"/compact\", {});\n }\n\n /** Adopt a writer's newer committed state. Returns whether anything was adopted. */\n async refresh(): Promise<boolean> {\n const res = await this.request<{ adopted: boolean }>(\"POST\", \"/refresh\", {});\n return res.adopted;\n }\n\n // ── Internals ─────────────────────────────────────────────────────────────\n\n /** Run a search-family request and decode the resulting hits' attrs. */\n private async searchRequest(\n path: string,\n body: Record<string, unknown>,\n ): Promise<Hit[]> {\n const hits = await this.request<RawHit[]>(\"POST\", path, prune(body));\n return hits.map((h) => this.decodeHit(h));\n }\n\n /** One wire hit into a {@link Hit}. Shared so every search surface decodes identically. */\n private decodeHit(h: RawHit): Hit {\n return {\n collection: h.collection,\n id: h.id,\n score: h.score,\n attrs: decodeAttrs(h.attrs),\n // Kept absent, not `undefined`, so an unannotated hit is the shape it always was.\n ...(h.annotations\n ? { annotations: decodeAnnotations(h.annotations) }\n : {}),\n };\n }\n\n /** Issue a request and parse a JSON body, mapping a non-2xx to {@link NidusError}. */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const res = await this.raw(method, path, body);\n const text = await res.text();\n if (!res.ok) {\n throw new NidusError(extractError(text, res.status), res.status);\n }\n return (text ? JSON.parse(text) : undefined) as T;\n }\n\n /** The bare transport: headers, auth, timeout, and transport-error mapping. */\n private async raw(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<Response> {\n const headers: Record<string, string> = { ...this.extraHeaders };\n if (this.token) headers.authorization = `Bearer ${this.token}`;\n let payload: string | undefined;\n if (body !== undefined) {\n headers[\"content-type\"] = \"application/json\";\n payload = JSON.stringify(body);\n }\n\n const controller = this.timeoutMs > 0 ? new AbortController() : undefined;\n const timer =\n controller && this.timeoutMs > 0\n ? setTimeout(() => controller.abort(), this.timeoutMs)\n : undefined;\n try {\n return await this.doFetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: payload,\n signal: controller?.signal,\n });\n } catch (err) {\n const reason =\n (controller?.signal.aborted ?? false)\n ? `request to ${path} timed out after ${this.timeoutMs}ms`\n : `request to ${path} failed: ${(err as Error).message}`;\n throw new NidusError(reason, 0);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n}\n\n/** A hit as it arrives on the wire, before attrs are decoded. */\ninterface RawHit {\n collection: string;\n id: string;\n score: number;\n attrs: Record<string, Value>;\n annotations?: WireAnnotations;\n}\n\n/** An `/aggregate` response, whose sums arrive as tagged {@link Value}s. */\ninterface RawAggregation {\n count: number;\n sums: Record<string, Value>;\n groups?: {\n value: Value | null;\n count: number;\n sums: Record<string, Value>;\n }[];\n groups_truncated?: boolean;\n}\n\n/** A `/search/batch` response: exactly one of the two fields is present. */\ninterface RawBatchSearch {\n results?: RawHit[][];\n fused?: RawHit[];\n}\n\n/** Encode `rankBy` to its externally-tagged wire form, dropping the knobs left unset. */\nfunction encodeRankBy(rank: RankBy | undefined): unknown {\n if (!rank) return undefined;\n const d = rank.decay;\n return {\n Decay: prune({\n field: d.field,\n origin: d.origin instanceof Date ? d.origin.getTime() : d.origin,\n scale: d.scale,\n decay: d.decay,\n lambda: d.lambda,\n missing: d.missing,\n }),\n };\n}\n\n/** Encode `highlight`: `true` is the empty object the server reads as \"all defaults\". */\nfunction encodeHighlight(h: boolean | HighlightOptions | undefined): unknown {\n if (h === undefined || h === false) return undefined;\n if (h === true) return {};\n return prune({\n max_fragments: h.maxFragments,\n fragment_chars: h.fragmentChars,\n });\n}\n\n/** Encode `rerank`. Undefined sub-fields drop out at `JSON.stringify`, not here. */\nfunction encodeRerank(r: RerankOptions | undefined): unknown {\n if (r === undefined) return undefined;\n return { query: r.query, overscan: r.overscan, text_attr: r.textAttr };\n}\n\n/** Path-segment encode a collection name (allows slashes/spaces in names). */\nfunction enc(name: string): string {\n return encodeURIComponent(name);\n}\n\n/**\n * Encode one `setFtsSchema` field. A string passes through as the server's bare-name\n * form; an object becomes the snake_case body, pruned so an unset knob keeps the\n * server's default rather than being sent as `undefined`.\n */\nfunction encodeFtsField(f: string | FtsField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n k1: f.k1,\n b: f.b,\n language: f.language,\n ascii_folding: f.asciiFolding,\n max_token_len: f.maxTokenLen,\n });\n}\n\n/**\n * Encode one `setFilterIndex` field, on the same bare-name-or-object rule as\n * {@link encodeFtsField}. Pruning matters here: the server defaults both structures to\n * `true`, so sending an explicit `undefined` would be indistinguishable from `false`.\n */\nfunction encodeFilterIndexField(f: string | FilterIndexField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n tokens: f.tokens,\n trigrams: f.trigrams,\n });\n}\n\n/** Drop `undefined` fields so server `#[serde(default)]`s apply instead. */\nfunction prune(body: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, val] of Object.entries(body)) {\n if (val !== undefined) out[k] = val;\n }\n return out;\n}\n\n/** Pull the `{ \"error\": … }` message out of a failed response, or fall back. */\nfunction extractError(text: string, status: number): string {\n try {\n const parsed = JSON.parse(text);\n if (parsed && typeof parsed.error === \"string\") return parsed.error;\n } catch {\n // not JSON — fall through\n }\n return text || `HTTP ${status}`;\n}\n","//! Filter builder producing the bare predicate-array wire shape.\n//\n// A `Filter` is AND-combined predicates; on the wire it is a plain array. Each\n// predicate is a *positive assertion about a present attribute* — an absent key\n// matches nothing, including the negative predicates (`ne`/`notIn`) and ranges.\n// Comparisons are same-type only (Int↔Int numeric, Float↔Float by IEEE, Str↔Str\n// lexical, Bool↔Bool, DateTime↔DateTime as instants), so an operand's encoded type\n// has to match the attribute's: `ge(\"score\", v.float(2))`, not `ge(\"score\", 2)`.\n\nimport type { AttrInput, Filter, Predicate, Value } from \"./types.js\";\nimport { encodeValue } from \"./values.js\";\n\n/**\n * Predicate constructors. Each accepts a plain JS value (auto-normalized) or an\n * explicit `v.*` {@link Value}. Combine results into a {@link Filter} array, or\n * use {@link f.and} for readability.\n */\nexport const f = {\n /** `attrs[key] === value`. */\n eq: (key: string, value: AttrInput): Predicate => ({\n Eq: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is present and `!== value`. */\n ne: (key: string, value: AttrInput): Predicate => ({\n Ne: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `Str` matching the glob pattern (`*`, `?`, `[..]`). */\n glob: (key: string, pattern: string): Predicate => ({ Glob: [key, pattern] }),\n /**\n * {@link f.glob}, ignoring **ASCII** case on both sides — `\"Src/*\"` matches\n * `\"src/main.rs\"`. Non-ASCII is not folded (`É` does not match `é`).\n */\n iglob: (key: string, pattern: string): Predicate => ({\n IGlob: [key, pattern],\n }),\n /** `attrs[key]` equals one of `values`. */\n in: (key: string, values: AttrInput[]): Predicate => ({\n In: [key, values.map(encodeValue)],\n }),\n /** `attrs[key]` is present and equals none of `values`. */\n notIn: (key: string, values: AttrInput[]): Predicate => ({\n NotIn: [key, values.map(encodeValue)],\n }),\n /** `attrs[key] < value` (same-type, orderable). */\n lt: (key: string, value: AttrInput): Predicate => ({\n Lt: [key, encodeValue(value)],\n }),\n /** `attrs[key] <= value` (same-type, orderable). */\n le: (key: string, value: AttrInput): Predicate => ({\n Le: [key, encodeValue(value)],\n }),\n /** `attrs[key] > value` (same-type, orderable). */\n gt: (key: string, value: AttrInput): Predicate => ({\n Gt: [key, encodeValue(value)],\n }),\n /** `attrs[key] >= value` (same-type, orderable). */\n ge: (key: string, value: AttrInput): Predicate => ({\n Ge: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` containing `value` (whole-element, not substring). */\n contains: (key: string, value: AttrInput): Predicate => ({\n Contains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a present `List` not containing `value`. */\n notContains: (key: string, value: AttrInput): Predicate => ({\n NotContains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` sharing at least one element with `values`. */\n containsAny: (key: string, values: AttrInput[]): Predicate => ({\n ContainsAny: [key, values.map(encodeValue)],\n }),\n /** Every sub-predicate holds. `all()` is `true`. */\n all: (...preds: Predicate[]): Predicate => ({ All: preds }),\n /** At least one sub-predicate holds. `any()` is `false`. */\n any: (...preds: Predicate[]): Predicate => ({ Any: preds }),\n /**\n * The sub-predicate does not hold. Differs from {@link f.ne} on an absent key:\n * `not(eq(k, v))` matches a record with no `k`, `ne(k, v)` does not.\n */\n not: (pred: Predicate): Predicate => ({ Not: pred }),\n /**\n * `attrs[key]` is within `maxEdits` Levenshtein edits of `text`, ASCII-case-folded on\n * both sides; a `List` matches if any element does. The only three-element predicate.\n * A `maxEdits` above 8 is refused by the server, not clamped.\n */\n fuzzy: (key: string, text: string, maxEdits: number): Predicate => ({\n Fuzzy: [key, text, maxEdits],\n }),\n /**\n * Every token of `text` appears among `attrs[key]`'s tokens, in any order. Tokens are\n * ASCII-case-folded runs of alphanumerics; a `List` matches if any single element does.\n */\n containsAllTokens: (key: string, text: string): Predicate => ({\n ContainsAllTokens: [key, text],\n }),\n /** At least one token of `text` appears among `attrs[key]`'s tokens. Empty never matches. */\n containsAnyToken: (key: string, text: string): Predicate => ({\n ContainsAnyToken: [key, text],\n }),\n /** `text`'s tokens appear consecutively and in order — a phrase match. */\n containsTokenSequence: (key: string, text: string): Predicate => ({\n ContainsTokenSequence: [key, text],\n }),\n /**\n * `attrs[key]` matches the regular expression, **anchored at both ends** like\n * {@link f.glob} — `.*` opts back into a substring search, and `(?i)` into case folding.\n * The syntax is Rust's `regex`, not JS's: no backreferences and no lookaround.\n */\n regex: (key: string, pattern: string): Predicate => ({ Regex: [key, pattern] }),\n /** Collect predicates into a {@link Filter} (purely sugar — they already AND). */\n and: (...preds: Predicate[]): Filter => preds,\n} as const;\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AoC;AAAA,IAC7D,aAAa,CAAC,KAAK,OAAO,IAAI,WAAW,CAAC;AAAA,EAC5C;AAAA;AAAA,EAEA,KAAK,IAAI,WAAmC,EAAE,KAAK,MAAM;AAAA;AAAA,EAEzD,KAAK,IAAI,WAAmC,EAAE,KAAK,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKzD,KAAK,CAAC,UAAgC,EAAE,KAAK,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlD,OAAO,CAAC,KAAa,MAAc,cAAiC;AAAA,IAClE,OAAO,CAAC,KAAK,MAAM,QAAQ;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,mBAAmB,CAAC,KAAa,UAA6B;AAAA,IAC5D,mBAAmB,CAAC,KAAK,IAAI;AAAA,EAC/B;AAAA;AAAA,EAEA,kBAAkB,CAAC,KAAa,UAA6B;AAAA,IAC3D,kBAAkB,CAAC,KAAK,IAAI;AAAA,EAC9B;AAAA;AAAA,EAEA,uBAAuB,CAAC,KAAa,UAA6B;AAAA,IAChE,uBAAuB,CAAC,KAAK,IAAI;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,CAAC,KAAa,aAAgC,EAAE,OAAO,CAAC,KAAK,OAAO,EAAE;AAAA;AAAA,EAE7E,KAAK,IAAI,UAA+B;AAC1C;","names":["f"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/annotations.ts","../src/errors.ts","../src/values.ts","../src/client.ts","../src/filter.ts"],"sourcesContent":["//! `@duckedup/nidus` — the JavaScript/TypeScript client for nidus.\n//\n// A zero-dependency, cross-runtime remote client over the `nidus serve` HTTP API.\n// Point a {@link NidusClient} at a local or remote server, then upsert and search.\n\nexport { NidusClient } from \"./client.js\";\nexport type { FetchLike, NidusClientOptions } from \"./client.js\";\nexport { NidusError } from \"./errors.js\";\nexport { f } from \"./filter.js\";\nexport { decodeAttrs, decodeValue, encodeAttrs, encodeValue, v } from \"./values.js\";\nexport type {\n AggregateOptions,\n Aggregation,\n AnnInfo,\n AnnotationOptions,\n Annotations,\n AttrInput,\n ClauseScore,\n ClusterStatus,\n Decay,\n DecodedRecord,\n DecodedValue,\n Expand,\n Filter,\n FilterIndexField,\n Footprint,\n Fragment,\n FtsCombine,\n FtsField,\n Highlight,\n HighlightOptions,\n Hit,\n HybridQuerySpelling,\n HybridSearchBase,\n HybridSearchOptions,\n LegScore,\n LimitPer,\n ListOptions,\n NidusRecord,\n OrderBy,\n Predicate,\n ProjectionOptions,\n RankBy,\n RankingOptions,\n Readiness,\n RecallOptions,\n RecordInput,\n RememberOptions,\n RememberResult,\n RerankOptions,\n Rollup,\n SearchOptions,\n SimilarSearchOptions,\n Stats,\n TextClause,\n TextQuerySpelling,\n TextSearchBase,\n TextSearchOptions,\n Value,\n} from \"./types.js\";\n","//! Decoding a hit's optional annotations — the opt-in \"why did this match\".\n//\n// One rule here is JS's alone. The server reports a highlight span as a **UTF-8 byte**\n// range into the fragment text, but a JS string is indexed in UTF-16 code units, so\n// `text.slice(...span)` on a raw span is wrong for any non-ASCII excerpt. Converted here,\n// once, so a caller's obvious slice is the right one.\n\nimport type { Annotations, Fragment, Highlight } from \"./types.js\";\n\n/** A fragment as it arrives: `spans` are UTF-8 byte offsets into `text`. */\ninterface WireFragment {\n text: string;\n spans: [number, number][];\n}\n\ninterface WireHighlight {\n field: string;\n fragments: WireFragment[];\n}\n\n/** A hit's annotations as they arrive, before the span offsets are converted. */\nexport interface WireAnnotations {\n vector?: { rank: number; score: number };\n text?: { rank: number; score: number };\n clauses?: { field: string; score: number }[];\n highlights?: WireHighlight[];\n}\n\n/**\n * Decode a hit's annotations, converting every highlight span to JS string indices. The\n * parts the server omitted stay omitted rather than becoming empty arrays.\n */\nexport function decodeAnnotations(a: WireAnnotations): Annotations {\n const out: Annotations = {};\n if (a.vector) out.vector = a.vector;\n if (a.text) out.text = a.text;\n if (a.clauses) out.clauses = a.clauses;\n if (a.highlights) out.highlights = a.highlights.map(decodeHighlight);\n return out;\n}\n\nfunction decodeHighlight(h: WireHighlight): Highlight {\n return { field: h.field, fragments: h.fragments.map(decodeFragment) };\n}\n\nfunction decodeFragment(fr: WireFragment): Fragment {\n return { text: fr.text, spans: toStringIndices(fr.text, fr.spans) };\n}\n\n/**\n * Convert UTF-8 byte ranges into `text` to JS string indices (UTF-16 code units), so\n * `text.slice(...span)` yields the matched term. An all-ASCII excerpt needs no conversion\n * and is the common case, so it is detected before any table is built.\n */\nexport function toStringIndices(\n text: string,\n spans: [number, number][],\n): [number, number][] {\n if (spans.length === 0 || isAscii(text)) return spans;\n const index = byteToUnit(text);\n const at = (b: number): number =>\n index[Math.min(Math.max(b, 0), index.length - 1)]!;\n return spans.map(([start, end]): [number, number] => [at(start), at(end)]);\n}\n\n/** One entry per byte of `text` (plus its end), holding that byte's UTF-16 index. */\nfunction byteToUnit(text: string): number[] {\n const index: number[] = [];\n let unit = 0;\n // A byte *inside* a codepoint maps to that codepoint's start. Spans land on token\n // boundaries, so this only keeps a malformed offset from landing mid-surrogate.\n for (const ch of text) {\n for (let n = utf8Len(ch.codePointAt(0)!); n > 0; n--) index.push(unit);\n unit += ch.length;\n }\n index.push(unit);\n return index;\n}\n\nfunction utf8Len(codePoint: number): number {\n if (codePoint < 0x80) return 1;\n if (codePoint < 0x800) return 2;\n return codePoint < 0x10000 ? 3 : 4;\n}\n\n/** True when every code unit is ASCII, i.e. byte offsets already *are* string indices. */\nfunction isAscii(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) > 0x7f) return false;\n }\n return true;\n}\n","//! Error type carrying the HTTP status the server reported.\n//\n// The server replies to a failed request with `{ \"error\": <message> }` and a\n// meaningful status (`src/server/mod.rs#classify`): 400 dimension mismatch,\n// 403 read-only store, 409 writer-lock conflict, 507 capacity/OOM, 500 otherwise.\n// Callers branch on `.status` to tell a client fault from a server fault.\n\n/** An error returned by a `nidus` server, or a transport failure reaching it. */\nexport class NidusError extends Error {\n /** The HTTP status code, or `0` for a transport/timeout failure (no response). */\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = \"NidusError\";\n this.status = status;\n }\n\n /** A malformed request the server rejected (HTTP 400). */\n get isBadRequest(): boolean {\n return this.status === 400;\n }\n /** The store is read-only (HTTP 403). */\n get isReadOnly(): boolean {\n return this.status === 403;\n }\n /** The writer lock is held by another process (HTTP 409). */\n get isLocked(): boolean {\n return this.status === 409;\n }\n /** Out of capacity: `max_vector_bytes` exceeded or OOM (HTTP 507). */\n get isOutOfCapacity(): boolean {\n return this.status === 507;\n }\n}\n","//! Ergonomic constructors and decoders for the externally-tagged `Value` wire type.\n//\n// Callers should never hand-write `{ Str: \"x\" }`. Use `v.str(\"x\")`, `v.int(5)`,\n// etc., or just pass plain JS values into `attrs` — `encodeValue` normalizes them.\n//\n// One rule is JS's alone. The store's `Int` and `Float` are separate types compared\n// same-type only, but JS has one `number` and `1.0 === 1`, so `Number.isInteger` has to\n// decide. A whole-numbered measurement therefore lands as an `Int` in whichever records\n// it came out round, and a `Float` range filter then skips exactly those: write such a\n// field with `v.float`. Go and Python have the types JS lacks and decide from them.\n\nimport type { AttrInput, DecodedValue, Value } from \"./types.js\";\n\n/** Every tag this SDK version knows, in the order `decodeValue` tries them. */\nconst TAGS = [\"Str\", \"Int\", \"Bool\", \"List\", \"Float\", \"DateTime\"] as const;\n\n/**\n * Value constructors mirroring the `Value` variants. `v.int` requires a safe\n * integer and `v.float` a finite number — `NaN`/`Infinity` have no JSON spelling,\n * and `JSON.stringify` would quietly write `null`.\n */\nexport const v = {\n str: (s: string): Value => ({ Str: s }),\n int: (n: number): Value => {\n if (!Number.isInteger(n)) {\n throw new TypeError(`v.int expects an integer, got ${n}`);\n }\n return { Int: n };\n },\n float: (n: number): Value => {\n if (typeof n !== \"number\" || !Number.isFinite(n)) {\n throw new TypeError(`v.float expects a finite number, got ${n}`);\n }\n return { Float: n };\n },\n bool: (b: boolean): Value => ({ Bool: b }),\n list: (items: string[]): Value => ({ List: items }),\n /**\n * A UTC instant, from a `Date` or a raw epoch-millisecond count. Milliseconds is\n * the wire type, so there is no sub-millisecond precision and no timezone.\n */\n datetime: (when: Date | number): Value => {\n const ms = when instanceof Date ? when.getTime() : when;\n if (!Number.isSafeInteger(ms)) {\n throw new TypeError(\n `v.datetime expects a valid Date or epoch ms, got ${when}`,\n );\n }\n return { DateTime: ms };\n },\n /** The explicit `Null` value — set-but-empty, distinct from an absent key. */\n nil: (): Value => \"Null\",\n} as const;\n\n/** True if `x` is already a wire-tagged {@link Value}. */\nfunction isValue(x: unknown): x is Value {\n if (x === \"Null\") return true;\n if (typeof x !== \"object\" || x === null) return false;\n return TAGS.some((tag) => tag in x);\n}\n\n/**\n * Normalize a caller-supplied {@link AttrInput} into the wire {@link Value} shape.\n * Plain scalars map by type; an already-tagged `Value` passes through unchanged.\n * Throws on a non-finite number, an invalid `Date`, or a non-string list element.\n */\nexport function encodeValue(input: AttrInput): Value {\n if (isValue(input)) return input;\n if (input === null) return \"Null\";\n switch (typeof input) {\n case \"string\":\n return { Str: input };\n case \"boolean\":\n return { Bool: input };\n case \"number\":\n return Number.isInteger(input) ? v.int(input) : v.float(input);\n case \"object\":\n // Date before the array check: both are objects, only one is a list.\n if (input instanceof Date) return v.datetime(input);\n if (Array.isArray(input)) {\n if (!input.every((e) => typeof e === \"string\")) {\n throw new TypeError(\"a List attribute must contain only strings\");\n }\n return { List: input };\n }\n // falls through\n default:\n throw new TypeError(`cannot encode attribute value: ${String(input)}`);\n }\n}\n\n/** Normalize a whole `attrs` map of {@link AttrInput} into wire {@link Value}s. */\nexport function encodeAttrs(\n attrs: Record<string, AttrInput>,\n): Record<string, Value> {\n const out: Record<string, Value> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = encodeValue(val);\n }\n return out;\n}\n\n/** Decode a wire {@link Value} back to a plain JS value. */\nexport function decodeValue(value: Value): DecodedValue {\n if (value === \"Null\") return null;\n if (\"Str\" in value) return value.Str;\n if (\"Int\" in value) return value.Int;\n if (\"Bool\" in value) return value.Bool;\n if (\"List\" in value) return value.List;\n if (\"Float\" in value) return value.Float;\n // A Date, not the raw number: a number would demote every instant to an Int\n // when a decoded attrs map is written back.\n if (\"DateTime\" in value) return new Date(value.DateTime);\n // Unknown tag (forward-compat): hand it back untouched.\n return value as unknown as DecodedValue;\n}\n\n/** Decode a whole wire `attrs` map back to plain JS values. */\nexport function decodeAttrs(\n attrs: Record<string, Value>,\n): Record<string, DecodedValue> {\n const out: Record<string, DecodedValue> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = decodeValue(val);\n }\n return out;\n}\n","//! `NidusClient` — a remote client over the `nidus serve` HTTP API.\n//\n// One method per endpoint (`src/server/mod.rs`). \"Local vs remote\" is just the\n// base URL: point at a local `nidus serve` or any reachable host. Built on the\n// platform-global `fetch`, so it runs unchanged on Node 18+, Deno, Bun, Cloudflare\n// Workers, and browsers — with no runtime dependencies.\n\nimport { decodeAnnotations, type WireAnnotations } from \"./annotations.js\";\nimport { NidusError } from \"./errors.js\";\nimport type {\n AggregateOptions,\n Aggregation,\n BatchSearchOptions,\n ClusterStatus,\n DecodedRecord,\n Expand,\n Filter,\n FilterIndexField,\n FtsField,\n HighlightOptions,\n Hit,\n HybridSearchOptions,\n ListOptions,\n NidusRecord,\n RankBy,\n Readiness,\n RecallOptions,\n RecordInput,\n RememberOptions,\n RememberResult,\n RerankOptions,\n Rollup,\n SearchOptions,\n SimilarSearchOptions,\n Stats,\n TextSearchOptions,\n Value,\n} from \"./types.js\";\nimport { decodeAttrs, decodeValue, encodeAttrs } from \"./values.js\";\n\n/** Minimal `fetch` signature the client needs — satisfied by the platform global. */\nexport type FetchLike = (\n input: string,\n init?: RequestInit,\n) => Promise<Response>;\n\n/** Construction options for {@link NidusClient}. */\nexport interface NidusClientOptions {\n /** Base URL of the server, e.g. `http://127.0.0.1:7700`. Trailing slash optional. */\n baseUrl: string;\n /** Bearer token, when the server was started with `--token`. */\n token?: string;\n /** Override the `fetch` implementation (defaults to `globalThis.fetch`). */\n fetch?: FetchLike;\n /** Per-request timeout in milliseconds. Omit (or `0`) to disable. */\n timeoutMs?: number;\n /** Extra headers sent on every request. */\n headers?: Record<string, string>;\n}\n\nexport class NidusClient {\n private readonly baseUrl: string;\n private readonly token?: string;\n private readonly doFetch: FetchLike;\n private readonly timeoutMs: number;\n private readonly extraHeaders: Record<string, string>;\n\n constructor(options: NidusClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError(\"NidusClient requires a baseUrl\");\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.token = options.token;\n this.timeoutMs = options.timeoutMs ?? 0;\n this.extraHeaders = options.headers ?? {};\n const f = options.fetch ?? globalThis.fetch;\n if (typeof f !== \"function\") {\n throw new TypeError(\n \"no fetch available; pass options.fetch (Node < 18, or a custom runtime)\",\n );\n }\n // Bind so a passed `globalThis.fetch` keeps its `this`.\n this.doFetch = f === globalThis.fetch ? f.bind(globalThis) : f;\n }\n\n // ── Admin / introspection ─────────────────────────────────────────────────\n\n /** Liveness check. Returns `true` when the server answers `/health`. */\n async health(): Promise<boolean> {\n try {\n const res = await this.raw(\"GET\", \"/health\");\n return res.ok;\n } catch {\n return false;\n }\n }\n\n /** Store-wide introspection: dimension, distance, ANN config, collections, footprint. */\n stats(): Promise<Stats> {\n return this.request<Stats>(\"GET\", \"/stats\");\n }\n\n /**\n * Readiness: whether this instance can serve. A `503` is the negative answer, not an\n * error, so a poll loop branches on `ready` instead of catching. Other failures throw.\n */\n async ready(): Promise<Readiness> {\n const res = await this.raw(\"GET\", \"/ready\");\n const text = await res.text();\n if (res.status === 503) return { ready: false, reason: extractError(text, 503) };\n if (!res.ok) throw new NidusError(extractError(text, res.status), res.status);\n return JSON.parse(text) as Readiness;\n }\n\n /** Cluster role, writer-handle state, fencing token, commit counter, staleness. */\n cluster(): Promise<ClusterStatus> {\n return this.request<ClusterStatus>(\"GET\", \"/cluster\");\n }\n\n /** List every collection name. */\n collections(): Promise<string[]> {\n return this.request<string[]>(\"GET\", \"/collections\");\n }\n\n /** Create a collection. Idempotent on the server side. */\n async createCollection(name: string): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}`, {});\n }\n\n /** Drop a collection and all its records. */\n async dropCollection(name: string): Promise<void> {\n await this.request(\"DELETE\", `/collections/${enc(name)}`);\n }\n\n /** Read a collection's free-form string metadata. */\n getMeta(name: string): Promise<Record<string, string>> {\n return this.request<Record<string, string>>(\n \"GET\",\n `/collections/${enc(name)}/meta`,\n );\n }\n\n /** Replace a collection's free-form string metadata. */\n async setMeta(name: string, meta: Record<string, string>): Promise<void> {\n await this.request(\"PUT\", `/collections/${enc(name)}/meta`, meta);\n }\n\n // ── Data ──────────────────────────────────────────────────────────────────\n\n /**\n * Insert or replace records (idempotent on `id` within the collection).\n * `attrs` accept plain JS values or `v.*` helpers; they are normalized for you.\n * Returns the number of records upserted.\n */\n async upsert(name: string, records: RecordInput[]): Promise<number> {\n const wire: NidusRecord[] = records.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: encodeAttrs(r.attrs),\n }));\n const res = await this.request<{ upserted: number }>(\n \"POST\",\n `/collections/${enc(name)}/upsert`,\n { records: wire },\n );\n return res.upserted;\n }\n\n /** Delete records by id. Returns the number deleted. */\n async delete(name: string, opts: { ids: string[] }): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { ids: opts.ids },\n );\n return res.deleted;\n }\n\n /** Delete every record matching `filter`. Returns the number deleted. */\n async deleteWhere(name: string, filter: Filter): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { filter },\n );\n return res.deleted;\n }\n\n /** Fetch every record in a collection (attrs decoded to plain JS values). */\n async records(name: string): Promise<DecodedRecord[]> {\n const recs = await this.request<NidusRecord[]>(\n \"GET\",\n `/collections/${enc(name)}/records`,\n );\n return recs.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: decodeAttrs(r.attrs),\n }));\n }\n\n /**\n * Declare the full-text-indexed attribute fields for a collection. A bare string\n * takes the server's BM25/analyzer defaults; an {@link FtsField} object tunes `k1`,\n * `b`, and the analyzer for that field alone.\n */\n async setFtsSchema(\n name: string,\n fields: (string | FtsField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/fts-schema`, {\n fields: fields.map(encodeFtsField),\n });\n }\n\n /**\n * Declare which attribute fields are indexed for the text predicates (`Fuzzy`,\n * `ContainsAllTokens`, `ContainsAnyToken`, `ContainsTokenSequence`, `Regex`). Fields\n * already written are indexed as part of applying the declaration.\n *\n * This changes how fast those predicates run, never what they return: the index\n * proposes candidate documents and the predicate itself still decides. The cost is\n * paid at write time and in memory. Pass an empty array to drop the declaration.\n */\n async setFilterIndex(\n name: string,\n fields: (string | FilterIndexField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/filter-index`, {\n fields: fields.map(encodeFilterIndexField),\n });\n }\n\n // ── Search ──────────────────────────────────────────────────────────────\n\n /** Vector (cosine) nearest-neighbour search. Empty `scope` searches all collections. */\n search(opts: SearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search\", {\n query: opts.query,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n expand: encodeExpand(opts.expand),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Records most like an existing one. The source record itself is never returned. */\n searchSimilar(opts: SimilarSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search/similar\", {\n collection: opts.collection,\n id: opts.id,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n expand: encodeExpand(opts.expand),\n });\n }\n\n /**\n * BM25 full-text search over one indexed field, or over a `clauses` list folded by\n * `combine` (`\"Sum\"` unless said otherwise). Naming the fields both ways is a `400`.\n */\n textSearch(opts: TextSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/text-search\", {\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, query: opts.query }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n expand: encodeExpand(opts.expand),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /**\n * Hybrid search: fuse a vector query and a BM25 text query via RRF. The text leg takes\n * the same single-field / `clauses` choice as {@link NidusClient.textSearch}.\n */\n hybridSearch(opts: HybridSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/hybrid-search\", {\n vector: opts.vector,\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, text: opts.text }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n filter: opts.filter ?? [],\n rrf_k: opts.rrfK,\n candidates: opts.candidates,\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n vector_weight: opts.vectorWeight,\n text_weight: opts.textWeight,\n expand: encodeExpand(opts.expand),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Metadata-only listing (no vector), paginated by `offset`/`limit`. */\n list(opts: ListOptions = {}): Promise<Hit[]> {\n return this.searchRequest(\"/list\", {\n scope: opts.scope ?? [],\n offset: opts.offset,\n limit: opts.limit,\n filter: opts.filter ?? [],\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n order_by: opts.orderBy,\n });\n }\n\n /**\n * Count the records matching a filter and sum the named attributes. Answered from the\n * in-RAM index alone — no record is built and no vector is read.\n */\n async aggregate(opts: AggregateOptions = {}): Promise<Aggregation> {\n const res = await this.request<RawAggregation>(\n \"POST\",\n \"/aggregate\",\n prune({\n scope: opts.scope ?? [],\n filter: opts.filter ?? [],\n sum: opts.sum ?? [],\n group_by: opts.groupBy,\n }),\n );\n // Every sum is an `Int` or a `Float`, both of which decode to a JS number.\n return {\n count: res.count,\n sums: decodeAttrs(res.sums) as Record<string, number>,\n // Kept absent, not `undefined`, so an ungrouped answer is the shape it always was.\n ...(res.groups\n ? {\n groups: res.groups.map((g) => ({\n value: g.value === null ? null : decodeValue(g.value),\n count: g.count,\n sums: decodeAttrs(g.sums) as Record<string, number>,\n })),\n }\n : {}),\n ...(res.groups_truncated ? { groupsTruncated: true } : {}),\n };\n }\n\n /**\n * Answer several vector queries in one round-trip (16 max). Returns one ranking per\n * query in request order, or — with `opts.fuse` — a single array holding the one fused\n * ranking, so the return shape is uniform either way.\n *\n * The server validates the whole batch before running any leg, so a malformed query\n * fails the call rather than returning a partial answer that cannot be told apart.\n */\n async batchSearch(opts: BatchSearchOptions): Promise<Hit[][]> {\n const body = prune({\n queries: opts.queries.map((q) => ({\n query: q.query,\n scope: q.scope ?? [],\n top_k: q.topK,\n offset: q.offset,\n min_score: q.minScore,\n filter: q.filter ?? [],\n exact: q.exact,\n include_attributes: q.includeAttributes,\n exclude_attributes: q.excludeAttributes,\n rank_by: encodeRankBy(q.rankBy),\n limit_per: q.limitPer,\n diversity: q.diversity,\n expand: encodeExpand(q.expand),\n })),\n fuse: opts.fuse\n ? prune({\n rrf_k: opts.fuse.rrfK,\n weights: opts.fuse.weights,\n top_k: opts.fuse.topK,\n })\n : undefined,\n });\n const res = await this.request<RawBatchSearch>(\n \"POST\",\n \"/search/batch\",\n body,\n );\n return (res.fused ? [res.fused] : (res.results ?? [])).map((hits) =>\n hits.map((h) => this.decodeHit(h)),\n );\n }\n\n // ── Memory (text-native) ──────────────────────────────────────────────────\n //\n // Available only when `nidus serve` was started with an embedder\n // (`--embed-provider …`); otherwise these answer `400`. The server embeds the\n // text/query — the client only sends strings.\n\n /**\n * Embed `text` and upsert it under `id` in `collection` (idempotent on `id`).\n * With `opts.mode === \"summarize\"` the server summarizes first, embeds the\n * summary, and stamps a `nidus.summary` attr (requires the server to have a\n * summarizer). The raw text is always stored under `nidus.text`. `opts.attrs` accept plain JS values or `v.*`\n * helpers; they are normalized for you.\n *\n * Read `id` off the result rather than assuming the one you passed:\n * `opts.dedupeThreshold` can redirect the write onto a near-duplicate.\n */\n async remember(\n collection: string,\n id: string,\n text: string,\n opts: RememberOptions = {},\n ): Promise<RememberResult> {\n const res = await this.request<Partial<RememberResult> | undefined>(\n \"POST\",\n `/collections/${enc(collection)}/remember`,\n prune({\n id,\n text,\n mode: opts.mode,\n attrs: opts.attrs ? encodeAttrs(opts.attrs) : undefined,\n ttl_seconds: opts.ttlSeconds,\n dedupe_threshold: opts.dedupeThreshold,\n }),\n );\n // A server predating the echoed fields answers `{ok, upserted}`; falling back to the\n // requested id keeps that case honest instead of reporting `undefined` as the target.\n return {\n id: res?.id ?? id,\n upserted: res?.upserted ?? 0,\n deduped: res?.deduped ?? false,\n };\n }\n\n /**\n * Embed `query` and vector-search `collection`, best-first (attrs decoded to\n * plain JS values). Refused with a cross-model guard if the collection was\n * written with a different embedder than the server's.\n */\n recall(\n collection: string,\n query: string,\n opts: RecallOptions = {},\n ): Promise<Hit[]> {\n return this.searchRequest(`/collections/${enc(collection)}/recall`, {\n query,\n top_k: opts.topK,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n diversity: opts.diversity,\n rollup: encodeRollup(opts.rollup),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n // ── Maintenance ───────────────────────────────────────────────────────────\n\n /** Force a durability flush. */\n async flush(): Promise<void> {\n await this.request(\"POST\", \"/flush\", {});\n }\n\n /** Compact the store (reclaim space from deleted/overwritten rows). */\n async compact(): Promise<void> {\n await this.request(\"POST\", \"/compact\", {});\n }\n\n /** Adopt a writer's newer committed state. Returns whether anything was adopted. */\n async refresh(): Promise<boolean> {\n const res = await this.request<{ adopted: boolean }>(\"POST\", \"/refresh\", {});\n return res.adopted;\n }\n\n // ── Internals ─────────────────────────────────────────────────────────────\n\n /** Run a search-family request and decode the resulting hits' attrs. */\n private async searchRequest(\n path: string,\n body: Record<string, unknown>,\n ): Promise<Hit[]> {\n const hits = await this.request<RawHit[]>(\"POST\", path, prune(body));\n return hits.map((h) => this.decodeHit(h));\n }\n\n /** One wire hit into a {@link Hit}. Shared so every search surface decodes identically. */\n private decodeHit(h: RawHit): Hit {\n return {\n collection: h.collection,\n id: h.id,\n score: h.score,\n attrs: decodeAttrs(h.attrs),\n // Kept absent, not `undefined`, so an unannotated hit is the shape it always was.\n ...(h.annotations\n ? { annotations: decodeAnnotations(h.annotations) }\n : {}),\n ...(h.context !== undefined ? { context: h.context } : {}),\n };\n }\n\n /** Issue a request and parse a JSON body, mapping a non-2xx to {@link NidusError}. */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const res = await this.raw(method, path, body);\n const text = await res.text();\n if (!res.ok) {\n throw new NidusError(extractError(text, res.status), res.status);\n }\n return (text ? JSON.parse(text) : undefined) as T;\n }\n\n /** The bare transport: headers, auth, timeout, and transport-error mapping. */\n private async raw(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<Response> {\n const headers: Record<string, string> = { ...this.extraHeaders };\n if (this.token) headers.authorization = `Bearer ${this.token}`;\n let payload: string | undefined;\n if (body !== undefined) {\n headers[\"content-type\"] = \"application/json\";\n payload = JSON.stringify(body);\n }\n\n const controller = this.timeoutMs > 0 ? new AbortController() : undefined;\n const timer =\n controller && this.timeoutMs > 0\n ? setTimeout(() => controller.abort(), this.timeoutMs)\n : undefined;\n try {\n return await this.doFetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: payload,\n signal: controller?.signal,\n });\n } catch (err) {\n const reason =\n (controller?.signal.aborted ?? false)\n ? `request to ${path} timed out after ${this.timeoutMs}ms`\n : `request to ${path} failed: ${(err as Error).message}`;\n throw new NidusError(reason, 0);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n}\n\n/** A hit as it arrives on the wire, before attrs are decoded. */\ninterface RawHit {\n collection: string;\n id: string;\n score: number;\n attrs: Record<string, Value>;\n annotations?: WireAnnotations;\n context?: string;\n}\n\n/** An `/aggregate` response, whose sums arrive as tagged {@link Value}s. */\ninterface RawAggregation {\n count: number;\n sums: Record<string, Value>;\n groups?: {\n value: Value | null;\n count: number;\n sums: Record<string, Value>;\n }[];\n groups_truncated?: boolean;\n}\n\n/** A `/search/batch` response: exactly one of the two fields is present. */\ninterface RawBatchSearch {\n results?: RawHit[][];\n fused?: RawHit[];\n}\n\n/** Encode `rankBy` to its externally-tagged wire form, dropping the knobs left unset. */\n/** camelCase → the wire's snake_case, omitting the object entirely when unset. */\nfunction encodeExpand(e: Expand | undefined): unknown {\n if (!e) return undefined;\n return prune({\n radius: e.radius,\n parent_field: e.parentField,\n index_field: e.indexField,\n text_field: e.textField,\n });\n}\n\nfunction encodeRollup(r: Rollup | undefined): unknown {\n if (!r) return undefined;\n return prune({ per_parent: r.perParent, neighbours: r.neighbours });\n}\n\nfunction encodeRankBy(rank: RankBy | undefined): unknown {\n if (!rank) return undefined;\n const d = rank.decay;\n return {\n Decay: prune({\n field: d.field,\n origin: d.origin instanceof Date ? d.origin.getTime() : d.origin,\n scale: d.scale,\n decay: d.decay,\n lambda: d.lambda,\n missing: d.missing,\n }),\n };\n}\n\n/** Encode `highlight`: `true` is the empty object the server reads as \"all defaults\". */\nfunction encodeHighlight(h: boolean | HighlightOptions | undefined): unknown {\n if (h === undefined || h === false) return undefined;\n if (h === true) return {};\n return prune({\n max_fragments: h.maxFragments,\n fragment_chars: h.fragmentChars,\n });\n}\n\n/** Encode `rerank`. Undefined sub-fields drop out at `JSON.stringify`, not here. */\nfunction encodeRerank(r: RerankOptions | undefined): unknown {\n if (r === undefined) return undefined;\n return { query: r.query, overscan: r.overscan, text_attr: r.textAttr };\n}\n\n/** Path-segment encode a collection name (allows slashes/spaces in names). */\nfunction enc(name: string): string {\n return encodeURIComponent(name);\n}\n\n/**\n * Encode one `setFtsSchema` field. A string passes through as the server's bare-name\n * form; an object becomes the snake_case body, pruned so an unset knob keeps the\n * server's default rather than being sent as `undefined`.\n */\nfunction encodeFtsField(f: string | FtsField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n k1: f.k1,\n b: f.b,\n language: f.language,\n ascii_folding: f.asciiFolding,\n max_token_len: f.maxTokenLen,\n });\n}\n\n/**\n * Encode one `setFilterIndex` field, on the same bare-name-or-object rule as\n * {@link encodeFtsField}. Pruning matters here: the server defaults both structures to\n * `true`, so sending an explicit `undefined` would be indistinguishable from `false`.\n */\nfunction encodeFilterIndexField(f: string | FilterIndexField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n tokens: f.tokens,\n trigrams: f.trigrams,\n });\n}\n\n/** Drop `undefined` fields so server `#[serde(default)]`s apply instead. */\nfunction prune(body: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, val] of Object.entries(body)) {\n if (val !== undefined) out[k] = val;\n }\n return out;\n}\n\n/** Pull the `{ \"error\": … }` message out of a failed response, or fall back. */\nfunction extractError(text: string, status: number): string {\n try {\n const parsed = JSON.parse(text);\n if (parsed && typeof parsed.error === \"string\") return parsed.error;\n } catch {\n // not JSON — fall through\n }\n return text || `HTTP ${status}`;\n}\n","//! Filter builder producing the bare predicate-array wire shape.\n//\n// A `Filter` is AND-combined predicates; on the wire it is a plain array. Each\n// predicate is a *positive assertion about a present attribute* — an absent key\n// matches nothing, including the negative predicates (`ne`/`notIn`) and ranges.\n// Comparisons are same-type only (Int↔Int numeric, Float↔Float by IEEE, Str↔Str\n// lexical, Bool↔Bool, DateTime↔DateTime as instants), so an operand's encoded type\n// has to match the attribute's: `ge(\"score\", v.float(2))`, not `ge(\"score\", 2)`.\n\nimport type { AttrInput, Filter, Predicate, Value } from \"./types.js\";\nimport { encodeValue } from \"./values.js\";\n\n/**\n * Predicate constructors. Each accepts a plain JS value (auto-normalized) or an\n * explicit `v.*` {@link Value}. Combine results into a {@link Filter} array, or\n * use {@link f.and} for readability.\n */\nexport const f = {\n /** `attrs[key] === value`. */\n eq: (key: string, value: AttrInput): Predicate => ({\n Eq: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is present and `!== value`. */\n ne: (key: string, value: AttrInput): Predicate => ({\n Ne: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `Str` matching the glob pattern (`*`, `?`, `[..]`). */\n glob: (key: string, pattern: string): Predicate => ({ Glob: [key, pattern] }),\n /**\n * {@link f.glob}, ignoring **ASCII** case on both sides — `\"Src/*\"` matches\n * `\"src/main.rs\"`. Non-ASCII is not folded (`É` does not match `é`).\n */\n iglob: (key: string, pattern: string): Predicate => ({\n IGlob: [key, pattern],\n }),\n /** `attrs[key]` equals one of `values`. */\n in: (key: string, values: AttrInput[]): Predicate => ({\n In: [key, values.map(encodeValue)],\n }),\n /** `attrs[key]` is present and equals none of `values`. */\n notIn: (key: string, values: AttrInput[]): Predicate => ({\n NotIn: [key, values.map(encodeValue)],\n }),\n /** `attrs[key] < value` (same-type, orderable). */\n lt: (key: string, value: AttrInput): Predicate => ({\n Lt: [key, encodeValue(value)],\n }),\n /** `attrs[key] <= value` (same-type, orderable). */\n le: (key: string, value: AttrInput): Predicate => ({\n Le: [key, encodeValue(value)],\n }),\n /** `attrs[key] > value` (same-type, orderable). */\n gt: (key: string, value: AttrInput): Predicate => ({\n Gt: [key, encodeValue(value)],\n }),\n /** `attrs[key] >= value` (same-type, orderable). */\n ge: (key: string, value: AttrInput): Predicate => ({\n Ge: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` containing `value` (whole-element, not substring). */\n contains: (key: string, value: AttrInput): Predicate => ({\n Contains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a present `List` not containing `value`. */\n notContains: (key: string, value: AttrInput): Predicate => ({\n NotContains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` sharing at least one element with `values`. */\n containsAny: (key: string, values: AttrInput[]): Predicate => ({\n ContainsAny: [key, values.map(encodeValue)],\n }),\n /** Every sub-predicate holds. `all()` is `true`. */\n all: (...preds: Predicate[]): Predicate => ({ All: preds }),\n /** At least one sub-predicate holds. `any()` is `false`. */\n any: (...preds: Predicate[]): Predicate => ({ Any: preds }),\n /**\n * The sub-predicate does not hold. Differs from {@link f.ne} on an absent key:\n * `not(eq(k, v))` matches a record with no `k`, `ne(k, v)` does not.\n */\n not: (pred: Predicate): Predicate => ({ Not: pred }),\n /**\n * `attrs[key]` is within `maxEdits` Levenshtein edits of `text`, ASCII-case-folded on\n * both sides; a `List` matches if any element does. The only three-element predicate.\n * A `maxEdits` above 8 is refused by the server, not clamped.\n */\n fuzzy: (key: string, text: string, maxEdits: number): Predicate => ({\n Fuzzy: [key, text, maxEdits],\n }),\n /**\n * Every token of `text` appears among `attrs[key]`'s tokens, in any order. Tokens are\n * ASCII-case-folded runs of alphanumerics; a `List` matches if any single element does.\n */\n containsAllTokens: (key: string, text: string): Predicate => ({\n ContainsAllTokens: [key, text],\n }),\n /** At least one token of `text` appears among `attrs[key]`'s tokens. Empty never matches. */\n containsAnyToken: (key: string, text: string): Predicate => ({\n ContainsAnyToken: [key, text],\n }),\n /** `text`'s tokens appear consecutively and in order — a phrase match. */\n containsTokenSequence: (key: string, text: string): Predicate => ({\n ContainsTokenSequence: [key, text],\n }),\n /**\n * `attrs[key]` matches the regular expression, **anchored at both ends** like\n * {@link f.glob} — `.*` opts back into a substring search, and `(?i)` into case folding.\n * The syntax is Rust's `regex`, not JS's: no backreferences and no lookaround.\n */\n regex: (key: string, pattern: string): Predicate => ({ Regex: [key, pattern] }),\n /** Collect predicates into a {@link Filter} (purely sugar — they already AND). */\n and: (...preds: Predicate[]): Filter => preds,\n} as const;\n\n// Aliases for the comparison operators, for callers who prefer them.\nexport type { Filter, Predicate, Value };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgCO,SAAS,kBAAkB,GAAiC;AACjE,QAAM,MAAmB,CAAC;AAC1B,MAAI,EAAE,OAAQ,KAAI,SAAS,EAAE;AAC7B,MAAI,EAAE,KAAM,KAAI,OAAO,EAAE;AACzB,MAAI,EAAE,QAAS,KAAI,UAAU,EAAE;AAC/B,MAAI,EAAE,WAAY,KAAI,aAAa,EAAE,WAAW,IAAI,eAAe;AACnE,SAAO;AACT;AAEA,SAAS,gBAAgB,GAA6B;AACpD,SAAO,EAAE,OAAO,EAAE,OAAO,WAAW,EAAE,UAAU,IAAI,cAAc,EAAE;AACtE;AAEA,SAAS,eAAe,IAA4B;AAClD,SAAO,EAAE,MAAM,GAAG,MAAM,OAAO,gBAAgB,GAAG,MAAM,GAAG,KAAK,EAAE;AACpE;AAOO,SAAS,gBACd,MACA,OACoB;AACpB,MAAI,MAAM,WAAW,KAAK,QAAQ,IAAI,EAAG,QAAO;AAChD,QAAM,QAAQ,WAAW,IAAI;AAC7B,QAAM,KAAK,CAAC,MACV,MAAM,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,MAAM,SAAS,CAAC,CAAC;AAClD,SAAO,MAAM,IAAI,CAAC,CAAC,OAAO,GAAG,MAAwB,CAAC,GAAG,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC;AAC3E;AAGA,SAAS,WAAW,MAAwB;AAC1C,QAAM,QAAkB,CAAC;AACzB,MAAI,OAAO;AAGX,aAAW,MAAM,MAAM;A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B;AAAA,IAC5D,mBAAmB,CAAC,KAAK,IAAI;AAAA,EAC/B;AAAA;AAAA,EAEA,kBAAkB,CAAC,KAAa,UAA6B;AAAA,IAC3D,kBAAkB,CAAC,KAAK,IAAI;AAAA,EAC9B;AAAA;AAAA,EAEA,uBAAuB,CAAC,KAAa,UAA6B;AAAA,IAChE,uBAAuB,CAAC,KAAK,IAAI;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,CAAC,KAAa,aAAgC,EAAE,OAAO,CAAC,KAAK,OAAO,EAAE;AAAA;AAAA,EAE7E,KAAK,IAAI,UAA+B;AAC1C;","names":["f"]}
package/dist/index.d.cts CHANGED
@@ -107,6 +107,9 @@ interface Hit {
107
107
  attrs: Record<string, DecodedValue>;
108
108
  /** Why this hit matched — present only when the query asked to `explain` or highlight. */
109
109
  annotations?: Annotations;
110
+ /** The hit's chunk widened with its neighbours. Present only when the query asked to
111
+ * `expand` (or, on recall, to `rollup`). */
112
+ context?: string;
110
113
  }
111
114
  /** One fusion leg's own view of a hit: its rank in that leg (0-based) and that leg's score. */
112
115
  interface LegScore {
@@ -252,6 +255,25 @@ interface LimitPer {
252
255
  field: string;
253
256
  max: number;
254
257
  }
258
+ /**
259
+ * Widen each hit with the neighbouring chunks of its own document, returned as
260
+ * {@link Hit.context}. Payload only: the ranking is exactly what it was without it.
261
+ * Every field but `radius` defaults to the reserved attrs `nidus ingest` stamps.
262
+ */
263
+ interface Expand {
264
+ radius: number;
265
+ parentField?: string;
266
+ indexField?: string;
267
+ textField?: string;
268
+ }
269
+ /**
270
+ * Read a chunked corpus as documents rather than fragments: keep each document's best
271
+ * `perParent` chunks, then widen each with `neighbours` chunks either side.
272
+ */
273
+ interface Rollup {
274
+ perParent?: number;
275
+ neighbours?: number;
276
+ }
255
277
  /**
256
278
  * Sort a {@link NidusClient.list} by an attribute instead of storage order. Values of
257
279
  * another type, unorderable ones (`null`/lists/`NaN`), and records missing the attribute
@@ -271,6 +293,8 @@ interface RankingOptions {
271
293
  * Omitted leaves the ranking exactly as it is.
272
294
  */
273
295
  diversity?: number;
296
+ /** See {@link Expand}. Adds `context` to each hit and changes nothing else. */
297
+ expand?: Expand;
274
298
  }
275
299
  /** How several {@link TextClause}s fold into one text score. */
276
300
  type FtsCombine = "Sum" | "Max";
@@ -445,6 +469,8 @@ interface HybridSearchBase extends AnnotationOptions {
445
469
  vectorWeight?: number;
446
470
  /** Weight on the BM25 leg's RRF contribution (default `1`). */
447
471
  textWeight?: number;
472
+ /** See {@link Expand}. Applied after fusion, so the RRF order is untouched. */
473
+ expand?: Expand;
448
474
  /** See {@link RerankOptions}. `query` is required here. */
449
475
  rerank?: RerankOptions;
450
476
  }
@@ -555,6 +581,8 @@ interface RecallOptions {
555
581
  * stop filling the recalled window. `1` is pure relevance, `0` pure variety.
556
582
  */
557
583
  diversity?: number;
584
+ /** See {@link Rollup}. The text-native spelling of `limitPer` plus `expand`. */
585
+ rollup?: Rollup;
558
586
  /** See {@link RerankOptions}. Defaults `query` to the request's own text. */
559
587
  rerank?: RerankOptions;
560
588
  }
@@ -811,4 +839,4 @@ declare function decodeValue(value: Value): DecodedValue;
811
839
  /** Decode a whole wire `attrs` map back to plain JS values. */
812
840
  declare function decodeAttrs(attrs: Record<string, Value>): Record<string, DecodedValue>;
813
841
 
814
- export { type AggregateOptions, type Aggregation, type AnnInfo, type AnnotationOptions, type Annotations, type AttrInput, type ClauseScore, type ClusterStatus, type Decay, type DecodedRecord, type DecodedValue, type FetchLike, type Filter, type FilterIndexField, type Footprint, type Fragment, type FtsCombine, type FtsField, type Highlight, type HighlightOptions, type Hit, type HybridQuerySpelling, type HybridSearchBase, type HybridSearchOptions, type LegScore, type LimitPer, type ListOptions, NidusClient, type NidusClientOptions, NidusError, type NidusRecord, type OrderBy, type Predicate, type ProjectionOptions, type RankBy, type RankingOptions, type Readiness, type RecallOptions, type RecordInput, type RememberOptions, type RememberResult, type RerankOptions, type SearchOptions, type SimilarSearchOptions, type Stats, type TextClause, type TextQuerySpelling, type TextSearchBase, type TextSearchOptions, type Value, decodeAttrs, decodeValue, encodeAttrs, encodeValue, f, v };
842
+ export { type AggregateOptions, type Aggregation, type AnnInfo, type AnnotationOptions, type Annotations, type AttrInput, type ClauseScore, type ClusterStatus, type Decay, type DecodedRecord, type DecodedValue, type Expand, type FetchLike, type Filter, type FilterIndexField, type Footprint, type Fragment, type FtsCombine, type FtsField, type Highlight, type HighlightOptions, type Hit, type HybridQuerySpelling, type HybridSearchBase, type HybridSearchOptions, type LegScore, type LimitPer, type ListOptions, NidusClient, type NidusClientOptions, NidusError, type NidusRecord, type OrderBy, type Predicate, type ProjectionOptions, type RankBy, type RankingOptions, type Readiness, type RecallOptions, type RecordInput, type RememberOptions, type RememberResult, type RerankOptions, type Rollup, type SearchOptions, type SimilarSearchOptions, type Stats, type TextClause, type TextQuerySpelling, type TextSearchBase, type TextSearchOptions, type Value, decodeAttrs, decodeValue, encodeAttrs, encodeValue, f, v };
package/dist/index.d.ts CHANGED
@@ -107,6 +107,9 @@ interface Hit {
107
107
  attrs: Record<string, DecodedValue>;
108
108
  /** Why this hit matched — present only when the query asked to `explain` or highlight. */
109
109
  annotations?: Annotations;
110
+ /** The hit's chunk widened with its neighbours. Present only when the query asked to
111
+ * `expand` (or, on recall, to `rollup`). */
112
+ context?: string;
110
113
  }
111
114
  /** One fusion leg's own view of a hit: its rank in that leg (0-based) and that leg's score. */
112
115
  interface LegScore {
@@ -252,6 +255,25 @@ interface LimitPer {
252
255
  field: string;
253
256
  max: number;
254
257
  }
258
+ /**
259
+ * Widen each hit with the neighbouring chunks of its own document, returned as
260
+ * {@link Hit.context}. Payload only: the ranking is exactly what it was without it.
261
+ * Every field but `radius` defaults to the reserved attrs `nidus ingest` stamps.
262
+ */
263
+ interface Expand {
264
+ radius: number;
265
+ parentField?: string;
266
+ indexField?: string;
267
+ textField?: string;
268
+ }
269
+ /**
270
+ * Read a chunked corpus as documents rather than fragments: keep each document's best
271
+ * `perParent` chunks, then widen each with `neighbours` chunks either side.
272
+ */
273
+ interface Rollup {
274
+ perParent?: number;
275
+ neighbours?: number;
276
+ }
255
277
  /**
256
278
  * Sort a {@link NidusClient.list} by an attribute instead of storage order. Values of
257
279
  * another type, unorderable ones (`null`/lists/`NaN`), and records missing the attribute
@@ -271,6 +293,8 @@ interface RankingOptions {
271
293
  * Omitted leaves the ranking exactly as it is.
272
294
  */
273
295
  diversity?: number;
296
+ /** See {@link Expand}. Adds `context` to each hit and changes nothing else. */
297
+ expand?: Expand;
274
298
  }
275
299
  /** How several {@link TextClause}s fold into one text score. */
276
300
  type FtsCombine = "Sum" | "Max";
@@ -445,6 +469,8 @@ interface HybridSearchBase extends AnnotationOptions {
445
469
  vectorWeight?: number;
446
470
  /** Weight on the BM25 leg's RRF contribution (default `1`). */
447
471
  textWeight?: number;
472
+ /** See {@link Expand}. Applied after fusion, so the RRF order is untouched. */
473
+ expand?: Expand;
448
474
  /** See {@link RerankOptions}. `query` is required here. */
449
475
  rerank?: RerankOptions;
450
476
  }
@@ -555,6 +581,8 @@ interface RecallOptions {
555
581
  * stop filling the recalled window. `1` is pure relevance, `0` pure variety.
556
582
  */
557
583
  diversity?: number;
584
+ /** See {@link Rollup}. The text-native spelling of `limitPer` plus `expand`. */
585
+ rollup?: Rollup;
558
586
  /** See {@link RerankOptions}. Defaults `query` to the request's own text. */
559
587
  rerank?: RerankOptions;
560
588
  }
@@ -811,4 +839,4 @@ declare function decodeValue(value: Value): DecodedValue;
811
839
  /** Decode a whole wire `attrs` map back to plain JS values. */
812
840
  declare function decodeAttrs(attrs: Record<string, Value>): Record<string, DecodedValue>;
813
841
 
814
- export { type AggregateOptions, type Aggregation, type AnnInfo, type AnnotationOptions, type Annotations, type AttrInput, type ClauseScore, type ClusterStatus, type Decay, type DecodedRecord, type DecodedValue, type FetchLike, type Filter, type FilterIndexField, type Footprint, type Fragment, type FtsCombine, type FtsField, type Highlight, type HighlightOptions, type Hit, type HybridQuerySpelling, type HybridSearchBase, type HybridSearchOptions, type LegScore, type LimitPer, type ListOptions, NidusClient, type NidusClientOptions, NidusError, type NidusRecord, type OrderBy, type Predicate, type ProjectionOptions, type RankBy, type RankingOptions, type Readiness, type RecallOptions, type RecordInput, type RememberOptions, type RememberResult, type RerankOptions, type SearchOptions, type SimilarSearchOptions, type Stats, type TextClause, type TextQuerySpelling, type TextSearchBase, type TextSearchOptions, type Value, decodeAttrs, decodeValue, encodeAttrs, encodeValue, f, v };
842
+ export { type AggregateOptions, type Aggregation, type AnnInfo, type AnnotationOptions, type Annotations, type AttrInput, type ClauseScore, type ClusterStatus, type Decay, type DecodedRecord, type DecodedValue, type Expand, type FetchLike, type Filter, type FilterIndexField, type Footprint, type Fragment, type FtsCombine, type FtsField, type Highlight, type HighlightOptions, type Hit, type HybridQuerySpelling, type HybridSearchBase, type HybridSearchOptions, type LegScore, type LimitPer, type ListOptions, NidusClient, type NidusClientOptions, NidusError, type NidusRecord, type OrderBy, type Predicate, type ProjectionOptions, type RankBy, type RankingOptions, type Readiness, type RecallOptions, type RecordInput, type RememberOptions, type RememberResult, type RerankOptions, type Rollup, type SearchOptions, type SimilarSearchOptions, type Stats, type TextClause, type TextQuerySpelling, type TextSearchBase, type TextSearchOptions, type Value, decodeAttrs, decodeValue, encodeAttrs, encodeValue, f, v };
package/dist/index.js CHANGED
@@ -319,6 +319,7 @@ var NidusClient = class {
319
319
  rank_by: encodeRankBy(opts.rankBy),
320
320
  limit_per: opts.limitPer,
321
321
  diversity: opts.diversity,
322
+ expand: encodeExpand(opts.expand),
322
323
  rerank: encodeRerank(opts.rerank)
323
324
  });
324
325
  }
@@ -337,7 +338,8 @@ var NidusClient = class {
337
338
  exclude_attributes: opts.excludeAttributes,
338
339
  rank_by: encodeRankBy(opts.rankBy),
339
340
  limit_per: opts.limitPer,
340
- diversity: opts.diversity
341
+ diversity: opts.diversity,
342
+ expand: encodeExpand(opts.expand)
341
343
  });
342
344
  }
343
345
  /**
@@ -359,6 +361,7 @@ var NidusClient = class {
359
361
  rank_by: encodeRankBy(opts.rankBy),
360
362
  limit_per: opts.limitPer,
361
363
  diversity: opts.diversity,
364
+ expand: encodeExpand(opts.expand),
362
365
  rerank: encodeRerank(opts.rerank)
363
366
  });
364
367
  }
@@ -380,6 +383,7 @@ var NidusClient = class {
380
383
  highlight: encodeHighlight(opts.highlight),
381
384
  vector_weight: opts.vectorWeight,
382
385
  text_weight: opts.textWeight,
386
+ expand: encodeExpand(opts.expand),
383
387
  rerank: encodeRerank(opts.rerank)
384
388
  });
385
389
  }
@@ -446,7 +450,8 @@ var NidusClient = class {
446
450
  exclude_attributes: q.excludeAttributes,
447
451
  rank_by: encodeRankBy(q.rankBy),
448
452
  limit_per: q.limitPer,
449
- diversity: q.diversity
453
+ diversity: q.diversity,
454
+ expand: encodeExpand(q.expand)
450
455
  })),
451
456
  fuse: opts.fuse ? prune({
452
457
  rrf_k: opts.fuse.rrfK,
@@ -509,6 +514,7 @@ var NidusClient = class {
509
514
  min_score: opts.minScore,
510
515
  filter: opts.filter ?? [],
511
516
  diversity: opts.diversity,
517
+ rollup: encodeRollup(opts.rollup),
512
518
  rerank: encodeRerank(opts.rerank)
513
519
  });
514
520
  }
@@ -540,7 +546,8 @@ var NidusClient = class {
540
546
  score: h.score,
541
547
  attrs: decodeAttrs(h.attrs),
542
548
  // Kept absent, not `undefined`, so an unannotated hit is the shape it always was.
543
- ...h.annotations ? { annotations: decodeAnnotations(h.annotations) } : {}
549
+ ...h.annotations ? { annotations: decodeAnnotations(h.annotations) } : {},
550
+ ...h.context !== void 0 ? { context: h.context } : {}
544
551
  };
545
552
  }
546
553
  /** Issue a request and parse a JSON body, mapping a non-2xx to {@link NidusError}. */
@@ -578,6 +585,19 @@ var NidusClient = class {
578
585
  }
579
586
  }
580
587
  };
588
+ function encodeExpand(e) {
589
+ if (!e) return void 0;
590
+ return prune({
591
+ radius: e.radius,
592
+ parent_field: e.parentField,
593
+ index_field: e.indexField,
594
+ text_field: e.textField
595
+ });
596
+ }
597
+ function encodeRollup(r) {
598
+ if (!r) return void 0;
599
+ return prune({ per_parent: r.perParent, neighbours: r.neighbours });
600
+ }
581
601
  function encodeRankBy(rank) {
582
602
  if (!rank) return void 0;
583
603
  const d = rank.decay;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/annotations.ts","../src/errors.ts","../src/values.ts","../src/client.ts","../src/filter.ts"],"sourcesContent":["//! Decoding a hit's optional annotations — the opt-in \"why did this match\".\n//\n// One rule here is JS's alone. The server reports a highlight span as a **UTF-8 byte**\n// range into the fragment text, but a JS string is indexed in UTF-16 code units, so\n// `text.slice(...span)` on a raw span is wrong for any non-ASCII excerpt. Converted here,\n// once, so a caller's obvious slice is the right one.\n\nimport type { Annotations, Fragment, Highlight } from \"./types.js\";\n\n/** A fragment as it arrives: `spans` are UTF-8 byte offsets into `text`. */\ninterface WireFragment {\n text: string;\n spans: [number, number][];\n}\n\ninterface WireHighlight {\n field: string;\n fragments: WireFragment[];\n}\n\n/** A hit's annotations as they arrive, before the span offsets are converted. */\nexport interface WireAnnotations {\n vector?: { rank: number; score: number };\n text?: { rank: number; score: number };\n clauses?: { field: string; score: number }[];\n highlights?: WireHighlight[];\n}\n\n/**\n * Decode a hit's annotations, converting every highlight span to JS string indices. The\n * parts the server omitted stay omitted rather than becoming empty arrays.\n */\nexport function decodeAnnotations(a: WireAnnotations): Annotations {\n const out: Annotations = {};\n if (a.vector) out.vector = a.vector;\n if (a.text) out.text = a.text;\n if (a.clauses) out.clauses = a.clauses;\n if (a.highlights) out.highlights = a.highlights.map(decodeHighlight);\n return out;\n}\n\nfunction decodeHighlight(h: WireHighlight): Highlight {\n return { field: h.field, fragments: h.fragments.map(decodeFragment) };\n}\n\nfunction decodeFragment(fr: WireFragment): Fragment {\n return { text: fr.text, spans: toStringIndices(fr.text, fr.spans) };\n}\n\n/**\n * Convert UTF-8 byte ranges into `text` to JS string indices (UTF-16 code units), so\n * `text.slice(...span)` yields the matched term. An all-ASCII excerpt needs no conversion\n * and is the common case, so it is detected before any table is built.\n */\nexport function toStringIndices(\n text: string,\n spans: [number, number][],\n): [number, number][] {\n if (spans.length === 0 || isAscii(text)) return spans;\n const index = byteToUnit(text);\n const at = (b: number): number =>\n index[Math.min(Math.max(b, 0), index.length - 1)]!;\n return spans.map(([start, end]): [number, number] => [at(start), at(end)]);\n}\n\n/** One entry per byte of `text` (plus its end), holding that byte's UTF-16 index. */\nfunction byteToUnit(text: string): number[] {\n const index: number[] = [];\n let unit = 0;\n // A byte *inside* a codepoint maps to that codepoint's start. Spans land on token\n // boundaries, so this only keeps a malformed offset from landing mid-surrogate.\n for (const ch of text) {\n for (let n = utf8Len(ch.codePointAt(0)!); n > 0; n--) index.push(unit);\n unit += ch.length;\n }\n index.push(unit);\n return index;\n}\n\nfunction utf8Len(codePoint: number): number {\n if (codePoint < 0x80) return 1;\n if (codePoint < 0x800) return 2;\n return codePoint < 0x10000 ? 3 : 4;\n}\n\n/** True when every code unit is ASCII, i.e. byte offsets already *are* string indices. */\nfunction isAscii(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) > 0x7f) return false;\n }\n return true;\n}\n","//! Error type carrying the HTTP status the server reported.\n//\n// The server replies to a failed request with `{ \"error\": <message> }` and a\n// meaningful status (`src/server/mod.rs#classify`): 400 dimension mismatch,\n// 403 read-only store, 409 writer-lock conflict, 507 capacity/OOM, 500 otherwise.\n// Callers branch on `.status` to tell a client fault from a server fault.\n\n/** An error returned by a `nidus` server, or a transport failure reaching it. */\nexport class NidusError extends Error {\n /** The HTTP status code, or `0` for a transport/timeout failure (no response). */\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = \"NidusError\";\n this.status = status;\n }\n\n /** A malformed request the server rejected (HTTP 400). */\n get isBadRequest(): boolean {\n return this.status === 400;\n }\n /** The store is read-only (HTTP 403). */\n get isReadOnly(): boolean {\n return this.status === 403;\n }\n /** The writer lock is held by another process (HTTP 409). */\n get isLocked(): boolean {\n return this.status === 409;\n }\n /** Out of capacity: `max_vector_bytes` exceeded or OOM (HTTP 507). */\n get isOutOfCapacity(): boolean {\n return this.status === 507;\n }\n}\n","//! Ergonomic constructors and decoders for the externally-tagged `Value` wire type.\n//\n// Callers should never hand-write `{ Str: \"x\" }`. Use `v.str(\"x\")`, `v.int(5)`,\n// etc., or just pass plain JS values into `attrs` — `encodeValue` normalizes them.\n//\n// One rule is JS's alone. The store's `Int` and `Float` are separate types compared\n// same-type only, but JS has one `number` and `1.0 === 1`, so `Number.isInteger` has to\n// decide. A whole-numbered measurement therefore lands as an `Int` in whichever records\n// it came out round, and a `Float` range filter then skips exactly those: write such a\n// field with `v.float`. Go and Python have the types JS lacks and decide from them.\n\nimport type { AttrInput, DecodedValue, Value } from \"./types.js\";\n\n/** Every tag this SDK version knows, in the order `decodeValue` tries them. */\nconst TAGS = [\"Str\", \"Int\", \"Bool\", \"List\", \"Float\", \"DateTime\"] as const;\n\n/**\n * Value constructors mirroring the `Value` variants. `v.int` requires a safe\n * integer and `v.float` a finite number — `NaN`/`Infinity` have no JSON spelling,\n * and `JSON.stringify` would quietly write `null`.\n */\nexport const v = {\n str: (s: string): Value => ({ Str: s }),\n int: (n: number): Value => {\n if (!Number.isInteger(n)) {\n throw new TypeError(`v.int expects an integer, got ${n}`);\n }\n return { Int: n };\n },\n float: (n: number): Value => {\n if (typeof n !== \"number\" || !Number.isFinite(n)) {\n throw new TypeError(`v.float expects a finite number, got ${n}`);\n }\n return { Float: n };\n },\n bool: (b: boolean): Value => ({ Bool: b }),\n list: (items: string[]): Value => ({ List: items }),\n /**\n * A UTC instant, from a `Date` or a raw epoch-millisecond count. Milliseconds is\n * the wire type, so there is no sub-millisecond precision and no timezone.\n */\n datetime: (when: Date | number): Value => {\n const ms = when instanceof Date ? when.getTime() : when;\n if (!Number.isSafeInteger(ms)) {\n throw new TypeError(\n `v.datetime expects a valid Date or epoch ms, got ${when}`,\n );\n }\n return { DateTime: ms };\n },\n /** The explicit `Null` value — set-but-empty, distinct from an absent key. */\n nil: (): Value => \"Null\",\n} as const;\n\n/** True if `x` is already a wire-tagged {@link Value}. */\nfunction isValue(x: unknown): x is Value {\n if (x === \"Null\") return true;\n if (typeof x !== \"object\" || x === null) return false;\n return TAGS.some((tag) => tag in x);\n}\n\n/**\n * Normalize a caller-supplied {@link AttrInput} into the wire {@link Value} shape.\n * Plain scalars map by type; an already-tagged `Value` passes through unchanged.\n * Throws on a non-finite number, an invalid `Date`, or a non-string list element.\n */\nexport function encodeValue(input: AttrInput): Value {\n if (isValue(input)) return input;\n if (input === null) return \"Null\";\n switch (typeof input) {\n case \"string\":\n return { Str: input };\n case \"boolean\":\n return { Bool: input };\n case \"number\":\n return Number.isInteger(input) ? v.int(input) : v.float(input);\n case \"object\":\n // Date before the array check: both are objects, only one is a list.\n if (input instanceof Date) return v.datetime(input);\n if (Array.isArray(input)) {\n if (!input.every((e) => typeof e === \"string\")) {\n throw new TypeError(\"a List attribute must contain only strings\");\n }\n return { List: input };\n }\n // falls through\n default:\n throw new TypeError(`cannot encode attribute value: ${String(input)}`);\n }\n}\n\n/** Normalize a whole `attrs` map of {@link AttrInput} into wire {@link Value}s. */\nexport function encodeAttrs(\n attrs: Record<string, AttrInput>,\n): Record<string, Value> {\n const out: Record<string, Value> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = encodeValue(val);\n }\n return out;\n}\n\n/** Decode a wire {@link Value} back to a plain JS value. */\nexport function decodeValue(value: Value): DecodedValue {\n if (value === \"Null\") return null;\n if (\"Str\" in value) return value.Str;\n if (\"Int\" in value) return value.Int;\n if (\"Bool\" in value) return value.Bool;\n if (\"List\" in value) return value.List;\n if (\"Float\" in value) return value.Float;\n // A Date, not the raw number: a number would demote every instant to an Int\n // when a decoded attrs map is written back.\n if (\"DateTime\" in value) return new Date(value.DateTime);\n // Unknown tag (forward-compat): hand it back untouched.\n return value as unknown as DecodedValue;\n}\n\n/** Decode a whole wire `attrs` map back to plain JS values. */\nexport function decodeAttrs(\n attrs: Record<string, Value>,\n): Record<string, DecodedValue> {\n const out: Record<string, DecodedValue> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = decodeValue(val);\n }\n return out;\n}\n","//! `NidusClient` — a remote client over the `nidus serve` HTTP API.\n//\n// One method per endpoint (`src/server/mod.rs`). \"Local vs remote\" is just the\n// base URL: point at a local `nidus serve` or any reachable host. Built on the\n// platform-global `fetch`, so it runs unchanged on Node 18+, Deno, Bun, Cloudflare\n// Workers, and browsers — with no runtime dependencies.\n\nimport { decodeAnnotations, type WireAnnotations } from \"./annotations.js\";\nimport { NidusError } from \"./errors.js\";\nimport type {\n AggregateOptions,\n Aggregation,\n BatchSearchOptions,\n ClusterStatus,\n DecodedRecord,\n Filter,\n FilterIndexField,\n FtsField,\n HighlightOptions,\n Hit,\n HybridSearchOptions,\n ListOptions,\n NidusRecord,\n RankBy,\n Readiness,\n RecallOptions,\n RecordInput,\n RememberOptions,\n RememberResult,\n RerankOptions,\n SearchOptions,\n SimilarSearchOptions,\n Stats,\n TextSearchOptions,\n Value,\n} from \"./types.js\";\nimport { decodeAttrs, decodeValue, encodeAttrs } from \"./values.js\";\n\n/** Minimal `fetch` signature the client needs — satisfied by the platform global. */\nexport type FetchLike = (\n input: string,\n init?: RequestInit,\n) => Promise<Response>;\n\n/** Construction options for {@link NidusClient}. */\nexport interface NidusClientOptions {\n /** Base URL of the server, e.g. `http://127.0.0.1:7700`. Trailing slash optional. */\n baseUrl: string;\n /** Bearer token, when the server was started with `--token`. */\n token?: string;\n /** Override the `fetch` implementation (defaults to `globalThis.fetch`). */\n fetch?: FetchLike;\n /** Per-request timeout in milliseconds. Omit (or `0`) to disable. */\n timeoutMs?: number;\n /** Extra headers sent on every request. */\n headers?: Record<string, string>;\n}\n\nexport class NidusClient {\n private readonly baseUrl: string;\n private readonly token?: string;\n private readonly doFetch: FetchLike;\n private readonly timeoutMs: number;\n private readonly extraHeaders: Record<string, string>;\n\n constructor(options: NidusClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError(\"NidusClient requires a baseUrl\");\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.token = options.token;\n this.timeoutMs = options.timeoutMs ?? 0;\n this.extraHeaders = options.headers ?? {};\n const f = options.fetch ?? globalThis.fetch;\n if (typeof f !== \"function\") {\n throw new TypeError(\n \"no fetch available; pass options.fetch (Node < 18, or a custom runtime)\",\n );\n }\n // Bind so a passed `globalThis.fetch` keeps its `this`.\n this.doFetch = f === globalThis.fetch ? f.bind(globalThis) : f;\n }\n\n // ── Admin / introspection ─────────────────────────────────────────────────\n\n /** Liveness check. Returns `true` when the server answers `/health`. */\n async health(): Promise<boolean> {\n try {\n const res = await this.raw(\"GET\", \"/health\");\n return res.ok;\n } catch {\n return false;\n }\n }\n\n /** Store-wide introspection: dimension, distance, ANN config, collections, footprint. */\n stats(): Promise<Stats> {\n return this.request<Stats>(\"GET\", \"/stats\");\n }\n\n /**\n * Readiness: whether this instance can serve. A `503` is the negative answer, not an\n * error, so a poll loop branches on `ready` instead of catching. Other failures throw.\n */\n async ready(): Promise<Readiness> {\n const res = await this.raw(\"GET\", \"/ready\");\n const text = await res.text();\n if (res.status === 503) return { ready: false, reason: extractError(text, 503) };\n if (!res.ok) throw new NidusError(extractError(text, res.status), res.status);\n return JSON.parse(text) as Readiness;\n }\n\n /** Cluster role, writer-handle state, fencing token, commit counter, staleness. */\n cluster(): Promise<ClusterStatus> {\n return this.request<ClusterStatus>(\"GET\", \"/cluster\");\n }\n\n /** List every collection name. */\n collections(): Promise<string[]> {\n return this.request<string[]>(\"GET\", \"/collections\");\n }\n\n /** Create a collection. Idempotent on the server side. */\n async createCollection(name: string): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}`, {});\n }\n\n /** Drop a collection and all its records. */\n async dropCollection(name: string): Promise<void> {\n await this.request(\"DELETE\", `/collections/${enc(name)}`);\n }\n\n /** Read a collection's free-form string metadata. */\n getMeta(name: string): Promise<Record<string, string>> {\n return this.request<Record<string, string>>(\n \"GET\",\n `/collections/${enc(name)}/meta`,\n );\n }\n\n /** Replace a collection's free-form string metadata. */\n async setMeta(name: string, meta: Record<string, string>): Promise<void> {\n await this.request(\"PUT\", `/collections/${enc(name)}/meta`, meta);\n }\n\n // ── Data ──────────────────────────────────────────────────────────────────\n\n /**\n * Insert or replace records (idempotent on `id` within the collection).\n * `attrs` accept plain JS values or `v.*` helpers; they are normalized for you.\n * Returns the number of records upserted.\n */\n async upsert(name: string, records: RecordInput[]): Promise<number> {\n const wire: NidusRecord[] = records.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: encodeAttrs(r.attrs),\n }));\n const res = await this.request<{ upserted: number }>(\n \"POST\",\n `/collections/${enc(name)}/upsert`,\n { records: wire },\n );\n return res.upserted;\n }\n\n /** Delete records by id. Returns the number deleted. */\n async delete(name: string, opts: { ids: string[] }): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { ids: opts.ids },\n );\n return res.deleted;\n }\n\n /** Delete every record matching `filter`. Returns the number deleted. */\n async deleteWhere(name: string, filter: Filter): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { filter },\n );\n return res.deleted;\n }\n\n /** Fetch every record in a collection (attrs decoded to plain JS values). */\n async records(name: string): Promise<DecodedRecord[]> {\n const recs = await this.request<NidusRecord[]>(\n \"GET\",\n `/collections/${enc(name)}/records`,\n );\n return recs.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: decodeAttrs(r.attrs),\n }));\n }\n\n /**\n * Declare the full-text-indexed attribute fields for a collection. A bare string\n * takes the server's BM25/analyzer defaults; an {@link FtsField} object tunes `k1`,\n * `b`, and the analyzer for that field alone.\n */\n async setFtsSchema(\n name: string,\n fields: (string | FtsField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/fts-schema`, {\n fields: fields.map(encodeFtsField),\n });\n }\n\n /**\n * Declare which attribute fields are indexed for the text predicates (`Fuzzy`,\n * `ContainsAllTokens`, `ContainsAnyToken`, `ContainsTokenSequence`, `Regex`). Fields\n * already written are indexed as part of applying the declaration.\n *\n * This changes how fast those predicates run, never what they return: the index\n * proposes candidate documents and the predicate itself still decides. The cost is\n * paid at write time and in memory. Pass an empty array to drop the declaration.\n */\n async setFilterIndex(\n name: string,\n fields: (string | FilterIndexField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/filter-index`, {\n fields: fields.map(encodeFilterIndexField),\n });\n }\n\n // ── Search ──────────────────────────────────────────────────────────────\n\n /** Vector (cosine) nearest-neighbour search. Empty `scope` searches all collections. */\n search(opts: SearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search\", {\n query: opts.query,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Records most like an existing one. The source record itself is never returned. */\n searchSimilar(opts: SimilarSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search/similar\", {\n collection: opts.collection,\n id: opts.id,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n });\n }\n\n /**\n * BM25 full-text search over one indexed field, or over a `clauses` list folded by\n * `combine` (`\"Sum\"` unless said otherwise). Naming the fields both ways is a `400`.\n */\n textSearch(opts: TextSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/text-search\", {\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, query: opts.query }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /**\n * Hybrid search: fuse a vector query and a BM25 text query via RRF. The text leg takes\n * the same single-field / `clauses` choice as {@link NidusClient.textSearch}.\n */\n hybridSearch(opts: HybridSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/hybrid-search\", {\n vector: opts.vector,\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, text: opts.text }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n filter: opts.filter ?? [],\n rrf_k: opts.rrfK,\n candidates: opts.candidates,\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n vector_weight: opts.vectorWeight,\n text_weight: opts.textWeight,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Metadata-only listing (no vector), paginated by `offset`/`limit`. */\n list(opts: ListOptions = {}): Promise<Hit[]> {\n return this.searchRequest(\"/list\", {\n scope: opts.scope ?? [],\n offset: opts.offset,\n limit: opts.limit,\n filter: opts.filter ?? [],\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n order_by: opts.orderBy,\n });\n }\n\n /**\n * Count the records matching a filter and sum the named attributes. Answered from the\n * in-RAM index alone — no record is built and no vector is read.\n */\n async aggregate(opts: AggregateOptions = {}): Promise<Aggregation> {\n const res = await this.request<RawAggregation>(\n \"POST\",\n \"/aggregate\",\n prune({\n scope: opts.scope ?? [],\n filter: opts.filter ?? [],\n sum: opts.sum ?? [],\n group_by: opts.groupBy,\n }),\n );\n // Every sum is an `Int` or a `Float`, both of which decode to a JS number.\n return {\n count: res.count,\n sums: decodeAttrs(res.sums) as Record<string, number>,\n // Kept absent, not `undefined`, so an ungrouped answer is the shape it always was.\n ...(res.groups\n ? {\n groups: res.groups.map((g) => ({\n value: g.value === null ? null : decodeValue(g.value),\n count: g.count,\n sums: decodeAttrs(g.sums) as Record<string, number>,\n })),\n }\n : {}),\n ...(res.groups_truncated ? { groupsTruncated: true } : {}),\n };\n }\n\n /**\n * Answer several vector queries in one round-trip (16 max). Returns one ranking per\n * query in request order, or — with `opts.fuse` — a single array holding the one fused\n * ranking, so the return shape is uniform either way.\n *\n * The server validates the whole batch before running any leg, so a malformed query\n * fails the call rather than returning a partial answer that cannot be told apart.\n */\n async batchSearch(opts: BatchSearchOptions): Promise<Hit[][]> {\n const body = prune({\n queries: opts.queries.map((q) => ({\n query: q.query,\n scope: q.scope ?? [],\n top_k: q.topK,\n offset: q.offset,\n min_score: q.minScore,\n filter: q.filter ?? [],\n exact: q.exact,\n include_attributes: q.includeAttributes,\n exclude_attributes: q.excludeAttributes,\n rank_by: encodeRankBy(q.rankBy),\n limit_per: q.limitPer,\n diversity: q.diversity,\n })),\n fuse: opts.fuse\n ? prune({\n rrf_k: opts.fuse.rrfK,\n weights: opts.fuse.weights,\n top_k: opts.fuse.topK,\n })\n : undefined,\n });\n const res = await this.request<RawBatchSearch>(\n \"POST\",\n \"/search/batch\",\n body,\n );\n return (res.fused ? [res.fused] : (res.results ?? [])).map((hits) =>\n hits.map((h) => this.decodeHit(h)),\n );\n }\n\n // ── Memory (text-native) ──────────────────────────────────────────────────\n //\n // Available only when `nidus serve` was started with an embedder\n // (`--embed-provider …`); otherwise these answer `400`. The server embeds the\n // text/query — the client only sends strings.\n\n /**\n * Embed `text` and upsert it under `id` in `collection` (idempotent on `id`).\n * With `opts.mode === \"summarize\"` the server summarizes first, embeds the\n * summary, and stamps a `nidus.summary` attr (requires the server to have a\n * summarizer). The raw text is always stored under `nidus.text`. `opts.attrs` accept plain JS values or `v.*`\n * helpers; they are normalized for you.\n *\n * Read `id` off the result rather than assuming the one you passed:\n * `opts.dedupeThreshold` can redirect the write onto a near-duplicate.\n */\n async remember(\n collection: string,\n id: string,\n text: string,\n opts: RememberOptions = {},\n ): Promise<RememberResult> {\n const res = await this.request<Partial<RememberResult> | undefined>(\n \"POST\",\n `/collections/${enc(collection)}/remember`,\n prune({\n id,\n text,\n mode: opts.mode,\n attrs: opts.attrs ? encodeAttrs(opts.attrs) : undefined,\n ttl_seconds: opts.ttlSeconds,\n dedupe_threshold: opts.dedupeThreshold,\n }),\n );\n // A server predating the echoed fields answers `{ok, upserted}`; falling back to the\n // requested id keeps that case honest instead of reporting `undefined` as the target.\n return {\n id: res?.id ?? id,\n upserted: res?.upserted ?? 0,\n deduped: res?.deduped ?? false,\n };\n }\n\n /**\n * Embed `query` and vector-search `collection`, best-first (attrs decoded to\n * plain JS values). Refused with a cross-model guard if the collection was\n * written with a different embedder than the server's.\n */\n recall(\n collection: string,\n query: string,\n opts: RecallOptions = {},\n ): Promise<Hit[]> {\n return this.searchRequest(`/collections/${enc(collection)}/recall`, {\n query,\n top_k: opts.topK,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n diversity: opts.diversity,\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n // ── Maintenance ───────────────────────────────────────────────────────────\n\n /** Force a durability flush. */\n async flush(): Promise<void> {\n await this.request(\"POST\", \"/flush\", {});\n }\n\n /** Compact the store (reclaim space from deleted/overwritten rows). */\n async compact(): Promise<void> {\n await this.request(\"POST\", \"/compact\", {});\n }\n\n /** Adopt a writer's newer committed state. Returns whether anything was adopted. */\n async refresh(): Promise<boolean> {\n const res = await this.request<{ adopted: boolean }>(\"POST\", \"/refresh\", {});\n return res.adopted;\n }\n\n // ── Internals ─────────────────────────────────────────────────────────────\n\n /** Run a search-family request and decode the resulting hits' attrs. */\n private async searchRequest(\n path: string,\n body: Record<string, unknown>,\n ): Promise<Hit[]> {\n const hits = await this.request<RawHit[]>(\"POST\", path, prune(body));\n return hits.map((h) => this.decodeHit(h));\n }\n\n /** One wire hit into a {@link Hit}. Shared so every search surface decodes identically. */\n private decodeHit(h: RawHit): Hit {\n return {\n collection: h.collection,\n id: h.id,\n score: h.score,\n attrs: decodeAttrs(h.attrs),\n // Kept absent, not `undefined`, so an unannotated hit is the shape it always was.\n ...(h.annotations\n ? { annotations: decodeAnnotations(h.annotations) }\n : {}),\n };\n }\n\n /** Issue a request and parse a JSON body, mapping a non-2xx to {@link NidusError}. */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const res = await this.raw(method, path, body);\n const text = await res.text();\n if (!res.ok) {\n throw new NidusError(extractError(text, res.status), res.status);\n }\n return (text ? JSON.parse(text) : undefined) as T;\n }\n\n /** The bare transport: headers, auth, timeout, and transport-error mapping. */\n private async raw(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<Response> {\n const headers: Record<string, string> = { ...this.extraHeaders };\n if (this.token) headers.authorization = `Bearer ${this.token}`;\n let payload: string | undefined;\n if (body !== undefined) {\n headers[\"content-type\"] = \"application/json\";\n payload = JSON.stringify(body);\n }\n\n const controller = this.timeoutMs > 0 ? new AbortController() : undefined;\n const timer =\n controller && this.timeoutMs > 0\n ? setTimeout(() => controller.abort(), this.timeoutMs)\n : undefined;\n try {\n return await this.doFetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: payload,\n signal: controller?.signal,\n });\n } catch (err) {\n const reason =\n (controller?.signal.aborted ?? false)\n ? `request to ${path} timed out after ${this.timeoutMs}ms`\n : `request to ${path} failed: ${(err as Error).message}`;\n throw new NidusError(reason, 0);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n}\n\n/** A hit as it arrives on the wire, before attrs are decoded. */\ninterface RawHit {\n collection: string;\n id: string;\n score: number;\n attrs: Record<string, Value>;\n annotations?: WireAnnotations;\n}\n\n/** An `/aggregate` response, whose sums arrive as tagged {@link Value}s. */\ninterface RawAggregation {\n count: number;\n sums: Record<string, Value>;\n groups?: {\n value: Value | null;\n count: number;\n sums: Record<string, Value>;\n }[];\n groups_truncated?: boolean;\n}\n\n/** A `/search/batch` response: exactly one of the two fields is present. */\ninterface RawBatchSearch {\n results?: RawHit[][];\n fused?: RawHit[];\n}\n\n/** Encode `rankBy` to its externally-tagged wire form, dropping the knobs left unset. */\nfunction encodeRankBy(rank: RankBy | undefined): unknown {\n if (!rank) return undefined;\n const d = rank.decay;\n return {\n Decay: prune({\n field: d.field,\n origin: d.origin instanceof Date ? d.origin.getTime() : d.origin,\n scale: d.scale,\n decay: d.decay,\n lambda: d.lambda,\n missing: d.missing,\n }),\n };\n}\n\n/** Encode `highlight`: `true` is the empty object the server reads as \"all defaults\". */\nfunction encodeHighlight(h: boolean | HighlightOptions | undefined): unknown {\n if (h === undefined || h === false) return undefined;\n if (h === true) return {};\n return prune({\n max_fragments: h.maxFragments,\n fragment_chars: h.fragmentChars,\n });\n}\n\n/** Encode `rerank`. Undefined sub-fields drop out at `JSON.stringify`, not here. */\nfunction encodeRerank(r: RerankOptions | undefined): unknown {\n if (r === undefined) return undefined;\n return { query: r.query, overscan: r.overscan, text_attr: r.textAttr };\n}\n\n/** Path-segment encode a collection name (allows slashes/spaces in names). */\nfunction enc(name: string): string {\n return encodeURIComponent(name);\n}\n\n/**\n * Encode one `setFtsSchema` field. A string passes through as the server's bare-name\n * form; an object becomes the snake_case body, pruned so an unset knob keeps the\n * server's default rather than being sent as `undefined`.\n */\nfunction encodeFtsField(f: string | FtsField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n k1: f.k1,\n b: f.b,\n language: f.language,\n ascii_folding: f.asciiFolding,\n max_token_len: f.maxTokenLen,\n });\n}\n\n/**\n * Encode one `setFilterIndex` field, on the same bare-name-or-object rule as\n * {@link encodeFtsField}. Pruning matters here: the server defaults both structures to\n * `true`, so sending an explicit `undefined` would be indistinguishable from `false`.\n */\nfunction encodeFilterIndexField(f: string | FilterIndexField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n tokens: f.tokens,\n trigrams: f.trigrams,\n });\n}\n\n/** Drop `undefined` fields so server `#[serde(default)]`s apply instead. */\nfunction prune(body: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, val] of Object.entries(body)) {\n if (val !== undefined) out[k] = val;\n }\n return out;\n}\n\n/** Pull the `{ \"error\": … }` message out of a failed response, or fall back. */\nfunction extractError(text: string, status: number): string {\n try {\n const parsed = JSON.parse(text);\n if (parsed && typeof parsed.error === \"string\") return parsed.error;\n } catch {\n // not JSON — fall through\n }\n return text || `HTTP ${status}`;\n}\n","//! Filter builder producing the bare predicate-array wire shape.\n//\n// A `Filter` is AND-combined predicates; on the wire it is a plain array. Each\n// predicate is a *positive assertion about a present attribute* — an absent key\n// matches nothing, including the negative predicates (`ne`/`notIn`) and ranges.\n// Comparisons are same-type only (Int↔Int numeric, Float↔Float by IEEE, Str↔Str\n// lexical, Bool↔Bool, DateTime↔DateTime as instants), so an operand's encoded type\n// has to match the attribute's: `ge(\"score\", v.float(2))`, not `ge(\"score\", 2)`.\n\nimport type { AttrInput, Filter, Predicate, Value } from \"./types.js\";\nimport { encodeValue } from \"./values.js\";\n\n/**\n * Predicate constructors. Each accepts a plain JS value (auto-normalized) or an\n * explicit `v.*` {@link Value}. Combine results into a {@link Filter} array, or\n * use {@link f.and} for readability.\n */\nexport const f = {\n /** `attrs[key] === value`. */\n eq: (key: string, value: AttrInput): Predicate => ({\n Eq: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is present and `!== value`. */\n ne: (key: string, value: AttrInput): Predicate => ({\n Ne: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `Str` matching the glob pattern (`*`, `?`, `[..]`). */\n glob: (key: string, pattern: string): Predicate => ({ Glob: [key, pattern] }),\n /**\n * {@link f.glob}, ignoring **ASCII** case on both sides — `\"Src/*\"` matches\n * `\"src/main.rs\"`. Non-ASCII is not folded (`É` does not match `é`).\n */\n iglob: (key: string, pattern: string): Predicate => ({\n IGlob: [key, pattern],\n }),\n /** `attrs[key]` equals one of `values`. */\n in: (key: string, values: AttrInput[]): Predicate => ({\n In: [key, values.map(encodeValue)],\n }),\n /** `attrs[key]` is present and equals none of `values`. */\n notIn: (key: string, values: AttrInput[]): Predicate => ({\n NotIn: [key, values.map(encodeValue)],\n }),\n /** `attrs[key] < value` (same-type, orderable). */\n lt: (key: string, value: AttrInput): Predicate => ({\n Lt: [key, encodeValue(value)],\n }),\n /** `attrs[key] <= value` (same-type, orderable). */\n le: (key: string, value: AttrInput): Predicate => ({\n Le: [key, encodeValue(value)],\n }),\n /** `attrs[key] > value` (same-type, orderable). */\n gt: (key: string, value: AttrInput): Predicate => ({\n Gt: [key, encodeValue(value)],\n }),\n /** `attrs[key] >= value` (same-type, orderable). */\n ge: (key: string, value: AttrInput): Predicate => ({\n Ge: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` containing `value` (whole-element, not substring). */\n contains: (key: string, value: AttrInput): Predicate => ({\n Contains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a present `List` not containing `value`. */\n notContains: (key: string, value: AttrInput): Predicate => ({\n NotContains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` sharing at least one element with `values`. */\n containsAny: (key: string, values: AttrInput[]): Predicate => ({\n ContainsAny: [key, values.map(encodeValue)],\n }),\n /** Every sub-predicate holds. `all()` is `true`. */\n all: (...preds: Predicate[]): Predicate => ({ All: preds }),\n /** At least one sub-predicate holds. `any()` is `false`. */\n any: (...preds: Predicate[]): Predicate => ({ Any: preds }),\n /**\n * The sub-predicate does not hold. Differs from {@link f.ne} on an absent key:\n * `not(eq(k, v))` matches a record with no `k`, `ne(k, v)` does not.\n */\n not: (pred: Predicate): Predicate => ({ Not: pred }),\n /**\n * `attrs[key]` is within `maxEdits` Levenshtein edits of `text`, ASCII-case-folded on\n * both sides; a `List` matches if any element does. The only three-element predicate.\n * A `maxEdits` above 8 is refused by the server, not clamped.\n */\n fuzzy: (key: string, text: string, maxEdits: number): Predicate => ({\n Fuzzy: [key, text, maxEdits],\n }),\n /**\n * Every token of `text` appears among `attrs[key]`'s tokens, in any order. Tokens are\n * ASCII-case-folded runs of alphanumerics; a `List` matches if any single element does.\n */\n containsAllTokens: (key: string, text: string): Predicate => ({\n ContainsAllTokens: [key, text],\n }),\n /** At least one token of `text` appears among `attrs[key]`'s tokens. Empty never matches. */\n containsAnyToken: (key: string, text: string): Predicate => ({\n ContainsAnyToken: [key, text],\n }),\n /** `text`'s tokens appear consecutively and in order — a phrase match. */\n containsTokenSequence: (key: string, text: string): Predicate => ({\n ContainsTokenSequence: [key, text],\n }),\n /**\n * `attrs[key]` matches the regular expression, **anchored at both ends** like\n * {@link f.glob} — `.*` opts back into a substring search, and `(?i)` into case folding.\n * The syntax is Rust's `regex`, not JS's: no backreferences and no lookaround.\n */\n regex: (key: string, pattern: string): Predicate => ({ Regex: [key, pattern] }),\n /** Collect predicates into a {@link Filter} (purely sugar — they already AND). */\n and: (...preds: Predicate[]): Filter => preds,\n} as const;\n\n// Aliases for the comparison operators, for callers who prefer them.\nexport type { Filter, Predicate, Value };\n"],"mappings":";AAgCO,SAAS,kBAAkB,GAAiC;AACjE,QAAM,MAAmB,CAAC;AAC1B,MAAI,EAAE,OAAQ,KAAI,SAAS,EAAE;AAC7B,MAAI,EAAE,KAAM,KAAI,OAAO,EAAE;AACzB,MAAI,EAAE,QAAS,KAAI,UAAU,EAAE;AAC/B,MAAI,EAAE,WAAY,KAAI,aAAa,EAAE,WAAW,IAAI,eAAe;AACnE,SAAO;AACT;AAEA,SAAS,gBAAgB,GAA6B;AACpD,SAAO,EAAE,OAAO,EAAE,OAAO,WAAW,EAAE,UAAU,IAAI,cAAc,EAAE;AACtE;AAEA,SAAS,eAAe,IAA4B;AAClD,SAAO,EAAE,MAAM,GAAG,MAAM,OAAO,gBAAgB,GAAG,MAA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AA,EAEA,uBAAuB,CAAC,KAAa,UAA6B;AAAA,IAChE,uBAAuB,CAAC,KAAK,IAAI;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,CAAC,KAAa,aAAgC,EAAE,OAAO,CAAC,KAAK,OAAO,EAAE;AAAA;AAAA,EAE7E,KAAK,IAAI,UAA+B;AAC1C;","names":["f"]}
1
+ {"version":3,"sources":["../src/annotations.ts","../src/errors.ts","../src/values.ts","../src/client.ts","../src/filter.ts"],"sourcesContent":["//! Decoding a hit's optional annotations — the opt-in \"why did this match\".\n//\n// One rule here is JS's alone. The server reports a highlight span as a **UTF-8 byte**\n// range into the fragment text, but a JS string is indexed in UTF-16 code units, so\n// `text.slice(...span)` on a raw span is wrong for any non-ASCII excerpt. Converted here,\n// once, so a caller's obvious slice is the right one.\n\nimport type { Annotations, Fragment, Highlight } from \"./types.js\";\n\n/** A fragment as it arrives: `spans` are UTF-8 byte offsets into `text`. */\ninterface WireFragment {\n text: string;\n spans: [number, number][];\n}\n\ninterface WireHighlight {\n field: string;\n fragments: WireFragment[];\n}\n\n/** A hit's annotations as they arrive, before the span offsets are converted. */\nexport interface WireAnnotations {\n vector?: { rank: number; score: number };\n text?: { rank: number; score: number };\n clauses?: { field: string; score: number }[];\n highlights?: WireHighlight[];\n}\n\n/**\n * Decode a hit's annotations, converting every highlight span to JS string indices. The\n * parts the server omitted stay omitted rather than becoming empty arrays.\n */\nexport function decodeAnnotations(a: WireAnnotations): Annotations {\n const out: Annotations = {};\n if (a.vector) out.vector = a.vector;\n if (a.text) out.text = a.text;\n if (a.clauses) out.clauses = a.clauses;\n if (a.highlights) out.highlights = a.highlights.map(decodeHighlight);\n return out;\n}\n\nfunction decodeHighlight(h: WireHighlight): Highlight {\n return { field: h.field, fragments: h.fragments.map(decodeFragment) };\n}\n\nfunction decodeFragment(fr: WireFragment): Fragment {\n return { text: fr.text, spans: toStringIndices(fr.text, fr.spans) };\n}\n\n/**\n * Convert UTF-8 byte ranges into `text` to JS string indices (UTF-16 code units), so\n * `text.slice(...span)` yields the matched term. An all-ASCII excerpt needs no conversion\n * and is the common case, so it is detected before any table is built.\n */\nexport function toStringIndices(\n text: string,\n spans: [number, number][],\n): [number, number][] {\n if (spans.length === 0 || isAscii(text)) return spans;\n const index = byteToUnit(text);\n const at = (b: number): number =>\n index[Math.min(Math.max(b, 0), index.length - 1)]!;\n return spans.map(([start, end]): [number, number] => [at(start), at(end)]);\n}\n\n/** One entry per byte of `text` (plus its end), holding that byte's UTF-16 index. */\nfunction byteToUnit(text: string): number[] {\n const index: number[] = [];\n let unit = 0;\n // A byte *inside* a codepoint maps to that codepoint's start. Spans land on token\n // boundaries, so this only keeps a malformed offset from landing mid-surrogate.\n for (const ch of text) {\n for (let n = utf8Len(ch.codePointAt(0)!); n > 0; n--) index.push(unit);\n unit += ch.length;\n }\n index.push(unit);\n return index;\n}\n\nfunction utf8Len(codePoint: number): number {\n if (codePoint < 0x80) return 1;\n if (codePoint < 0x800) return 2;\n return codePoint < 0x10000 ? 3 : 4;\n}\n\n/** True when every code unit is ASCII, i.e. byte offsets already *are* string indices. */\nfunction isAscii(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) > 0x7f) return false;\n }\n return true;\n}\n","//! Error type carrying the HTTP status the server reported.\n//\n// The server replies to a failed request with `{ \"error\": <message> }` and a\n// meaningful status (`src/server/mod.rs#classify`): 400 dimension mismatch,\n// 403 read-only store, 409 writer-lock conflict, 507 capacity/OOM, 500 otherwise.\n// Callers branch on `.status` to tell a client fault from a server fault.\n\n/** An error returned by a `nidus` server, or a transport failure reaching it. */\nexport class NidusError extends Error {\n /** The HTTP status code, or `0` for a transport/timeout failure (no response). */\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = \"NidusError\";\n this.status = status;\n }\n\n /** A malformed request the server rejected (HTTP 400). */\n get isBadRequest(): boolean {\n return this.status === 400;\n }\n /** The store is read-only (HTTP 403). */\n get isReadOnly(): boolean {\n return this.status === 403;\n }\n /** The writer lock is held by another process (HTTP 409). */\n get isLocked(): boolean {\n return this.status === 409;\n }\n /** Out of capacity: `max_vector_bytes` exceeded or OOM (HTTP 507). */\n get isOutOfCapacity(): boolean {\n return this.status === 507;\n }\n}\n","//! Ergonomic constructors and decoders for the externally-tagged `Value` wire type.\n//\n// Callers should never hand-write `{ Str: \"x\" }`. Use `v.str(\"x\")`, `v.int(5)`,\n// etc., or just pass plain JS values into `attrs` — `encodeValue` normalizes them.\n//\n// One rule is JS's alone. The store's `Int` and `Float` are separate types compared\n// same-type only, but JS has one `number` and `1.0 === 1`, so `Number.isInteger` has to\n// decide. A whole-numbered measurement therefore lands as an `Int` in whichever records\n// it came out round, and a `Float` range filter then skips exactly those: write such a\n// field with `v.float`. Go and Python have the types JS lacks and decide from them.\n\nimport type { AttrInput, DecodedValue, Value } from \"./types.js\";\n\n/** Every tag this SDK version knows, in the order `decodeValue` tries them. */\nconst TAGS = [\"Str\", \"Int\", \"Bool\", \"List\", \"Float\", \"DateTime\"] as const;\n\n/**\n * Value constructors mirroring the `Value` variants. `v.int` requires a safe\n * integer and `v.float` a finite number — `NaN`/`Infinity` have no JSON spelling,\n * and `JSON.stringify` would quietly write `null`.\n */\nexport const v = {\n str: (s: string): Value => ({ Str: s }),\n int: (n: number): Value => {\n if (!Number.isInteger(n)) {\n throw new TypeError(`v.int expects an integer, got ${n}`);\n }\n return { Int: n };\n },\n float: (n: number): Value => {\n if (typeof n !== \"number\" || !Number.isFinite(n)) {\n throw new TypeError(`v.float expects a finite number, got ${n}`);\n }\n return { Float: n };\n },\n bool: (b: boolean): Value => ({ Bool: b }),\n list: (items: string[]): Value => ({ List: items }),\n /**\n * A UTC instant, from a `Date` or a raw epoch-millisecond count. Milliseconds is\n * the wire type, so there is no sub-millisecond precision and no timezone.\n */\n datetime: (when: Date | number): Value => {\n const ms = when instanceof Date ? when.getTime() : when;\n if (!Number.isSafeInteger(ms)) {\n throw new TypeError(\n `v.datetime expects a valid Date or epoch ms, got ${when}`,\n );\n }\n return { DateTime: ms };\n },\n /** The explicit `Null` value — set-but-empty, distinct from an absent key. */\n nil: (): Value => \"Null\",\n} as const;\n\n/** True if `x` is already a wire-tagged {@link Value}. */\nfunction isValue(x: unknown): x is Value {\n if (x === \"Null\") return true;\n if (typeof x !== \"object\" || x === null) return false;\n return TAGS.some((tag) => tag in x);\n}\n\n/**\n * Normalize a caller-supplied {@link AttrInput} into the wire {@link Value} shape.\n * Plain scalars map by type; an already-tagged `Value` passes through unchanged.\n * Throws on a non-finite number, an invalid `Date`, or a non-string list element.\n */\nexport function encodeValue(input: AttrInput): Value {\n if (isValue(input)) return input;\n if (input === null) return \"Null\";\n switch (typeof input) {\n case \"string\":\n return { Str: input };\n case \"boolean\":\n return { Bool: input };\n case \"number\":\n return Number.isInteger(input) ? v.int(input) : v.float(input);\n case \"object\":\n // Date before the array check: both are objects, only one is a list.\n if (input instanceof Date) return v.datetime(input);\n if (Array.isArray(input)) {\n if (!input.every((e) => typeof e === \"string\")) {\n throw new TypeError(\"a List attribute must contain only strings\");\n }\n return { List: input };\n }\n // falls through\n default:\n throw new TypeError(`cannot encode attribute value: ${String(input)}`);\n }\n}\n\n/** Normalize a whole `attrs` map of {@link AttrInput} into wire {@link Value}s. */\nexport function encodeAttrs(\n attrs: Record<string, AttrInput>,\n): Record<string, Value> {\n const out: Record<string, Value> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = encodeValue(val);\n }\n return out;\n}\n\n/** Decode a wire {@link Value} back to a plain JS value. */\nexport function decodeValue(value: Value): DecodedValue {\n if (value === \"Null\") return null;\n if (\"Str\" in value) return value.Str;\n if (\"Int\" in value) return value.Int;\n if (\"Bool\" in value) return value.Bool;\n if (\"List\" in value) return value.List;\n if (\"Float\" in value) return value.Float;\n // A Date, not the raw number: a number would demote every instant to an Int\n // when a decoded attrs map is written back.\n if (\"DateTime\" in value) return new Date(value.DateTime);\n // Unknown tag (forward-compat): hand it back untouched.\n return value as unknown as DecodedValue;\n}\n\n/** Decode a whole wire `attrs` map back to plain JS values. */\nexport function decodeAttrs(\n attrs: Record<string, Value>,\n): Record<string, DecodedValue> {\n const out: Record<string, DecodedValue> = {};\n for (const [k, val] of Object.entries(attrs)) {\n out[k] = decodeValue(val);\n }\n return out;\n}\n","//! `NidusClient` — a remote client over the `nidus serve` HTTP API.\n//\n// One method per endpoint (`src/server/mod.rs`). \"Local vs remote\" is just the\n// base URL: point at a local `nidus serve` or any reachable host. Built on the\n// platform-global `fetch`, so it runs unchanged on Node 18+, Deno, Bun, Cloudflare\n// Workers, and browsers — with no runtime dependencies.\n\nimport { decodeAnnotations, type WireAnnotations } from \"./annotations.js\";\nimport { NidusError } from \"./errors.js\";\nimport type {\n AggregateOptions,\n Aggregation,\n BatchSearchOptions,\n ClusterStatus,\n DecodedRecord,\n Expand,\n Filter,\n FilterIndexField,\n FtsField,\n HighlightOptions,\n Hit,\n HybridSearchOptions,\n ListOptions,\n NidusRecord,\n RankBy,\n Readiness,\n RecallOptions,\n RecordInput,\n RememberOptions,\n RememberResult,\n RerankOptions,\n Rollup,\n SearchOptions,\n SimilarSearchOptions,\n Stats,\n TextSearchOptions,\n Value,\n} from \"./types.js\";\nimport { decodeAttrs, decodeValue, encodeAttrs } from \"./values.js\";\n\n/** Minimal `fetch` signature the client needs — satisfied by the platform global. */\nexport type FetchLike = (\n input: string,\n init?: RequestInit,\n) => Promise<Response>;\n\n/** Construction options for {@link NidusClient}. */\nexport interface NidusClientOptions {\n /** Base URL of the server, e.g. `http://127.0.0.1:7700`. Trailing slash optional. */\n baseUrl: string;\n /** Bearer token, when the server was started with `--token`. */\n token?: string;\n /** Override the `fetch` implementation (defaults to `globalThis.fetch`). */\n fetch?: FetchLike;\n /** Per-request timeout in milliseconds. Omit (or `0`) to disable. */\n timeoutMs?: number;\n /** Extra headers sent on every request. */\n headers?: Record<string, string>;\n}\n\nexport class NidusClient {\n private readonly baseUrl: string;\n private readonly token?: string;\n private readonly doFetch: FetchLike;\n private readonly timeoutMs: number;\n private readonly extraHeaders: Record<string, string>;\n\n constructor(options: NidusClientOptions) {\n if (!options.baseUrl) {\n throw new TypeError(\"NidusClient requires a baseUrl\");\n }\n this.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n this.token = options.token;\n this.timeoutMs = options.timeoutMs ?? 0;\n this.extraHeaders = options.headers ?? {};\n const f = options.fetch ?? globalThis.fetch;\n if (typeof f !== \"function\") {\n throw new TypeError(\n \"no fetch available; pass options.fetch (Node < 18, or a custom runtime)\",\n );\n }\n // Bind so a passed `globalThis.fetch` keeps its `this`.\n this.doFetch = f === globalThis.fetch ? f.bind(globalThis) : f;\n }\n\n // ── Admin / introspection ─────────────────────────────────────────────────\n\n /** Liveness check. Returns `true` when the server answers `/health`. */\n async health(): Promise<boolean> {\n try {\n const res = await this.raw(\"GET\", \"/health\");\n return res.ok;\n } catch {\n return false;\n }\n }\n\n /** Store-wide introspection: dimension, distance, ANN config, collections, footprint. */\n stats(): Promise<Stats> {\n return this.request<Stats>(\"GET\", \"/stats\");\n }\n\n /**\n * Readiness: whether this instance can serve. A `503` is the negative answer, not an\n * error, so a poll loop branches on `ready` instead of catching. Other failures throw.\n */\n async ready(): Promise<Readiness> {\n const res = await this.raw(\"GET\", \"/ready\");\n const text = await res.text();\n if (res.status === 503) return { ready: false, reason: extractError(text, 503) };\n if (!res.ok) throw new NidusError(extractError(text, res.status), res.status);\n return JSON.parse(text) as Readiness;\n }\n\n /** Cluster role, writer-handle state, fencing token, commit counter, staleness. */\n cluster(): Promise<ClusterStatus> {\n return this.request<ClusterStatus>(\"GET\", \"/cluster\");\n }\n\n /** List every collection name. */\n collections(): Promise<string[]> {\n return this.request<string[]>(\"GET\", \"/collections\");\n }\n\n /** Create a collection. Idempotent on the server side. */\n async createCollection(name: string): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}`, {});\n }\n\n /** Drop a collection and all its records. */\n async dropCollection(name: string): Promise<void> {\n await this.request(\"DELETE\", `/collections/${enc(name)}`);\n }\n\n /** Read a collection's free-form string metadata. */\n getMeta(name: string): Promise<Record<string, string>> {\n return this.request<Record<string, string>>(\n \"GET\",\n `/collections/${enc(name)}/meta`,\n );\n }\n\n /** Replace a collection's free-form string metadata. */\n async setMeta(name: string, meta: Record<string, string>): Promise<void> {\n await this.request(\"PUT\", `/collections/${enc(name)}/meta`, meta);\n }\n\n // ── Data ──────────────────────────────────────────────────────────────────\n\n /**\n * Insert or replace records (idempotent on `id` within the collection).\n * `attrs` accept plain JS values or `v.*` helpers; they are normalized for you.\n * Returns the number of records upserted.\n */\n async upsert(name: string, records: RecordInput[]): Promise<number> {\n const wire: NidusRecord[] = records.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: encodeAttrs(r.attrs),\n }));\n const res = await this.request<{ upserted: number }>(\n \"POST\",\n `/collections/${enc(name)}/upsert`,\n { records: wire },\n );\n return res.upserted;\n }\n\n /** Delete records by id. Returns the number deleted. */\n async delete(name: string, opts: { ids: string[] }): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { ids: opts.ids },\n );\n return res.deleted;\n }\n\n /** Delete every record matching `filter`. Returns the number deleted. */\n async deleteWhere(name: string, filter: Filter): Promise<number> {\n const res = await this.request<{ deleted: number }>(\n \"POST\",\n `/collections/${enc(name)}/delete`,\n { filter },\n );\n return res.deleted;\n }\n\n /** Fetch every record in a collection (attrs decoded to plain JS values). */\n async records(name: string): Promise<DecodedRecord[]> {\n const recs = await this.request<NidusRecord[]>(\n \"GET\",\n `/collections/${enc(name)}/records`,\n );\n return recs.map((r) => ({\n id: r.id,\n ...(r.vector !== undefined ? { vector: r.vector } : {}),\n attrs: decodeAttrs(r.attrs),\n }));\n }\n\n /**\n * Declare the full-text-indexed attribute fields for a collection. A bare string\n * takes the server's BM25/analyzer defaults; an {@link FtsField} object tunes `k1`,\n * `b`, and the analyzer for that field alone.\n */\n async setFtsSchema(\n name: string,\n fields: (string | FtsField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/fts-schema`, {\n fields: fields.map(encodeFtsField),\n });\n }\n\n /**\n * Declare which attribute fields are indexed for the text predicates (`Fuzzy`,\n * `ContainsAllTokens`, `ContainsAnyToken`, `ContainsTokenSequence`, `Regex`). Fields\n * already written are indexed as part of applying the declaration.\n *\n * This changes how fast those predicates run, never what they return: the index\n * proposes candidate documents and the predicate itself still decides. The cost is\n * paid at write time and in memory. Pass an empty array to drop the declaration.\n */\n async setFilterIndex(\n name: string,\n fields: (string | FilterIndexField)[],\n ): Promise<void> {\n await this.request(\"POST\", `/collections/${enc(name)}/filter-index`, {\n fields: fields.map(encodeFilterIndexField),\n });\n }\n\n // ── Search ──────────────────────────────────────────────────────────────\n\n /** Vector (cosine) nearest-neighbour search. Empty `scope` searches all collections. */\n search(opts: SearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search\", {\n query: opts.query,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n expand: encodeExpand(opts.expand),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Records most like an existing one. The source record itself is never returned. */\n searchSimilar(opts: SimilarSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/search/similar\", {\n collection: opts.collection,\n id: opts.id,\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n exact: opts.exact,\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n expand: encodeExpand(opts.expand),\n });\n }\n\n /**\n * BM25 full-text search over one indexed field, or over a `clauses` list folded by\n * `combine` (`\"Sum\"` unless said otherwise). Naming the fields both ways is a `400`.\n */\n textSearch(opts: TextSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/text-search\", {\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, query: opts.query }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n rank_by: encodeRankBy(opts.rankBy),\n limit_per: opts.limitPer,\n diversity: opts.diversity,\n expand: encodeExpand(opts.expand),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /**\n * Hybrid search: fuse a vector query and a BM25 text query via RRF. The text leg takes\n * the same single-field / `clauses` choice as {@link NidusClient.textSearch}.\n */\n hybridSearch(opts: HybridSearchOptions): Promise<Hit[]> {\n return this.searchRequest(\"/hybrid-search\", {\n vector: opts.vector,\n ...(opts.clauses\n ? { clauses: opts.clauses, combine: opts.combine }\n : { field: opts.field, text: opts.text }),\n scope: opts.scope ?? [],\n top_k: opts.topK,\n offset: opts.offset,\n filter: opts.filter ?? [],\n rrf_k: opts.rrfK,\n candidates: opts.candidates,\n explain: opts.explain,\n highlight: encodeHighlight(opts.highlight),\n vector_weight: opts.vectorWeight,\n text_weight: opts.textWeight,\n expand: encodeExpand(opts.expand),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n /** Metadata-only listing (no vector), paginated by `offset`/`limit`. */\n list(opts: ListOptions = {}): Promise<Hit[]> {\n return this.searchRequest(\"/list\", {\n scope: opts.scope ?? [],\n offset: opts.offset,\n limit: opts.limit,\n filter: opts.filter ?? [],\n include_attributes: opts.includeAttributes,\n exclude_attributes: opts.excludeAttributes,\n order_by: opts.orderBy,\n });\n }\n\n /**\n * Count the records matching a filter and sum the named attributes. Answered from the\n * in-RAM index alone — no record is built and no vector is read.\n */\n async aggregate(opts: AggregateOptions = {}): Promise<Aggregation> {\n const res = await this.request<RawAggregation>(\n \"POST\",\n \"/aggregate\",\n prune({\n scope: opts.scope ?? [],\n filter: opts.filter ?? [],\n sum: opts.sum ?? [],\n group_by: opts.groupBy,\n }),\n );\n // Every sum is an `Int` or a `Float`, both of which decode to a JS number.\n return {\n count: res.count,\n sums: decodeAttrs(res.sums) as Record<string, number>,\n // Kept absent, not `undefined`, so an ungrouped answer is the shape it always was.\n ...(res.groups\n ? {\n groups: res.groups.map((g) => ({\n value: g.value === null ? null : decodeValue(g.value),\n count: g.count,\n sums: decodeAttrs(g.sums) as Record<string, number>,\n })),\n }\n : {}),\n ...(res.groups_truncated ? { groupsTruncated: true } : {}),\n };\n }\n\n /**\n * Answer several vector queries in one round-trip (16 max). Returns one ranking per\n * query in request order, or — with `opts.fuse` — a single array holding the one fused\n * ranking, so the return shape is uniform either way.\n *\n * The server validates the whole batch before running any leg, so a malformed query\n * fails the call rather than returning a partial answer that cannot be told apart.\n */\n async batchSearch(opts: BatchSearchOptions): Promise<Hit[][]> {\n const body = prune({\n queries: opts.queries.map((q) => ({\n query: q.query,\n scope: q.scope ?? [],\n top_k: q.topK,\n offset: q.offset,\n min_score: q.minScore,\n filter: q.filter ?? [],\n exact: q.exact,\n include_attributes: q.includeAttributes,\n exclude_attributes: q.excludeAttributes,\n rank_by: encodeRankBy(q.rankBy),\n limit_per: q.limitPer,\n diversity: q.diversity,\n expand: encodeExpand(q.expand),\n })),\n fuse: opts.fuse\n ? prune({\n rrf_k: opts.fuse.rrfK,\n weights: opts.fuse.weights,\n top_k: opts.fuse.topK,\n })\n : undefined,\n });\n const res = await this.request<RawBatchSearch>(\n \"POST\",\n \"/search/batch\",\n body,\n );\n return (res.fused ? [res.fused] : (res.results ?? [])).map((hits) =>\n hits.map((h) => this.decodeHit(h)),\n );\n }\n\n // ── Memory (text-native) ──────────────────────────────────────────────────\n //\n // Available only when `nidus serve` was started with an embedder\n // (`--embed-provider …`); otherwise these answer `400`. The server embeds the\n // text/query — the client only sends strings.\n\n /**\n * Embed `text` and upsert it under `id` in `collection` (idempotent on `id`).\n * With `opts.mode === \"summarize\"` the server summarizes first, embeds the\n * summary, and stamps a `nidus.summary` attr (requires the server to have a\n * summarizer). The raw text is always stored under `nidus.text`. `opts.attrs` accept plain JS values or `v.*`\n * helpers; they are normalized for you.\n *\n * Read `id` off the result rather than assuming the one you passed:\n * `opts.dedupeThreshold` can redirect the write onto a near-duplicate.\n */\n async remember(\n collection: string,\n id: string,\n text: string,\n opts: RememberOptions = {},\n ): Promise<RememberResult> {\n const res = await this.request<Partial<RememberResult> | undefined>(\n \"POST\",\n `/collections/${enc(collection)}/remember`,\n prune({\n id,\n text,\n mode: opts.mode,\n attrs: opts.attrs ? encodeAttrs(opts.attrs) : undefined,\n ttl_seconds: opts.ttlSeconds,\n dedupe_threshold: opts.dedupeThreshold,\n }),\n );\n // A server predating the echoed fields answers `{ok, upserted}`; falling back to the\n // requested id keeps that case honest instead of reporting `undefined` as the target.\n return {\n id: res?.id ?? id,\n upserted: res?.upserted ?? 0,\n deduped: res?.deduped ?? false,\n };\n }\n\n /**\n * Embed `query` and vector-search `collection`, best-first (attrs decoded to\n * plain JS values). Refused with a cross-model guard if the collection was\n * written with a different embedder than the server's.\n */\n recall(\n collection: string,\n query: string,\n opts: RecallOptions = {},\n ): Promise<Hit[]> {\n return this.searchRequest(`/collections/${enc(collection)}/recall`, {\n query,\n top_k: opts.topK,\n min_score: opts.minScore,\n filter: opts.filter ?? [],\n diversity: opts.diversity,\n rollup: encodeRollup(opts.rollup),\n rerank: encodeRerank(opts.rerank),\n });\n }\n\n // ── Maintenance ───────────────────────────────────────────────────────────\n\n /** Force a durability flush. */\n async flush(): Promise<void> {\n await this.request(\"POST\", \"/flush\", {});\n }\n\n /** Compact the store (reclaim space from deleted/overwritten rows). */\n async compact(): Promise<void> {\n await this.request(\"POST\", \"/compact\", {});\n }\n\n /** Adopt a writer's newer committed state. Returns whether anything was adopted. */\n async refresh(): Promise<boolean> {\n const res = await this.request<{ adopted: boolean }>(\"POST\", \"/refresh\", {});\n return res.adopted;\n }\n\n // ── Internals ─────────────────────────────────────────────────────────────\n\n /** Run a search-family request and decode the resulting hits' attrs. */\n private async searchRequest(\n path: string,\n body: Record<string, unknown>,\n ): Promise<Hit[]> {\n const hits = await this.request<RawHit[]>(\"POST\", path, prune(body));\n return hits.map((h) => this.decodeHit(h));\n }\n\n /** One wire hit into a {@link Hit}. Shared so every search surface decodes identically. */\n private decodeHit(h: RawHit): Hit {\n return {\n collection: h.collection,\n id: h.id,\n score: h.score,\n attrs: decodeAttrs(h.attrs),\n // Kept absent, not `undefined`, so an unannotated hit is the shape it always was.\n ...(h.annotations\n ? { annotations: decodeAnnotations(h.annotations) }\n : {}),\n ...(h.context !== undefined ? { context: h.context } : {}),\n };\n }\n\n /** Issue a request and parse a JSON body, mapping a non-2xx to {@link NidusError}. */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const res = await this.raw(method, path, body);\n const text = await res.text();\n if (!res.ok) {\n throw new NidusError(extractError(text, res.status), res.status);\n }\n return (text ? JSON.parse(text) : undefined) as T;\n }\n\n /** The bare transport: headers, auth, timeout, and transport-error mapping. */\n private async raw(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<Response> {\n const headers: Record<string, string> = { ...this.extraHeaders };\n if (this.token) headers.authorization = `Bearer ${this.token}`;\n let payload: string | undefined;\n if (body !== undefined) {\n headers[\"content-type\"] = \"application/json\";\n payload = JSON.stringify(body);\n }\n\n const controller = this.timeoutMs > 0 ? new AbortController() : undefined;\n const timer =\n controller && this.timeoutMs > 0\n ? setTimeout(() => controller.abort(), this.timeoutMs)\n : undefined;\n try {\n return await this.doFetch(`${this.baseUrl}${path}`, {\n method,\n headers,\n body: payload,\n signal: controller?.signal,\n });\n } catch (err) {\n const reason =\n (controller?.signal.aborted ?? false)\n ? `request to ${path} timed out after ${this.timeoutMs}ms`\n : `request to ${path} failed: ${(err as Error).message}`;\n throw new NidusError(reason, 0);\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n}\n\n/** A hit as it arrives on the wire, before attrs are decoded. */\ninterface RawHit {\n collection: string;\n id: string;\n score: number;\n attrs: Record<string, Value>;\n annotations?: WireAnnotations;\n context?: string;\n}\n\n/** An `/aggregate` response, whose sums arrive as tagged {@link Value}s. */\ninterface RawAggregation {\n count: number;\n sums: Record<string, Value>;\n groups?: {\n value: Value | null;\n count: number;\n sums: Record<string, Value>;\n }[];\n groups_truncated?: boolean;\n}\n\n/** A `/search/batch` response: exactly one of the two fields is present. */\ninterface RawBatchSearch {\n results?: RawHit[][];\n fused?: RawHit[];\n}\n\n/** Encode `rankBy` to its externally-tagged wire form, dropping the knobs left unset. */\n/** camelCase → the wire's snake_case, omitting the object entirely when unset. */\nfunction encodeExpand(e: Expand | undefined): unknown {\n if (!e) return undefined;\n return prune({\n radius: e.radius,\n parent_field: e.parentField,\n index_field: e.indexField,\n text_field: e.textField,\n });\n}\n\nfunction encodeRollup(r: Rollup | undefined): unknown {\n if (!r) return undefined;\n return prune({ per_parent: r.perParent, neighbours: r.neighbours });\n}\n\nfunction encodeRankBy(rank: RankBy | undefined): unknown {\n if (!rank) return undefined;\n const d = rank.decay;\n return {\n Decay: prune({\n field: d.field,\n origin: d.origin instanceof Date ? d.origin.getTime() : d.origin,\n scale: d.scale,\n decay: d.decay,\n lambda: d.lambda,\n missing: d.missing,\n }),\n };\n}\n\n/** Encode `highlight`: `true` is the empty object the server reads as \"all defaults\". */\nfunction encodeHighlight(h: boolean | HighlightOptions | undefined): unknown {\n if (h === undefined || h === false) return undefined;\n if (h === true) return {};\n return prune({\n max_fragments: h.maxFragments,\n fragment_chars: h.fragmentChars,\n });\n}\n\n/** Encode `rerank`. Undefined sub-fields drop out at `JSON.stringify`, not here. */\nfunction encodeRerank(r: RerankOptions | undefined): unknown {\n if (r === undefined) return undefined;\n return { query: r.query, overscan: r.overscan, text_attr: r.textAttr };\n}\n\n/** Path-segment encode a collection name (allows slashes/spaces in names). */\nfunction enc(name: string): string {\n return encodeURIComponent(name);\n}\n\n/**\n * Encode one `setFtsSchema` field. A string passes through as the server's bare-name\n * form; an object becomes the snake_case body, pruned so an unset knob keeps the\n * server's default rather than being sent as `undefined`.\n */\nfunction encodeFtsField(f: string | FtsField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n k1: f.k1,\n b: f.b,\n language: f.language,\n ascii_folding: f.asciiFolding,\n max_token_len: f.maxTokenLen,\n });\n}\n\n/**\n * Encode one `setFilterIndex` field, on the same bare-name-or-object rule as\n * {@link encodeFtsField}. Pruning matters here: the server defaults both structures to\n * `true`, so sending an explicit `undefined` would be indistinguishable from `false`.\n */\nfunction encodeFilterIndexField(f: string | FilterIndexField): unknown {\n if (typeof f === \"string\") return f;\n return prune({\n field: f.field,\n tokens: f.tokens,\n trigrams: f.trigrams,\n });\n}\n\n/** Drop `undefined` fields so server `#[serde(default)]`s apply instead. */\nfunction prune(body: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, val] of Object.entries(body)) {\n if (val !== undefined) out[k] = val;\n }\n return out;\n}\n\n/** Pull the `{ \"error\": … }` message out of a failed response, or fall back. */\nfunction extractError(text: string, status: number): string {\n try {\n const parsed = JSON.parse(text);\n if (parsed && typeof parsed.error === \"string\") return parsed.error;\n } catch {\n // not JSON — fall through\n }\n return text || `HTTP ${status}`;\n}\n","//! Filter builder producing the bare predicate-array wire shape.\n//\n// A `Filter` is AND-combined predicates; on the wire it is a plain array. Each\n// predicate is a *positive assertion about a present attribute* — an absent key\n// matches nothing, including the negative predicates (`ne`/`notIn`) and ranges.\n// Comparisons are same-type only (Int↔Int numeric, Float↔Float by IEEE, Str↔Str\n// lexical, Bool↔Bool, DateTime↔DateTime as instants), so an operand's encoded type\n// has to match the attribute's: `ge(\"score\", v.float(2))`, not `ge(\"score\", 2)`.\n\nimport type { AttrInput, Filter, Predicate, Value } from \"./types.js\";\nimport { encodeValue } from \"./values.js\";\n\n/**\n * Predicate constructors. Each accepts a plain JS value (auto-normalized) or an\n * explicit `v.*` {@link Value}. Combine results into a {@link Filter} array, or\n * use {@link f.and} for readability.\n */\nexport const f = {\n /** `attrs[key] === value`. */\n eq: (key: string, value: AttrInput): Predicate => ({\n Eq: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is present and `!== value`. */\n ne: (key: string, value: AttrInput): Predicate => ({\n Ne: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `Str` matching the glob pattern (`*`, `?`, `[..]`). */\n glob: (key: string, pattern: string): Predicate => ({ Glob: [key, pattern] }),\n /**\n * {@link f.glob}, ignoring **ASCII** case on both sides — `\"Src/*\"` matches\n * `\"src/main.rs\"`. Non-ASCII is not folded (`É` does not match `é`).\n */\n iglob: (key: string, pattern: string): Predicate => ({\n IGlob: [key, pattern],\n }),\n /** `attrs[key]` equals one of `values`. */\n in: (key: string, values: AttrInput[]): Predicate => ({\n In: [key, values.map(encodeValue)],\n }),\n /** `attrs[key]` is present and equals none of `values`. */\n notIn: (key: string, values: AttrInput[]): Predicate => ({\n NotIn: [key, values.map(encodeValue)],\n }),\n /** `attrs[key] < value` (same-type, orderable). */\n lt: (key: string, value: AttrInput): Predicate => ({\n Lt: [key, encodeValue(value)],\n }),\n /** `attrs[key] <= value` (same-type, orderable). */\n le: (key: string, value: AttrInput): Predicate => ({\n Le: [key, encodeValue(value)],\n }),\n /** `attrs[key] > value` (same-type, orderable). */\n gt: (key: string, value: AttrInput): Predicate => ({\n Gt: [key, encodeValue(value)],\n }),\n /** `attrs[key] >= value` (same-type, orderable). */\n ge: (key: string, value: AttrInput): Predicate => ({\n Ge: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` containing `value` (whole-element, not substring). */\n contains: (key: string, value: AttrInput): Predicate => ({\n Contains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a present `List` not containing `value`. */\n notContains: (key: string, value: AttrInput): Predicate => ({\n NotContains: [key, encodeValue(value)],\n }),\n /** `attrs[key]` is a `List` sharing at least one element with `values`. */\n containsAny: (key: string, values: AttrInput[]): Predicate => ({\n ContainsAny: [key, values.map(encodeValue)],\n }),\n /** Every sub-predicate holds. `all()` is `true`. */\n all: (...preds: Predicate[]): Predicate => ({ All: preds }),\n /** At least one sub-predicate holds. `any()` is `false`. */\n any: (...preds: Predicate[]): Predicate => ({ Any: preds }),\n /**\n * The sub-predicate does not hold. Differs from {@link f.ne} on an absent key:\n * `not(eq(k, v))` matches a record with no `k`, `ne(k, v)` does not.\n */\n not: (pred: Predicate): Predicate => ({ Not: pred }),\n /**\n * `attrs[key]` is within `maxEdits` Levenshtein edits of `text`, ASCII-case-folded on\n * both sides; a `List` matches if any element does. The only three-element predicate.\n * A `maxEdits` above 8 is refused by the server, not clamped.\n */\n fuzzy: (key: string, text: string, maxEdits: number): Predicate => ({\n Fuzzy: [key, text, maxEdits],\n }),\n /**\n * Every token of `text` appears among `attrs[key]`'s tokens, in any order. Tokens are\n * ASCII-case-folded runs of alphanumerics; a `List` matches if any single element does.\n */\n containsAllTokens: (key: string, text: string): Predicate => ({\n ContainsAllTokens: [key, text],\n }),\n /** At least one token of `text` appears among `attrs[key]`'s tokens. Empty never matches. */\n containsAnyToken: (key: string, text: string): Predicate => ({\n ContainsAnyToken: [key, text],\n }),\n /** `text`'s tokens appear consecutively and in order — a phrase match. */\n containsTokenSequence: (key: string, text: string): Predicate => ({\n ContainsTokenSequence: [key, text],\n }),\n /**\n * `attrs[key]` matches the regular expression, **anchored at both ends** like\n * {@link f.glob} — `.*` opts back into a substring search, and `(?i)` into case folding.\n * The syntax is Rust's `regex`, not JS's: no backreferences and no lookaround.\n */\n regex: (key: string, pattern: string): Predicate => ({ Regex: [key, pattern] }),\n /** Collect predicates into a {@link Filter} (purely sugar — they already AND). */\n and: (...preds: Predicate[]): Filter => preds,\n} as const;\n\n// Aliases for the comparison operators, for callers who pref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,OAAO,CAAC,KAAa,aAAgC,EAAE,OAAO,CAAC,KAAK,OAAO,EAAE;AAAA;AAAA,EAE7E,KAAK,IAAI,UAA+B;AAC1C;","names":["f"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckedup/nidus",
3
- "version": "0.74.0",
3
+ "version": "0.76.0",
4
4
  "description": "JavaScript/TypeScript client for nidus — a small, fast vector store. Connects to a local or remote `nidus serve` over HTTP.",
5
5
  "type": "module",
6
6
  "license": "MIT",