@openfn/language-commcare 3.2.8 → 3.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ast.json CHANGED
@@ -348,7 +348,7 @@
348
348
  "method",
349
349
  "path",
350
350
  "body",
351
- "options"
351
+ "params"
352
352
  ],
353
353
  "docs": {
354
354
  "description": "Make a general HTTP request against the Commcare server. Use this to make any request to Commcare REST API.",
@@ -358,6 +358,11 @@
358
358
  "description": "request(\"GET\", \"/a/asri/api/v0.5/case\");",
359
359
  "caption": "Get a resource. Equivalent to `<baseUrl>/a/asri/api/v0.5/case`"
360
360
  },
361
+ {
362
+ "title": "example",
363
+ "description": "request(\"GET\", \"/case\", {}, { offset:0, limit: 20 })",
364
+ "caption": "Get a resource using query parameters. Equivalent to `<baseUrl>/case?offset=0&limit=20`"
365
+ },
361
366
  {
362
367
  "title": "function",
363
368
  "description": null,
@@ -397,12 +402,12 @@
397
402
  },
398
403
  {
399
404
  "title": "param",
400
- "description": "Optional request params",
405
+ "description": "An object of query parameters to be encoded into the URL",
401
406
  "type": {
402
407
  "type": "NameExpression",
403
- "name": "RequestOptions"
408
+ "name": "object"
404
409
  },
405
- "name": "options"
410
+ "name": "params"
406
411
  },
407
412
  {
408
413
  "title": "returns",
package/dist/index.cjs CHANGED
@@ -107,8 +107,8 @@ var configureAuth = (auth, headers = {}) => {
107
107
  var prepareNextState = (state, response, callback = (s) => s) => {
108
108
  const { body, ...responseWithoutBody } = response;
109
109
  const nextState = {
110
- ...(0, import_language_common.composeNextState)(state, body.objects ?? body),
111
- response: { ...responseWithoutBody, ...{ meta: body.meta } }
110
+ ...(0, import_language_common.composeNextState)(state, (body == null ? void 0 : body.objects) ?? body),
111
+ response: { ...responseWithoutBody, ...{ meta: body == null ? void 0 : body.meta } }
112
112
  };
113
113
  return callback(nextState);
114
114
  };
@@ -298,13 +298,13 @@ function fetchReportData(reportId, params, postUrl) {
298
298
  return state;
299
299
  };
300
300
  }
301
- function request2(method, path, body, options = {}) {
301
+ function request2(method, path, body, params = {}) {
302
302
  return async (state) => {
303
- const [resolvedMethod, resolvedPath, resolvedBody, resolvedOptions] = (0, import_util2.expandReferences)(state, method, path, body, options);
303
+ const [resolvedMethod, resolvedPath, resolvedBody, resolvedParams] = (0, import_util2.expandReferences)(state, method, path, body, params);
304
304
  const response = await request(state.configuration, resolvedPath, {
305
305
  method: resolvedMethod,
306
306
  data: resolvedBody,
307
- params: resolvedOptions,
307
+ params: resolvedParams,
308
308
  contentType: "application/json"
309
309
  });
310
310
  return prepareNextState(state, response);
package/dist/index.js CHANGED
@@ -62,8 +62,8 @@ var configureAuth = (auth, headers = {}) => {
62
62
  var prepareNextState = (state, response, callback = (s) => s) => {
63
63
  const { body, ...responseWithoutBody } = response;
64
64
  const nextState = {
65
- ...composeNextState(state, body.objects ?? body),
66
- response: { ...responseWithoutBody, ...{ meta: body.meta } }
65
+ ...composeNextState(state, (body == null ? void 0 : body.objects) ?? body),
66
+ response: { ...responseWithoutBody, ...{ meta: body == null ? void 0 : body.meta } }
67
67
  };
68
68
  return callback(nextState);
69
69
  };
@@ -270,13 +270,13 @@ function fetchReportData(reportId, params, postUrl) {
270
270
  return state;
271
271
  };
272
272
  }
273
- function request2(method, path, body, options = {}) {
273
+ function request2(method, path, body, params = {}) {
274
274
  return async (state) => {
275
- const [resolvedMethod, resolvedPath, resolvedBody, resolvedOptions] = expandReferences(state, method, path, body, options);
275
+ const [resolvedMethod, resolvedPath, resolvedBody, resolvedParams] = expandReferences(state, method, path, body, params);
276
276
  const response = await request(state.configuration, resolvedPath, {
277
277
  method: resolvedMethod,
278
278
  data: resolvedBody,
279
- params: resolvedOptions,
279
+ params: resolvedParams,
280
280
  contentType: "application/json"
281
281
  });
282
282
  return prepareNextState(state, response);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-commcare",
3
- "version": "3.2.8",
3
+ "version": "3.2.10",
4
4
  "description": "Commcare Language Pack for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -21,10 +21,9 @@
21
21
  "js2xmlparser": "^1.0.0",
22
22
  "lodash-fp": "^0.10.4",
23
23
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz",
24
- "@openfn/language-common": "2.3.0"
24
+ "@openfn/language-common": "2.3.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@openfn/simple-ast": "^0.4.1",
28
27
  "assertion-error": "^1.1.0",
29
28
  "chai": "^4.3.7",
30
29
  "deep-eql": "^4.1.3",
@@ -116,16 +116,18 @@ export function fetchReportData(reportId: string, params: any, postUrl: string):
116
116
  * Make a general HTTP request against the Commcare server. Use this to make any request to Commcare REST API.
117
117
  * @example <caption>Get a resource. Equivalent to `<baseUrl>/a/asri/api/v0.5/case`</caption>
118
118
  * request("GET", "/a/asri/api/v0.5/case");
119
+ * @example <caption>Get a resource using query parameters. Equivalent to `<baseUrl>/case?offset=0&limit=20`</caption>
120
+ * request("GET", "/case", {}, { offset:0, limit: 20 })
119
121
  * @function
120
122
  * @public
121
123
  * @param {string} method - HTTP method to use
122
124
  * @param {string} path - Path to resource
123
125
  * @param {object} body - Object which will be attached to the body
124
- * @param {RequestOptions} options - Optional request params
126
+ * @param {object} params - An object of query parameters to be encoded into the URL
125
127
  * @returns {Operation}
126
128
  * @state {CommcareHttpState}
127
129
  */
128
- export function request(method: string, path: string, body: object, options?: RequestOptions): Operation;
130
+ export function request(method: string, path: string, body: object, params?: object): Operation;
129
131
  /**
130
132
  * Bulk upload data to CommCare for case-data or lookup-table. Accepts an array of objects, converts them into
131
133
  * an XLS representation, and uploads.