/**
* State object
* @typedef {Object} HttpState
* @property data - the parsed response body
* @property response - the response from the HTTP server, including headers, statusCode, body, etc
* @property references - an array of all previous data objects used in the Job
**/
/**
* Options provided to the HTTP request
* @typedef {Object} RequestOptions
* @public
* @property {object|string} body - body data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
* @property {object} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.
* @property {object} form - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
* @property {object} query - An object of query parameters to be encoded into the URL.
* @property {object} headers - An object of headers to append to the request.
* @property {string} parseAs - Parse the response body as json, text or stream. By default will use the response headers.
* @property {number} timeout - Request timeout in ms. Default: 300 seconds.
* @property {object} tls - TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
*/
/**
* PDF Body Options object. {@link https://docs.pdfshift.io/#convert|See PDFShift documentation} for more details.
* @typedef {Object} PDFBodyOptions
* @property {boolean} sandbox - Generates PDF documents in dev mode that doesn't count in the credits.
* @property {boolean} encode - Return the generated PDF in Base64 encoded format, instead of raw. Defaults to `true`.
* @property {string} filename - Optional. Must be 7+ characters (letters, numbers, "-" or "_").
* If set, the API returns a temporary S3 URL (file kept 2 days); otherwise, it returns a Base64 PDF.
*/
/**
* Generate a PDF from an HTML string.
* @function
* @public
* @param {string} htmlTemplateString - A HTML string or url to convert to PDF
* @param {PDFBodyOptions} [options] - Optional configuration for PDF generation
* @example
Generate a PDF from a HTML string
* generatePDF(
* `
*
* Sales Report
* Date: 2025-02-01
* Total Sales: $42
*
*
* `);
* @example Generate a PDF with options
* generatePDF(
* `
*
* Sales Report
* Date: 2025-02-01
* Total Sales: $42
*
*
* `, {
* sandbox: true});
* @example Generate a PDF from a url
* generatePDF('https://www.example.com/', {
* sandbox: true,
* encode: false,
* });
* @example Generate a PDF with a filename
* generatePDF('https://www.example.com/', {
* sandbox: true,
* filename: 'example.pdf',
* });
* @returns {Operation}
* @state data - The parsed response body when `filename` is provided, otherwise a base64-encoded string.
*/
export function generatePDF(htmlTemplateString: string, options?: PDFBodyOptions): Operation;
/**
* PDF Body Options object. {@link https://docs.pdfshift.io/#convert|See PDFShift documentation} for more details.
* @typedef {Object} BodyOptions
* @property {string} source - The HTML string or url to convert to PDF.
* @property {boolean} sandbox - Generates PDF documents in dev mode that doesn't count in the credits.
* @property {boolean} encode - Return the generated PDF in Base64 encoded format, instead of raw. Defaults to `true`.
* @property {string} filename - Optional. Must be 7+ characters (letters, numbers, "-" or "_").
* If set, the API returns a temporary S3 URL (file kept 2 days); otherwise, it returns a Base64 PDF.
*/
/**
* Make a general HTTP request to PDFShift
* @example Make a request to convert a HTML string to PDF
* request(
* 'POST',
* '/convert/pdf',
* { source: $.html },
* );
* @function
* @public
* @param {string} method - HTTP method to use
* @param {string} path - Path to resource
* @param {BodyOptions} body - Object which will be attached to the POST body
* @param {RequestOptions} options - Optional request options
* @returns {Operation}
* @state {HttpState}
*/
export function request(method: string, path: string, body: BodyOptions, options?: RequestOptions): Operation;
/**
* State object
*/
export type HttpState = {
/**
* - the parsed response body
*/
data: any;
/**
* - the response from the HTTP server, including headers, statusCode, body, etc
*/
response: any;
/**
* - an array of all previous data objects used in the Job
*/
references: any;
};
/**
* Options provided to the HTTP request
*/
export type RequestOptions = any;
/**
* PDF Body Options object. {@link https://docs.pdfshift.io/#convert|See PDFShift documentation} for more details.
*/
export type PDFBodyOptions = {
/**
* - Generates PDF documents in dev mode that doesn't count in the credits.
*/
sandbox: boolean;
/**
* - Return the generated PDF in Base64 encoded format, instead of raw. Defaults to `true`.
*/
encode: boolean;
/**
* - Optional. Must be 7+ characters (letters, numbers, "-" or "_").
* If set, the API returns a temporary S3 URL (file kept 2 days); otherwise, it returns a Base64 PDF.
*/
filename: string;
};
/**
* PDF Body Options object. {@link https://docs.pdfshift.io/#convert|See PDFShift documentation} for more details.
*/
export type BodyOptions = {
/**
* - The HTML string or url to convert to PDF.
*/
source: string;
/**
* - Generates PDF documents in dev mode that doesn't count in the credits.
*/
sandbox: boolean;
/**
* - Return the generated PDF in Base64 encoded format, instead of raw. Defaults to `true`.
*/
encode: boolean;
/**
* - Optional. Must be 7+ characters (letters, numbers, "-" or "_").
* If set, the API returns a temporary S3 URL (file kept 2 days); otherwise, it returns a Base64 PDF.
*/
filename: string;
};
export { as, assert, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, log, map, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";