Files
AFFiNE-Mirror/packages/backend/native/index.d.ts
2026-01-18 16:31:12 +08:00

164 lines
5.2 KiB
TypeScript

/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class Tokenizer {
count(content: string, allowedSpecial?: Array<string> | undefined | null): number
}
/**
* Adds a document ID to the workspace root doc's meta.pages array.
* This registers the document in the workspace so it appears in the UI.
*
* # Arguments
* * `root_doc_bin` - The current root doc binary (workspaceId doc)
* * `doc_id` - The document ID to add
* * `title` - Optional title for the document
*
* # Returns
* A Buffer containing the y-octo update binary to apply to the root doc
*/
export declare function addDocToRootDoc(rootDocBin: Buffer, docId: string, title?: string | undefined | null): Buffer
export const AFFINE_PRO_LICENSE_AES_KEY: string | undefined | null
export const AFFINE_PRO_PUBLIC_KEY: string | undefined | null
export interface Chunk {
index: number
content: string
}
/**
* Converts markdown content to AFFiNE-compatible y-octo document binary.
*
* # Arguments
* * `title` - The document title
* * `markdown` - The markdown content to convert
* * `doc_id` - The document ID to use for the y-octo doc
*
* # Returns
* A Buffer containing the y-octo document update binary
*/
export declare function createDocWithMarkdown(title: string, markdown: string, docId: string): Buffer
export declare function fromModelName(modelName: string): Tokenizer | null
export declare function getMime(input: Uint8Array): string
export declare function htmlSanitize(input: string): string
/**
* Merge updates in form like `Y.applyUpdate(doc, update)` way and return the
* result binary.
*/
export declare function mergeUpdatesInApplyWay(updates: Array<Buffer>): Buffer
export declare function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export interface NativeBlockInfo {
blockId: string
flavour: string
content?: Array<string>
blob?: Array<string>
refDocId?: Array<string>
refInfo?: Array<string>
parentFlavour?: string
parentBlockId?: string
additional?: string
}
export interface NativeCrawlResult {
blocks: Array<NativeBlockInfo>
title: string
summary: string
}
export interface NativeMarkdownResult {
title: string
markdown: string
}
export interface NativePageDocContent {
title: string
summary: string
}
export interface NativeWorkspaceDocContent {
name: string
avatarKey: string
}
export interface ParsedDoc {
name: string
chunks: Array<Chunk>
}
export declare function parseDoc(filePath: string, doc: Buffer): Promise<ParsedDoc>
export declare function parseDocFromBinary(docBin: Buffer, docId: string): NativeCrawlResult
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>
/**
* Updates or creates the docProperties record for a document.
*
* # Arguments
* * `existing_binary` - The current docProperties document binary
* * `properties_doc_id` - The docProperties document ID
* (db$${workspaceId}$docProperties)
* * `target_doc_id` - The document ID to update in docProperties
* * `created_by` - Optional creator user ID
* * `updated_by` - Optional updater user ID
*
* # Returns
* A Buffer containing only the delta (changes) as a y-octo update binary
*/
export declare function updateDocProperties(existingBinary: Buffer, propertiesDocId: string, targetDocId: string, createdBy?: string | undefined | null, updatedBy?: string | undefined | null): Buffer
/**
* Updates a document's title without touching content blocks.
*
* # Arguments
* * `existing_binary` - The current document binary
* * `title` - The new title
* * `doc_id` - The document ID
*
* # Returns
* A Buffer containing only the delta (changes) as a y-octo update binary
*/
export declare function updateDocTitle(existingBinary: Buffer, title: string, docId: string): Buffer
/**
* Updates an existing document with new markdown content.
* Uses structural diffing to apply block-level replacements for changes.
*
* # Arguments
* * `existing_binary` - The current document binary
* * `new_markdown` - The new markdown content to apply
* * `doc_id` - The document ID
*
* # Returns
* A Buffer containing only the delta (changes) as a y-octo update binary
*/
export declare function updateDocWithMarkdown(existingBinary: Buffer, newMarkdown: string, docId: string): Buffer
/**
* Updates a document title in the workspace root doc's meta.pages array.
*
* # Arguments
* * `root_doc_bin` - The current root doc binary (workspaceId doc)
* * `doc_id` - The document ID to update
* * `title` - The new title for the document
*
* # Returns
* A Buffer containing the y-octo update binary to apply to the root doc
*/
export declare function updateRootDocMetaTitle(rootDocBin: Buffer, docId: string, title: string): Buffer
export declare function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>