UNPKG

chromiumly

Version:

A lightweight Typescript library that interacts with Gotenberg's different modules to convert a variety of document formats to PDF files.

202 lines (201 loc) 5.95 kB
/** * Enum representing the available Chromium routes for conversion. * @enum {string} */ export declare enum ChromiumRoute { URL = "url", HTML = "html", MARKDOWN = "markdown" } /** * Enum representing the available routes for the PDF engine. * @enum {string} */ declare enum PdfEngineRoute { CONVERT = "convert", MERGE = "merge", READ_METADATA = "metadata/read", WRITE_METADATA = "metadata/write", READ_BOOKMARKS = "bookmarks/read", WRITE_BOOKMARKS = "bookmarks/write", SPLIT = "split", FLATTEN = "flatten", ENCRYPT = "encrypt", EMBED = "embed", WATERMARK = "watermark", STAMP = "stamp", ROTATE = "rotate" } /** * Enum representing the available routes for LibreOffice. * @enum {string} */ declare enum LibreOfficeRoute { CONVERT = "convert" } declare enum SystemRoute { HEALTH = "health", VERSION = "version", DEBUG = "debug", PROMETHEUS_METRICS = "prometheus/metrics" } /** * Enum representing the available routes for Templates. * @enum {string} */ export declare enum TemplatesRoute { GENERATE = "generate" } /** * Class providing constants and routes for interacting with the Gotenberg service and related engines. */ export declare class Chromiumly { /** * Default endpoint for the hosted Chromiumly API. */ private static readonly HOSTED_API_ENDPOINT; /** * The Gotenberg service endpoint. * @type {string} */ private static gotenbergEndpoint; /** * The username for basic authentication with the Gotenberg service. * @type {string | undefined} */ private static gotenbergApiBasicAuthUsername; /** * The password for basic authentication with the Gotenberg service. * @type {string | undefined} */ private static gotenbergApiBasicAuthPassword; /** * The API key for X-Api-Key authentication with the Gotenberg service. * @type {string | undefined} */ private static gotenbergApiKey; /** * Custom HTTP headers to be sent with each request. * @type {Record<string, string> | undefined} */ private static customHttpHeaders; /** * The path for Chromium-related conversions. * @type {string} */ static readonly CHROMIUM_CONVERT_PATH = "forms/chromium/convert"; /** * The path for Chromium-related screenshots. * @type {string} */ static readonly CHROMIUM_SCREENSHOT_PATH = "forms/chromium/screenshot"; /** * The path for PDF engine-related operations. * @type {string} */ static readonly PDF_ENGINES_PATH = "forms/pdfengines"; /** * The path for LibreOffice-related conversions. * @type {string} */ static readonly LIBRE_OFFICE_PATH = "forms/libreoffice"; /** * The path for Templates-related operations. * @type {string} */ static readonly TEMPLATES_PATH = "templates"; /** * Routes for Chromium conversions. * @type {Object} */ static readonly CHROMIUM_ROUTES: { url: ChromiumRoute; html: ChromiumRoute; markdown: ChromiumRoute; }; /** * Routes for PDF engine operations. * @type {Object} */ static readonly PDF_ENGINE_ROUTES: { convert: PdfEngineRoute; merge: PdfEngineRoute; readMetadata: PdfEngineRoute; writeMetadata: PdfEngineRoute; readBookmarks: PdfEngineRoute; writeBookmarks: PdfEngineRoute; split: PdfEngineRoute; flatten: PdfEngineRoute; encrypt: PdfEngineRoute; embed: PdfEngineRoute; watermark: PdfEngineRoute; stamp: PdfEngineRoute; rotate: PdfEngineRoute; }; /** * Routes for LibreOffice conversions. * @type {Object} */ static readonly LIBRE_OFFICE_ROUTES: { convert: LibreOfficeRoute; }; /** * Routes for system endpoints. * @type {Object} */ static readonly SYSTEM_ROUTES: { health: SystemRoute; version: SystemRoute; debug: SystemRoute; prometheusMetrics: SystemRoute; }; /** * Routes for Templates generation. * @type {Object} */ static readonly TEMPLATES_ROUTES: { generate: TemplatesRoute; }; /** * Configures the Gotenberg service endpoint and other optional parameters. * @param {Object} config - Configuration object. * @param {string} [config.endpoint] - The Gotenberg service endpoint. Optional when using the hosted API with an API key. * @param {string} [config.username] - The username for basic authentication. * @param {string} [config.password] - The password for basic authentication. * @param {string} [config.apiKey] - The API key for X-Api-Key authentication. * @param {Record<string, string>} [config.customHttpHeaders] - Custom HTTP headers to be sent with each request. */ static configure(config: { endpoint?: string; username?: string; password?: string; apiKey?: string; customHttpHeaders?: Record<string, string>; }): void; /** * Gets the Gotenberg service endpoint. * @returns {string} */ static getGotenbergEndpoint(): string; /** * Gets the username for basic authentication. * @returns {string | undefined} */ static getGotenbergApiBasicAuthUsername(): string | undefined; /** * Gets the password for basic authentication. * @returns {string | undefined} */ static getGotenbergApiBasicAuthPassword(): string | undefined; /** * Gets the API key for X-Api-Key authentication. * @returns {string | undefined} */ static getGotenbergApiKey(): string | undefined; /** * Gets the custom HTTP headers. * @returns {Record<string, string> | undefined} */ static getCustomHttpHeaders(): Record<string, string> | undefined; } export {};