@koolbase/react-native 9.1.0 → 10.0.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/CHANGELOG.md +1342 -0
- package/README.md +462 -511
- package/dist/{auth-storage.d.ts → cjs/auth-storage.d.ts} +1 -1
- package/dist/cjs/index.d.ts +19 -0
- package/dist/cjs/index.js +125 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/platform.d.ts +2 -0
- package/dist/cjs/platform.js +43 -0
- package/dist/esm/auth-storage.d.ts +26 -0
- package/dist/esm/auth-storage.js +100 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.js +106 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/platform.d.ts +2 -0
- package/dist/esm/platform.js +37 -0
- package/package.json +30 -24
- package/dist/analytics.d.ts +0 -24
- package/dist/analytics.js +0 -114
- package/dist/apple-auth.d.ts +0 -22
- package/dist/apple-auth.js +0 -74
- package/dist/auth-errors.d.ts +0 -117
- package/dist/auth-errors.js +0 -250
- package/dist/auth.d.ts +0 -199
- package/dist/auth.js +0 -794
- package/dist/cache-store.d.ts +0 -11
- package/dist/cache-store.js +0 -136
- package/dist/code-push.d.ts +0 -59
- package/dist/code-push.js +0 -255
- package/dist/database-errors.d.ts +0 -95
- package/dist/database-errors.js +0 -173
- package/dist/database.d.ts +0 -208
- package/dist/database.js +0 -508
- package/dist/device-id.d.ts +0 -1
- package/dist/device-id.js +0 -60
- package/dist/device-metadata.d.ts +0 -36
- package/dist/device-metadata.js +0 -102
- package/dist/flags.d.ts +0 -15
- package/dist/flags.js +0 -76
- package/dist/functions.d.ts +0 -8
- package/dist/functions.js +0 -70
- package/dist/index.d.ts +0 -45
- package/dist/index.js +0 -193
- package/dist/logic-engine.d.ts +0 -17
- package/dist/logic-engine.js +0 -193
- package/dist/messaging.d.ts +0 -13
- package/dist/messaging.js +0 -36
- package/dist/realtime.d.ts +0 -19
- package/dist/realtime.js +0 -148
- package/dist/record.d.ts +0 -2
- package/dist/record.js +0 -20
- package/dist/storage-errors.d.ts +0 -163
- package/dist/storage-errors.js +0 -249
- package/dist/storage.d.ts +0 -184
- package/dist/storage.js +0 -438
- package/dist/sync-engine.d.ts +0 -16
- package/dist/sync-engine.js +0 -86
- package/dist/types.d.ts +0 -470
- package/dist/types.js +0 -40
- /package/dist/{auth-storage.js → cjs/auth-storage.js} +0 -0
package/dist/database-errors.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KoolbaseVectorDimensionMismatchError = exports.KoolbaseRateLimitError = exports.KoolbasePermissionError = exports.KoolbaseValidationError = exports.KoolbaseNotFoundError = exports.KoolbaseConflictError = exports.KoolbaseDataError = void 0;
|
|
4
|
-
exports.koolbaseDataError = koolbaseDataError;
|
|
5
|
-
/**
|
|
6
|
-
* Base class for errors surfaced by the Koolbase data layer (database reads
|
|
7
|
-
* and writes). Every data error carries a `message` and, when the server
|
|
8
|
-
* provides one, its stable `code` (e.g. `not_found`, `validation_error`,
|
|
9
|
-
* `unique_violation`).
|
|
10
|
-
*
|
|
11
|
-
* Catch this to handle any data-layer failure generically, or catch a
|
|
12
|
-
* specific subclass to branch on the kind of failure.
|
|
13
|
-
*/
|
|
14
|
-
class KoolbaseDataError extends Error {
|
|
15
|
-
constructor(message, code) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.name = 'KoolbaseDataError';
|
|
19
|
-
Object.setPrototypeOf(this, KoolbaseDataError.prototype);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.KoolbaseDataError = KoolbaseDataError;
|
|
23
|
-
/**
|
|
24
|
-
* Thrown when a write is rejected because the value would violate a
|
|
25
|
-
* collection's unique constraint — the server responds with 409 Conflict.
|
|
26
|
-
* Catch it to handle duplicates, e.g. an email or username already in use.
|
|
27
|
-
*
|
|
28
|
-
* `field` names the field that collided, when the server reports it
|
|
29
|
-
* (`details.field`) — useful when a collection has more than one unique
|
|
30
|
-
* constraint and you need to know which value clashed.
|
|
31
|
-
*
|
|
32
|
-
* Surfaced by `insert`, `update`, and `upsert` whenever the server is
|
|
33
|
-
* reachable and rejects the write with a 409. These writes are online-first:
|
|
34
|
-
* a server-side conflict throws immediately. Only a genuine network failure
|
|
35
|
-
* falls back to the offline queue, where a conflict that surfaces at sync
|
|
36
|
-
* time is handled by the sync engine rather than thrown here.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* try {
|
|
40
|
-
* await koolbase.db.upsert('users', { email }, { name });
|
|
41
|
-
* } catch (e) {
|
|
42
|
-
* if (e instanceof KoolbaseConflictError) {
|
|
43
|
-
* showError(`That ${e.field ?? 'value'} is already registered.`);
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
*/
|
|
47
|
-
class KoolbaseConflictError extends KoolbaseDataError {
|
|
48
|
-
constructor(message, field) {
|
|
49
|
-
super(message ?? 'Value violates a unique constraint', 'unique_violation');
|
|
50
|
-
this.field = field;
|
|
51
|
-
this.name = 'KoolbaseConflictError';
|
|
52
|
-
Object.setPrototypeOf(this, KoolbaseConflictError.prototype);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.KoolbaseConflictError = KoolbaseConflictError;
|
|
56
|
-
/**
|
|
57
|
-
* Thrown when the requested record or collection does not exist — the server
|
|
58
|
-
* responds with 404 and code `not_found` / `record_not_found` /
|
|
59
|
-
* `collection_not_found`.
|
|
60
|
-
*/
|
|
61
|
-
class KoolbaseNotFoundError extends KoolbaseDataError {
|
|
62
|
-
constructor(message) {
|
|
63
|
-
super(message ?? 'The requested resource was not found', 'not_found');
|
|
64
|
-
this.name = 'KoolbaseNotFoundError';
|
|
65
|
-
Object.setPrototypeOf(this, KoolbaseNotFoundError.prototype);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.KoolbaseNotFoundError = KoolbaseNotFoundError;
|
|
69
|
-
/**
|
|
70
|
-
* Thrown when the request is rejected as invalid — the server responds with
|
|
71
|
-
* 400 and code `validation_error`.
|
|
72
|
-
*/
|
|
73
|
-
class KoolbaseValidationError extends KoolbaseDataError {
|
|
74
|
-
constructor(message) {
|
|
75
|
-
super(message ?? 'The request was invalid', 'validation_error');
|
|
76
|
-
this.name = 'KoolbaseValidationError';
|
|
77
|
-
Object.setPrototypeOf(this, KoolbaseValidationError.prototype);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.KoolbaseValidationError = KoolbaseValidationError;
|
|
81
|
-
/**
|
|
82
|
-
* Thrown when the caller is authenticated but not allowed to perform the
|
|
83
|
-
* operation — the server responds with 403 and code `permission_denied`
|
|
84
|
-
* (typically a collection access rule rejecting the read/write).
|
|
85
|
-
*/
|
|
86
|
-
class KoolbasePermissionError extends KoolbaseDataError {
|
|
87
|
-
constructor(message) {
|
|
88
|
-
super(message ?? 'You do not have permission to perform this action', 'permission_denied');
|
|
89
|
-
this.name = 'KoolbasePermissionError';
|
|
90
|
-
Object.setPrototypeOf(this, KoolbasePermissionError.prototype);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.KoolbasePermissionError = KoolbasePermissionError;
|
|
94
|
-
/**
|
|
95
|
-
* Thrown when the server is rate-limiting the caller — 429 with code
|
|
96
|
-
* `rate_limit`. Back off and retry after a short delay.
|
|
97
|
-
*/
|
|
98
|
-
class KoolbaseRateLimitError extends KoolbaseDataError {
|
|
99
|
-
constructor(message) {
|
|
100
|
-
super(message ?? 'Too many requests, please slow down', 'rate_limit');
|
|
101
|
-
this.name = 'KoolbaseRateLimitError';
|
|
102
|
-
Object.setPrototypeOf(this, KoolbaseRateLimitError.prototype);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.KoolbaseRateLimitError = KoolbaseRateLimitError;
|
|
106
|
-
/**
|
|
107
|
-
* Thrown when the supplied vector's length does not match the dimension
|
|
108
|
-
* declared on the collection's vector field — the server responds with
|
|
109
|
-
* 400 and code `vector_dimension_mismatch`. The message includes both
|
|
110
|
-
* the expected and actual dimensions so you can surface a precise error.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* try {
|
|
114
|
-
* await koolbase.db.setVector(id, 'embedding', [0.1, 0.2]); // 2 dims
|
|
115
|
-
* } catch (e) {
|
|
116
|
-
* if (e instanceof KoolbaseVectorDimensionMismatchError) {
|
|
117
|
-
* showError(e.message); // "expected 1536, got 2"
|
|
118
|
-
* }
|
|
119
|
-
* }
|
|
120
|
-
*/
|
|
121
|
-
class KoolbaseVectorDimensionMismatchError extends KoolbaseDataError {
|
|
122
|
-
constructor(message) {
|
|
123
|
-
super(message ?? 'Vector dimension does not match field declaration', 'vector_dimension_mismatch');
|
|
124
|
-
this.name = 'KoolbaseVectorDimensionMismatchError';
|
|
125
|
-
Object.setPrototypeOf(this, KoolbaseVectorDimensionMismatchError.prototype);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.KoolbaseVectorDimensionMismatchError = KoolbaseVectorDimensionMismatchError;
|
|
129
|
-
/**
|
|
130
|
-
* Maps a non-2xx data-layer response to a typed {@link KoolbaseDataError},
|
|
131
|
-
* preferring the server's stable `code` and falling back to the HTTP status
|
|
132
|
-
* for older or uncoded responses. Always returns an error to throw.
|
|
133
|
-
*/
|
|
134
|
-
function koolbaseDataError(status, body, fallbackMessage = 'Request failed') {
|
|
135
|
-
const code = body?.code;
|
|
136
|
-
const message = body?.error ?? fallbackMessage;
|
|
137
|
-
const field = body?.details?.field;
|
|
138
|
-
// ─── code-first ───
|
|
139
|
-
switch (code) {
|
|
140
|
-
case 'unique_violation':
|
|
141
|
-
return new KoolbaseConflictError(message, field);
|
|
142
|
-
case 'not_found':
|
|
143
|
-
case 'record_not_found':
|
|
144
|
-
case 'collection_not_found':
|
|
145
|
-
case 'vector_not_found':
|
|
146
|
-
case 'vector_field_not_found':
|
|
147
|
-
return new KoolbaseNotFoundError(message);
|
|
148
|
-
case 'permission_denied':
|
|
149
|
-
return new KoolbasePermissionError(message);
|
|
150
|
-
case 'rate_limit':
|
|
151
|
-
return new KoolbaseRateLimitError(message);
|
|
152
|
-
case 'validation_error':
|
|
153
|
-
case 'vector_collection_mismatch':
|
|
154
|
-
case 'unsupported_dimension':
|
|
155
|
-
return new KoolbaseValidationError(message);
|
|
156
|
-
case 'vector_dimension_mismatch':
|
|
157
|
-
return new KoolbaseVectorDimensionMismatchError(message);
|
|
158
|
-
}
|
|
159
|
-
// ─── status fallback (pre-code servers) ───
|
|
160
|
-
switch (status) {
|
|
161
|
-
case 409:
|
|
162
|
-
return new KoolbaseConflictError(message);
|
|
163
|
-
case 404:
|
|
164
|
-
return new KoolbaseNotFoundError(message);
|
|
165
|
-
case 403:
|
|
166
|
-
return new KoolbasePermissionError(message);
|
|
167
|
-
case 429:
|
|
168
|
-
return new KoolbaseRateLimitError(message);
|
|
169
|
-
case 400:
|
|
170
|
-
return new KoolbaseValidationError(message);
|
|
171
|
-
}
|
|
172
|
-
return new KoolbaseDataError(message, code);
|
|
173
|
-
}
|
package/dist/database.d.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { KoolbaseConfig, KoolbaseRecord, QueryOptions, QueryResult, UpsertResult, BatchOp, BatchResult, KoolbaseVector, SemanticSearchResult, SearchMode } from './types';
|
|
2
|
-
export declare class KoolbaseDatabase {
|
|
3
|
-
private config;
|
|
4
|
-
private getUserId;
|
|
5
|
-
private getToken;
|
|
6
|
-
private syncEngine;
|
|
7
|
-
constructor(config: KoolbaseConfig, getUserId: () => string | null, getToken: () => Promise<string | null>);
|
|
8
|
-
private buildHeaders;
|
|
9
|
-
private request;
|
|
10
|
-
private runQuery;
|
|
11
|
-
query(collection: string, options?: QueryOptions): Promise<QueryResult>;
|
|
12
|
-
/**
|
|
13
|
-
* Insert a new record into a collection.
|
|
14
|
-
*
|
|
15
|
-
* Online-first: awaits the server so a server-side rejection (unique
|
|
16
|
-
* violation, validation error, permission denial) surfaces as the typed
|
|
17
|
-
* `KoolbaseDataError` subclass — `insert` now throws `KoolbaseConflictError`
|
|
18
|
-
* with the offending field on a 409, matching `upsert` and `update`.
|
|
19
|
-
*
|
|
20
|
-
* On genuine network failure (server unreachable, timeout) the write is
|
|
21
|
-
* accepted optimistically: saved to the local cache and queued for sync
|
|
22
|
-
* when connectivity returns.
|
|
23
|
-
*/
|
|
24
|
-
insert(collection: string, data: Record<string, unknown>): Promise<KoolbaseRecord>;
|
|
25
|
-
/**
|
|
26
|
-
* Insert a record, or update the existing one matching `match`.
|
|
27
|
-
*
|
|
28
|
-
* The server decides: exactly one match updates it, no match inserts a new
|
|
29
|
-
* record (seeded with the `match` fields), more than one match is an error.
|
|
30
|
-
* Returns the resulting record and a `created` flag (true = inserted, false
|
|
31
|
-
* = updated).
|
|
32
|
-
*
|
|
33
|
-
* Online-only by design. Unlike `insert`, an upsert is NOT queued offline:
|
|
34
|
-
* the insert-vs-update decision needs the server's authoritative view of
|
|
35
|
-
* what already exists, so deferring it could create a duplicate or apply a
|
|
36
|
-
* wrong update on later sync. It throws on network failure instead. A raw
|
|
37
|
-
* fetch is used (not `request`) so the status code is readable: 201 =
|
|
38
|
-
* created, 200 = updated.
|
|
39
|
-
*/
|
|
40
|
-
upsert(collection: string, match: Record<string, unknown>, data: Record<string, unknown>): Promise<UpsertResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Bulk-delete every record in `collection` matching `filters`.
|
|
43
|
-
*
|
|
44
|
-
* The server applies the collection's delete rule (scoping to the caller for
|
|
45
|
-
* owner/scoped rules) and returns the number of records deleted.
|
|
46
|
-
*
|
|
47
|
-
* Online-only by design — like upsert, this is NOT queued offline: a bulk
|
|
48
|
-
* delete needs the server's authoritative view of what matches, so it throws
|
|
49
|
-
* on network failure rather than risk deleting the wrong set on later sync.
|
|
50
|
-
* The collection cache is invalidated on success.
|
|
51
|
-
*/
|
|
52
|
-
deleteWhere(collection: string, filters: Record<string, unknown>): Promise<number>;
|
|
53
|
-
/**
|
|
54
|
-
* Run multiple writes as a single atomic transaction.
|
|
55
|
-
*
|
|
56
|
-
* All `operations` commit together or none are applied — the server runs
|
|
57
|
-
* them in one database transaction and rolls back entirely on any failure.
|
|
58
|
-
* Operations apply in order and may span multiple collections.
|
|
59
|
-
*
|
|
60
|
-
* Online-only by design (like `upsert` and `deleteWhere`): atomicity needs
|
|
61
|
-
* the server's authoritative view, so a batch is never queued offline — it
|
|
62
|
-
* throws on network failure. A server-side rejection throws a
|
|
63
|
-
* `KoolbaseDataException` whose message identifies which operation failed;
|
|
64
|
-
* nothing was persisted.
|
|
65
|
-
*
|
|
66
|
-
* Returns one `BatchResult` per operation, in order.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* const results = await Koolbase.db.batch([
|
|
70
|
-
* BatchOp.insert('orders', { total: 50 }),
|
|
71
|
-
* BatchOp.update(inventoryId, { stock: 9 }),
|
|
72
|
-
* BatchOp.upsert('counters', { match: { name: 'orders' }, data: { value: 1 } }),
|
|
73
|
-
* BatchOp.delete(cartItemId),
|
|
74
|
-
* ]);
|
|
75
|
-
*/
|
|
76
|
-
batch(operations: BatchOp[]): Promise<BatchResult[]>;
|
|
77
|
-
get(recordId: string): Promise<KoolbaseRecord>;
|
|
78
|
-
/**
|
|
79
|
-
* Update a record's fields by id.
|
|
80
|
-
*
|
|
81
|
-
* Online-first: awaits the server so a server-side rejection (unique
|
|
82
|
-
* violation, not found, permission denial) surfaces as the typed
|
|
83
|
-
* `KoolbaseDataError` subclass. An update that would violate a unique
|
|
84
|
-
* constraint now throws `KoolbaseConflictError` with the offending field —
|
|
85
|
-
* same shape as `insert` and `upsert`.
|
|
86
|
-
*
|
|
87
|
-
* On genuine network failure the update is queued for sync and a partial
|
|
88
|
-
* optimistic record is returned so the UI can re-render the new fields
|
|
89
|
-
* immediately.
|
|
90
|
-
*/
|
|
91
|
-
update(recordId: string, data: Record<string, unknown>): Promise<KoolbaseRecord>;
|
|
92
|
-
delete(recordId: string): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* Write (or replace) a vector for a record on the named `field`.
|
|
95
|
-
*
|
|
96
|
-
* The field must already be declared on the collection via the dashboard
|
|
97
|
-
* or CLI. `vector.length` must match the field's declared dimension;
|
|
98
|
-
* otherwise throws `KoolbaseVectorDimensionMismatchError`.
|
|
99
|
-
*
|
|
100
|
-
* Online-only — vectors are not cached locally or queued offline because
|
|
101
|
-
* HNSW similarity search has no useful offline semantics.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* await Koolbase.db.setVector(
|
|
105
|
-
* articleId,
|
|
106
|
-
* 'embedding',
|
|
107
|
-
* await myEmbeddingModel.encode(article.content),
|
|
108
|
-
* );
|
|
109
|
-
*/
|
|
110
|
-
setVector(recordId: string, field: string, vector: number[]): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Read a record's stored vector on the named `field`.
|
|
113
|
-
*
|
|
114
|
-
* Throws `KoolbaseNotFoundError` if either the field is not declared or
|
|
115
|
-
* no vector has been set for this record on this field. Throws
|
|
116
|
-
* `KoolbasePermissionError` if the caller cannot read this record per
|
|
117
|
-
* the collection's read rule.
|
|
118
|
-
*
|
|
119
|
-
* Online-only.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* const v = await Koolbase.db.getVector(articleId, 'embedding');
|
|
123
|
-
* console.log(`${v.vector.length}-dim, updated ${v.updatedAt}`);
|
|
124
|
-
*/
|
|
125
|
-
getVector(recordId: string, field: string): Promise<KoolbaseVector>;
|
|
126
|
-
/**
|
|
127
|
-
* Remove a record's stored vector on the named `field`.
|
|
128
|
-
*
|
|
129
|
-
* Online-only. Throws `KoolbaseNotFoundError` if no vector is set for
|
|
130
|
-
* `(recordId, field)`; throws `KoolbasePermissionError` if the caller
|
|
131
|
-
* cannot write this record per the collection's write rule.
|
|
132
|
-
*
|
|
133
|
-
* Note: this removes the vector from the dimension table but does NOT
|
|
134
|
-
* remove the field declaration itself — the field stays on the
|
|
135
|
-
* collection and is still settable on other records.
|
|
136
|
-
*/
|
|
137
|
-
deleteVector(recordId: string, field: string): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Queue an embedding job for a record's vector field. The server's
|
|
140
|
-
* embedding worker picks it up within ~1 second.
|
|
141
|
-
*
|
|
142
|
-
* If `text` is omitted, the vector field's configured `source_field`
|
|
143
|
-
* value on the record is used.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* await Koolbase.db.embedText({
|
|
147
|
-
* collection: 'articles',
|
|
148
|
-
* recordId: article.$id,
|
|
149
|
-
* vectorField: 'content_embedding',
|
|
150
|
-
* });
|
|
151
|
-
*/
|
|
152
|
-
embedText(opts: {
|
|
153
|
-
collection: string;
|
|
154
|
-
recordId: string;
|
|
155
|
-
vectorField: string;
|
|
156
|
-
text?: string;
|
|
157
|
-
}): Promise<void>;
|
|
158
|
-
/**
|
|
159
|
-
* Search for records based on their semantic similarity to a query.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* // Server-side embedding — most common:
|
|
163
|
-
* const result = await Koolbase.db.searchSemantic({
|
|
164
|
-
* collection: 'articles',
|
|
165
|
-
* field: 'content_embedding',
|
|
166
|
-
* queryText: 'how do I configure CI/CD?',
|
|
167
|
-
* limit: 10,
|
|
168
|
-
* });
|
|
169
|
-
*
|
|
170
|
-
* // Client-side embedding:
|
|
171
|
-
* const result = await Koolbase.db.searchSemantic({
|
|
172
|
-
* collection: 'articles',
|
|
173
|
-
* field: 'content_embedding',
|
|
174
|
-
* queryVector: precomputed,
|
|
175
|
-
* limit: 10,
|
|
176
|
-
* });
|
|
177
|
-
*
|
|
178
|
-
* // Hybrid search (vector + BM25, RRF-fused):
|
|
179
|
-
* const result = await Koolbase.db.searchSemantic({
|
|
180
|
-
* collection: 'articles',
|
|
181
|
-
* field: 'content_embedding',
|
|
182
|
-
* queryText: 'how do I configure CI/CD?',
|
|
183
|
-
* mode: 'hybrid',
|
|
184
|
-
* minSimilarity: 70,
|
|
185
|
-
* });
|
|
186
|
-
*
|
|
187
|
-
* `mode` selects the retrieval strategy:
|
|
188
|
-
* - `'semantic'` (default) — pure vector search via HNSW
|
|
189
|
-
* - `'lexical'` — pure BM25 over the field's source text
|
|
190
|
-
* - `'hybrid'` — vector + lexical, RRF-fused (k=60)
|
|
191
|
-
*
|
|
192
|
-
* `minSimilarity` (0..100, optional) filters out results below the
|
|
193
|
-
* given similarity percentage server-side. Saves bandwidth on weak
|
|
194
|
-
* matches. Only valid for semantic and hybrid; rejected by the
|
|
195
|
-
* server on lexical mode.
|
|
196
|
-
*/
|
|
197
|
-
searchSemantic(opts: {
|
|
198
|
-
collection: string;
|
|
199
|
-
field: string;
|
|
200
|
-
queryVector?: number[];
|
|
201
|
-
queryText?: string;
|
|
202
|
-
limit?: number;
|
|
203
|
-
where?: Record<string, unknown>;
|
|
204
|
-
mode?: SearchMode;
|
|
205
|
-
minSimilarity?: number;
|
|
206
|
-
}): Promise<SemanticSearchResult>;
|
|
207
|
-
syncPendingWrites(): Promise<void>;
|
|
208
|
-
}
|