/**
* Options provided to the HTTP request
* @typedef {Object} RequestOptions
* @public
* @property {object} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.
* @property {string} contentType - Sets the `Content-Type` header on the request. Defaults to `json`. Supported values: `json`, `xml`, `string`, and `form` (for FormData).
* @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).This is only applicable to the request function
* @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
*/
/**
* 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
* @private
**/
/**
* Execute a sequence of operations
* Wraps `language-common/execute`, and prepends initial state for http.
* @example
* execute(
* create('foo'),
* delete('bar')
* )(state)
* @param {Operations} operations - Operations to be performed.
* @returns {Operation}
*/
export function execute(...operations: Operations): Operation;
/**
* Make a HTTP request. If `configuration.baseUrl` is set, paths must be relative.
* @public
* @example
Make a GET request
* request('GET', '/patient', {
* query: { foo: 'bar', a: 1 },
* });
* @example Make a POST request with a body
* request('POST', '/todos', {
* body:{
* "userId": 1,
* "title": "delectus aut autem",
* "completed": false
* },
* });
* @function
* @param {string} method - The HTTP method to use.
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
* @param {RequestOptions} options - Body, Query, Headers and Authentication parameters
* @state {HttpState}
* @returns {Operation}
*/
export function request(method: string, path: string, options: RequestOptions): Operation;
/**
* Make a GET request. If `configuration.baseUrl` is set, paths must be relative.
* @public
* @example GET request with query parameters and custom headers
* get('/patient', {
* query: { foo: 'bar', a: 1 },
* });
* @function
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
* @param {RequestOptions} options - Body, Query, Headers and Authentication parameters
* @state {HttpState}
* @returns {Operation}
*/
export function get(path: string, options: RequestOptions): Operation;
/**
* Make a POST request. If `configuration.baseUrl` is set, paths must be relative.
* @public
* @example POST a resource with from state
* post('/patient', $.data);
* @example POST a resource with custom headers
* post('/patient', $.data, {
* headers: { 'content-type': 'application/fhir+json' },
* });
* @function
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
* @param {object} data - Body data to append to the request. JSON will be converted to a string.
* @param {RequestOptions} options - Query, Headers and Authentication parameters
* @state {HttpState}
* @returns {operation}
*/
export function post(path: string, data: object, options: RequestOptions): operation;
/**
* Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.
* @public
* @example PUT a resource from state
* put('/patient', $.data);
* @example PUT a resource with custom headers
* put('/patient', $.data, {
* headers: { 'content-type': 'application/fhir+json' },
* })
* @function
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
* @param {object} data - Body data to append to the request. JSON will be converted to a string.
* @param {RequestOptions} options - Query, Headers and Auth parameters
* @state {HttpState}
* @returns {Operation}
*/
export function put(path: string, data: object, options: RequestOptions): Operation;
/**
* Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.
* @public
* @example PATCH a resource from state
* patch('/patient', $.data);
* @example PATCH a resource with custom headers
* patch('/patient', $.data, {
* headers: { 'content-type': 'application/fhir+json' },
* });
* @function
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
* @param {object} data - Body data to append to the request. JSON will be converted to a string.
* @param {RequestOptions} options - Query, Headers and Auth parameters
* @state {HttpState}
* @returns {Operation}
*/
export function patch(path: string, data: object, options: RequestOptions): Operation;
/**
* Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.
* @public
* @example DELETE a resource by ID
* del(`/myendpoint/${$.data.id}`);
* @function
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
* @param {RequestOptions} options - Query, Headers and Auth parameters
* @state {HttpState}
* @returns {Operation}
*/
export function del(path: string, options: RequestOptions): Operation;
/**
* Parse XML with the Cheerio parser
* @public
* @example Parse XML from state.response
* parseXML(
* (state) => state.response,
* ($) => {
* return $("table[class=your_table]").parsetable(true, true, true);
* }
* );
* @example Using parseXML with a callback to extract data
* parseXML(
* (state) => state.response,
* ($) => $("table[class=your_table]").parsetable(true, true, true)
* ).then((next) => ({ ...next, results: next.data.data }));
* @function
* @param {String} data - Body string to be parsed
* @param {function} script - script for extracting data
* @state data - the parsed XML as a JSON object
* @state references - an array of all previous data objects used in the Job
* @returns {Operation}
*/
export function parseXML(data: string, script: Function): Operation;
/**
* Options provided to the HTTP request
*/
export type RequestOptions = any;
/**
* 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;
};
export { alterState, arrayToString, as, chunk, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, humanProper, lastReferenceValue, map, merge, parseCsv, scrubEmojis, sourceValue, splitKeys, toArray } from "@openfn/language-common";