/** * 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 */ /** * Make a GET request * @example Get a stockout report * get("DispensingUnit/Dashboard/StockOutReport"); * @function * @public * @param {string} path - Path to resource * @param {RequestOptions} options - Optional request options * @returns {Operation} * @state {HttpState} */ export function get(path: string, options: RequestOptions): Operation; /** * Make a POST request * @example * post("Patient/CheckPrescription", { "prescriptionRowGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6" }); * @function * @public * @param {string} path - Path to resource * @param {object} body - Object which will be attached to the POST body * @param {RequestOptions} options - Optional request options * @returns {Operation} * @state {HttpState} */ export function post(path: string, body: object, options: RequestOptions): Operation; /** * Make a general HTTP requests * @example * request("POST", "DispensingUnit/Request/History", { "search": {} }); * @function * @public * @param {string} method - HTTP method to use * @param {string} path - Path to resource * @param {object} 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: object, 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; export { as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, map, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";