@cyphra/runtime 0.6.0 → 0.8.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/dist/index.d.ts +195 -16
- package/dist/index.js +396 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -203,6 +203,12 @@ type ModelTypeDef = {
|
|
|
203
203
|
/** `@id` / `@unique` keys usable in `findUnique`, `connect`, … */
|
|
204
204
|
readonly unique: string;
|
|
205
205
|
readonly relations: Record<string, RelationTypeDef>;
|
|
206
|
+
/** `Vector(N)` scalar keys (absent when the model has none). */
|
|
207
|
+
readonly vectors?: string;
|
|
208
|
+
/** `Vector(N)` keys with a `@vectorIndex`: the fields `findSimilar` can search. */
|
|
209
|
+
readonly vectorIndexes?: string;
|
|
210
|
+
/** Names of the model's `@@fulltext` indexes: what `search` can query (absent when none). */
|
|
211
|
+
readonly fulltextIndexes?: string;
|
|
206
212
|
};
|
|
207
213
|
type TypeMap = Record<string, ModelTypeDef>;
|
|
208
214
|
type Scalars<TM extends TypeMap, M extends keyof TM> = TM[M]["scalars"];
|
|
@@ -212,10 +218,48 @@ type Target<TM extends TypeMap, M extends keyof TM, R extends keyof Relations<TM
|
|
|
212
218
|
type Simplify<T> = {
|
|
213
219
|
[K in keyof T]: T[K];
|
|
214
220
|
} & {};
|
|
221
|
+
/** `Vector(N)` scalar keys of model `M`. */
|
|
222
|
+
type VectorKeys<TM extends TypeMap, M extends keyof TM> = TM[M] extends {
|
|
223
|
+
vectors: infer V extends string;
|
|
224
|
+
} ? V : never;
|
|
225
|
+
/** `Vector(N)` keys of model `M` with a `@vectorIndex` (what `findSimilar` searches). */
|
|
226
|
+
type VectorIndexKeys<TM extends TypeMap, M extends keyof TM> = TM[M] extends {
|
|
227
|
+
vectorIndexes: infer V extends string;
|
|
228
|
+
} ? V : never;
|
|
229
|
+
/** Names of the `@@fulltext` indexes of model `M` (what `search` queries). */
|
|
230
|
+
type FulltextIndexNames<TM extends TypeMap, M extends keyof TM> = TM[M] extends {
|
|
231
|
+
fulltextIndexes: infer V extends string;
|
|
232
|
+
} ? V : never;
|
|
233
|
+
/** Any JSON value: the TypeScript type of a `Json` field. */
|
|
234
|
+
type JsonValue = string | number | boolean | null | readonly JsonValue[] | {
|
|
235
|
+
readonly [key: string]: JsonValue;
|
|
236
|
+
};
|
|
215
237
|
/** Types with `lt` / `lte` / `gt` / `gte` (strings compare lexicographically, by code point). */
|
|
216
|
-
type Comparable = number | string | Date;
|
|
238
|
+
type Comparable = number | bigint | string | Date;
|
|
239
|
+
/**
|
|
240
|
+
* `true` for a union of string literals (an enum field), `false` for `string` and other types.
|
|
241
|
+
*/
|
|
242
|
+
type IsEnum<T> = [T] extends [string] ? string extends T ? false : [T] extends [never] ? false : true : false;
|
|
243
|
+
/** `true` for `JsonValue` (a `Json` field): every JSON value is assignable to it. */
|
|
244
|
+
type IsJson<T> = [JsonValue] extends [T] ? true : false;
|
|
245
|
+
/**
|
|
246
|
+
* Json fields compare their whole stored JSON text: `null`, `{ equals }`, `{ not }` (no bare value,
|
|
247
|
+
* no deep queries).
|
|
248
|
+
*/
|
|
249
|
+
type JsonFilter = null | {
|
|
250
|
+
equals?: JsonValue;
|
|
251
|
+
not?: JsonValue;
|
|
252
|
+
};
|
|
253
|
+
/** Enum fields: equality and membership, typed to the enum's values. */
|
|
254
|
+
type EnumFilter<T> = T | {
|
|
255
|
+
equals?: T;
|
|
256
|
+
not?: T | EnumFilter<T>;
|
|
257
|
+
in?: readonly NonNullable<T>[];
|
|
258
|
+
notIn?: readonly NonNullable<T>[];
|
|
259
|
+
};
|
|
217
260
|
/** Filter on one scalar field. A bare value means `equals`; `null` means "property absent". */
|
|
218
|
-
type ScalarFilter<T> =
|
|
261
|
+
type ScalarFilter<T> = IsJson<T> extends true ? JsonFilter : IsEnum<NonNullable<T>> extends true ? EnumFilter<T> : BaseScalarFilter<T>;
|
|
262
|
+
type BaseScalarFilter<T> = [NonNullable<T>] extends [readonly (infer E)[]] ? {
|
|
219
263
|
/** List contains this element. */
|
|
220
264
|
has?: E;
|
|
221
265
|
/** List contains every element. */
|
|
@@ -260,8 +304,13 @@ type RelationFilter<TM extends TypeMap, D extends RelationTypeDef> = D["many"] e
|
|
|
260
304
|
/** No related node matching this (`null`: a related node exists). */
|
|
261
305
|
isNot?: WhereInput<TM, D["target"] & keyof TM> | null;
|
|
262
306
|
};
|
|
307
|
+
/** Vector fields only filter on presence (search them with `findSimilar`). */
|
|
308
|
+
type VectorFilter = null | {
|
|
309
|
+
equals?: null;
|
|
310
|
+
not?: null;
|
|
311
|
+
};
|
|
263
312
|
type WhereInput<TM extends TypeMap, M extends keyof TM> = {
|
|
264
|
-
[K in keyof Scalars<TM, M>]?: ScalarFilter<Scalars<TM, M>[K]>;
|
|
313
|
+
[K in keyof Scalars<TM, M>]?: K extends VectorKeys<TM, M> ? VectorFilter : ScalarFilter<Scalars<TM, M>[K]>;
|
|
265
314
|
} & {
|
|
266
315
|
[R in keyof Relations<TM, M>]?: RelationFilter<TM, Rel<TM, M, R>>;
|
|
267
316
|
} & {
|
|
@@ -281,13 +330,24 @@ type SortOrder = "asc" | "desc";
|
|
|
281
330
|
type ToManyRelations<TM extends TypeMap, M extends keyof TM> = {
|
|
282
331
|
[R in keyof Relations<TM, M> & string]: Rel<TM, M, R>["many"] extends true ? R : never;
|
|
283
332
|
}[keyof Relations<TM, M> & string];
|
|
284
|
-
/**
|
|
333
|
+
/** Scalar keys of `Json` fields (they cannot be sorted). */
|
|
334
|
+
type JsonKeys<TM extends TypeMap, M extends keyof TM> = {
|
|
335
|
+
[K in keyof Scalars<TM, M>]: IsJson<Scalars<TM, M>[K]> extends true ? K : never;
|
|
336
|
+
}[keyof Scalars<TM, M>];
|
|
337
|
+
/**
|
|
338
|
+
* One `orderBy` entry: scalars, a to-many relation by its count (`{ posts: { _count: "desc" } }`),
|
|
339
|
+
* or a to-one relation by a scalar of the related node (`{ author: { name: "asc" } }`).
|
|
340
|
+
*/
|
|
285
341
|
type OrderByItem<TM extends TypeMap, M extends keyof TM> = {
|
|
286
|
-
[K in keyof Scalars<TM, M>]?: SortOrder;
|
|
342
|
+
[K in Exclude<keyof Scalars<TM, M>, VectorKeys<TM, M> | JsonKeys<TM, M>>]?: SortOrder;
|
|
287
343
|
} & {
|
|
288
344
|
[R in ToManyRelations<TM, M>]?: {
|
|
289
345
|
_count?: SortOrder;
|
|
290
346
|
};
|
|
347
|
+
} & {
|
|
348
|
+
[R in ToOneRelations<TM, M>]?: {
|
|
349
|
+
[K in Exclude<keyof Scalars<TM, Target<TM, M, R>>, VectorKeys<TM, Target<TM, M, R>> | JsonKeys<TM, Target<TM, M, R>>>]?: SortOrder;
|
|
350
|
+
};
|
|
291
351
|
};
|
|
292
352
|
type OrderByInput<TM extends TypeMap, M extends keyof TM> = OrderByItem<TM, M> | readonly OrderByItem<TM, M>[];
|
|
293
353
|
/** Options for loading a relation inside `select` / `include`. */
|
|
@@ -379,8 +439,13 @@ type NumberUpdate = {
|
|
|
379
439
|
decrement?: number;
|
|
380
440
|
multiply?: number;
|
|
381
441
|
};
|
|
442
|
+
type BigIntUpdate = {
|
|
443
|
+
increment?: bigint;
|
|
444
|
+
decrement?: bigint;
|
|
445
|
+
multiply?: bigint;
|
|
446
|
+
};
|
|
382
447
|
type ScalarUpdate<TM extends TypeMap, M extends keyof TM> = {
|
|
383
|
-
[K in keyof Scalars<TM, M>]?: Scalars<TM, M>[K] extends number | null ? Scalars<TM, M>[K] | NumberUpdate : Scalars<TM, M>[K];
|
|
448
|
+
[K in keyof Scalars<TM, M>]?: Scalars<TM, M>[K] extends number | null ? Scalars<TM, M>[K] | NumberUpdate : Scalars<TM, M>[K] extends bigint | null ? Scalars<TM, M>[K] | BigIntUpdate : Scalars<TM, M>[K];
|
|
384
449
|
};
|
|
385
450
|
type RelationUpdate<TM extends TypeMap, D extends RelationTypeDef> = RelationCreate<TM, D> & (D["many"] extends true ? {
|
|
386
451
|
/** Remove the edge(s) to these nodes (the nodes are kept). */
|
|
@@ -441,13 +506,19 @@ type BatchResult = {
|
|
|
441
506
|
count: number;
|
|
442
507
|
};
|
|
443
508
|
type ScalarKeys<TM extends TypeMap, M extends keyof TM> = keyof Scalars<TM, M> & string;
|
|
444
|
-
/**
|
|
509
|
+
/**
|
|
510
|
+
* Scalar keys whose (non-null) type is `number` or `bigint` (`Int`, `Float`, `BigInt`): valid for
|
|
511
|
+
* `_sum` / `_avg`.
|
|
512
|
+
*/
|
|
445
513
|
type NumericKeys<TM extends TypeMap, M extends keyof TM> = {
|
|
446
|
-
[K in ScalarKeys<TM, M>]: NonNullable<Scalars<TM, M>[K]> extends number ? K : never;
|
|
514
|
+
[K in ScalarKeys<TM, M>]: NonNullable<Scalars<TM, M>[K]> extends number | bigint ? K : never;
|
|
447
515
|
}[ScalarKeys<TM, M>];
|
|
448
|
-
/**
|
|
516
|
+
/**
|
|
517
|
+
* Scalar keys of `Int`, `Float`, `BigInt`, `String`, enum, `DateTime` and `Date` fields: valid for
|
|
518
|
+
* `_min` / `_max`.
|
|
519
|
+
*/
|
|
449
520
|
type MinMaxKeys<TM extends TypeMap, M extends keyof TM> = {
|
|
450
|
-
[K in ScalarKeys<TM, M>]: NonNullable<Scalars<TM, M>[K]> extends number | string | Date ? K : never;
|
|
521
|
+
[K in ScalarKeys<TM, M>]: IsJson<Scalars<TM, M>[K]> extends true ? never : NonNullable<Scalars<TM, M>[K]> extends number | bigint | string | Date ? K : never;
|
|
451
522
|
}[ScalarKeys<TM, M>];
|
|
452
523
|
/** Rejects keys outside `Allowed` (TypeScript does not check excess keys of inferred generics). */
|
|
453
524
|
type OnlyKeys<T, Allowed extends PropertyKey> = {
|
|
@@ -469,9 +540,9 @@ type FieldSel<K extends PropertyKey> = AggregateFieldsInput<K> | undefined;
|
|
|
469
540
|
type AggregateProjection<TM extends TypeMap, M extends keyof TM, C, Su, Av, Mi, Ma> = {
|
|
470
541
|
/** `true`: number of nodes. An object: `_all` (nodes) and/or fields (non-null values). */
|
|
471
542
|
_count?: C extends object ? C & OnlyKeys<C, ScalarKeys<TM, M> | "_all"> : C;
|
|
472
|
-
/** Sum of non-null values (`Int` / `Float`); `null` when there are none. */
|
|
543
|
+
/** Sum of non-null values (`Int` / `Float` / `BigInt`); `null` when there are none. */
|
|
473
544
|
_sum?: Su & OnlyKeys<Su, NumericKeys<TM, M>>;
|
|
474
|
-
/** Mean of non-null values (`Int` / `Float`); `null` when there are none. */
|
|
545
|
+
/** Mean of non-null values (`Int` / `Float` / `BigInt`, as a `number`); `null` when there are none. */
|
|
475
546
|
_avg?: Av & OnlyKeys<Av, NumericKeys<TM, M>>;
|
|
476
547
|
/** Smallest non-null value (`Int`, `Float`, `String`, `DateTime`, `Date`). */
|
|
477
548
|
_min?: Mi & OnlyKeys<Mi, MinMaxKeys<TM, M>>;
|
|
@@ -484,6 +555,10 @@ type CountOut<C> = C extends true ? number : {
|
|
|
484
555
|
type AggOut<Sel, V> = {
|
|
485
556
|
[K in TrueKeys<Sel>]: V;
|
|
486
557
|
};
|
|
558
|
+
/** `_sum` of a `BigInt` field is a `bigint`; of an `Int` / `Float` field, a `number`. */
|
|
559
|
+
type SumOut<TM extends TypeMap, M extends keyof TM, Sel> = {
|
|
560
|
+
[K in TrueKeys<Sel>]: (K extends keyof Scalars<TM, M> ? NonNullable<Scalars<TM, M>[K]> extends bigint ? bigint : number : number) | null;
|
|
561
|
+
};
|
|
487
562
|
type ValueOut<TM extends TypeMap, M extends keyof TM, Sel> = {
|
|
488
563
|
[K in TrueKeys<Sel> & keyof Scalars<TM, M>]: NonNullable<Scalars<TM, M>[K]> | null;
|
|
489
564
|
};
|
|
@@ -491,7 +566,7 @@ type ValueOut<TM extends TypeMap, M extends keyof TM, Sel> = {
|
|
|
491
566
|
type AggregateResult<TM extends TypeMap, M extends keyof TM, C, Su, Av, Mi, Ma> = Simplify<([C] extends [undefined] ? unknown : {
|
|
492
567
|
_count: CountOut<Exclude<C, undefined>>;
|
|
493
568
|
}) & ([Su] extends [undefined] ? unknown : {
|
|
494
|
-
_sum:
|
|
569
|
+
_sum: SumOut<TM, M, Su>;
|
|
495
570
|
}) & ([Av] extends [undefined] ? unknown : {
|
|
496
571
|
_avg: AggOut<Av, number | null>;
|
|
497
572
|
}) & ([Mi] extends [undefined] ? unknown : {
|
|
@@ -532,7 +607,7 @@ type FilterObject<T> = Exclude<ScalarFilter<T>, T>;
|
|
|
532
607
|
type HavingAggregates<TM extends TypeMap, M extends keyof TM, K> = {
|
|
533
608
|
_count?: ScalarFilter<number>;
|
|
534
609
|
} & (K extends NumericKeys<TM, M> ? {
|
|
535
|
-
_sum?: ScalarFilter<number | null>;
|
|
610
|
+
_sum?: ScalarFilter<(NonNullable<Scalars<TM, M>[K & keyof Scalars<TM, M>]> extends bigint ? bigint : number) | null>;
|
|
536
611
|
_avg?: ScalarFilter<number | null>;
|
|
537
612
|
} : unknown) & (K extends MinMaxKeys<TM, M> ? {
|
|
538
613
|
_min?: ScalarFilter<NonNullable<Scalars<TM, M>[K & keyof Scalars<TM, M>]> | null>;
|
|
@@ -679,6 +754,82 @@ type ShortestPathArgs<TM extends TypeMap, M extends keyof TM, R extends SelfRela
|
|
|
679
754
|
};
|
|
680
755
|
/** A shortest path: its nodes (honouring `select` / `include`) and its typed edges. */
|
|
681
756
|
type ShortestPathResult<TM extends TypeMap, M extends keyof TM, R extends keyof Relations<TM, M>, N> = Path<N, PathEdge<EdgeProps<Rel<TM, M, R>>>>;
|
|
757
|
+
type FindSimilarArgs<TM extends TypeMap, M extends keyof TM> = {
|
|
758
|
+
/** The `Vector(N)` field to search; it must have a `@vectorIndex`. */
|
|
759
|
+
field: VectorIndexKeys<TM, M>;
|
|
760
|
+
/** Query embedding. Its length must equal the field's dimensions (checked at runtime). */
|
|
761
|
+
vector: readonly number[];
|
|
762
|
+
/** Number of results (best first). */
|
|
763
|
+
k: number;
|
|
764
|
+
/**
|
|
765
|
+
* Filter on the results. The vector index has no filter argument, so `findSimilar` asks it for
|
|
766
|
+
* `candidates` neighbours, filters them, and widens the search (×4) until `k` rows match or the
|
|
767
|
+
* index is exhausted. Use `exact: true` when the filter is selective.
|
|
768
|
+
*/
|
|
769
|
+
where?: WhereInput<TM, M>;
|
|
770
|
+
/** Drop results scoring below this (scores are in `[0, 1]`, higher is more similar). */
|
|
771
|
+
minScore?: number;
|
|
772
|
+
/**
|
|
773
|
+
* Neighbours asked from the index on the first attempt (at least `k`; default `k`, or
|
|
774
|
+
* `max(10 × k, 100)` with a `where`). More candidates improve the recall of the approximate search.
|
|
775
|
+
*/
|
|
776
|
+
candidates?: number;
|
|
777
|
+
/** Upper bound on the candidates of a filtered search (default: no bound). */
|
|
778
|
+
maxCandidates?: number;
|
|
779
|
+
/**
|
|
780
|
+
* Skip the index: score every node matching `where` with `vector.similarity.*` (exact results,
|
|
781
|
+
* Neo4j 5.18+). Fast when `where` narrows the search to a few thousand nodes.
|
|
782
|
+
*/
|
|
783
|
+
exact?: boolean;
|
|
784
|
+
};
|
|
785
|
+
/** A `findSimilar` result: the node (honouring `select` / `include`) and its similarity score. */
|
|
786
|
+
type SimilarResult<N> = Simplify<N & {
|
|
787
|
+
$score: number;
|
|
788
|
+
}>;
|
|
789
|
+
type VectorDelegate<TM extends TypeMap, M extends keyof TM> = [VectorIndexKeys<TM, M>] extends [
|
|
790
|
+
never
|
|
791
|
+
] ? unknown : {
|
|
792
|
+
/**
|
|
793
|
+
* The `k` nodes whose `field` is most similar to `vector`, best first, each with its
|
|
794
|
+
* `$score`, through the field's vector index (`db.index.vector.queryNodes`, Neo4j 5.15+).
|
|
795
|
+
*/
|
|
796
|
+
findSimilar<S extends Sel<TM, M> = undefined, I extends Inc<TM, M> = undefined>(args: FindSimilarArgs<TM, M> & Projection<S, I>): Promise<SimilarResult<Out<TM, M, S, I>>[]>;
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* How `search` reads `query`: `"lucene"` passes it through as Lucene query syntax (`title:graph*`,
|
|
800
|
+
* `"exact phrase"`, `a AND NOT b`, `fuzzy~`); `"terms"` escapes it and matches any of its words
|
|
801
|
+
* (ranked by relevance); `"phrase"` escapes it and matches the words in that order.
|
|
802
|
+
*/
|
|
803
|
+
type SearchMode = "lucene" | "terms" | "phrase";
|
|
804
|
+
type SearchArgs<TM extends TypeMap, M extends keyof TM> = {
|
|
805
|
+
/** The `@@fulltext` index to query (one of this model's index names). */
|
|
806
|
+
index: FulltextIndexNames<TM, M>;
|
|
807
|
+
/** The search text. A blank query matches nothing (`[]`). */
|
|
808
|
+
query: string;
|
|
809
|
+
/** How to read `query` (default `"lucene"`: Lucene query syntax, passed through). */
|
|
810
|
+
mode?: SearchMode;
|
|
811
|
+
/** Filter on the hits, applied in the same statement before `skip` / `take`. */
|
|
812
|
+
where?: WhereInput<TM, M>;
|
|
813
|
+
/** Drop hits scoring below this (Lucene scores: positive, unbounded, per-query). */
|
|
814
|
+
minScore?: number;
|
|
815
|
+
/** Hits to skip, after filtering and ranking. */
|
|
816
|
+
skip?: number;
|
|
817
|
+
/** Maximum number of hits (default: all of them). */
|
|
818
|
+
take?: number;
|
|
819
|
+
};
|
|
820
|
+
/** A `search` result: the node (honouring `select` / `include`) and its relevance score. */
|
|
821
|
+
type SearchResult<N> = Simplify<N & {
|
|
822
|
+
$score: number;
|
|
823
|
+
}>;
|
|
824
|
+
type FulltextDelegate<TM extends TypeMap, M extends keyof TM> = [
|
|
825
|
+
FulltextIndexNames<TM, M>
|
|
826
|
+
] extends [never] ? unknown : {
|
|
827
|
+
/**
|
|
828
|
+
* Nodes matching a full-text `query` on one of the model's `@@fulltext` indexes, best first,
|
|
829
|
+
* each with its `$score` (`db.index.fulltext.queryNodes`).
|
|
830
|
+
*/
|
|
831
|
+
search<S extends Sel<TM, M> = undefined, I extends Inc<TM, M> = undefined>(args: SearchArgs<TM, M> & Projection<S, I>): Promise<SearchResult<Out<TM, M, S, I>>[]>;
|
|
832
|
+
};
|
|
682
833
|
type Sel<TM extends TypeMap, M extends keyof TM> = SelectInput<TM, M> | undefined;
|
|
683
834
|
type Inc<TM extends TypeMap, M extends keyof TM> = IncludeInput<TM, M> | undefined;
|
|
684
835
|
type Out<TM extends TypeMap, M extends keyof TM, S, I> = Payload<TM, M, {
|
|
@@ -686,7 +837,8 @@ type Out<TM extends TypeMap, M extends keyof TM, S, I> = Payload<TM, M, {
|
|
|
686
837
|
include: I;
|
|
687
838
|
}>;
|
|
688
839
|
/** Operations available on `db.<model>`. */
|
|
689
|
-
type ModelDelegate<TM extends TypeMap, M extends keyof TM> =
|
|
840
|
+
type ModelDelegate<TM extends TypeMap, M extends keyof TM> = BaseModelDelegate<TM, M> & VectorDelegate<TM, M> & FulltextDelegate<TM, M>;
|
|
841
|
+
type BaseModelDelegate<TM extends TypeMap, M extends keyof TM> = {
|
|
690
842
|
findMany<S extends Sel<TM, M> = undefined, I extends Inc<TM, M> = undefined>(args?: FindManyArgs<TM, M> & Projection<S, I>): Promise<Out<TM, M, S, I>[]>;
|
|
691
843
|
findFirst<S extends Sel<TM, M> = undefined, I extends Inc<TM, M> = undefined>(args?: FindManyArgs<TM, M> & Projection<S, I>): Promise<Out<TM, M, S, I> | null>;
|
|
692
844
|
/** `null` when no node matches. */
|
|
@@ -817,10 +969,37 @@ declare class NotFoundError extends CyphraError {
|
|
|
817
969
|
/** Collision-resistant, URL-safe id (cuid2-style: a letter followed by 23 base-36 chars). */
|
|
818
970
|
declare function createCuid(): string;
|
|
819
971
|
|
|
972
|
+
/**
|
|
973
|
+
* `search`: full-text search on a node model through one of its `@@fulltext` indexes.
|
|
974
|
+
*
|
|
975
|
+
* One read-only statement: `db.index.fulltext.queryNodes(index, query)` returns every node of the
|
|
976
|
+
* index matching the Lucene query, with its relevance score; `where` and `minScore` filter those
|
|
977
|
+
* hits in the same statement, then the rows are ranked by score (best first) and `skip` / `take`
|
|
978
|
+
* page through them. Unlike a vector search there is no top-k cut-off before the filter, so a
|
|
979
|
+
* filtered search never comes back short.
|
|
980
|
+
*
|
|
981
|
+
* Scores are Lucene's (BM25): positive, unbounded, and only comparable within one query.
|
|
982
|
+
*
|
|
983
|
+
* @packageDocumentation
|
|
984
|
+
*/
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Escape `text` for Lucene's query syntax (what `db.index.fulltext.queryNodes` parses): every
|
|
988
|
+
* special character (`+ - && || ! ( ) { } [ ] ^ " ~ * ? : \ /`) and the `AND` / `OR` / `NOT`
|
|
989
|
+
* operators are backslash-escaped, so user input is searched as plain words.
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* ```ts
|
|
993
|
+
* escapeLucene('C++ (beta) AND "x"'); // 'C\\+\\+ \\(beta\\) \\AND \\"x\\"'
|
|
994
|
+
* await db.post.search({ index: "postSearch", query: `title:${escapeLucene(input)}~` });
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
declare function escapeLucene(text: string): string;
|
|
998
|
+
|
|
820
999
|
/**
|
|
821
1000
|
* Best-effort conversion of arbitrary driver values to plain JS: integers → number,
|
|
822
1001
|
* temporal values → `Date`, nodes/relationships → their properties. Used for raw queries.
|
|
823
1002
|
*/
|
|
824
1003
|
declare function toNative(value: unknown): unknown;
|
|
825
1004
|
|
|
826
|
-
export { type AggregateArgs, type AggregateFieldsInput, type AggregateResult, type BatchResult, type CountAggregateInput, type CountArgs, type CreateArgs, type CreateInput, type CreateManyArgs, CyphraClient, type CyphraClientOptions, type CyphraConnectionOptions, type CyphraDriverOptions, CyphraError, CyphraValidationError, type DelegateKey, type DeleteArgs, type DriverLike, type EdgeWhereInput, type FindManyArgs, type FindUniqueArgs, type GroupByArgs, type GroupByField, type GroupByKeys, type GroupByOrderByInput, type GroupByRow, type HavingInput, type IncludeInput, type MinMaxKeys, type ModelDelegate, type ModelDelegates, type ModelPath, type ModelTypeDef, NotFoundError, type NumericKeys, type OrderByInput, type OrmClient, type OrmOptions, type OrmTransactionClient, type Path, type PathEdge, type Payload, type QueryMode, type RelationCountInput, type RelationLoadArgs, type RelationTypeDef, type ScalarFilter, type SelectInput, type SelfRelations, type SessionLike, type ShortestPathArgs, type ShortestPathResult, type SortOrder, type ToManyRelations, type TransactionLike, type TraversalDirection, type TraversalResult, type TraverseArgs, type TypeMap, type UpdateArgs, type UpdateInput, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, createCuid, createOrm, toNative, toPlainRecord, toPlainRecords };
|
|
1005
|
+
export { type AggregateArgs, type AggregateFieldsInput, type AggregateResult, type BatchResult, type CountAggregateInput, type CountArgs, type CreateArgs, type CreateInput, type CreateManyArgs, CyphraClient, type CyphraClientOptions, type CyphraConnectionOptions, type CyphraDriverOptions, CyphraError, CyphraValidationError, type DelegateKey, type DeleteArgs, type DriverLike, type EdgeWhereInput, type EnumFilter, type FindManyArgs, type FindSimilarArgs, type FindUniqueArgs, type FulltextIndexNames, type GroupByArgs, type GroupByField, type GroupByKeys, type GroupByOrderByInput, type GroupByRow, type HavingInput, type IncludeInput, type JsonFilter, type JsonValue, type MinMaxKeys, type ModelDelegate, type ModelDelegates, type ModelPath, type ModelTypeDef, NotFoundError, type NumericKeys, type OrderByInput, type OrmClient, type OrmOptions, type OrmTransactionClient, type Path, type PathEdge, type Payload, type QueryMode, type RelationCountInput, type RelationLoadArgs, type RelationTypeDef, type ScalarFilter, type SearchArgs, type SearchMode, type SearchResult, type SelectInput, type SelfRelations, type SessionLike, type ShortestPathArgs, type ShortestPathResult, type SimilarResult, type SortOrder, type ToManyRelations, type TransactionLike, type TraversalDirection, type TraversalResult, type TraverseArgs, type TypeMap, type UpdateArgs, type UpdateInput, type UpdateManyArgs, type UpsertArgs, type VectorFilter, type VectorIndexKeys, type VectorKeys, type WhereInput, type WhereUniqueInput, createCuid, createOrm, escapeLucene, toNative, toPlainRecord, toPlainRecords };
|