mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat: database indexing support (#14181)
This commit is contained in:
14
packages/backend/native/index.d.ts
vendored
14
packages/backend/native/index.d.ts
vendored
@@ -50,6 +50,16 @@ export interface NativeMarkdownResult {
|
||||
markdown: string
|
||||
}
|
||||
|
||||
export interface NativePageDocContent {
|
||||
title: string
|
||||
summary: string
|
||||
}
|
||||
|
||||
export interface NativeWorkspaceDocContent {
|
||||
name: string
|
||||
avatarKey: string
|
||||
}
|
||||
|
||||
export interface ParsedDoc {
|
||||
name: string
|
||||
chunks: Array<Chunk>
|
||||
@@ -61,6 +71,10 @@ export declare function parseDocFromBinary(docBin: Buffer, docId: string): Nativ
|
||||
|
||||
export declare function parseDocToMarkdown(docBin: Buffer, docId: string, aiEditable?: boolean | undefined | null, docUrlPrefix?: string | undefined | null): NativeMarkdownResult
|
||||
|
||||
export declare function parsePageDoc(docBin: Buffer, maxSummaryLength?: number | undefined | null): NativePageDocContent | null
|
||||
|
||||
export declare function parseWorkspaceDoc(docBin: Buffer): NativeWorkspaceDocContent | null
|
||||
|
||||
export declare function readAllDocIdsFromRootDoc(docBin: Buffer, includeTrash?: boolean | undefined | null): Array<string>
|
||||
|
||||
export declare function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use affine_common::doc_parser::{self, BlockInfo, CrawlResult, MarkdownResult};
|
||||
use affine_common::doc_parser::{
|
||||
self, BlockInfo, CrawlResult, MarkdownResult, PageDocContent, WorkspaceDocContent,
|
||||
};
|
||||
use napi::bindgen_prelude::*;
|
||||
use napi_derive::napi;
|
||||
|
||||
@@ -17,6 +19,36 @@ impl From<MarkdownResult> for NativeMarkdownResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct NativePageDocContent {
|
||||
pub title: String,
|
||||
pub summary: String,
|
||||
}
|
||||
|
||||
impl From<PageDocContent> for NativePageDocContent {
|
||||
fn from(result: PageDocContent) -> Self {
|
||||
Self {
|
||||
title: result.title,
|
||||
summary: result.summary,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct NativeWorkspaceDocContent {
|
||||
pub name: String,
|
||||
pub avatar_key: String,
|
||||
}
|
||||
|
||||
impl From<WorkspaceDocContent> for NativeWorkspaceDocContent {
|
||||
fn from(result: WorkspaceDocContent) -> Self {
|
||||
Self {
|
||||
name: result.name,
|
||||
avatar_key: result.avatar_key,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct NativeBlockInfo {
|
||||
pub block_id: String,
|
||||
@@ -70,6 +102,23 @@ pub fn parse_doc_from_binary(doc_bin: Buffer, doc_id: String) -> Result<NativeCr
|
||||
Ok(result.into())
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn parse_page_doc(
|
||||
doc_bin: Buffer,
|
||||
max_summary_length: Option<i32>,
|
||||
) -> Result<Option<NativePageDocContent>> {
|
||||
let result = doc_parser::parse_page_doc(doc_bin.into(), max_summary_length.map(|v| v as isize))
|
||||
.map_err(|e| Error::new(Status::GenericFailure, e.to_string()))?;
|
||||
Ok(result.map(Into::into))
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn parse_workspace_doc(doc_bin: Buffer) -> Result<Option<NativeWorkspaceDocContent>> {
|
||||
let result = doc_parser::parse_workspace_doc(doc_bin.into())
|
||||
.map_err(|e| Error::new(Status::GenericFailure, e.to_string()))?;
|
||||
Ok(result.map(Into::into))
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn parse_doc_to_markdown(
|
||||
doc_bin: Buffer,
|
||||
|
||||
Reference in New Issue
Block a user