/** * State object * @typedef {Object} ODKHttpState * @property data - the parsed response body * @property response - the response from the ODK HTTP server (with the body removed) * @property references - an array of all the previous data values * @private **/ /** * Options provided to the HTTP request * @typedef {Object} RequestOptions * @public * @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. */ /** * Fetch all submissions to a given form. * @example Get all submissions to a form called 'patient-follow-up' * getSubmissions(22, 'patient-follow-up'); * @example Filter submissions since a given date * getSubmissions(22, 'patient-follow-up', { $filter: "$root/Submissions/__system/submissionDate gt 2020-01-31T23:59:59.999Z" }); * @function * @public * @param {number} projectId - Id of the project the form belongs to * @param {string} xmlFormId - Id of the form to fetch submissions for * @param {string} query - Query parameters to append to the request, see {@link https://docs.getodk.org/central-api-odata-endpoints/#data-document} * @returns {Operation} * @state {ODKHttpState} * @state data - array of form submission objects */ export function getSubmissions(projectId: number, xmlFormId: string, query?: string): Operation; /** * Fetch all forms for a project. * @example Fetch all forms for project with id 22 * getForms(22); * @function * @public * @param {number} projectId - Id of the project * @returns {Operation} * @state {ODKHttpState} * @state data - array of form data objects */ export function getForms(projectId: number): Operation; /** * Make a GET request against the ODK server. * @example Get a list of available projects * get("v1/projects"); * @example Get projects with query parameters * get("v1/projects", { * query: { datasets: true } * }); * @function * @public * @param {string} path - Path to resource * @param {RequestOptions} options - Options to configure the HTTP request * @returns {Operation} * @state {ODKHttpState} */ export function get(path: string, options: RequestOptions): Operation; /** * Make a POST request against the ODK server. * @example Create a new project * post('v1/projects', { name: 'Project Name' }); * @function * @public * @param {string} path - Path to resource * @param {object} body - Object which will be attached to the POST body * @param {RequestOptions} options - Options to configure the HTTP request * @returns {Operation} * @state {ODKHttpState} */ export function post(path: string, body: object, options: RequestOptions): Operation; /** * Make a general HTTP request against the ODK server. * @example Make a POST request to create a new project * request("POST", 'v1/projects', { name: 'Project Name' }); * @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 body * @param {RequestOptions} options - Optional request params * @returns {Operation} * @state {ODKHttpState} */ export function request(method: string, path: string, body: object, options?: RequestOptions): Operation; /** * Execute a sequence of operations. * Wraps `language-common/execute`, and prepends initial state for odk. * @private * @param {Operations} operations - Operations to be performed. * @returns {Operation} * @state {ODKHttpState} */ export function execute(...operations: Operations): Operation; /** * State object */ export type ODKHttpState = { /** * - the parsed response body */ data: any; /** * - the response from the ODK HTTP server (with the body removed) */ response: any; /** * - an array of all the previous data values */ references: any; }; /** * Options provided to the HTTP request */ export type RequestOptions = any; export { combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, lastReferenceValue, log, merge, sourceValue } from "@openfn/language-common";