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

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0-beta.2
4
+
5
+ ### Minor Changes
6
+
7
+ - Types for one search per keystroke: `GroupedSearchRequest`, `SearchGroup` and `GroupedSearchResult` for `search/groups` (one text answered in named sections, each with its own filter, rows and count), `MultiSearchQuery` for a `search/multi` search that says for itself whether it counts in the statistics, and `includeFields` on `QueryProxy` to get only the record fields a page shows. Also on `QueryProxy`: `collapseBy` (one record per value of a field, such as one row per title), `counts` (named counts in the same search, read from the result's `counts`), and `facetSelections` and `facetRanges` (facets that leave out their own selection, for OR within a facet group). `removeDuplicates` is gone: the server never acted on it.
8
+
9
+ ## 4.0.0-beta.1
10
+
11
+ ### Minor Changes
12
+
13
+ - 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`.
14
+
3
15
  ## 4.0.0-beta.0
4
16
 
5
17
  ### 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, MultiSearchQuery, SearchGroup, GroupedSearchRequest } 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, GroupedSearchResult } 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,7 +75,31 @@ 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;
75
- removeDuplicates?: 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;
86
+ /** With includeDocuments: only these top-level fields of each record. Null or empty: the whole record. */
87
+ includeFields?: string[] | null;
88
+ /** One record per value of these fields, in the ranking's order: the best-ranked kept, the next
89
+ * with a value not seen taking a duplicate's place; `offset` counts the records kept. Each field
90
+ * must have a role and not be an array. With includeFields, these fields must be among them. */
91
+ collapseBy?: string[] | null;
92
+ /** Named counts, each a filter expression: how many of the records `count` counts each lets
93
+ * through, in the result's `counts`. Counted over the same set as the facets, so no extra search;
94
+ * not the count a separate search with that filter would give where the typo levels differ. */
95
+ counts?: Record<string, string> | null;
96
+ /** The values ticked on facets, by Facetable field: the list holds records with one of a field's
97
+ * values (OR within a field, AND between fields and with the filter), and each selected field's
98
+ * facet is counted without its own selection. */
99
+ facetSelections?: Record<string, string[]> | null;
100
+ /** A range on a facet, by field: a filter expression on that field alone (`publishedYear >= 2010`),
101
+ * the field Facetable and Filterable. Its facet and facetStats are counted without it. */
102
+ facetRanges?: Record<string, string> | null;
76
103
  sortAscending?: boolean;
77
104
  sortBy?: string | null;
78
105
  timeOutLimitMilliseconds?: number;
@@ -84,3 +111,33 @@ export interface QueryProxy {
84
111
  /** The result then also says how well it explains the text: a {@link QueryFitResult}. */
85
112
  measureFit?: boolean;
86
113
  }
114
+ /** One search of `POST .../search/multi`: a search that may say for itself how it goes into the
115
+ * statistics, over the query string's `?count=`, `?source=` and `?session=`. */
116
+ export interface MultiSearchQuery extends QueryProxy {
117
+ /** Whether this search is a visitor's; left out: the query string's. */
118
+ count?: boolean | null;
119
+ source?: string | null;
120
+ session?: string | null;
121
+ }
122
+ /** One section of a {@link GroupedSearchRequest}. */
123
+ export interface SearchGroup {
124
+ /** The section's key in the answer's `groups`; unique in the request. */
125
+ name: string;
126
+ /** A filter expression for the section, ANDed with the search's own `filterExpression`. */
127
+ filter?: string | null;
128
+ /** How many records the section lists; 0 lists none and still counts. */
129
+ rows: number;
130
+ /** Count by this filter instead of `filter`: list the upcoming events, count them all. */
131
+ countFilter?: string | null;
132
+ /** The section's own candidates, ranking and match, each replacing the search's whole. */
133
+ candidates?: CandidateSetup | null;
134
+ ranking?: RankingProxy | null;
135
+ match?: MatchSetup | null;
136
+ /** The section that is the visitor's search, the one recorded in the statistics; none marked: the first. */
137
+ primary?: boolean;
138
+ }
139
+ /** The body of `POST .../search/groups`: one text answered in named sections. Everything but
140
+ * `groups` is every section's. At most 20 groups. */
141
+ export interface GroupedSearchRequest extends QueryProxy {
142
+ groups: SearchGroup[];
143
+ }
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,34 @@ 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
+ /** For each name in query.counts, how many of the records `count` counts its filter lets through. */
64
+ counts?: Record<string, number> | null;
65
+ /** Per number field among the facets: its lowest and highest value and how many records hold one. */
66
+ facetStats?: {
67
+ [field: string]: FacetStats;
68
+ } | null;
69
+ /** With query.includeDocuments: each record's JSON, as an object, in the order of `records`;
70
+ * null for a record deleted since. Type it with a generic when the shape is known:
71
+ * `Result<Book>`. */
72
+ documents?: Array<TDocument | null> | null;
73
+ /** The names of the cold storage each listed record holds, by record key, where any does and the
74
+ * caller's key may read it. Absent when none does. */
75
+ cold?: {
76
+ [documentKey: string]: string[];
77
+ } | null;
54
78
  didTimeOut: boolean;
55
79
  /** Set when the search was refused rather than finding nothing. */
56
80
  reason?: ProcessError | null;
@@ -77,7 +101,7 @@ export interface Result {
77
101
  fill?: PageFill | null;
78
102
  }
79
103
  /** A {@link Result} of a search with `measureFit`: how well the results explain the text. */
80
- export interface QueryFitResult extends Result {
104
+ export interface QueryFitResult<TDocument = Record<string, unknown>> extends Result<TDocument> {
81
105
  /** Share of the query's weight (its words' IDF) the best explaining result explains, 0 to 1. */
82
106
  explainedShare: number;
83
107
  /** Share carried by informative words no result explains, 0 to 1. */
@@ -85,3 +109,23 @@ export interface QueryFitResult extends Result {
85
109
  explainedWords: string[];
86
110
  unexplainedWords: string[];
87
111
  }
112
+ /** One answer of `POST .../search/multi`, in the place of its search: a {@link Result} with the
113
+ * `queryId` a single search sends as the `Indx-Query-Id` header, or the failure of that search
114
+ * alone, with the status and problem a single search would have had. */
115
+ export type MultiSearchAnswer<TDocument = Record<string, unknown>> = (Result<TDocument> & {
116
+ queryId?: string | null;
117
+ }) | MultiSearchFailure;
118
+ export interface MultiSearchFailure {
119
+ status: number;
120
+ error: IndxProblem;
121
+ }
122
+ /** The most searches one `search/multi` call takes. */
123
+ export declare const MAX_SEARCHES_PER_MULTI = 20;
124
+ /** The answer of `POST .../search/groups`: each section's result by its name, a failed one as its
125
+ * failure, and the one `queryId` a click in any section refers to. */
126
+ export interface GroupedSearchResult<TDocument = Record<string, unknown>> {
127
+ groups: {
128
+ [name: string]: Result<TDocument> | MultiSearchFailure;
129
+ };
130
+ queryId?: string | null;
131
+ }
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.2",
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",