feat: integrate native indexer for mobile (#14174)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Added full-text search functionality to mobile apps (Android and iOS),
enabling document indexing and search capabilities.
* Enhanced blob upload support with new GraphQL mutations for creating,
completing, and managing file uploads.

* **Improvements**
* iOS and Android now use SQLite storage backend for improved indexing
performance, aligning with desktop experience.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2025-12-28 21:34:39 +08:00
committed by GitHub
parent 504460438f
commit 20a80015c0
24 changed files with 1993 additions and 39 deletions

View File

@@ -618,4 +618,121 @@ class NbStorePlugin : Plugin() {
}
}
}
@PluginMethod
fun ftsAddDocument(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val id = call.getStringEnsure("id")
val indexName = call.getStringEnsure("indexName")
val docId = call.getStringEnsure("docId")
val text = call.getStringEnsure("text")
val index = call.getBoolean("index")
?: throw IllegalArgumentException("index is required")
docStoragePool.ftsAddDocument(id, indexName, docId, text, index)
call.resolve()
} catch (e: Exception) {
call.reject("Failed to add document to fts: ${e.message}", null, e)
}
}
}
@PluginMethod
fun ftsDeleteDocument(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val id = call.getStringEnsure("id")
val indexName = call.getStringEnsure("indexName")
val docId = call.getStringEnsure("docId")
docStoragePool.ftsDeleteDocument(id, indexName, docId)
call.resolve()
} catch (e: Exception) {
call.reject("Failed to delete document from fts: ${e.message}", null, e)
}
}
}
@PluginMethod
fun ftsSearch(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val id = call.getStringEnsure("id")
val indexName = call.getStringEnsure("indexName")
val query = call.getStringEnsure("query")
val results = docStoragePool.ftsSearch(id, indexName, query)
val mapped = results.map {
JSObject()
.put("id", it.id)
.put("score", it.score)
.put("terms", JSArray(it.terms))
}
call.resolve(
JSObject().put("results", JSArray(mapped))
)
} catch (e: Exception) {
call.reject("Failed to search fts: ${e.message}", null, e)
}
}
}
@PluginMethod
fun ftsGetDocument(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val id = call.getStringEnsure("id")
val indexName = call.getStringEnsure("indexName")
val docId = call.getStringEnsure("docId")
val text = docStoragePool.ftsGetDocument(id, indexName, docId)
call.resolve(JSObject().put("text", text))
} catch (e: Exception) {
call.reject("Failed to get fts document: ${e.message}", null, e)
}
}
}
@PluginMethod
fun ftsGetMatches(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val id = call.getStringEnsure("id")
val indexName = call.getStringEnsure("indexName")
val docId = call.getStringEnsure("docId")
val query = call.getStringEnsure("query")
val matches = docStoragePool.ftsGetMatches(id, indexName, docId, query)
val mapped = matches.map {
JSObject()
.put("start", it.start.toInt())
.put("end", it.end.toInt())
}
call.resolve(JSObject().put("matches", JSArray(mapped)))
} catch (e: Exception) {
call.reject("Failed to get fts matches: ${e.message}", null, e)
}
}
}
@PluginMethod
fun ftsFlushIndex(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val id = call.getStringEnsure("id")
docStoragePool.ftsFlushIndex(id)
call.resolve()
} catch (e: Exception) {
call.reject("Failed to flush fts index: ${e.message}", null, e)
}
}
}
@PluginMethod
fun ftsIndexVersion(call: PluginCall) {
launch(Dispatchers.IO) {
try {
val version = docStoragePool.ftsIndexVersion()
call.resolve(JSObject().put("indexVersion", version))
} catch (e: Exception) {
call.reject("Failed to get fts index version: ${e.message}", null, e)
}
}
}
}

View File

@@ -768,6 +768,20 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
@@ -814,6 +828,20 @@ fun uniffi_affine_mobile_native_checksum_method_docstoragepool_delete_doc(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_disconnect(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_add_document(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_delete_document(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_flush_index(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_get_document(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_get_matches(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_index_version(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_search(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_get_blob(
): Short
fun uniffi_affine_mobile_native_checksum_method_docstoragepool_get_blob_uploaded_at(
@@ -925,6 +953,20 @@ fun uniffi_affine_mobile_native_fn_method_docstoragepool_delete_doc(`ptr`: Point
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_disconnect(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_add_document(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`indexName`: RustBuffer.ByValue,`docId`: RustBuffer.ByValue,`text`: RustBuffer.ByValue,`index`: Byte,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_delete_document(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`indexName`: RustBuffer.ByValue,`docId`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_flush_index(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_get_document(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`indexName`: RustBuffer.ByValue,`docId`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_get_matches(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`indexName`: RustBuffer.ByValue,`docId`: RustBuffer.ByValue,`query`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_index_version(`ptr`: Pointer,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_fts_search(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`indexName`: RustBuffer.ByValue,`query`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_get_blob(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`key`: RustBuffer.ByValue,
): Long
fun uniffi_affine_mobile_native_fn_method_docstoragepool_get_blob_uploaded_at(`ptr`: Pointer,`universalId`: RustBuffer.ByValue,`peer`: RustBuffer.ByValue,`blobId`: RustBuffer.ByValue,
@@ -1125,6 +1167,27 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_disconnect() != 20410.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_add_document() != 37651.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_delete_document() != 47292.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_flush_index() != 9921.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_get_document() != 45953.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_get_matches() != 35972.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_index_version() != 44498.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_fts_search() != 28341.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_affine_mobile_native_checksum_method_docstoragepool_get_blob() != 56927.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
@@ -1423,6 +1486,29 @@ public object FfiConverterLong: FfiConverter<Long, Long> {
}
}
/**
* @suppress
*/
public object FfiConverterDouble: FfiConverter<Double, Double> {
override fun lift(value: Double): Double {
return value
}
override fun read(buf: ByteBuffer): Double {
return buf.getDouble()
}
override fun lower(value: Double): Double {
return value
}
override fun allocationSize(value: Double) = 8UL
override fun write(value: Double, buf: ByteBuffer) {
buf.putDouble(value)
}
}
/**
* @suppress
*/
@@ -1619,6 +1705,20 @@ public interface DocStoragePoolInterface {
suspend fun `disconnect`(`universalId`: kotlin.String)
suspend fun `ftsAddDocument`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String, `text`: kotlin.String, `index`: kotlin.Boolean)
suspend fun `ftsDeleteDocument`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String)
suspend fun `ftsFlushIndex`(`universalId`: kotlin.String)
suspend fun `ftsGetDocument`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String): kotlin.String?
suspend fun `ftsGetMatches`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String, `query`: kotlin.String): List<MatchRange>
suspend fun `ftsIndexVersion`(): kotlin.UInt
suspend fun `ftsSearch`(`universalId`: kotlin.String, `indexName`: kotlin.String, `query`: kotlin.String): List<SearchHit>
suspend fun `getBlob`(`universalId`: kotlin.String, `key`: kotlin.String): Blob?
suspend fun `getBlobUploadedAt`(`universalId`: kotlin.String, `peer`: kotlin.String, `blobId`: kotlin.String): kotlin.Long?
@@ -1885,6 +1985,156 @@ open class DocStoragePool: Disposable, AutoCloseable, DocStoragePoolInterface
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsAddDocument`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String, `text`: kotlin.String, `index`: kotlin.Boolean) {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_add_document(
thisPtr,
FfiConverterString.lower(`universalId`),FfiConverterString.lower(`indexName`),FfiConverterString.lower(`docId`),FfiConverterString.lower(`text`),FfiConverterBoolean.lower(`index`),
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_void(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_void(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_void(future) },
// lift function
{ Unit },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsDeleteDocument`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String) {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_delete_document(
thisPtr,
FfiConverterString.lower(`universalId`),FfiConverterString.lower(`indexName`),FfiConverterString.lower(`docId`),
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_void(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_void(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_void(future) },
// lift function
{ Unit },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsFlushIndex`(`universalId`: kotlin.String) {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_flush_index(
thisPtr,
FfiConverterString.lower(`universalId`),
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_void(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_void(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_void(future) },
// lift function
{ Unit },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsGetDocument`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String) : kotlin.String? {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_get_document(
thisPtr,
FfiConverterString.lower(`universalId`),FfiConverterString.lower(`indexName`),FfiConverterString.lower(`docId`),
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_rust_buffer(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_rust_buffer(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_rust_buffer(future) },
// lift function
{ FfiConverterOptionalString.lift(it) },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsGetMatches`(`universalId`: kotlin.String, `indexName`: kotlin.String, `docId`: kotlin.String, `query`: kotlin.String) : List<MatchRange> {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_get_matches(
thisPtr,
FfiConverterString.lower(`universalId`),FfiConverterString.lower(`indexName`),FfiConverterString.lower(`docId`),FfiConverterString.lower(`query`),
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_rust_buffer(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_rust_buffer(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_rust_buffer(future) },
// lift function
{ FfiConverterSequenceTypeMatchRange.lift(it) },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsIndexVersion`() : kotlin.UInt {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_index_version(
thisPtr,
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_u32(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_u32(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_u32(future) },
// lift function
{ FfiConverterUInt.lift(it) },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `ftsSearch`(`universalId`: kotlin.String, `indexName`: kotlin.String, `query`: kotlin.String) : List<SearchHit> {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
UniffiLib.INSTANCE.uniffi_affine_mobile_native_fn_method_docstoragepool_fts_search(
thisPtr,
FfiConverterString.lower(`universalId`),FfiConverterString.lower(`indexName`),FfiConverterString.lower(`query`),
)
},
{ future, callback, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_poll_rust_buffer(future, callback, continuation) },
{ future, continuation -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_complete_rust_buffer(future, continuation) },
{ future -> UniffiLib.INSTANCE.ffi_affine_mobile_native_rust_future_free_rust_buffer(future) },
// lift function
{ FfiConverterSequenceTypeSearchHit.lift(it) },
// Error FFI converter
UniffiException.ErrorHandler,
)
}
@Throws(UniffiException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `getBlob`(`universalId`: kotlin.String, `key`: kotlin.String) : Blob? {
@@ -2696,6 +2946,74 @@ public object FfiConverterTypeListedBlob: FfiConverterRustBuffer<ListedBlob> {
data class MatchRange (
var `start`: kotlin.UInt,
var `end`: kotlin.UInt
) {
companion object
}
/**
* @suppress
*/
public object FfiConverterTypeMatchRange: FfiConverterRustBuffer<MatchRange> {
override fun read(buf: ByteBuffer): MatchRange {
return MatchRange(
FfiConverterUInt.read(buf),
FfiConverterUInt.read(buf),
)
}
override fun allocationSize(value: MatchRange) = (
FfiConverterUInt.allocationSize(value.`start`) +
FfiConverterUInt.allocationSize(value.`end`)
)
override fun write(value: MatchRange, buf: ByteBuffer) {
FfiConverterUInt.write(value.`start`, buf)
FfiConverterUInt.write(value.`end`, buf)
}
}
data class SearchHit (
var `id`: kotlin.String,
var `score`: kotlin.Double,
var `terms`: List<kotlin.String>
) {
companion object
}
/**
* @suppress
*/
public object FfiConverterTypeSearchHit: FfiConverterRustBuffer<SearchHit> {
override fun read(buf: ByteBuffer): SearchHit {
return SearchHit(
FfiConverterString.read(buf),
FfiConverterDouble.read(buf),
FfiConverterSequenceString.read(buf),
)
}
override fun allocationSize(value: SearchHit) = (
FfiConverterString.allocationSize(value.`id`) +
FfiConverterDouble.allocationSize(value.`score`) +
FfiConverterSequenceString.allocationSize(value.`terms`)
)
override fun write(value: SearchHit, buf: ByteBuffer) {
FfiConverterString.write(value.`id`, buf)
FfiConverterDouble.write(value.`score`, buf)
FfiConverterSequenceString.write(value.`terms`, buf)
}
}
data class SetBlob (
var `key`: kotlin.String,
var `data`: kotlin.String,
@@ -3188,6 +3506,62 @@ public object FfiConverterSequenceTypeListedBlob: FfiConverterRustBuffer<List<Li
/**
* @suppress
*/
public object FfiConverterSequenceTypeMatchRange: FfiConverterRustBuffer<List<MatchRange>> {
override fun read(buf: ByteBuffer): List<MatchRange> {
val len = buf.getInt()
return List<MatchRange>(len) {
FfiConverterTypeMatchRange.read(buf)
}
}
override fun allocationSize(value: List<MatchRange>): ULong {
val sizeForLength = 4UL
val sizeForItems = value.map { FfiConverterTypeMatchRange.allocationSize(it) }.sum()
return sizeForLength + sizeForItems
}
override fun write(value: List<MatchRange>, buf: ByteBuffer) {
buf.putInt(value.size)
value.iterator().forEach {
FfiConverterTypeMatchRange.write(it, buf)
}
}
}
/**
* @suppress
*/
public object FfiConverterSequenceTypeSearchHit: FfiConverterRustBuffer<List<SearchHit>> {
override fun read(buf: ByteBuffer): List<SearchHit> {
val len = buf.getInt()
return List<SearchHit>(len) {
FfiConverterTypeSearchHit.read(buf)
}
}
override fun allocationSize(value: List<SearchHit>): ULong {
val sizeForLength = 4UL
val sizeForItems = value.map { FfiConverterTypeSearchHit.allocationSize(it) }.sum()
return sizeForLength + sizeForItems
}
override fun write(value: List<SearchHit>, buf: ByteBuffer) {
buf.putInt(value.size)
value.iterator().forEach {
FfiConverterTypeSearchHit.write(it, buf)
}
}
}

View File

@@ -171,7 +171,9 @@ export interface NbStorePlugin {
id: string;
indexName: string;
query: string;
}) => Promise<{ id: string; score: number; terms: Array<string> }[]>;
}) => Promise<{
results: { id: string; score: number; terms: Array<string> }[];
}>;
ftsGetDocument: (options: {
id: string;
indexName: string;
@@ -182,7 +184,7 @@ export interface NbStorePlugin {
indexName: string;
docId: string;
query: string;
}) => Promise<Array<{ start: number; end: number }>>;
}) => Promise<{ matches: Array<{ start: number; end: number }> }>;
ftsFlushIndex: (options: { id: string }) => Promise<void>;
ftsIndexVersion: () => Promise<number>;
ftsIndexVersion: () => Promise<{ indexVersion: number }>;
}

View File

@@ -370,11 +370,12 @@ export const NbStoreNativeDBApis: NativeDBApis = {
indexName: string,
query: string
): Promise<{ id: string; score: number; terms: Array<string> }[]> {
return await NbStore.ftsSearch({
const { results } = await NbStore.ftsSearch({
id,
indexName,
query,
});
return results ?? [];
},
ftsGetDocument: async function (
id: string,
@@ -394,12 +395,13 @@ export const NbStoreNativeDBApis: NativeDBApis = {
docId: string,
query: string
): Promise<{ start: number; end: number }[]> {
return await NbStore.ftsGetMatches({
const { matches } = await NbStore.ftsGetMatches({
id,
indexName,
docId,
query,
});
return matches ?? [];
},
ftsFlushIndex: async function (id: string): Promise<void> {
await NbStore.ftsFlushIndex({
@@ -407,6 +409,6 @@ export const NbStoreNativeDBApis: NativeDBApis = {
});
},
ftsIndexVersion: function (): Promise<number> {
return NbStore.ftsIndexVersion();
return NbStore.ftsIndexVersion().then(res => res.indexVersion);
},
};