feat(server): synthetic root doc (#14794)
This commit is contained in:
7
packages/backend/native/index.d.ts
vendored
7
packages/backend/native/index.d.ts
vendored
@@ -26,6 +26,8 @@ export const AFFINE_PRO_LICENSE_AES_KEY: string | undefined | null
|
||||
|
||||
export const AFFINE_PRO_PUBLIC_KEY: string | undefined | null
|
||||
|
||||
export declare function buildPublicRootDoc(rootDocBin: Buffer, docMetas: Array<PublicDocMetaInput>): Buffer
|
||||
|
||||
export interface Chunk {
|
||||
index: number
|
||||
content: string
|
||||
@@ -120,6 +122,11 @@ export declare function parseWorkspaceDoc(docBin: Buffer): NativeWorkspaceDocCon
|
||||
|
||||
export declare function processImage(input: Buffer, maxEdge: number, keepExif: boolean): Promise<Buffer>
|
||||
|
||||
export interface PublicDocMetaInput {
|
||||
id: string
|
||||
title?: string
|
||||
}
|
||||
|
||||
export declare function readAllDocIdsFromRootDoc(docBin: Buffer, includeTrash?: boolean | undefined | null): Array<string>
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,6 +54,12 @@ impl From<WorkspaceDocContent> for NativeWorkspaceDocContent {
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct PublicDocMetaInput {
|
||||
pub id: String,
|
||||
pub title: Option<String>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct NativeBlockInfo {
|
||||
pub block_id: String,
|
||||
@@ -254,6 +260,19 @@ pub fn add_doc_to_root_doc(root_doc_bin: Buffer, doc_id: String, title: Option<S
|
||||
Ok(Buffer::from(result))
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn build_public_root_doc(root_doc_bin: Buffer, doc_metas: Vec<PublicDocMetaInput>) -> Result<Buffer> {
|
||||
let metas = doc_metas
|
||||
.iter()
|
||||
.map(|meta| (meta.id.as_str(), meta.title.as_deref()))
|
||||
.collect::<Vec<_>>();
|
||||
let result = map_napi_err(
|
||||
doc_parser::build_public_root_doc(&root_doc_bin, &metas),
|
||||
Status::GenericFailure,
|
||||
)?;
|
||||
Ok(Buffer::from(result))
|
||||
}
|
||||
|
||||
/// Updates a document title in the workspace root doc's meta.pages array.
|
||||
///
|
||||
/// # Arguments
|
||||
|
||||
Reference in New Issue
Block a user