import type { RequestBuilder } from "../request-builder"; import type { RequestOptions } from "../base-client"; /** Parameters for generating a PDF from HTML. */ export interface GeneratePdfParams { /** HTML content to convert to PDF (max 2MB). */ html: string; /** Output filename (default: "document.pdf"). */ filename?: string; /** * When true, stores the PDF in platform Storage and returns a storage_key. * When false, returns the PDF as base64-encoded string. * Default: false. */ store?: boolean; /** Workspace ID — required when store is true. */ workspace_id?: string; } /** Response when store is true. */ export interface GeneratePdfStoredResponse { storage_key: string; /** UUID of the StorageFile record. Use with `storage.files.requestDownloadUrl(file_id)` to get a presigned download URL. */ file_id: string; } /** Union response from generatePdf (when store is true). */ export type GeneratePdfResponse = GeneratePdfStoredResponse; /** Parameters for generating a PDF and emailing it. */ export interface EmailReportParams { /** HTML content to convert to PDF (max 2MB). */ html: string; /** Recipient email address. */ to: string; /** Email subject line. */ subject: string; /** HTML body for the email (default: generic attachment note). */ body_html?: string; /** PDF attachment filename (default: "report.pdf"). */ filename?: string; /** Also store the PDF in platform Storage. */ store?: boolean; /** Workspace ID — required when store is true. */ workspace_id?: string; } /** Response from emailReport. */ export interface EmailReportResponse { /** Whether the email was sent successfully. */ sent: boolean; /** Storage key if store was true, null otherwise. */ storage_key: string | null; /** Error message if storage failed (email still sent). */ storage_error?: string; } /** * HTML-to-PDF generation and report delivery (ISV / Platform Admin surface). * * Converts HTML to PDF via the platform's Gotenberg microservice and optionally * stores the result in platform Storage or emails it as an attachment. * * Accessed via `admin.documents.*`. * * @param rb - The internal `RequestBuilder` instance used to execute API calls. * @returns An object containing `generatePdf` and `emailReport` methods. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * * // Generate and store a PDF * const result = await admin.documents.generatePdf({ * html: '