@openfn/language-commcare 1.5.1 → 1.5.3

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Language CommCare [![Build Status](https://travis-ci.org/OpenFn/language-commcare.svg?branch=master)](https://travis-ci.org/OpenFn/language-commcare)
1
+ # Language CommCare
2
2
 
3
3
  Language Pack for interacting with the CommCare API.
4
4
 
@@ -14,24 +14,16 @@ https://github.com/dimagi/commcare/wiki/casexml20
14
14
 
15
15
  ## Documentation
16
16
 
17
- ## Sample configuration
17
+ ## Configuration
18
18
 
19
- The "appId" is the UUID which designates your commcare project as different from
19
+ View all the required and optional properties for `state.configuration` in the official [configuration-schema](https://docs.openfn.org/adaptors/packages/commcare-configuration-schema/) definition.
20
+
21
+ - The "appId" is the UUID which designates your commcare project as different from
20
22
  everyone elses. It can be found in the URL of your application when you first
21
23
  enter it from the project screen. I.e., the last part of this url:
22
24
  `https://www.commcarehq.org/a/YOUR_PROJECT/apps/view/YOUR_APP_ID/`
23
25
 
24
- Note that the username is your full email address.
25
-
26
- ```json
27
- {
28
- "appId": "the-long-uuid-in-the-url-that-designates-a-unique-commcare-project",
29
- "password": "shhh",
30
- "username": "test@openfn.org",
31
- "applicationName": "some-proof-of-concept",
32
- "hostUrl": "https://www.commcarehq.org"
33
- }
34
- ```
26
+ - Note that the username is your full email address.
35
27
 
36
28
  ## `fetchReportData` to pull aggregate data from CommCare
37
29
 
@@ -83,6 +75,7 @@ complex body target:
83
75
  ## Submitting data to CommCare HQ
84
76
 
85
77
  ### Submit an XLS file
78
+
86
79
  This function bulk submit a JSON object as xls file to CommCare HQ
87
80
 
88
81
  ```js
@@ -175,7 +168,8 @@ So the JSON emitted by your expression should look like this:
175
168
 
176
169
  ## Development
177
170
 
178
- Clone the [adaptors monorepo](https://github.com/OpenFn/adaptors). Follow the `Getting Started` guide inside to get set up.
171
+ Clone the [adaptors monorepo](https://github.com/OpenFn/adaptors). Follow the
172
+ `Getting Started` guide inside to get set up.
179
173
 
180
174
  Run tests using `pnpm run test` or `pnpm run test:watch`
181
175
 
package/ast.json CHANGED
@@ -19,9 +19,8 @@
19
19
  "description": "submitXls(\n [\n {name: 'Mamadou', phone: '000000'},\n ],\n {\n case_type: 'student',\n search_field: 'external_id',\n create_new_cases: 'on',\n }\n)"
20
20
  },
21
21
  {
22
- "title": "constructor",
22
+ "title": "function",
23
23
  "description": null,
24
- "type": null,
25
24
  "name": null
26
25
  },
27
26
  {
@@ -72,9 +71,8 @@
72
71
  "description": "submit(\n fields(\n field(\"@\", function(state) {\n return {\n \"xmlns\": \"http://openrosa.org/formdesigner/form-id-here\"\n };\n }),\n field(\"question1\", dataValue(\"answer1\")),\n field(\"question2\", \"Some answer here.\")\n )\n )"
73
72
  },
74
73
  {
75
- "title": "constructor",
74
+ "title": "function",
76
75
  "description": null,
77
- "type": null,
78
76
  "name": null
79
77
  },
80
78
  {
@@ -118,9 +116,8 @@
118
116
  "description": "fetchReportData(reportId, params, postUrl)"
119
117
  },
120
118
  {
121
- "title": "constructor",
119
+ "title": "function",
122
120
  "description": null,
123
- "type": null,
124
121
  "name": null
125
122
  },
126
123
  {
@@ -6,32 +6,47 @@
6
6
  "type": "string",
7
7
  "description": "The CommCare host url",
8
8
  "format": "uri",
9
- "minLength": 1
9
+ "minLength": 1,
10
+ "examples": [
11
+ "https://www.commcarehq.org"
12
+ ]
10
13
  },
11
14
  "applicationName": {
12
15
  "title": "Application Name",
13
16
  "type": "string",
14
17
  "description": "The CommCare application name",
15
- "minLength": 1
18
+ "minLength": 1,
19
+ "examples": [
20
+ "some-proof-of-concept"
21
+ ]
16
22
  },
17
23
  "appId": {
18
24
  "title": "App ID",
19
25
  "type": "string",
20
26
  "description": "Your CommCare project UUID",
21
- "minLength": 1
27
+ "minLength": 1,
28
+ "examples": [
29
+ "the-long-uuid-in-the-url-that-designates-a-unique-commcare-project"
30
+ ]
22
31
  },
23
32
  "username": {
24
33
  "title": "Username",
25
34
  "type": "string",
26
35
  "description": "The username to log in to CommCare",
27
- "minLength": 1
36
+ "minLength": 1,
37
+ "examples": [
38
+ "test@openfn.org"
39
+ ]
28
40
  },
29
41
  "password": {
30
42
  "title": "Password",
31
43
  "type": "string",
32
44
  "description": "The password to log in to CommCare",
33
45
  "writeOnly": true,
34
- "minLength": 1
46
+ "minLength": 1,
47
+ "examples": [
48
+ "superscretepassword"
49
+ ]
35
50
  }
36
51
  },
37
52
  "type": "object",
package/dist/index.cjs CHANGED
@@ -25,8 +25,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
25
25
  // src/index.js
26
26
  var src_exports = {};
27
27
  __export(src_exports, {
28
- Adaptor: () => Adaptor_exports,
29
- default: () => src_default
28
+ alterState: () => import_language_common2.alterState,
29
+ arrayToString: () => import_language_common2.arrayToString,
30
+ combine: () => import_language_common2.combine,
31
+ dataPath: () => import_language_common2.dataPath,
32
+ dataValue: () => import_language_common2.dataValue,
33
+ default: () => src_default,
34
+ each: () => import_language_common2.each,
35
+ execute: () => execute,
36
+ fetchReportData: () => fetchReportData,
37
+ field: () => import_language_common2.field,
38
+ fields: () => import_language_common2.fields,
39
+ fn: () => import_language_common2.fn,
40
+ http: () => import_language_common2.http,
41
+ lastReferenceValue: () => import_language_common2.lastReferenceValue,
42
+ merge: () => import_language_common2.merge,
43
+ sourceValue: () => import_language_common2.sourceValue,
44
+ submit: () => submit,
45
+ submitXls: () => submitXls
30
46
  });
31
47
  module.exports = __toCommonJS(src_exports);
32
48
 
@@ -180,5 +196,21 @@ function fetchReportData(reportId, params, postUrl) {
180
196
  var src_default = Adaptor_exports;
181
197
  // Annotate the CommonJS export names for ESM import in node:
182
198
  0 && (module.exports = {
183
- Adaptor
199
+ alterState,
200
+ arrayToString,
201
+ combine,
202
+ dataPath,
203
+ dataValue,
204
+ each,
205
+ execute,
206
+ fetchReportData,
207
+ field,
208
+ fields,
209
+ fn,
210
+ http,
211
+ lastReferenceValue,
212
+ merge,
213
+ sourceValue,
214
+ submit,
215
+ submitXls
184
216
  });
package/dist/index.js CHANGED
@@ -171,6 +171,22 @@ function fetchReportData(reportId, params, postUrl) {
171
171
  // src/index.js
172
172
  var src_default = Adaptor_exports;
173
173
  export {
174
- Adaptor_exports as Adaptor,
175
- src_default as default
174
+ alterState,
175
+ arrayToString,
176
+ combine,
177
+ dataPath,
178
+ dataValue,
179
+ src_default as default,
180
+ each,
181
+ execute,
182
+ fetchReportData,
183
+ field,
184
+ fields,
185
+ fn,
186
+ http2 as http,
187
+ lastReferenceValue,
188
+ merge,
189
+ sourceValue,
190
+ submit,
191
+ submitXls
176
192
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-commcare",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Commcare Language Pack for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "@openfn/language-common": "1.7.5",
21
- "@openfn/language-http": "^4.2.3",
21
+ "@openfn/language-http": "^4.2.5",
22
22
  "JSONPath": "^0.10.0",
23
23
  "form-data": "^4.0.0",
24
24
  "js2xmlparser": "^1.0.0",
@@ -6,26 +6,11 @@
6
6
  * create('foo'),
7
7
  * delete('bar')
8
8
  * )(state)
9
- * @constructor
9
+ * @function
10
10
  * @param {Operations} operations - Operations to be performed.
11
11
  * @returns {Operation}
12
12
  */
13
13
  export function execute(...operations: Operations): Operation;
14
- export class execute {
15
- /**
16
- * Execute a sequence of operations.
17
- * Wraps `language-common/execute`, and prepends initial state for commcare.
18
- * @example
19
- * execute(
20
- * create('foo'),
21
- * delete('bar')
22
- * )(state)
23
- * @constructor
24
- * @param {Operations} operations - Operations to be performed.
25
- * @returns {Operation}
26
- */
27
- constructor(...operations: Operations);
28
- }
29
14
  /**
30
15
  * Convert form data to xls then submit.
31
16
  * @public
@@ -40,34 +25,12 @@ export class execute {
40
25
  * create_new_cases: 'on',
41
26
  * }
42
27
  * )
43
- * @constructor
28
+ * @function
44
29
  * @param {Object} formData - Object including form data.
45
30
  * @param {Object} params - Request params including case type and external id.
46
31
  * @returns {Operation}
47
32
  */
48
33
  export function submitXls(formData: any, params: any): Operation;
49
- export class submitXls {
50
- /**
51
- * Convert form data to xls then submit.
52
- * @public
53
- * @example
54
- * submitXls(
55
- * [
56
- * {name: 'Mamadou', phone: '000000'},
57
- * ],
58
- * {
59
- * case_type: 'student',
60
- * search_field: 'external_id',
61
- * create_new_cases: 'on',
62
- * }
63
- * )
64
- * @constructor
65
- * @param {Object} formData - Object including form data.
66
- * @param {Object} params - Request params including case type and external id.
67
- * @returns {Operation}
68
- */
69
- constructor(formData: any, params: any);
70
- }
71
34
  /**
72
35
  * Submit form data
73
36
  * @public
@@ -83,59 +46,22 @@ export class submitXls {
83
46
  * field("question2", "Some answer here.")
84
47
  * )
85
48
  * )
86
- * @constructor
49
+ * @function
87
50
  * @param {Object} formData - Object including form data.
88
51
  * @returns {Operation}
89
52
  */
90
53
  export function submit(formData: any): Operation;
91
- export class submit {
92
- /**
93
- * Submit form data
94
- * @public
95
- * @example
96
- * submit(
97
- * fields(
98
- * field("@", function(state) {
99
- * return {
100
- * "xmlns": "http://openrosa.org/formdesigner/form-id-here"
101
- * };
102
- * }),
103
- * field("question1", dataValue("answer1")),
104
- * field("question2", "Some answer here.")
105
- * )
106
- * )
107
- * @constructor
108
- * @param {Object} formData - Object including form data.
109
- * @returns {Operation}
110
- */
111
- constructor(formData: any);
112
- }
113
54
  /**
114
55
  * Make a GET request to CommCare's Reports API
115
56
  * and POST the response to somewhere else.
116
57
  * @public
117
58
  * @example
118
59
  * fetchReportData(reportId, params, postUrl)
119
- * @constructor
60
+ * @function
120
61
  * @param {String} reportId - API name of the report.
121
62
  * @param {Object} params - Query params, incl: limit, offset, and custom report filters.
122
63
  * @param {String} postUrl - Url to which the response object will be posted.
123
64
  * @returns {Operation}
124
65
  */
125
66
  export function fetchReportData(reportId: string, params: any, postUrl: string): Operation;
126
- export class fetchReportData {
127
- /**
128
- * Make a GET request to CommCare's Reports API
129
- * and POST the response to somewhere else.
130
- * @public
131
- * @example
132
- * fetchReportData(reportId, params, postUrl)
133
- * @constructor
134
- * @param {String} reportId - API name of the report.
135
- * @param {Object} params - Query params, incl: limit, offset, and custom report filters.
136
- * @param {String} postUrl - Url to which the response object will be posted.
137
- * @returns {Operation}
138
- */
139
- constructor(reportId: string, params: any, postUrl: string);
140
- }
141
67
  export { fn, alterState, arrayToString, combine, dataPath, dataValue, each, field, fields, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Adaptor };
2
1
  export default Adaptor;
2
+ export * from "./Adaptor";
3
3
  import * as Adaptor from "./Adaptor";