@openfn/language-commcare 1.5.2 → 1.5.4
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 +5 -13
- package/ast.json +3 -6
- package/configuration-schema.json +20 -5
- package/package.json +3 -3
- package/types/Adaptor.d.ts +4 -78
package/README.md
CHANGED
|
@@ -14,24 +14,16 @@ https://github.com/dimagi/commcare/wiki/casexml20
|
|
|
14
14
|
|
|
15
15
|
## Documentation
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Configuration
|
|
18
18
|
|
|
19
|
-
|
|
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
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-commcare",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "Commcare Language Pack for OpenFn",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"configuration-schema.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@openfn/language-common": "1.7.
|
|
21
|
-
"@openfn/language-http": "^4.2.
|
|
20
|
+
"@openfn/language-common": "1.7.6",
|
|
21
|
+
"@openfn/language-http": "^4.2.7",
|
|
22
22
|
"JSONPath": "^0.10.0",
|
|
23
23
|
"form-data": "^4.0.0",
|
|
24
24
|
"js2xmlparser": "^1.0.0",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -6,26 +6,11 @@
|
|
|
6
6
|
* create('foo'),
|
|
7
7
|
* delete('bar')
|
|
8
8
|
* )(state)
|
|
9
|
-
* @
|
|
9
|
+
* @private
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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";
|