chromiumly
Version:
A lightweight Typescript library that interacts with Gotenberg's different modules to convert a variety of document formats to PDF files.
141 lines (140 loc) • 4.18 kB
TypeScript
/**
* 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",
SPLIT = "split",
FLATTEN = "flatten",
ENCRYPT = "encrypt",
EMBED = "embed"
}
/**
* Enum representing the available routes for LibreOffice.
* @enum {string}
*/
declare enum LibreOfficeRoute {
CONVERT = "convert"
}
/**
* Class providing constants and routes for interacting with the Gotenberg service and related engines.
*/
export declare class Chromiumly {
/**
* 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;
/**
* 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";
/**
* 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;
split: PdfEngineRoute;
flatten: PdfEngineRoute;
encrypt: PdfEngineRoute;
embed: PdfEngineRoute;
};
/**
* Routes for LibreOffice conversions.
* @type {Object}
*/
static readonly LIBRE_OFFICE_ROUTES: {
convert: LibreOfficeRoute;
};
/**
* Configures the Gotenberg service endpoint and other optional parameters.
* @param {Object} config - Configuration object.
* @param {string} config.endpoint - The Gotenberg service endpoint.
* @param {string} [config.username] - The username for basic authentication.
* @param {string} [config.password] - The password for basic 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;
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 custom HTTP headers.
* @returns {Record<string, string> | undefined}
*/
static getCustomHttpHeaders(): Record<string, string> | undefined;
}
export {};