@openfn/language-kobotoolbox 4.0.0 → 4.1.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 +36 -1
- package/dist/index.cjs +9 -6
- package/dist/index.js +9 -6
- package/package.json +2 -2
- package/types/Adaptor.d.ts +9 -1
- package/types/util.d.ts +1 -0
package/ast.json
CHANGED
|
@@ -60,6 +60,16 @@
|
|
|
60
60
|
"description": "getSubmissions('aXecHjmbATuF6iGFmvBLBX', { query: { _submission_time:{ $gte: \"2025-03-12T21:54:20\" } } });",
|
|
61
61
|
"caption": "Get form submissions with a query"
|
|
62
62
|
},
|
|
63
|
+
{
|
|
64
|
+
"title": "example",
|
|
65
|
+
"description": "getSubmissions('aXecHjmbATuF6iGFmvBLBX', { sort: { _submission_time: -1 } });",
|
|
66
|
+
"caption": "Get form submissions with sorting"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"title": "example",
|
|
70
|
+
"description": "getSubmissions('aXecHjmbATuF6iGFmvBLBX', { start: 10 });",
|
|
71
|
+
"caption": "Get form submissions with specific start index"
|
|
72
|
+
},
|
|
63
73
|
{
|
|
64
74
|
"title": "function",
|
|
65
75
|
"description": null,
|
|
@@ -92,6 +102,18 @@
|
|
|
92
102
|
"name": "options",
|
|
93
103
|
"default": "{}"
|
|
94
104
|
},
|
|
105
|
+
{
|
|
106
|
+
"title": "param",
|
|
107
|
+
"description": "Field and direction to sort submissions by.",
|
|
108
|
+
"type": {
|
|
109
|
+
"type": "OptionalType",
|
|
110
|
+
"expression": {
|
|
111
|
+
"type": "NameExpression",
|
|
112
|
+
"name": "object"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"name": "options.sort"
|
|
116
|
+
},
|
|
95
117
|
{
|
|
96
118
|
"title": "param",
|
|
97
119
|
"description": "Query options to filter the submissions. See query operators {@link http://docs.mongodb.org/manual/reference/operator/query/.}",
|
|
@@ -106,7 +128,20 @@
|
|
|
106
128
|
},
|
|
107
129
|
{
|
|
108
130
|
"title": "param",
|
|
109
|
-
"description": "
|
|
131
|
+
"description": "The index of the first submission to return.",
|
|
132
|
+
"type": {
|
|
133
|
+
"type": "OptionalType",
|
|
134
|
+
"expression": {
|
|
135
|
+
"type": "NameExpression",
|
|
136
|
+
"name": "number"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"name": "options.start",
|
|
140
|
+
"default": "0"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"title": "param",
|
|
144
|
+
"description": "Maximum number of submissions to fetch. Pass `Infinity` to disable the limit and download all submissions",
|
|
110
145
|
"type": {
|
|
111
146
|
"type": "OptionalType",
|
|
112
147
|
"expression": {
|
package/dist/index.cjs
CHANGED
|
@@ -151,6 +151,9 @@ async function requestWithPagination(state, path, options = {}) {
|
|
|
151
151
|
} while (shouldFetchMoreContent);
|
|
152
152
|
return results;
|
|
153
153
|
}
|
|
154
|
+
function maybeStringify(query) {
|
|
155
|
+
return typeof query === "string" ? query : JSON.stringify(query);
|
|
156
|
+
}
|
|
154
157
|
|
|
155
158
|
// src/Adaptor.js
|
|
156
159
|
var import_language_common3 = require("@openfn/language-common");
|
|
@@ -183,18 +186,18 @@ function getSubmissions(formId, options) {
|
|
|
183
186
|
formId,
|
|
184
187
|
options
|
|
185
188
|
);
|
|
186
|
-
const { query, limit, pageSize } = resolvedOptions;
|
|
189
|
+
const { query, limit, pageSize, sort, start } = resolvedOptions;
|
|
187
190
|
const path = `/assets/${resolvedFormId}/data/`;
|
|
188
191
|
const qs = {};
|
|
189
192
|
if (query) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
193
|
+
qs.query = maybeStringify(query);
|
|
194
|
+
}
|
|
195
|
+
if (sort) {
|
|
196
|
+
qs.sort = maybeStringify(sort);
|
|
195
197
|
}
|
|
196
198
|
const requestOptions = {
|
|
197
199
|
query: { ...qs },
|
|
200
|
+
start,
|
|
198
201
|
limit,
|
|
199
202
|
pageSize
|
|
200
203
|
};
|
package/dist/index.js
CHANGED
|
@@ -121,6 +121,9 @@ async function requestWithPagination(state, path, options = {}) {
|
|
|
121
121
|
} while (shouldFetchMoreContent);
|
|
122
122
|
return results;
|
|
123
123
|
}
|
|
124
|
+
function maybeStringify(query) {
|
|
125
|
+
return typeof query === "string" ? query : JSON.stringify(query);
|
|
126
|
+
}
|
|
124
127
|
|
|
125
128
|
// src/Adaptor.js
|
|
126
129
|
import {
|
|
@@ -167,18 +170,18 @@ function getSubmissions(formId, options) {
|
|
|
167
170
|
formId,
|
|
168
171
|
options
|
|
169
172
|
);
|
|
170
|
-
const { query, limit, pageSize } = resolvedOptions;
|
|
173
|
+
const { query, limit, pageSize, sort, start } = resolvedOptions;
|
|
171
174
|
const path = `/assets/${resolvedFormId}/data/`;
|
|
172
175
|
const qs = {};
|
|
173
176
|
if (query) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
177
|
+
qs.query = maybeStringify(query);
|
|
178
|
+
}
|
|
179
|
+
if (sort) {
|
|
180
|
+
qs.sort = maybeStringify(sort);
|
|
179
181
|
}
|
|
180
182
|
const requestOptions = {
|
|
181
183
|
query: { ...qs },
|
|
184
|
+
start,
|
|
182
185
|
limit,
|
|
183
186
|
pageSize
|
|
184
187
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-kobotoolbox",
|
|
3
3
|
"label": "KoboToolbox",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"description": "A KoboToolbox Language Pack for OpenFn",
|
|
6
6
|
"homepage": "https://docs.openfn.org",
|
|
7
7
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"configuration-schema.json"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@openfn/language-common": "2.
|
|
21
|
+
"@openfn/language-common": "2.5.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"assertion-error": "^1.0.1",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -29,18 +29,26 @@ export function getForms(): Operation;
|
|
|
29
29
|
* getSubmissions('aXecHjmbATuF6iGFmvBLBX', { limit: Infinity });
|
|
30
30
|
* @example <caption>Get form submissions with a query</caption>
|
|
31
31
|
* getSubmissions('aXecHjmbATuF6iGFmvBLBX', { query: { _submission_time:{ $gte: "2025-03-12T21:54:20" } } });
|
|
32
|
+
* @example <caption>Get form submissions with sorting</caption>
|
|
33
|
+
* getSubmissions('aXecHjmbATuF6iGFmvBLBX', { sort: { _submission_time: -1 } });
|
|
34
|
+
* @example <caption>Get form submissions with specific start index</caption>
|
|
35
|
+
* getSubmissions('aXecHjmbATuF6iGFmvBLBX', { start: 10 });
|
|
32
36
|
* @function
|
|
33
37
|
* @public
|
|
34
38
|
* @param {string} formId - Form Id to get the specific submissions
|
|
35
39
|
* @param {object} [options={}] - Options to control the request
|
|
40
|
+
* @param {object} [options.sort] - Field and direction to sort submissions by.
|
|
36
41
|
* @param {object} [options.query] - Query options to filter the submissions. See query operators {@link http://docs.mongodb.org/manual/reference/operator/query/.}
|
|
37
|
-
* @param {number} [options.
|
|
42
|
+
* @param {number} [options.start=0] - The index of the first submission to return.
|
|
43
|
+
* @param {number} [options.limit=30000] - Maximum number of submissions to fetch. Pass `Infinity` to disable the limit and download all submissions
|
|
38
44
|
* @param {number} [options.pageSize=10000] - Limits the size of each page of submissions. Maximum value is 30000.
|
|
39
45
|
* @state data - an array of submission objects
|
|
40
46
|
* @returns {Operation}
|
|
41
47
|
*/
|
|
42
48
|
export function getSubmissions(formId: string, options?: {
|
|
49
|
+
sort?: object;
|
|
43
50
|
query?: object;
|
|
51
|
+
start?: number;
|
|
44
52
|
limit?: number;
|
|
45
53
|
pageSize?: number;
|
|
46
54
|
}): Operation;
|
package/types/util.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export function prepareNextState(state: any, response: any): any;
|
|
2
2
|
export function request(state: any, method: any, path: any, opts?: {}): Promise<any>;
|
|
3
3
|
export function requestWithPagination(state: any, path: any, options?: {}): Promise<any[]>;
|
|
4
|
+
export function maybeStringify(query: any): string;
|
|
4
5
|
export const DEFAULT_LIMIT: 30000;
|
|
5
6
|
export const DEFAULT_PAGE_SIZE: 10000;
|