@openfn/language-commcare 2.2.1 → 2.3.1
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 +185 -46
- package/dist/index.cjs +44 -10
- package/dist/index.js +44 -10
- package/package.json +2 -3
- package/types/Adaptor.d.ts +7 -65
package/ast.json
CHANGED
|
@@ -1,5 +1,139 @@
|
|
|
1
1
|
{
|
|
2
2
|
"operations": [
|
|
3
|
+
{
|
|
4
|
+
"name": "execute",
|
|
5
|
+
"params": [
|
|
6
|
+
"operations"
|
|
7
|
+
],
|
|
8
|
+
"docs": {
|
|
9
|
+
"description": "Queries provided to the GET request",
|
|
10
|
+
"tags": [
|
|
11
|
+
{
|
|
12
|
+
"title": "typedef",
|
|
13
|
+
"description": null,
|
|
14
|
+
"type": {
|
|
15
|
+
"type": "NameExpression",
|
|
16
|
+
"name": "Object"
|
|
17
|
+
},
|
|
18
|
+
"name": "RequestQueries"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"title": "public",
|
|
22
|
+
"description": null,
|
|
23
|
+
"type": null
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"title": "property",
|
|
27
|
+
"description": "The maximum number of records to return. Default: 20. Maximum: 5000.",
|
|
28
|
+
"type": {
|
|
29
|
+
"type": "NameExpression",
|
|
30
|
+
"name": "number"
|
|
31
|
+
},
|
|
32
|
+
"name": "limit"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"title": "property",
|
|
36
|
+
"description": "The number of records to offset in the results. Default: 0",
|
|
37
|
+
"type": {
|
|
38
|
+
"type": "NameExpression",
|
|
39
|
+
"name": "number"
|
|
40
|
+
},
|
|
41
|
+
"name": "offset"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"title": "property",
|
|
45
|
+
"description": "Optional form XML namespace. See the [Commcare Docs](https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143979045/Finding+a+Form%27s+XMLNS)",
|
|
46
|
+
"type": {
|
|
47
|
+
"type": "NameExpression",
|
|
48
|
+
"name": "string"
|
|
49
|
+
},
|
|
50
|
+
"name": "xmlns"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"title": "property",
|
|
54
|
+
"description": "Optional date (and time). Will return only forms that have had data modified since the passed in date.",
|
|
55
|
+
"type": {
|
|
56
|
+
"type": "NameExpression",
|
|
57
|
+
"name": "string"
|
|
58
|
+
},
|
|
59
|
+
"name": "indexed_on_start"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"title": "property",
|
|
63
|
+
"description": "Optional date (and time). Will return only forms that have had data modified before the passed in date.",
|
|
64
|
+
"type": {
|
|
65
|
+
"type": "NameExpression",
|
|
66
|
+
"name": "string"
|
|
67
|
+
},
|
|
68
|
+
"name": "indexed_on_end"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"title": "property",
|
|
72
|
+
"description": "Optional date (and time). Will return only forms that were received after the passed in date.",
|
|
73
|
+
"type": {
|
|
74
|
+
"type": "NameExpression",
|
|
75
|
+
"name": "string"
|
|
76
|
+
},
|
|
77
|
+
"name": "received_on_start"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "property",
|
|
81
|
+
"description": "Optional date (and time). Will return only forms that were received before the passed in date.",
|
|
82
|
+
"type": {
|
|
83
|
+
"type": "NameExpression",
|
|
84
|
+
"name": "string"
|
|
85
|
+
},
|
|
86
|
+
"name": "received_on_end"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"title": "property",
|
|
90
|
+
"description": "The returned records will be limited to the application defined",
|
|
91
|
+
"type": {
|
|
92
|
+
"type": "NameExpression",
|
|
93
|
+
"name": "string"
|
|
94
|
+
},
|
|
95
|
+
"name": "app_id"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"title": "property",
|
|
99
|
+
"description": "A case UUID. Will only return forms which updated that case.",
|
|
100
|
+
"type": {
|
|
101
|
+
"type": "NameExpression",
|
|
102
|
+
"name": "string"
|
|
103
|
+
},
|
|
104
|
+
"name": "case_id"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"title": "property",
|
|
108
|
+
"description": "Optional user of group UUID used when getting cases",
|
|
109
|
+
"type": {
|
|
110
|
+
"type": "NameExpression",
|
|
111
|
+
"name": "string"
|
|
112
|
+
},
|
|
113
|
+
"name": "owner_id"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"title": "property",
|
|
117
|
+
"description": "Optional UUID for all cases last modified by that user",
|
|
118
|
+
"type": {
|
|
119
|
+
"type": "NameExpression",
|
|
120
|
+
"name": "string"
|
|
121
|
+
},
|
|
122
|
+
"name": "user_id"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"title": "property",
|
|
126
|
+
"description": "Optional case type to get all matching cases",
|
|
127
|
+
"type": {
|
|
128
|
+
"type": "NameExpression",
|
|
129
|
+
"name": "string"
|
|
130
|
+
},
|
|
131
|
+
"name": "type"
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
"valid": false
|
|
136
|
+
},
|
|
3
137
|
{
|
|
4
138
|
"name": "get",
|
|
5
139
|
"params": [
|
|
@@ -8,7 +142,7 @@
|
|
|
8
142
|
"callback"
|
|
9
143
|
],
|
|
10
144
|
"docs": {
|
|
11
|
-
"description": "Make a GET request to any commcare endpoint. The returned objects will be written to state.data.\nA `response` key will be added to state with the HTTP response and a `meta` key",
|
|
145
|
+
"description": "Make a GET request to any commcare endpoint. The returned objects will be written to state.data.\nUnless an `offset` is passed, `get()` will automatically pull down all pages of data if the response\nis paginated.\nA `response` key will be added to state with the HTTP response and a `meta` key",
|
|
12
146
|
"tags": [
|
|
13
147
|
{
|
|
14
148
|
"title": "public",
|
|
@@ -50,7 +184,7 @@
|
|
|
50
184
|
},
|
|
51
185
|
{
|
|
52
186
|
"title": "param",
|
|
53
|
-
"description": "
|
|
187
|
+
"description": "Callback invoked once per page of data retrieved.",
|
|
54
188
|
"type": {
|
|
55
189
|
"type": "OptionalType",
|
|
56
190
|
"expression": {
|
|
@@ -323,15 +457,15 @@
|
|
|
323
457
|
"description": null,
|
|
324
458
|
"type": null
|
|
325
459
|
},
|
|
326
|
-
{
|
|
327
|
-
"title": "example",
|
|
328
|
-
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
329
|
-
},
|
|
330
460
|
{
|
|
331
461
|
"title": "function",
|
|
332
462
|
"description": null,
|
|
333
463
|
"name": null
|
|
334
464
|
},
|
|
465
|
+
{
|
|
466
|
+
"title": "example",
|
|
467
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
468
|
+
},
|
|
335
469
|
{
|
|
336
470
|
"title": "param",
|
|
337
471
|
"description": "is the function",
|
|
@@ -367,15 +501,15 @@
|
|
|
367
501
|
"description": null,
|
|
368
502
|
"type": null
|
|
369
503
|
},
|
|
370
|
-
{
|
|
371
|
-
"title": "example",
|
|
372
|
-
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
373
|
-
},
|
|
374
504
|
{
|
|
375
505
|
"title": "function",
|
|
376
506
|
"description": null,
|
|
377
507
|
"name": null
|
|
378
508
|
},
|
|
509
|
+
{
|
|
510
|
+
"title": "example",
|
|
511
|
+
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
512
|
+
},
|
|
379
513
|
{
|
|
380
514
|
"title": "param",
|
|
381
515
|
"description": "The condition that returns true",
|
|
@@ -419,15 +553,15 @@
|
|
|
419
553
|
"description": null,
|
|
420
554
|
"type": null
|
|
421
555
|
},
|
|
422
|
-
{
|
|
423
|
-
"title": "example",
|
|
424
|
-
"description": "sourceValue('$.key')"
|
|
425
|
-
},
|
|
426
556
|
{
|
|
427
557
|
"title": "function",
|
|
428
558
|
"description": null,
|
|
429
559
|
"name": null
|
|
430
560
|
},
|
|
561
|
+
{
|
|
562
|
+
"title": "example",
|
|
563
|
+
"description": "sourceValue('$.key')"
|
|
564
|
+
},
|
|
431
565
|
{
|
|
432
566
|
"title": "param",
|
|
433
567
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -462,15 +596,15 @@
|
|
|
462
596
|
"description": null,
|
|
463
597
|
"type": null
|
|
464
598
|
},
|
|
465
|
-
{
|
|
466
|
-
"title": "example",
|
|
467
|
-
"description": "dataPath('key')"
|
|
468
|
-
},
|
|
469
599
|
{
|
|
470
600
|
"title": "function",
|
|
471
601
|
"description": null,
|
|
472
602
|
"name": null
|
|
473
603
|
},
|
|
604
|
+
{
|
|
605
|
+
"title": "example",
|
|
606
|
+
"description": "dataPath('key')"
|
|
607
|
+
},
|
|
474
608
|
{
|
|
475
609
|
"title": "param",
|
|
476
610
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -505,15 +639,15 @@
|
|
|
505
639
|
"description": null,
|
|
506
640
|
"type": null
|
|
507
641
|
},
|
|
508
|
-
{
|
|
509
|
-
"title": "example",
|
|
510
|
-
"description": "dataValue('key')"
|
|
511
|
-
},
|
|
512
642
|
{
|
|
513
643
|
"title": "function",
|
|
514
644
|
"description": null,
|
|
515
645
|
"name": null
|
|
516
646
|
},
|
|
647
|
+
{
|
|
648
|
+
"title": "example",
|
|
649
|
+
"description": "dataValue('key')"
|
|
650
|
+
},
|
|
517
651
|
{
|
|
518
652
|
"title": "param",
|
|
519
653
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -548,15 +682,15 @@
|
|
|
548
682
|
"description": null,
|
|
549
683
|
"type": null
|
|
550
684
|
},
|
|
551
|
-
{
|
|
552
|
-
"title": "example",
|
|
553
|
-
"description": "lastReferenceValue('key')"
|
|
554
|
-
},
|
|
555
685
|
{
|
|
556
686
|
"title": "function",
|
|
557
687
|
"description": null,
|
|
558
688
|
"name": null
|
|
559
689
|
},
|
|
690
|
+
{
|
|
691
|
+
"title": "example",
|
|
692
|
+
"description": "lastReferenceValue('key')"
|
|
693
|
+
},
|
|
560
694
|
{
|
|
561
695
|
"title": "param",
|
|
562
696
|
"description": "JSONPath referencing a point in `references`.",
|
|
@@ -592,15 +726,15 @@
|
|
|
592
726
|
"description": null,
|
|
593
727
|
"type": null
|
|
594
728
|
},
|
|
595
|
-
{
|
|
596
|
-
"title": "example",
|
|
597
|
-
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
598
|
-
},
|
|
599
729
|
{
|
|
600
730
|
"title": "function",
|
|
601
731
|
"description": null,
|
|
602
732
|
"name": null
|
|
603
733
|
},
|
|
734
|
+
{
|
|
735
|
+
"title": "example",
|
|
736
|
+
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
737
|
+
},
|
|
604
738
|
{
|
|
605
739
|
"title": "param",
|
|
606
740
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -644,15 +778,15 @@
|
|
|
644
778
|
"description": null,
|
|
645
779
|
"type": null
|
|
646
780
|
},
|
|
647
|
-
{
|
|
648
|
-
"title": "example",
|
|
649
|
-
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
650
|
-
},
|
|
651
781
|
{
|
|
652
782
|
"title": "function",
|
|
653
783
|
"description": null,
|
|
654
784
|
"name": null
|
|
655
785
|
},
|
|
786
|
+
{
|
|
787
|
+
"title": "example",
|
|
788
|
+
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
789
|
+
},
|
|
656
790
|
{
|
|
657
791
|
"title": "param",
|
|
658
792
|
"description": "Operations to be performed.",
|
|
@@ -688,15 +822,15 @@
|
|
|
688
822
|
"description": null,
|
|
689
823
|
"type": null
|
|
690
824
|
},
|
|
691
|
-
{
|
|
692
|
-
"title": "example",
|
|
693
|
-
"description": "field('destination_field_name__c', 'value')"
|
|
694
|
-
},
|
|
695
825
|
{
|
|
696
826
|
"title": "function",
|
|
697
827
|
"description": null,
|
|
698
828
|
"name": null
|
|
699
829
|
},
|
|
830
|
+
{
|
|
831
|
+
"title": "example",
|
|
832
|
+
"description": "field('destination_field_name__c', 'value')"
|
|
833
|
+
},
|
|
700
834
|
{
|
|
701
835
|
"title": "param",
|
|
702
836
|
"description": "Name of the field",
|
|
@@ -740,15 +874,15 @@
|
|
|
740
874
|
"description": null,
|
|
741
875
|
"type": null
|
|
742
876
|
},
|
|
743
|
-
{
|
|
744
|
-
"title": "example",
|
|
745
|
-
"description": "fields(list_of_fields)"
|
|
746
|
-
},
|
|
747
877
|
{
|
|
748
878
|
"title": "function",
|
|
749
879
|
"description": null,
|
|
750
880
|
"name": null
|
|
751
881
|
},
|
|
882
|
+
{
|
|
883
|
+
"title": "example",
|
|
884
|
+
"description": "fields(list_of_fields)"
|
|
885
|
+
},
|
|
752
886
|
{
|
|
753
887
|
"title": "param",
|
|
754
888
|
"description": "a list of fields",
|
|
@@ -793,6 +927,11 @@
|
|
|
793
927
|
"description": null,
|
|
794
928
|
"name": null
|
|
795
929
|
},
|
|
930
|
+
{
|
|
931
|
+
"title": "public",
|
|
932
|
+
"description": null,
|
|
933
|
+
"type": null
|
|
934
|
+
},
|
|
796
935
|
{
|
|
797
936
|
"title": "param",
|
|
798
937
|
"description": null,
|
|
@@ -837,15 +976,15 @@
|
|
|
837
976
|
"description": null,
|
|
838
977
|
"type": null
|
|
839
978
|
},
|
|
840
|
-
{
|
|
841
|
-
"title": "example",
|
|
842
|
-
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
843
|
-
},
|
|
844
979
|
{
|
|
845
980
|
"title": "function",
|
|
846
981
|
"description": null,
|
|
847
982
|
"name": null
|
|
848
983
|
},
|
|
984
|
+
{
|
|
985
|
+
"title": "example",
|
|
986
|
+
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
987
|
+
},
|
|
849
988
|
{
|
|
850
989
|
"title": "param",
|
|
851
990
|
"description": "Array of toString'able primatives.",
|
package/dist/index.cjs
CHANGED
|
@@ -142,28 +142,62 @@ function execute(...operations) {
|
|
|
142
142
|
}
|
|
143
143
|
function get(path, params = {}, callback = (s) => s) {
|
|
144
144
|
return async (state) => {
|
|
145
|
+
var _a, _b;
|
|
145
146
|
const { domain } = state.configuration;
|
|
146
147
|
const [resolvedPath, resolvedParams] = (0, import_util2.expandReferences)(
|
|
147
148
|
state,
|
|
148
149
|
path,
|
|
149
150
|
params
|
|
150
151
|
);
|
|
152
|
+
let offset, limit;
|
|
153
|
+
let nextState = state;
|
|
154
|
+
let result;
|
|
155
|
+
let allowPagination = isNaN(resolvedParams.offset);
|
|
151
156
|
try {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
let requestParams = {
|
|
158
|
+
...resolvedParams
|
|
159
|
+
};
|
|
160
|
+
do {
|
|
161
|
+
const response = await request(
|
|
162
|
+
state.configuration,
|
|
163
|
+
`/a/${domain}/api/v0.5/${resolvedPath}`,
|
|
164
|
+
{
|
|
165
|
+
method: "GET",
|
|
166
|
+
params: requestParams,
|
|
167
|
+
contentType: "application/json"
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
nextState = prepareNextState(state, response, callback);
|
|
171
|
+
if ((_b = (_a = response == null ? void 0 : response.body) == null ? void 0 : _a.meta) == null ? void 0 : _b.next) {
|
|
172
|
+
if (!result) {
|
|
173
|
+
result = [];
|
|
174
|
+
}
|
|
175
|
+
offset = response.body.meta.offset + response.body.meta.limit;
|
|
176
|
+
limit = response.body.meta.limit;
|
|
177
|
+
requestParams = {
|
|
178
|
+
...requestParams,
|
|
179
|
+
offset,
|
|
180
|
+
limit
|
|
181
|
+
};
|
|
182
|
+
result.push(...nextState.data);
|
|
183
|
+
} else {
|
|
184
|
+
if (result) {
|
|
185
|
+
result.push(...nextState.data);
|
|
186
|
+
} else {
|
|
187
|
+
result = nextState.data;
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
159
190
|
}
|
|
160
|
-
);
|
|
161
|
-
return
|
|
191
|
+
} while (allowPagination);
|
|
192
|
+
return {
|
|
193
|
+
...nextState,
|
|
194
|
+
data: result
|
|
195
|
+
};
|
|
162
196
|
} catch (e) {
|
|
163
197
|
if (e.statusCode === 404) {
|
|
164
198
|
e.body = { error: `Resource ${path} not found` };
|
|
165
199
|
}
|
|
166
|
-
throw e
|
|
200
|
+
throw e;
|
|
167
201
|
}
|
|
168
202
|
};
|
|
169
203
|
}
|
package/dist/index.js
CHANGED
|
@@ -116,28 +116,62 @@ function execute(...operations) {
|
|
|
116
116
|
}
|
|
117
117
|
function get(path, params = {}, callback = (s) => s) {
|
|
118
118
|
return async (state) => {
|
|
119
|
+
var _a, _b;
|
|
119
120
|
const { domain } = state.configuration;
|
|
120
121
|
const [resolvedPath, resolvedParams] = expandReferences(
|
|
121
122
|
state,
|
|
122
123
|
path,
|
|
123
124
|
params
|
|
124
125
|
);
|
|
126
|
+
let offset, limit;
|
|
127
|
+
let nextState = state;
|
|
128
|
+
let result;
|
|
129
|
+
let allowPagination = isNaN(resolvedParams.offset);
|
|
125
130
|
try {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
let requestParams = {
|
|
132
|
+
...resolvedParams
|
|
133
|
+
};
|
|
134
|
+
do {
|
|
135
|
+
const response = await request(
|
|
136
|
+
state.configuration,
|
|
137
|
+
`/a/${domain}/api/v0.5/${resolvedPath}`,
|
|
138
|
+
{
|
|
139
|
+
method: "GET",
|
|
140
|
+
params: requestParams,
|
|
141
|
+
contentType: "application/json"
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
nextState = prepareNextState(state, response, callback);
|
|
145
|
+
if ((_b = (_a = response == null ? void 0 : response.body) == null ? void 0 : _a.meta) == null ? void 0 : _b.next) {
|
|
146
|
+
if (!result) {
|
|
147
|
+
result = [];
|
|
148
|
+
}
|
|
149
|
+
offset = response.body.meta.offset + response.body.meta.limit;
|
|
150
|
+
limit = response.body.meta.limit;
|
|
151
|
+
requestParams = {
|
|
152
|
+
...requestParams,
|
|
153
|
+
offset,
|
|
154
|
+
limit
|
|
155
|
+
};
|
|
156
|
+
result.push(...nextState.data);
|
|
157
|
+
} else {
|
|
158
|
+
if (result) {
|
|
159
|
+
result.push(...nextState.data);
|
|
160
|
+
} else {
|
|
161
|
+
result = nextState.data;
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
133
164
|
}
|
|
134
|
-
);
|
|
135
|
-
return
|
|
165
|
+
} while (allowPagination);
|
|
166
|
+
return {
|
|
167
|
+
...nextState,
|
|
168
|
+
data: result
|
|
169
|
+
};
|
|
136
170
|
} catch (e) {
|
|
137
171
|
if (e.statusCode === 404) {
|
|
138
172
|
e.body = { error: `Resource ${path} not found` };
|
|
139
173
|
}
|
|
140
|
-
throw e
|
|
174
|
+
throw e;
|
|
141
175
|
}
|
|
142
176
|
};
|
|
143
177
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-commcare",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Commcare Language Pack for OpenFn",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"JSONPath": "^0.10.0",
|
|
21
21
|
"js2xmlparser": "^1.0.0",
|
|
22
22
|
"lodash-fp": "^0.10.4",
|
|
23
|
-
"sinon": "^18.0.0",
|
|
24
23
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz",
|
|
25
|
-
"@openfn/language-common": "1.15.
|
|
24
|
+
"@openfn/language-common": "1.15.1"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@openfn/simple-ast": "^0.4.1",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Queries provided to the GET request
|
|
3
3
|
* @typedef {Object} RequestQueries
|
|
4
|
+
* @public
|
|
4
5
|
* @property {number} limit - The maximum number of records to return. Default: 20. Maximum: 5000.
|
|
5
6
|
* @property {number} offset - The number of records to offset in the results. Default: 0
|
|
6
7
|
* @property {string} xmlns - Optional form XML namespace. See the [Commcare Docs](https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143979045/Finding+a+Form%27s+XMLNS)
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
/**
|
|
18
19
|
* Queries provided to the submitXls request
|
|
19
20
|
* @typedef {Object} RequestOptions
|
|
21
|
+
* @public
|
|
20
22
|
* @property {string} case_type - Optional case type
|
|
21
23
|
* @property {string} search_field - Optional search field
|
|
22
24
|
* @property {string} create_new_cases - Optional for allowing to create new cases. Default `:on`
|
|
@@ -36,6 +38,8 @@
|
|
|
36
38
|
export function execute(...operations: Operations): Operation;
|
|
37
39
|
/**
|
|
38
40
|
* Make a GET request to any commcare endpoint. The returned objects will be written to state.data.
|
|
41
|
+
* Unless an `offset` is passed, `get()` will automatically pull down all pages of data if the response
|
|
42
|
+
* is paginated.
|
|
39
43
|
* A `response` key will be added to state with the HTTP response and a `meta` key
|
|
40
44
|
* @public
|
|
41
45
|
* @example <caption>Get a list of cases</caption>
|
|
@@ -45,7 +49,7 @@ export function execute(...operations: Operations): Operation;
|
|
|
45
49
|
* @function
|
|
46
50
|
* @param {string} path - Path to resource
|
|
47
51
|
* @param {RequestQueries} params - Optional request params such as limit and offset.
|
|
48
|
-
* @param {function} [callback] -
|
|
52
|
+
* @param {function} [callback] - Callback invoked once per page of data retrieved.
|
|
49
53
|
* @returns {Operation}
|
|
50
54
|
*/
|
|
51
55
|
export function get(path: string, params?: RequestQueries, callback?: Function): Operation;
|
|
@@ -118,71 +122,9 @@ export function fetchReportData(reportId: string, params: RequestQueries, postUr
|
|
|
118
122
|
/**
|
|
119
123
|
* Queries provided to the GET request
|
|
120
124
|
*/
|
|
121
|
-
export type RequestQueries =
|
|
122
|
-
/**
|
|
123
|
-
* - The maximum number of records to return. Default: 20. Maximum: 5000.
|
|
124
|
-
*/
|
|
125
|
-
limit: number;
|
|
126
|
-
/**
|
|
127
|
-
* - The number of records to offset in the results. Default: 0
|
|
128
|
-
*/
|
|
129
|
-
offset: number;
|
|
130
|
-
/**
|
|
131
|
-
* - Optional form XML namespace. See the [Commcare Docs](https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143979045/Finding+a+Form%27s+XMLNS)
|
|
132
|
-
*/
|
|
133
|
-
xmlns: string;
|
|
134
|
-
/**
|
|
135
|
-
* - Optional date (and time). Will return only forms that have had data modified since the passed in date.
|
|
136
|
-
*/
|
|
137
|
-
indexed_on_start: string;
|
|
138
|
-
/**
|
|
139
|
-
* - Optional date (and time). Will return only forms that have had data modified before the passed in date.
|
|
140
|
-
*/
|
|
141
|
-
indexed_on_end: string;
|
|
142
|
-
/**
|
|
143
|
-
* - Optional date (and time). Will return only forms that were received after the passed in date.
|
|
144
|
-
*/
|
|
145
|
-
received_on_start: string;
|
|
146
|
-
/**
|
|
147
|
-
* - Optional date (and time). Will return only forms that were received before the passed in date.
|
|
148
|
-
*/
|
|
149
|
-
received_on_end: string;
|
|
150
|
-
/**
|
|
151
|
-
* - The returned records will be limited to the application defined
|
|
152
|
-
*/
|
|
153
|
-
app_id: string;
|
|
154
|
-
/**
|
|
155
|
-
* - A case UUID. Will only return forms which updated that case.
|
|
156
|
-
*/
|
|
157
|
-
case_id: string;
|
|
158
|
-
/**
|
|
159
|
-
* - Optional user of group UUID used when getting cases
|
|
160
|
-
*/
|
|
161
|
-
owner_id: string;
|
|
162
|
-
/**
|
|
163
|
-
* - Optional UUID for all cases last modified by that user
|
|
164
|
-
*/
|
|
165
|
-
user_id: string;
|
|
166
|
-
/**
|
|
167
|
-
* - Optional case type to get all matching cases
|
|
168
|
-
*/
|
|
169
|
-
type: string;
|
|
170
|
-
};
|
|
125
|
+
export type RequestQueries = any;
|
|
171
126
|
/**
|
|
172
127
|
* Queries provided to the submitXls request
|
|
173
128
|
*/
|
|
174
|
-
export type RequestOptions =
|
|
175
|
-
/**
|
|
176
|
-
* - Optional case type
|
|
177
|
-
*/
|
|
178
|
-
case_type: string;
|
|
179
|
-
/**
|
|
180
|
-
* - Optional search field
|
|
181
|
-
*/
|
|
182
|
-
search_field: string;
|
|
183
|
-
/**
|
|
184
|
-
* - Optional for allowing to create new cases. Default `:on`
|
|
185
|
-
*/
|
|
186
|
-
create_new_cases: string;
|
|
187
|
-
};
|
|
129
|
+
export type RequestOptions = any;
|
|
188
130
|
export { fn, fnIf, alterState, arrayToString, combine, dataPath, dataValue, each, field, fields, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
|