@indxsearch/indx-types 4.0.0-beta.0 → 4.0.0-beta.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0-beta.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Loads in plain Node, Vitest and anything else that resolves by the ESM rules: the build now imports its own files with their extensions, so the enums (`SearchMode`, `Tolerance`, `SystemState` …) work at runtime, not only under a bundler. And the rest of the 6.0 server's search is typed: `offset`, `facetFields`, `facetValueLimit` and `includeDocuments` on `QueryProxy`; `documents` (typed with a generic, `Result<Book>`), `facetStats` and `cold` on `Result`; `MultiSearchAnswer` for `search/multi`; and cold storage's `ColdWrite`, `ColdBatchItem`, `ColdBatchOutcome` and `ColdView`.
8
+
3
9
  ## 4.0.0-beta.0
4
10
 
5
11
  ### Major Changes
package/dist/boost.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BoostStrength, BuryStrength } from './enums';
2
- import { FilterProxy } from './filters';
1
+ import { BoostStrength, BuryStrength } from './enums.js';
2
+ import { FilterProxy } from './filters.js';
3
3
  export interface BoostProxy {
4
4
  boostStrength: BoostStrength;
5
5
  filterProxy: FilterProxy;
package/dist/cold.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Who may read a cold storage item. `public`: anyone who may read the dataset, a Search key in a
3
+ * browser included (but not a Search key over MCP, which reads none). `answer`: also Search or ask's
4
+ * answer, Read keys and Viewers, never a Search key. `private` (the default): only Full keys, Read
5
+ * keys with private cold storage allowed, and Editors and Admins in the console.
6
+ */
7
+ export type ColdVisibility = 'public' | 'answer' | 'private';
8
+ /** The body of `PUT .../documents/{key}/cold/{name}` (`?language=` optional): one item beside a
9
+ * record, never searched, read when a question needs it. */
10
+ export interface ColdWrite {
11
+ content: string;
12
+ /** e.g. `text/markdown`, `application/json`; default `text/plain`. */
13
+ contentType?: string | null;
14
+ description?: string | null;
15
+ /** Default `private`. */
16
+ visibility?: ColdVisibility | null;
17
+ /** The sender's own reference to where the content came from. */
18
+ sourceRef?: string | null;
19
+ /** When the source last changed it (ISO 8601): a write older than what is stored is refused. */
20
+ sourceUpdatedUtc?: string | null;
21
+ }
22
+ /** One item of `PUT .../cold` (`?prune=true` also deletes what the same sender wrote before and
23
+ * did not send now). The record is named by its Indx key, or by `id`: the id the dataset's webhook
24
+ * gave it, or the key as text. */
25
+ export interface ColdBatchItem extends ColdWrite {
26
+ name: string;
27
+ recordKey?: number | null;
28
+ id?: string | null;
29
+ language?: string | null;
30
+ }
31
+ /** How one batch item went, in the place of the item. */
32
+ export interface ColdBatchOutcome {
33
+ /** 0 when no record has the item's id. */
34
+ recordKey: number;
35
+ name: string;
36
+ language: string;
37
+ outcome: 'created' | 'updated' | 'versionmismatch' | 'olderthanstored' | 'refused' | (string & {});
38
+ /** Why, when it was not written. */
39
+ detail?: string | null;
40
+ /** The item's `id`, as it gave it. */
41
+ id?: string | null;
42
+ }
43
+ /** An item as read: `GET .../documents/{key}/cold` lists them without content, `GET .../cold/{name}`
44
+ * returns one with it. */
45
+ export interface ColdView {
46
+ name: string;
47
+ language: string;
48
+ recordKey: number;
49
+ /** Null in a listing. */
50
+ content?: string | null;
51
+ length: number;
52
+ contentType: string;
53
+ description: string;
54
+ visibility: ColdVisibility;
55
+ writtenBy: string;
56
+ writtenVia: string;
57
+ sourceRef?: string | null;
58
+ sourceUpdatedUtc?: string | null;
59
+ version: number;
60
+ createdUtc: string;
61
+ updatedUtc: string;
62
+ }
package/dist/cold.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/fields.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Tolerance } from './enums';
1
+ import { Tolerance } from './enums.js';
2
2
  export interface FieldProxy {
3
3
  fieldName: string;
4
4
  /** Read-only on GET; ignored on SET. */
@@ -28,9 +28,10 @@ export interface FieldProxy {
28
28
  bM25b?: number | null;
29
29
  /** Per-field term-frequency saturation parameter k1. Typical 1.0–2.0. */
30
30
  bM25k1?: number | null;
31
- /** The most a word may differ by in the field: Exact, OneEdit (the default), TwoEdits, ThreeEdits; a search's match.tolerance caps it. Until 6.0 coverageStrictness. */
31
+ /** The most a word may differ by in the field: Exact, OneEdit (the default), TwoEdits, ThreeEdits; a search's match.tolerance caps it. */
32
32
  tolerance?: Tolerance | null;
33
- /** The field's weight in Coverage against the heaviest field; 0 leaves it out of Coverage (until 6.0 coverageStrictness None). */
33
+ /** The field's weight in the reranker (ranking.rerank) against the heaviest field; 0 leaves it
34
+ * out of the reranker and the word lookup. */
34
35
  rerankWeight?: number | null;
35
36
  caseSensitive?: boolean | null;
36
37
  /** From how many letters the word being typed matches the start of a longer word in this
package/dist/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- export { SystemState, BoostStrength, BuryStrength, SynonymDirection, SearchMode, Tolerance, Rungs, IndexTerms } from './enums';
2
- export { JsonErrorType } from './errors';
3
- export { LoginInfo, LoginResponse, ChangePasswordRequest } from './auth';
4
- export { QueryProxy, MatchSetup, CandidateSetup, RankingProxy } from './query';
5
- export { FilterProxy, RangeFilterProxy, ValueFilterProxy, CombinedFilterProxy, InFilterProxy, PositionFilterProxy, FilterExpressionProxy, FilterExpressionResultProxy, FilterExpressionErrorDetail, UpdateFieldProxy, FilterFieldUpdateProxy } from './filters';
6
- export { RuleCondition, BoostRule, BuryRule, DatasetQueryParameters, QueryParametersResponse, FieldProfile, FieldProfileView, FieldProfilesResponse, FieldProfilesRequest } from './rules';
7
- export { BoostProxy, BuryProxy } from './boost';
8
- export { SynonymList, SynonymEntry } from './synonyms';
9
- export { VectorQueryProxy, HybridQueryProxy, EmbeddingResultEntry } from './vector';
10
- export { Result, QueryFitResult, ScoreEntry, ToleranceCounts, PageFill, MatchReport, RecordMatch, QueryWordMatch, WordMatch } from './result';
11
- export { SystemStatus, LicenseInfo } from './status';
12
- export { ParseResult, ProcessError, ProcessErrorCount } from './errors';
13
- export { IndxProblem, IndxProblemCode } from './problem';
14
- export { FieldProxy } from './fields';
15
- export { DataSetListDto } from './datasets';
16
- export { StringInt32KeyValuePair, StringSingleValueTuple } from './common';
1
+ export { SystemState, BoostStrength, BuryStrength, SynonymDirection, SearchMode, Tolerance, Rungs, IndexTerms } from './enums.js';
2
+ export { JsonErrorType } from './errors.js';
3
+ export { LoginInfo, LoginResponse, ChangePasswordRequest } from './auth.js';
4
+ export { QueryProxy, MatchSetup, CandidateSetup, RankingProxy } from './query.js';
5
+ export { FilterProxy, RangeFilterProxy, ValueFilterProxy, CombinedFilterProxy, InFilterProxy, PositionFilterProxy, FilterExpressionProxy, FilterExpressionResultProxy, FilterExpressionErrorDetail, UpdateFieldProxy, FilterFieldUpdateProxy } from './filters.js';
6
+ export { RuleCondition, BoostRule, BuryRule, DatasetQueryParameters, QueryParametersResponse, FieldProfile, FieldProfileView, FieldProfilesResponse, FieldProfilesRequest } from './rules.js';
7
+ export { BoostProxy, BuryProxy } from './boost.js';
8
+ export { SynonymList, SynonymEntry } from './synonyms.js';
9
+ export { VectorQueryProxy, HybridQueryProxy, EmbeddingResultEntry } from './vector.js';
10
+ export { Result, QueryFitResult, ScoreEntry, ToleranceCounts, PageFill, MatchReport, RecordMatch, QueryWordMatch, WordMatch, FacetStats, MultiSearchAnswer, MultiSearchFailure, MAX_SEARCHES_PER_MULTI } from './result.js';
11
+ export { ColdVisibility, ColdWrite, ColdBatchItem, ColdBatchOutcome, ColdView } from './cold.js';
12
+ export { SystemStatus, LicenseInfo } from './status.js';
13
+ export { ParseResult, ProcessError, ProcessErrorCount } from './errors.js';
14
+ export { IndxProblem, IndxProblemCode } from './problem.js';
15
+ export { FieldProxy } from './fields.js';
16
+ export { DataSetListDto } from './datasets.js';
17
+ export { StringInt32KeyValuePair, StringSingleValueTuple } from './common.js';
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  // Enums
2
- export { SystemState, BoostStrength, BuryStrength, SynonymDirection, SearchMode, Tolerance, Rungs, IndexTerms } from './enums';
3
- export { JsonErrorType } from './errors';
2
+ export { SystemState, BoostStrength, BuryStrength, SynonymDirection, SearchMode, Tolerance, Rungs, IndexTerms } from './enums.js';
3
+ export { JsonErrorType } from './errors.js';
4
+ // Result
5
+ export { MAX_SEARCHES_PER_MULTI } from './result.js';
package/dist/problem.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FilterExpressionErrorDetail } from './filters';
1
+ import { FilterExpressionErrorDetail } from './filters.js';
2
2
  /**
3
3
  * Machine-readable error code carried by every Indx error response, as the `code`
4
4
  * extension of an RFC 9457 problem document. Switch on this, not on the HTTP status: a 400 can
package/dist/query.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { FilterProxy } from './filters';
2
- import { BoostProxy, BuryProxy } from './boost';
3
- import { IndexTerms, Rungs, SearchMode, Tolerance } from './enums';
1
+ import { FilterProxy } from './filters.js';
2
+ import { BoostProxy, BuryProxy } from './boost.js';
3
+ import { IndexTerms, Rungs, SearchMode, Tolerance } from './enums.js';
4
4
  /** What counts as a hit. Every member optional: a member left out is the server's default. */
5
5
  export interface MatchSetup {
6
6
  /** The most a word may differ by; caps each field's own (FieldProxy.tolerance). Default TwoEdits. */
@@ -41,17 +41,17 @@ export interface CandidateSetup {
41
41
  }
42
42
  /** The order inside the rungs, with the boosts and buries as the tokens their endpoints give. */
43
43
  export interface RankingProxy {
44
- /** Whether Coverage reranks the candidates, in either mode. Default true. */
44
+ /** Whether the reranker orders the candidates by how their words were met, in either mode. Default true. */
45
45
  rerank?: boolean;
46
- /** Coverage's share of the score, 0 to 1. Default 0.2. */
46
+ /** The reranker's share of the score, 0 to 1. Default 0.2. */
47
47
  share?: number;
48
- /** How far the share moves towards Coverage while the last word is typed. Default 0.5. */
48
+ /** How far the share moves towards the reranker while the last word is typed. Default 0.5. */
49
49
  typingShift?: number;
50
50
  longFieldFrom?: number;
51
51
  longFieldWeightFloor?: number;
52
52
  /** The whole query in a field floors the score. Default true. */
53
53
  wholeQueryFloor?: boolean;
54
- /** Per field, its Coverage weight in this search. */
54
+ /** Per field, its reranker weight in this search. */
55
55
  fieldWeights?: Record<string, number> | null;
56
56
  /** Per field, a boost inside BM25F's saturation. */
57
57
  fieldBoosts?: Record<string, number> | null;
@@ -63,7 +63,10 @@ export interface RankingProxy {
63
63
  export interface QueryProxy {
64
64
  text?: string | null;
65
65
  maxNumberOfRecordsToReturn?: number;
66
- /** Default Coverage. */
66
+ /** How many ranked records to pass over before the first returned: page while `offset` is below
67
+ * the result's `ranked`. Default 0. */
68
+ offset?: number;
69
+ /** EditDistance or Bm25f. Left out: the dataset's mode, else EditDistance. */
67
70
  mode?: SearchMode;
68
71
  /** Null or left out: the defaults. */
69
72
  match?: MatchSetup | null;
@@ -72,6 +75,14 @@ export interface QueryProxy {
72
75
  /** Return `matchReport`, in any mode: how each query word was met in each record. */
73
76
  enableMatchReport?: boolean;
74
77
  enableFacets?: boolean;
78
+ /** The facetable fields to count; empty or left out counts every one. */
79
+ facetFields?: string[] | null;
80
+ /** The most values per facet field, the commonest first; 0 or left out returns them all.
81
+ * `facetStats` is of every value counted either way. */
82
+ facetValueLimit?: number;
83
+ /** The records' JSON comes with the result, in `documents`, in the order of `records`: one call
84
+ * instead of a search and a lookup. Default false. */
85
+ includeDocuments?: boolean;
75
86
  removeDuplicates?: boolean;
76
87
  sortAscending?: boolean;
77
88
  sortBy?: string | null;
package/dist/result.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { StringInt32KeyValuePair } from './common';
2
- import { SystemState, Tolerance } from './enums';
3
- import { ProcessError } from './errors';
1
+ import { StringInt32KeyValuePair } from './common.js';
2
+ import { SystemState, Tolerance } from './enums.js';
3
+ import { ProcessError } from './errors.js';
4
+ import { IndxProblem } from './problem.js';
4
5
  export interface ScoreEntry {
5
6
  documentKey: number;
6
7
  score: number;
7
8
  }
8
- /** How Coverage met a query word in a record. */
9
+ /** How a query word was met in a record. */
9
10
  export type WordMatch = 'NotFound' | 'Whole' | 'Prefix' | 'Suffix' | 'Joined' | 'RunTogether' | 'OneEdit' | 'TwoEdits' | 'ThreeEdits' | 'Synonym' | number;
10
11
  export interface QueryWordMatch {
11
12
  word: string;
@@ -46,11 +47,32 @@ export interface ToleranceCounts {
46
47
  /** Of the counted, those holding a run of words only through a synonym; null when none fired. */
47
48
  throughSynonym?: number | null;
48
49
  }
49
- export interface Result {
50
+ /** A number field's values in the set the facets are counted over (result.facetStats): the lowest,
51
+ * the highest, and how many records hold one; `count` is null for an array field, whose records can
52
+ * hold several values. */
53
+ export interface FacetStats {
54
+ min: number;
55
+ max: number;
56
+ count?: number | null;
57
+ }
58
+ export interface Result<TDocument = Record<string, unknown>> {
50
59
  records?: ScoreEntry[] | null;
51
60
  facets?: {
52
61
  [key: string]: StringInt32KeyValuePair[];
53
62
  } | null;
63
+ /** Per number field among the facets: its lowest and highest value and how many records hold one. */
64
+ facetStats?: {
65
+ [field: string]: FacetStats;
66
+ } | null;
67
+ /** With query.includeDocuments: each record's JSON, as an object, in the order of `records`;
68
+ * null for a record deleted since. Type it with a generic when the shape is known:
69
+ * `Result<Book>`. */
70
+ documents?: Array<TDocument | null> | null;
71
+ /** The names of the cold storage each listed record holds, by record key, where any does and the
72
+ * caller's key may read it. Absent when none does. */
73
+ cold?: {
74
+ [documentKey: string]: string[];
75
+ } | null;
54
76
  didTimeOut: boolean;
55
77
  /** Set when the search was refused rather than finding nothing. */
56
78
  reason?: ProcessError | null;
@@ -77,7 +99,7 @@ export interface Result {
77
99
  fill?: PageFill | null;
78
100
  }
79
101
  /** A {@link Result} of a search with `measureFit`: how well the results explain the text. */
80
- export interface QueryFitResult extends Result {
102
+ export interface QueryFitResult<TDocument = Record<string, unknown>> extends Result<TDocument> {
81
103
  /** Share of the query's weight (its words' IDF) the best explaining result explains, 0 to 1. */
82
104
  explainedShare: number;
83
105
  /** Share carried by informative words no result explains, 0 to 1. */
@@ -85,3 +107,15 @@ export interface QueryFitResult extends Result {
85
107
  explainedWords: string[];
86
108
  unexplainedWords: string[];
87
109
  }
110
+ /** One answer of `POST .../search/multi`, in the place of its search: a {@link Result} with the
111
+ * `queryId` a single search sends as the `Indx-Query-Id` header, or the failure of that search
112
+ * alone, with the status and problem a single search would have had. */
113
+ export type MultiSearchAnswer<TDocument = Record<string, unknown>> = (Result<TDocument> & {
114
+ queryId?: string | null;
115
+ }) | MultiSearchFailure;
116
+ export interface MultiSearchFailure {
117
+ status: number;
118
+ error: IndxProblem;
119
+ }
120
+ /** The most searches one `search/multi` call takes. */
121
+ export declare const MAX_SEARCHES_PER_MULTI = 20;
package/dist/result.js CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ /** The most searches one `search/multi` call takes. */
2
+ export const MAX_SEARCHES_PER_MULTI = 20;
package/dist/rules.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { BoostStrength, BuryStrength, SearchMode } from './enums';
2
- import { CandidateSetup, MatchSetup, RankingProxy } from './query';
3
- import { Tolerance } from './enums';
1
+ import { BoostStrength, BuryStrength, SearchMode } from './enums.js';
2
+ import { CandidateSetup, MatchSetup, RankingProxy } from './query.js';
3
+ import { Tolerance } from './enums.js';
4
4
  /** A condition of a saved boost or bury rule: a value, or a range on a number field. */
5
5
  export interface RuleCondition {
6
6
  field?: string | null;
package/dist/status.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SystemState } from './enums';
2
- import { ProcessErrorCount, ProcessError } from './errors';
1
+ import { SystemState } from './enums.js';
2
+ import { ProcessErrorCount, ProcessError } from './errors.js';
3
3
  export interface LicenseInfo {
4
4
  licensed: boolean;
5
5
  validLicense: boolean;
@@ -1,4 +1,4 @@
1
- import { SynonymDirection } from './enums';
1
+ import { SynonymDirection } from './enums.js';
2
2
  /**
3
3
  * One synonym rule: a set of terms plus the direction they expand in. Multi-word terms are
4
4
  * matched as whole phrases.
package/dist/vector.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FilterProxy } from './filters';
1
+ import { FilterProxy } from './filters.js';
2
2
  export interface VectorQueryProxy {
3
3
  fieldName?: string | null;
4
4
  vector?: number[] | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indxsearch/indx-types",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.1",
4
4
  "description": "TypeScript type definitions for Indx v2. Provides complete types for search queries, filters, boosts, results, and system status based on the official Swagger specification.",
5
5
  "keywords": [
6
6
  "indx",