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: '

Invoice

', * store: true, * workspace_id: 'ws-123', * }); * * // Generate and email a PDF * await admin.documents.emailReport({ * html: '

Monthly Report

', * to: 'client@example.com', * subject: 'Monthly Report — March 2026', * }); * ``` */ export declare function createDocumentsNamespace(rb: RequestBuilder): { /** * Generate a PDF from HTML content and store it in platform Storage. * * Always pass `store: true` and `workspace_id` to get a JSON response with * a `storage_key`. Without `store: true`, the server returns raw * `application/pdf` binary which cannot be parsed as JSON by this SDK method. * * HTML input is capped at 2MB by the server. * * @param params - PDF generation parameters. Set `store: true` and provide * `workspace_id` for JSON response. * @param options - Optional request options (abort signal, custom headers). * @returns A storage key reference for the generated PDF. * * @example * ```typescript * const { storage_key } = await admin.documents.generatePdf({ * html: 'Report', * store: true, * workspace_id: 'ws-123', * }); * ``` */ generatePdf: (params: GeneratePdfParams, options?: RequestOptions) => Promise; /** * Generate a PDF from HTML and email it as an attachment. * * The PDF is generated server-side and delivered via platform SMTP. * Optionally stores the PDF in platform Storage alongside the email delivery. * * If storage fails but the email succeeds, the response includes * `storage_error` with the failure reason (email is still delivered). * * @param params - Email report parameters. * @param options - Optional request options (abort signal, custom headers). * @returns Delivery status, optional storage key, and any storage error. * * @example * ```typescript * const result = await admin.documents.emailReport({ * html: '

Q1 Summary

', * to: 'finance@company.com', * subject: 'Q1 Financial Summary', * }); * console.log(result.sent); // true * ``` */ emailReport: (params: EmailReportParams, options?: RequestOptions) => Promise; }; //# sourceMappingURL=documents.d.ts.map