UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

172 lines (171 loc) 5.82 kB
/** * The extraction method to use for processing documents. */ export type DocumentExtractionMethod = 'mistral_ocr' | 'legacy'; /** * Options for customizing how data is extracted from a document. */ export interface ExtractDataFromDocumentOptions { /** * Minimum width/height (in pixels) of images to extract. Smaller images will be ignored. */ imageMinSizePixels?: number; /** * Whether to extract embedded images from the document. */ extractImages?: boolean; /** * Specific page indexes to extract from the document (0-based). If omitted, all pages are extracted. */ pageIndexes?: number[]; /** * The preferred method for extracting data from the document. */ preferredExtractionMethod?: DocumentExtractionMethod; } /** * Request payload for extracting data from a document via URL. */ export interface ExtractDataFromDocumentUrlRequest { /** * The publicly accessible URL pointing to the document file. */ url: string; /** * Optional parameters to control how the extraction is performed. */ options?: ExtractDataFromDocumentOptions; } /** * Request payload for extracting data from a document file (uploaded directly). */ export interface ExtractDataFromDocumentFileRequest { /** * Optional parameters to control how the extraction is performed. */ options?: ExtractDataFromDocumentOptions; } /** * Representation of an image extracted from a document, for use in generated content. */ export interface ExtractDataFromDocumentImage { /** * A unique identifier for the image. */ id: string; /** * A placeholder or marker in the content where this image should be inserted. */ textToReplaceInContent: string; /** * The base64-encoded image data, prefixed with its MIME type (e.g., data:image/png;base64,...). */ imageBase64Url: string; } /** * A single extracted page from the document, including structured content and images. */ export interface ExtractDataFromDocumentPage { /** * Optional title for the page (e.g., sheet name or section heading). */ title?: string; /** * Page index in the original document (0-based). */ index: number; /** * Extracted textual content or CSV representation of the page. */ content: string; /** * List of images extracted from this page. */ images: Array<ExtractDataFromDocumentImage>; } /** * The full result of extracting data from a document, including all pages and any extracted images. */ export interface ExtractDataFromDocumentResponse { /** * Array of pages containing extracted data. */ pages: Array<ExtractDataFromDocumentPage>; } /** * Create PDF request type. */ export type CreatePdfType = 'html' | 'url'; /** The type of output options to apply when creating a PDF document. */ export type CreatePdfOutputOptionsType = 'format' | 'dimensions'; /** Base interface for PDF output options. This is used to define the type of output options. */ export interface BaseCreatePdfOutputOptions { /** The type of output options, either 'format' or 'dimensions'. */ type: CreatePdfOutputOptionsType; } /** Output options by format */ export interface CreatePdfOutputFormatOptions extends BaseCreatePdfOutputOptions { /** The type of output options, always 'format' for this interface. */ type: 'format'; /** The type of formatting, always 'format' for this interface. */ format: 'letter' | 'legal' | 'tabloid' | 'ledger' | 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6'; } /** Output options by custom dimensions */ export interface CreatePdfOutputDimensionsOptions extends BaseCreatePdfOutputOptions { /** The type of formatting, always 'dimensions' for this interface. */ type: 'dimensions'; /** The width of the PDF document in pixels. */ width: number; /** The height of the PDF document in pixels. */ height: number; } /** Combined formatting options for creating a PDF document. */ export type CreatePdfOutputOptions = CreatePdfOutputFormatOptions | CreatePdfOutputDimensionsOptions; /** * Base request for creating a PDF document. */ export interface BaseCreatePdfRequest { /** * The type of PDF creation to perform, either from HTML or a URL. */ type: CreatePdfType; /** The formatting options for the PDF document. Can be either a predefined format (like 'letter') or custom dimensions. */ outputOptions?: CreatePdfOutputOptions; /** Optional title for the PDF document. */ title?: string; } /** * Request payload for creating a PDF from a URL. */ export interface CreatePdfFromUrlRequest extends BaseCreatePdfRequest { /** The type of PDF creation, always 'url' for this request. */ type: 'url'; /** * The URL of the webpage to convert into a PDF. */ url: string; } /** * Request payload for creating a PDF from HTML content. */ export interface CreatePdfFromHtmlRequest extends BaseCreatePdfRequest { /** The type of PDF creation, always 'html' for this request. */ type: 'html'; /** The HTML content to convert into a PDF. Should not contain <html>, <body>, <head>, should just include the inner HTML */ innerHtml: string; /** Optional URL for CSS styles to apply to the HTML content. */ cssUrl?: string; } /** * Combined request type for creating a PDF, which can be either from a URL or HTML content. */ export type CreatePdfRequest = CreatePdfFromUrlRequest | CreatePdfFromHtmlRequest; /** * Response type for the PDF creation operation, containing the URL of the generated PDF. */ export interface CreatePdfResponse { /** * The publicly accessible URL where the generated PDF can be downloaded. */ url: string; }