feat(server): native safe fetch (#14931)
This commit is contained in:
67
packages/backend/native/index.d.ts
vendored
67
packages/backend/native/index.d.ts
vendored
@@ -66,6 +66,12 @@ export const AFFINE_PRO_LICENSE_AES_KEY: string | undefined | null
|
||||
|
||||
export const AFFINE_PRO_PUBLIC_KEY: string | undefined | null
|
||||
|
||||
export declare function assertSafeUrl(request: AssertSafeUrlRequest): void
|
||||
|
||||
export interface AssertSafeUrlRequest {
|
||||
url: string
|
||||
}
|
||||
|
||||
export declare function buildPublicRootDoc(rootDocBin: Buffer, docMetas: Array<PublicDocMetaInput>): Buffer
|
||||
|
||||
export interface BuiltInPromptRenderContract {
|
||||
@@ -163,12 +169,30 @@ export interface Chunk {
|
||||
*/
|
||||
export declare function createDocWithMarkdown(title: string, markdown: string, docId: string): Buffer
|
||||
|
||||
export declare function fetchRemoteAttachment(request: RemoteAttachmentFetchRequest): Promise<RemoteAttachmentFetchResponse>
|
||||
|
||||
export declare function fromModelName(modelName: string): Tokenizer | null
|
||||
|
||||
export declare function getMime(input: Uint8Array): string
|
||||
|
||||
export declare function htmlSanitize(input: string): string
|
||||
|
||||
export interface ImageInspection {
|
||||
mimeType: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface ImageInspectionOptions {
|
||||
maxWidth?: number
|
||||
maxHeight?: number
|
||||
maxPixels?: number
|
||||
}
|
||||
|
||||
export declare function inferRemoteMimeType(request: RemoteMimeTypeRequest): Promise<string>
|
||||
|
||||
export declare function inspectImageForProxy(input: Buffer, options?: ImageInspectionOptions | undefined | null): ImageInspection
|
||||
|
||||
export declare function llmBuildCanonicalRequest(request: CanonicalChatRequestContract): LlmRequestContract
|
||||
|
||||
export declare function llmBuildCanonicalStructuredRequest(request: CanonicalStructuredRequestContract): LlmStructuredRequestContract
|
||||
@@ -572,6 +596,28 @@ export interface PublicDocMetaInput {
|
||||
|
||||
export declare function readAllDocIdsFromRootDoc(docBin: Buffer, includeTrash?: boolean | undefined | null): Array<string>
|
||||
|
||||
export interface RemoteAttachmentFetchRequest {
|
||||
url: string
|
||||
timeoutMs?: number
|
||||
maxBytes: number
|
||||
allowPrivateTargetOrigin?: boolean
|
||||
expectedContentTypePrefix?: string
|
||||
maxImageWidth?: number
|
||||
maxImageHeight?: number
|
||||
maxImagePixels?: number
|
||||
}
|
||||
|
||||
export interface RemoteAttachmentFetchResponse {
|
||||
finalUrl: string
|
||||
mimeType: string
|
||||
body: Buffer
|
||||
}
|
||||
|
||||
export interface RemoteMimeTypeRequest {
|
||||
url: string
|
||||
timeoutMs?: number
|
||||
}
|
||||
|
||||
export interface RequestedModelMatchRequest {
|
||||
providerIds: Array<string>
|
||||
optionalModels: Array<string>
|
||||
@@ -591,6 +637,27 @@ export interface RerankCandidate {
|
||||
|
||||
export declare function runNativeActionRecipePreparedStream(input: ActionRuntimeInput, callback: ((err: Error | null, arg: string) => void)): LlmStreamHandle
|
||||
|
||||
export declare function safeFetch(request: SafeFetchRequest): Promise<SafeFetchResponse>
|
||||
|
||||
export type SafeFetchMethod = 'get'|
|
||||
'head';
|
||||
|
||||
export interface SafeFetchRequest {
|
||||
url: string
|
||||
method?: SafeFetchMethod
|
||||
headers?: Record<string, string>
|
||||
timeoutMs?: number
|
||||
maxRedirects?: number
|
||||
maxBytes?: number
|
||||
}
|
||||
|
||||
export interface SafeFetchResponse {
|
||||
status: number
|
||||
finalUrl: string
|
||||
headers: Record<string, string>
|
||||
body: Buffer
|
||||
}
|
||||
|
||||
export interface ToolContract {
|
||||
name: string
|
||||
description?: string
|
||||
|
||||
Reference in New Issue
Block a user