@tstdl/base 0.93.21 → 0.93.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/application/application.js +1 -1
  2. package/authentication/server/module.d.ts +1 -1
  3. package/authentication/server/module.js +1 -6
  4. package/document-management/api/document-management.api.d.ts +0 -4
  5. package/document-management/service-models/document.service-model.d.ts +0 -2
  6. package/injector/injector.js +9 -9
  7. package/logger/manager.js +3 -3
  8. package/orm/data-types/bytea.d.ts +4 -14
  9. package/orm/data-types/bytea.js +2 -2
  10. package/orm/data-types/common.d.ts +18 -0
  11. package/orm/data-types/common.js +11 -0
  12. package/orm/data-types/index.d.ts +1 -0
  13. package/orm/data-types/index.js +1 -0
  14. package/orm/data-types/numeric-date.d.ts +4 -15
  15. package/orm/data-types/numeric-date.js +2 -2
  16. package/orm/data-types/timestamp.d.ts +4 -15
  17. package/orm/data-types/timestamp.js +2 -2
  18. package/orm/data-types/tsvector.d.ts +3 -13
  19. package/orm/data-types/tsvector.js +2 -2
  20. package/orm/decorators.d.ts +16 -54
  21. package/orm/decorators.js +24 -37
  22. package/orm/entity.d.ts +6 -9
  23. package/orm/entity.js +1 -2
  24. package/orm/query.d.ts +199 -61
  25. package/orm/query.js +2 -2
  26. package/orm/repository.types.d.ts +38 -9
  27. package/orm/server/drizzle/schema-converter.js +40 -118
  28. package/orm/server/query-converter.d.ts +21 -7
  29. package/orm/server/query-converter.js +194 -38
  30. package/orm/server/repository.d.ts +39 -22
  31. package/orm/server/repository.js +141 -71
  32. package/orm/server/types.d.ts +10 -2
  33. package/orm/sqls.d.ts +14 -16
  34. package/orm/sqls.js +34 -17
  35. package/package.json +2 -2
  36. package/test/drizzle/0000_nervous_iron_monger.sql +9 -0
  37. package/test/drizzle/meta/0000_snapshot.json +27 -7
  38. package/test/drizzle/meta/_journal.json +2 -44
  39. package/test/test.model.js +2 -6
  40. package/test1.js +18 -5
  41. package/test6.js +21 -35
  42. package/types/types.d.ts +8 -5
  43. package/utils/equals.js +2 -2
  44. package/utils/format-error.js +2 -2
  45. package/utils/helpers.js +3 -2
  46. package/utils/object/object.d.ts +4 -4
  47. package/test/drizzle/0000_sudden_sphinx.sql +0 -9
  48. package/test/drizzle/0001_organic_rhodey.sql +0 -2
  49. package/test/drizzle/0002_nice_squadron_supreme.sql +0 -1
  50. package/test/drizzle/0003_serious_mockingbird.sql +0 -1
  51. package/test/drizzle/0004_complete_pixie.sql +0 -1
  52. package/test/drizzle/0005_bumpy_sabra.sql +0 -1
  53. package/test/drizzle/0006_overrated_post.sql +0 -6
  54. package/test/drizzle/meta/0001_snapshot.json +0 -79
  55. package/test/drizzle/meta/0002_snapshot.json +0 -63
  56. package/test/drizzle/meta/0003_snapshot.json +0 -73
  57. package/test/drizzle/meta/0004_snapshot.json +0 -89
  58. package/test/drizzle/meta/0005_snapshot.json +0 -104
  59. package/test/drizzle/meta/0006_snapshot.json +0 -104
package/orm/entity.js CHANGED
@@ -14,7 +14,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
14
14
  import { Defaulted, Integer } from '../schema/index.js';
15
15
  import { EmbeddedProperty, PrimaryKeyProperty } from './decorators.js';
16
16
  import { JsonProperty, TimestampProperty, UuidProperty } from './schemas/index.js';
17
- export const entityMeta = '__entityMeta__';
18
17
  /**
19
18
  * Base class for extensible metadata attributes associated with an entity.
20
19
  * Allows storing arbitrary key-value pairs.
@@ -96,4 +95,4 @@ export {
96
95
  /**
97
96
  * @deprecated Use BaseEntity instead.
98
97
  */
99
- BaseEntity as EntityWithoutMetadata, };
98
+ BaseEntity as EntityWithoutMetadata };
package/orm/query.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import type { SQL, SQLWrapper } from 'drizzle-orm';
2
+ import type { LiteralUnion, UnionToIntersection } from 'type-fest';
2
3
  import type { Geometry } from '../types/geo-json.js';
3
4
  import type { Flatten, Record } from '../types/index.js';
4
5
  import type { UntaggedDeep } from '../types/tagged.js';
6
+ import type { BaseEntity } from './entity.js';
7
+ import type { TargetColumn } from './repository.types.js';
5
8
  /** Represents a logical query combining multiple sub-queries (e.g., $and, $or, $nor). */
6
9
  export type LogicalQuery<T = any> = LogicalAndQuery<T> | LogicalOrQuery<T> | LogicalNorQuery<T>;
7
10
  /** Union of keys representing logical query operators ('$and', '$or', '$nor'). */
@@ -15,16 +18,19 @@ export type ComparisonQueryBody<T = any> = {
15
18
  /** Represents either a full comparison query object or a direct value for equality comparison. */
16
19
  export type ComparisonQueryOrValue<T = any> = ComparisonQuery<T> | ComparisonValue<T>;
17
20
  /** Represents a comparison query using various operators like $eq, $ne, $gt, $in, etc. */
18
- export type ComparisonQuery<T = any> = Partial<ComparisonAndQuery<T> & ComparisonOrQuery<T> & ComparisonNotQuery<T> & ComparisonEqualsQuery<T> & ComparisonNotEqualsQuery<T> & ComparisonExistsQuery & ComparisonItemQuery<T> & ComparisonInQuery<T> & ComparisonNotInQuery<T> & ComparisonAllQuery<T> & ComparisonGreaterThanQuery<T> & ComparisonGreaterThanOrEqualsQuery<T> & ComparisonLessThanQuery<T> & ComparisonLessThanOrEqualsQuery<T> & ComparisonRegexQuery & ComparisonFtsQuery & ComparisonGeoShapeQuery & ComparisonGeoDistanceQuery>;
19
- export type FtsParser = 'raw' | 'plain' | 'phrase' | 'websearch';
21
+ export type ComparisonQuery<T = any> = Partial<ComparisonAndQuery<T> & ComparisonOrQuery<T> & ComparisonNotQuery<T> & ComparisonEqualsQuery<T> & ComparisonNotEqualsQuery<T> & ComparisonExistsQuery & ComparisonItemQuery<T> & ComparisonInQuery<T> & ComparisonNotInQuery<T> & ComparisonAllQuery<T> & ComparisonGreaterThanQuery<T> & ComparisonGreaterThanOrEqualsQuery<T> & ComparisonLessThanQuery<T> & ComparisonLessThanOrEqualsQuery<T> & ComparisonRegexQuery & ComparisonTsVectorQuery & ComparisonTrigramQuery & ComparisonParadeMatchQuery & ComparisonParadeTantivyQuery & ComparisonGeoShapeQuery & ComparisonGeoDistanceQuery>;
22
+ export type TsVectorParser = 'raw' | 'plain' | 'phrase' | 'websearch';
23
+ export type TsVectorWeight = 'A' | 'B' | 'C' | 'D';
24
+ export type TrigramSimilarityType = 'phrase' | 'word' | 'strict-word';
20
25
  /** Union of keys representing comparison query operators. */
21
26
  export type ComparisonQueryTypes = keyof ComparisonQuery;
22
27
  /** Array containing all valid comparison query operator keys. */
23
28
  export declare const allComparisonQueryTypes: ComparisonQueryTypes[];
24
29
  /** Represents specialized query types beyond simple comparisons. */
25
- export type SpecialQuery<T = any> = Partial<FullTextSearchQuery<T>>;
30
+ export type SpecialQuery<T extends BaseEntity = BaseEntity> = FullTextSearchQuery<T>;
31
+ export type FullTextSearchQuery<T extends BaseEntity = BaseEntity> = TsVectorSearchQuery<T> | TrigramSearchQuery<T> | ParadeDbSearchQuery<T>;
26
32
  /** Union of keys representing special query operators. */
27
- export type SpecialQueryTypes = keyof SpecialQuery;
33
+ export type SpecialQueryTypes = keyof UnionToIntersection<SpecialQuery>;
28
34
  /** Array containing all valid special query operator keys. */
29
35
  export declare const allSpecialQueryTypes: SpecialQueryTypes[];
30
36
  /**
@@ -32,13 +38,13 @@ export declare const allSpecialQueryTypes: SpecialQueryTypes[];
32
38
  * or a structured query object using logical and comparison operators.
33
39
  * @template T - The type of the entity being queried.
34
40
  */
35
- export type Query<T = any> = SQLWrapper | QueryObject<UntaggedDeep<T>>;
41
+ export type Query<T = any> = SQLWrapper | QueryObject<Extract<UntaggedDeep<T>, BaseEntity>>;
36
42
  /** Represents a structured query object, combining logical, comparison, and special queries. */
37
- export type QueryObject<T> = LogicalQuery<T> | (ComparisonQueryBody<T> & SpecialQuery<T>);
43
+ export type QueryObject<T extends BaseEntity> = LogicalQuery<T> | (ComparisonQueryBody<T> & Partial<SpecialQuery<T>>);
38
44
  /** Union of all possible query operator keys (logical, comparison, special). */
39
45
  export type QueryTypes = LogicalQueryTypes | ComparisonQueryTypes | SpecialQueryTypes;
40
46
  /** Array containing all valid query operator keys. */
41
- export declare const allQueryTypes: ("$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$all" | "$gt" | "$gte" | "$lt" | "$lte" | "$regex" | "$fts" | "$geoShape" | "$geoDistance")[];
47
+ export declare const allQueryTypes: ("$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$all" | "$gt" | "$gte" | "$lt" | "$lte" | "$regex" | "$tsvector" | "$trigram" | "$match" | "$tantivy" | "$geoShape" | "$geoDistance" | "$parade")[];
42
48
  /** Represents an AND logical query. All sub-queries must be true. */
43
49
  export type LogicalAndQuery<T = any> = {
44
50
  $and: readonly Query<T>[];
@@ -118,24 +124,45 @@ export type ComparisonRegexQuery = {
118
124
  flags: string;
119
125
  };
120
126
  };
121
- /** Represents a full-text search query. */
122
- export type ComparisonFtsQuery = {
123
- $fts: string | {
127
+ /** Represents a single-field tsvector full-text search query. */
128
+ export type ComparisonTsVectorQuery = {
129
+ $tsvector: string | {
124
130
  query: string;
131
+ parser?: TsVectorParser;
125
132
  /**
126
- * The search method to use.
127
- * - 'vector': (Default) Standard full-text search using tsvector and tsquery.
128
- * - 'similarity': Trigram-based similarity search using the pg_trgm extension.
133
+ * The language to use for the full-text search (e.g., 'english', 'simple').
129
134
  */
130
- method?: 'vector' | 'similarity';
131
- /**
132
- * The parser to use for the query. Only applicable for 'vector' method.
133
- */
134
- parser?: FtsParser;
135
+ language?: string | SQL;
136
+ };
137
+ };
138
+ /** Represents a single-field trigram similarity search query. */
139
+ export type ComparisonTrigramQuery = {
140
+ $trigram: string | {
141
+ query: string;
142
+ type?: TrigramSimilarityType;
135
143
  /**
136
- * The text search configuration (e.g., 'english', 'simple'). Can also be a SQL object for dynamic configuration. Only applicable for 'vector' method.
144
+ * ### **WARNING**
145
+ * Using a threshold here impacts performance as it switches from the `%` operator to a similarity comparison requiring functions.
146
+ * Use `pg_trgm.similarity_threshold(threshold)`, `pg_trgm.word_similarity_threshold(threshold)` or `pg_trgm.-_similarity_threshold(threshold)` to set a global threshold instead and omit this option, if possible.
137
147
  */
138
- language?: string | SQL;
148
+ threshold?: number;
149
+ };
150
+ };
151
+ /** Represents a ParadeDB match query. */
152
+ export type ComparisonParadeMatchQuery = {
153
+ $match: string | {
154
+ query: string;
155
+ distance?: number;
156
+ prefix?: boolean;
157
+ conjunctionMode?: boolean;
158
+ };
159
+ };
160
+ /** Represents a ParadeDB parse query (Tantivy syntax). */
161
+ export type ComparisonParadeTantivyQuery = {
162
+ $tantivy: string | {
163
+ query: string;
164
+ conjunctionMode?: boolean;
165
+ lenient?: boolean;
139
166
  };
140
167
  };
141
168
  /** Defines the possible spatial relationships for geospatial shape queries. */
@@ -162,46 +189,157 @@ export type ComparisonGeoDistanceQuery = {
162
189
  minDistance?: number;
163
190
  };
164
191
  };
165
- /** Represents a full-text search query across one or more fields. Used by the `search` repository method. */
166
- export type FullTextSearchQuery<T = any> = {
167
- $fts: {
168
- fields: readonly (Extract<keyof T, string>)[];
169
- text: string | SQL<string>;
170
- /**
171
- * The search method to use.
172
- * - 'vector': (Default) Standard full-text search using tsvector and tsquery.
173
- * - 'trigram': Trigram-based similarity search using the pg_trgm extension.
174
- */
175
- method?: 'vector' | 'trigram';
176
- vector?: {
177
- /**
178
- * The parser to use for the query. Only applicable for 'vector' method.
179
- */
180
- parser?: FtsParser;
181
- /**
182
- * The text search configuration (e.g., 'english', 'simple'). Can also be a SQL object for dynamic configuration. Only applicable for 'vector' method.
183
- */
184
- language?: string | SQL<string>;
185
- /**
186
- * Assigns weights to fields for ranking.
187
- * Keys are field names from `fields`, values are 'A', 'B', 'C', or 'D'.
188
- * Fields without a specified weight will use the default. Only applicable for 'vector' method.
189
- */
190
- weights?: Partial<Record<Extract<keyof T, string>, 'A' | 'B' | 'C' | 'D'>>;
191
- };
192
- trigram?: {
193
- /**
194
- * Type of similarity to use for 'trigram' search.
195
- * - 'normal': Standard trigram similarity (default).
196
- * - 'word': Word-based similarity.
197
- * - 'strict-word': Strict word-based similarity.
198
- * @default 'normal'
199
- */
200
- type?: 'phrase' | 'word' | 'strict-word';
201
- /**
202
- * Threshold for similarity matching (0 to 1). Only applicable for 'trigram' method.
203
- */
204
- threshold?: number | SQL<number>;
205
- };
192
+ /** Represents a multi-field tsvector search. */
193
+ export type TsVectorSearchQuery<T extends BaseEntity = BaseEntity> = {
194
+ $tsvector: {
195
+ fields: readonly (TargetColumn<T> | readonly [TargetColumn<T>, TsVectorWeight])[];
196
+ query: string | SQL<string>;
197
+ parser?: TsVectorParser;
198
+ language?: string | SQL<string>;
206
199
  };
207
200
  };
201
+ /** Represents a multi-field trigram search. */
202
+ export type TrigramSearchQuery<T extends BaseEntity = BaseEntity> = {
203
+ $trigram: {
204
+ fields: readonly TargetColumn<T>[];
205
+ query: string | SQL<string>;
206
+ type?: TrigramSimilarityType;
207
+ threshold?: number;
208
+ };
209
+ };
210
+ /**
211
+ * Represents a ParadeDB tokenizer configuration object for a `match` query.
212
+ */
213
+ export type ParadeDbTokenizerObject = {
214
+ type: LiteralUnion<'default' | 'whitespace' | 'raw' | 'keyword' | 'regex' | 'ngram' | 'source_code' | 'chinese_compatible' | 'chinese_lindera' | 'korean_lindera' | 'japanese_lindera' | 'jieba' | 'icu', string>;
215
+ [key: string]: any;
216
+ };
217
+ /**
218
+ * Represents a bound for a ParadeDB range query.
219
+ */
220
+ type ParadeDbRangeBound<V> = {
221
+ included: V;
222
+ } | {
223
+ excluded: V;
224
+ };
225
+ /** A recursive type representing the rich ParadeDB / Tantivy query DSL. */
226
+ export type ParadeDbQueryObject<T extends BaseEntity = BaseEntity> = {
227
+ all?: null;
228
+ empty?: null;
229
+ term?: {
230
+ field: TargetColumn<T>;
231
+ value: any;
232
+ };
233
+ fuzzy_term?: {
234
+ field: TargetColumn<T>;
235
+ value: string;
236
+ distance?: number;
237
+ transposition_cost_one?: boolean;
238
+ prefix?: boolean;
239
+ };
240
+ regex?: {
241
+ field: TargetColumn<T>;
242
+ pattern: string;
243
+ };
244
+ phrase?: {
245
+ field: TargetColumn<T>;
246
+ phrases: readonly string[];
247
+ slop?: number;
248
+ };
249
+ match?: {
250
+ field: TargetColumn<T>;
251
+ value: string;
252
+ distance?: number;
253
+ prefix?: boolean;
254
+ conjunction_mode?: boolean;
255
+ tokenizer?: ParadeDbTokenizerObject;
256
+ transposition_cost_one?: boolean;
257
+ };
258
+ boolean?: {
259
+ must?: ParadeDbQueryObject<T> | readonly ParadeDbQueryObject<T>[];
260
+ should?: ParadeDbQueryObject<T> | readonly ParadeDbQueryObject<T>[];
261
+ must_not?: ParadeDbQueryObject<T> | readonly ParadeDbQueryObject<T>[];
262
+ };
263
+ boost?: {
264
+ query: ParadeDbQueryObject<T>;
265
+ factor: number;
266
+ };
267
+ const_score?: {
268
+ query: ParadeDbQueryObject<T>;
269
+ score: number;
270
+ };
271
+ disjunction_max?: {
272
+ disjuncts: readonly ParadeDbQueryObject<T>[];
273
+ tie_breaker?: number;
274
+ };
275
+ parse?: {
276
+ query_string: string | SQL<string>;
277
+ lenient?: boolean;
278
+ conjunction_mode?: boolean;
279
+ };
280
+ parse_with_field?: {
281
+ field: TargetColumn<T>;
282
+ query_string: string | SQL<string>;
283
+ lenient?: boolean;
284
+ conjunction_mode?: boolean;
285
+ };
286
+ exists?: {
287
+ field: TargetColumn<T>;
288
+ };
289
+ range?: {
290
+ field: TargetColumn<T>;
291
+ lower_bound?: ParadeDbRangeBound<any> | null;
292
+ upper_bound?: ParadeDbRangeBound<any> | null;
293
+ is_datetime?: boolean;
294
+ };
295
+ term_set?: {
296
+ terms: readonly ParadeDbQueryObject<T>[];
297
+ };
298
+ phrase_prefix?: {
299
+ field: TargetColumn<T>;
300
+ phrases: readonly string[];
301
+ max_expansions?: number;
302
+ };
303
+ regex_phrase?: {
304
+ field: TargetColumn<T>;
305
+ regexes: readonly string[];
306
+ slop?: number;
307
+ max_expansions?: number;
308
+ };
309
+ more_like_this?: {
310
+ key_value?: any;
311
+ document?: readonly [string, any][];
312
+ min_doc_frequency?: number;
313
+ max_doc_frequency?: number;
314
+ min_term_frequency?: number;
315
+ max_query_terms?: number;
316
+ min_word_length?: number;
317
+ max_word_length?: number;
318
+ boost_factor?: number;
319
+ stop_words?: readonly string[];
320
+ };
321
+ range_term?: {
322
+ field: TargetColumn<T>;
323
+ value: any;
324
+ };
325
+ range_intersects?: {
326
+ field: TargetColumn<T>;
327
+ lower_bound: ParadeDbRangeBound<any>;
328
+ upper_bound: ParadeDbRangeBound<any>;
329
+ };
330
+ range_contains?: {
331
+ field: TargetColumn<T>;
332
+ lower_bound: ParadeDbRangeBound<any>;
333
+ upper_bound: ParadeDbRangeBound<any>;
334
+ };
335
+ range_within?: {
336
+ field: TargetColumn<T>;
337
+ lower_bound: ParadeDbRangeBound<any>;
338
+ upper_bound: ParadeDbRangeBound<any>;
339
+ };
340
+ };
341
+ /** Represents a ParadeDB search using its native JSON-based query language. */
342
+ export type ParadeDbSearchQuery<T extends BaseEntity = BaseEntity> = {
343
+ $parade: ParadeDbQueryObject<T>;
344
+ };
345
+ export {};
package/orm/query.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /** Array containing all valid logical query operator keys. */
2
2
  export const allLogicalQueryTypes = ['$and', '$or', '$nor'];
3
3
  /** Array containing all valid comparison query operator keys. */
4
- export const allComparisonQueryTypes = ['$all', '$not', '$eq', '$exists', '$gt', '$gte', '$in', '$item', '$lt', '$lte', '$neq', '$nin', '$regex', '$fts', '$geoDistance', '$geoShape'];
4
+ export const allComparisonQueryTypes = ['$all', '$not', '$eq', '$exists', '$gt', '$gte', '$in', '$item', '$lt', '$lte', '$neq', '$nin', '$regex', '$tsvector', '$trigram', '$match', '$tantivy', '$geoDistance', '$geoShape'];
5
5
  /** Array containing all valid special query operator keys. */
6
- export const allSpecialQueryTypes = ['$fts'];
6
+ export const allSpecialQueryTypes = ['$tsvector', '$trigram', '$parade'];
7
7
  /** Array containing all valid query operator keys. */
8
8
  export const allQueryTypes = [...allLogicalQueryTypes, ...allComparisonQueryTypes, ...allSpecialQueryTypes];
@@ -3,9 +3,9 @@
3
3
  * Defines types used by ORM repositories for operations like loading, updating, and creating entities.
4
4
  * Includes types for ordering, loading options, and entity data structures for create/update operations.
5
5
  */
6
- import type { Paths, Record, SimplifyObject, TypedOmit } from '../types/index.js';
6
+ import type { Path, Record, SimplifyObject, TypedOmit } from '../types/index.js';
7
7
  import type { UntaggedDeep } from '../types/tagged.js';
8
- import type { SQL, SQLWrapper } from 'drizzle-orm';
8
+ import type { AnyColumn, SQL, SQLWrapper } from 'drizzle-orm';
9
9
  import type { PartialDeep } from 'type-fest';
10
10
  import type { BaseEntity, Entity, EntityMetadata } from './entity.js';
11
11
  import type { FullTextSearchQuery, Query } from './query.js';
@@ -18,13 +18,13 @@ type WithSql<T> = {
18
18
  * or a raw Drizzle SQLWrapper for a complex target.
19
19
  * @template T - The entity type.
20
20
  */
21
- export type TargetColumnPaths<T extends BaseEntity> = Paths<UntaggedDeep<T>>;
21
+ export type TargetColumnPath<T extends BaseEntity = BaseEntity> = Path<UntaggedDeep<T>>;
22
22
  /**
23
23
  * Specifies the target column (e.g. for ordering, distinct on), which can be a property path within the entity
24
24
  * or a raw Drizzle SQLWrapper for a complex target.
25
25
  * @template T - The entity type.
26
26
  */
27
- export type TargetColumn<T extends BaseEntity> = TargetColumnPaths<T> | SQLWrapper;
27
+ export type TargetColumn<T extends BaseEntity = BaseEntity> = TargetColumnPath<T> | SQL | SQL.Aliased | AnyColumn;
28
28
  /** Specifies the direction for ordering results ('asc' or 'desc'). */
29
29
  export type OrderDirection = 'asc' | 'desc';
30
30
  /**
@@ -78,13 +78,42 @@ export type HighlightOptions<T extends BaseEntity> = {
78
78
  /**
79
79
  * The source to generate the highlight from. Can be one or more property paths or a raw SQL expression.
80
80
  */
81
- source: TargetColumnPaths<T> | SQL<string>;
82
- } & TsHeadlineOptions;
81
+ source: TargetColumnPath<T> | SQL<string>;
82
+ } & (TsHeadlineOptions | ParadeDbHighlightOptions);
83
+ /**
84
+ * Options for highlighting with ParadeDB (`pdb.snippet`).
85
+ */
86
+ export type ParadeDbHighlightOptions = {
87
+ /**
88
+ * Limits the number of characters in the snippet. Defaults to 150.
89
+ */
90
+ maxNumChars?: number;
91
+ /**
92
+ * The tag to use for the start of a highlighted term. Defaults to '<b>'.
93
+ */
94
+ startTag?: string;
95
+ /**
96
+ * The tag to use for the end of a highlighted term. Defaults to '</b>'.
97
+ */
98
+ endTag?: string;
99
+ /**
100
+ * Limits the number of highlighted terms returned in the snippet.
101
+ */
102
+ limit?: number;
103
+ /**
104
+ * Ignores the first N highlighted terms.
105
+ */
106
+ offset?: number;
107
+ };
83
108
  /**
84
109
  * Options for the `search` method.
85
110
  * @template T - The entity type.
86
111
  */
87
- export type SearchOptions<T extends BaseEntity> = SimplifyObject<FullTextSearchQuery<T>['$fts'] & TypedOmit<LoadManyOptions<T>, 'order'> & {
112
+ export type SearchOptions<T extends BaseEntity> = SimplifyObject<TypedOmit<LoadManyOptions<T>, 'order'> & {
113
+ /**
114
+ * The search query to execute.
115
+ */
116
+ query: FullTextSearchQuery<T>;
88
117
  /**
89
118
  * An additional filter to apply to the search query.
90
119
  */
@@ -96,7 +125,7 @@ export type SearchOptions<T extends BaseEntity> = SimplifyObject<FullTextSearchQ
96
125
  score: SQL | SQL.Aliased<number>;
97
126
  }) => Order<T>);
98
127
  /**
99
- * Whether to include a relevance score with each result. Only applicable for vector searches.
128
+ * Whether to include a relevance score with each result.
100
129
  * - If `true`, the default score is included.
101
130
  * - If a function is provided, it customizes the score calculation using the original score.
102
131
  * - If no order is specified, results are ordered by score descending, when score is enabled.
@@ -113,7 +142,7 @@ export type SearchOptions<T extends BaseEntity> = SimplifyObject<FullTextSearchQ
113
142
  /**
114
143
  * Enable and configure highlighting of search results.
115
144
  */
116
- highlight?: TargetColumnPaths<T> | SQL<string> | HighlightOptions<T>;
145
+ highlight?: TargetColumnPath<T> | SQL<string> | HighlightOptions<T>;
117
146
  }>;
118
147
  /**
119
148
  * Represents a single result from a full-text search operation.