@openfn/language-kobotoolbox 1.1.0 → 1.2.0

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 ADDED
@@ -0,0 +1,477 @@
1
+ {
2
+ "operations": [
3
+ {
4
+ "name": "getForms",
5
+ "params": [
6
+ "params",
7
+ "callback"
8
+ ],
9
+ "docs": {
10
+ "description": "Make a request to get the list of forms",
11
+ "tags": [
12
+ {
13
+ "title": "public",
14
+ "description": null,
15
+ "type": null
16
+ },
17
+ {
18
+ "title": "example",
19
+ "description": "getForms({}, state => {\n console.log(state.data);\n return state;\n});"
20
+ },
21
+ {
22
+ "title": "function",
23
+ "description": null,
24
+ "name": null
25
+ },
26
+ {
27
+ "title": "param",
28
+ "description": "Query, Headers and Authentication parameters",
29
+ "type": {
30
+ "type": "NameExpression",
31
+ "name": "object"
32
+ },
33
+ "name": "params"
34
+ },
35
+ {
36
+ "title": "param",
37
+ "description": "(Optional) Callback function to execute after fetching form list",
38
+ "type": {
39
+ "type": "NameExpression",
40
+ "name": "function"
41
+ },
42
+ "name": "callback"
43
+ },
44
+ {
45
+ "title": "returns",
46
+ "description": null,
47
+ "type": {
48
+ "type": "NameExpression",
49
+ "name": "Operation"
50
+ }
51
+ }
52
+ ]
53
+ },
54
+ "valid": true
55
+ }
56
+ ],
57
+ "exports": [],
58
+ "common": [
59
+ {
60
+ "name": "fn",
61
+ "params": [
62
+ "func"
63
+ ],
64
+ "docs": {
65
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
66
+ "tags": [
67
+ {
68
+ "title": "public",
69
+ "description": null,
70
+ "type": null
71
+ },
72
+ {
73
+ "title": "example",
74
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
75
+ },
76
+ {
77
+ "title": "function",
78
+ "description": null,
79
+ "name": null
80
+ },
81
+ {
82
+ "title": "param",
83
+ "description": "is the function",
84
+ "type": {
85
+ "type": "NameExpression",
86
+ "name": "Function"
87
+ },
88
+ "name": "func"
89
+ },
90
+ {
91
+ "title": "returns",
92
+ "description": null,
93
+ "type": {
94
+ "type": "NameExpression",
95
+ "name": "Operation"
96
+ }
97
+ }
98
+ ]
99
+ },
100
+ "valid": true
101
+ },
102
+ {
103
+ "name": "sourceValue",
104
+ "params": [
105
+ "path"
106
+ ],
107
+ "docs": {
108
+ "description": "Picks out a single value from source data.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
109
+ "tags": [
110
+ {
111
+ "title": "public",
112
+ "description": null,
113
+ "type": null
114
+ },
115
+ {
116
+ "title": "example",
117
+ "description": "sourceValue('$.key')"
118
+ },
119
+ {
120
+ "title": "function",
121
+ "description": null,
122
+ "name": null
123
+ },
124
+ {
125
+ "title": "param",
126
+ "description": "JSONPath referencing a point in `state`.",
127
+ "type": {
128
+ "type": "NameExpression",
129
+ "name": "String"
130
+ },
131
+ "name": "path"
132
+ },
133
+ {
134
+ "title": "returns",
135
+ "description": null,
136
+ "type": {
137
+ "type": "NameExpression",
138
+ "name": "Operation"
139
+ }
140
+ }
141
+ ]
142
+ },
143
+ "valid": true
144
+ },
145
+ {
146
+ "name": "dataPath",
147
+ "params": [
148
+ "path"
149
+ ],
150
+ "docs": {
151
+ "description": "Ensures a path points at the data.",
152
+ "tags": [
153
+ {
154
+ "title": "public",
155
+ "description": null,
156
+ "type": null
157
+ },
158
+ {
159
+ "title": "example",
160
+ "description": "dataPath('key')"
161
+ },
162
+ {
163
+ "title": "function",
164
+ "description": null,
165
+ "name": null
166
+ },
167
+ {
168
+ "title": "param",
169
+ "description": "JSONPath referencing a point in `data`.",
170
+ "type": {
171
+ "type": "NameExpression",
172
+ "name": "string"
173
+ },
174
+ "name": "path"
175
+ },
176
+ {
177
+ "title": "returns",
178
+ "description": null,
179
+ "type": {
180
+ "type": "NameExpression",
181
+ "name": "string"
182
+ }
183
+ }
184
+ ]
185
+ },
186
+ "valid": true
187
+ },
188
+ {
189
+ "name": "dataValue",
190
+ "params": [
191
+ "path"
192
+ ],
193
+ "docs": {
194
+ "description": "Picks out a single value from the source data object—usually `state.data`.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
195
+ "tags": [
196
+ {
197
+ "title": "public",
198
+ "description": null,
199
+ "type": null
200
+ },
201
+ {
202
+ "title": "example",
203
+ "description": "dataValue('key')"
204
+ },
205
+ {
206
+ "title": "function",
207
+ "description": null,
208
+ "name": null
209
+ },
210
+ {
211
+ "title": "param",
212
+ "description": "JSONPath referencing a point in `data`.",
213
+ "type": {
214
+ "type": "NameExpression",
215
+ "name": "String"
216
+ },
217
+ "name": "path"
218
+ },
219
+ {
220
+ "title": "returns",
221
+ "description": null,
222
+ "type": {
223
+ "type": "NameExpression",
224
+ "name": "Operation"
225
+ }
226
+ }
227
+ ]
228
+ },
229
+ "valid": true
230
+ },
231
+ {
232
+ "name": "lastReferenceValue",
233
+ "params": [
234
+ "path"
235
+ ],
236
+ "docs": {
237
+ "description": "Picks out the last reference value from source data.",
238
+ "tags": [
239
+ {
240
+ "title": "public",
241
+ "description": null,
242
+ "type": null
243
+ },
244
+ {
245
+ "title": "example",
246
+ "description": "lastReferenceValue('key')"
247
+ },
248
+ {
249
+ "title": "function",
250
+ "description": null,
251
+ "name": null
252
+ },
253
+ {
254
+ "title": "param",
255
+ "description": "JSONPath referencing a point in `references`.",
256
+ "type": {
257
+ "type": "NameExpression",
258
+ "name": "String"
259
+ },
260
+ "name": "path"
261
+ },
262
+ {
263
+ "title": "returns",
264
+ "description": null,
265
+ "type": {
266
+ "type": "NameExpression",
267
+ "name": "Operation"
268
+ }
269
+ }
270
+ ]
271
+ },
272
+ "valid": true
273
+ },
274
+ {
275
+ "name": "each",
276
+ "params": [
277
+ "dataSource",
278
+ "operation"
279
+ ],
280
+ "docs": {
281
+ "description": "Scopes an array of data based on a JSONPath.\nUseful when the source data has `n` items you would like to map to\nan operation.\nThe operation will receive a slice of the data based of each item\nof the JSONPath provided.\n\nIt also ensures the results of an operation make their way back into\nthe state's references.",
282
+ "tags": [
283
+ {
284
+ "title": "public",
285
+ "description": null,
286
+ "type": null
287
+ },
288
+ {
289
+ "title": "example",
290
+ "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
291
+ },
292
+ {
293
+ "title": "function",
294
+ "description": null,
295
+ "name": null
296
+ },
297
+ {
298
+ "title": "param",
299
+ "description": "JSONPath referencing a point in `state`.",
300
+ "type": {
301
+ "type": "NameExpression",
302
+ "name": "DataSource"
303
+ },
304
+ "name": "dataSource"
305
+ },
306
+ {
307
+ "title": "param",
308
+ "description": "The operation needed to be repeated.",
309
+ "type": {
310
+ "type": "NameExpression",
311
+ "name": "Operation"
312
+ },
313
+ "name": "operation"
314
+ },
315
+ {
316
+ "title": "returns",
317
+ "description": null,
318
+ "type": {
319
+ "type": "NameExpression",
320
+ "name": "Operation"
321
+ }
322
+ }
323
+ ]
324
+ },
325
+ "valid": true
326
+ },
327
+ {
328
+ "name": "field",
329
+ "params": [
330
+ "key",
331
+ "value"
332
+ ],
333
+ "docs": {
334
+ "description": "Returns a key, value pair in an array.",
335
+ "tags": [
336
+ {
337
+ "title": "public",
338
+ "description": null,
339
+ "type": null
340
+ },
341
+ {
342
+ "title": "example",
343
+ "description": "field('destination_field_name__c', 'value')"
344
+ },
345
+ {
346
+ "title": "function",
347
+ "description": null,
348
+ "name": null
349
+ },
350
+ {
351
+ "title": "param",
352
+ "description": "Name of the field",
353
+ "type": {
354
+ "type": "NameExpression",
355
+ "name": "string"
356
+ },
357
+ "name": "key"
358
+ },
359
+ {
360
+ "title": "param",
361
+ "description": "The value itself or a sourceable operation.",
362
+ "type": {
363
+ "type": "NameExpression",
364
+ "name": "Value"
365
+ },
366
+ "name": "value"
367
+ },
368
+ {
369
+ "title": "returns",
370
+ "description": null,
371
+ "type": {
372
+ "type": "NameExpression",
373
+ "name": "Field"
374
+ }
375
+ }
376
+ ]
377
+ },
378
+ "valid": true
379
+ },
380
+ {
381
+ "name": "fields",
382
+ "params": [
383
+ "fields"
384
+ ],
385
+ "docs": {
386
+ "description": "Zips key value pairs into an object.",
387
+ "tags": [
388
+ {
389
+ "title": "public",
390
+ "description": null,
391
+ "type": null
392
+ },
393
+ {
394
+ "title": "example",
395
+ "description": "fields(list_of_fields)"
396
+ },
397
+ {
398
+ "title": "function",
399
+ "description": null,
400
+ "name": null
401
+ },
402
+ {
403
+ "title": "param",
404
+ "description": "a list of fields",
405
+ "type": {
406
+ "type": "NameExpression",
407
+ "name": "Fields"
408
+ },
409
+ "name": "fields"
410
+ },
411
+ {
412
+ "title": "returns",
413
+ "description": null,
414
+ "type": {
415
+ "type": "NameExpression",
416
+ "name": "Object"
417
+ }
418
+ }
419
+ ]
420
+ },
421
+ "valid": true
422
+ },
423
+ {
424
+ "name": "merge",
425
+ "params": [
426
+ "dataSource",
427
+ "fields"
428
+ ],
429
+ "docs": {
430
+ "description": "Merges fields into each item in an array.",
431
+ "tags": [
432
+ {
433
+ "title": "public",
434
+ "description": null,
435
+ "type": null
436
+ },
437
+ {
438
+ "title": "example",
439
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
440
+ },
441
+ {
442
+ "title": "function",
443
+ "description": null,
444
+ "name": null
445
+ },
446
+ {
447
+ "title": "param",
448
+ "description": null,
449
+ "type": {
450
+ "type": "NameExpression",
451
+ "name": "DataSource"
452
+ },
453
+ "name": "dataSource"
454
+ },
455
+ {
456
+ "title": "param",
457
+ "description": "Group of fields to merge in.",
458
+ "type": {
459
+ "type": "NameExpression",
460
+ "name": "Object"
461
+ },
462
+ "name": "fields"
463
+ },
464
+ {
465
+ "title": "returns",
466
+ "description": null,
467
+ "type": {
468
+ "type": "NameExpression",
469
+ "name": "DataSource"
470
+ }
471
+ }
472
+ ]
473
+ },
474
+ "valid": true
475
+ }
476
+ ]
477
+ }
package/dist/index.cjs CHANGED
@@ -19,8 +19,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/index.js
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
- Adaptor: () => Adaptor_exports,
23
- default: () => src_default
22
+ alterState: () => import_language_common2.alterState,
23
+ dataPath: () => import_language_common2.dataPath,
24
+ dataValue: () => import_language_common2.dataValue,
25
+ default: () => src_default,
26
+ each: () => import_language_common2.each,
27
+ execute: () => execute,
28
+ field: () => import_language_common2.field,
29
+ fields: () => import_language_common2.fields,
30
+ fn: () => import_language_common2.fn,
31
+ getForms: () => getForms,
32
+ getSubmissions: () => getSubmissions,
33
+ http: () => import_language_common2.http,
34
+ lastReferenceValue: () => import_language_common2.lastReferenceValue,
35
+ merge: () => import_language_common2.merge,
36
+ sourceValue: () => import_language_common2.sourceValue
24
37
  });
25
38
  module.exports = __toCommonJS(src_exports);
26
39
 
@@ -34,6 +47,7 @@ __export(Adaptor_exports, {
34
47
  execute: () => execute,
35
48
  field: () => import_language_common2.field,
36
49
  fields: () => import_language_common2.fields,
50
+ fn: () => import_language_common2.fn,
37
51
  getForms: () => getForms,
38
52
  getSubmissions: () => getSubmissions,
39
53
  http: () => import_language_common2.http,
@@ -101,5 +115,18 @@ function getSubmissions(params, callback) {
101
115
  var src_default = Adaptor_exports;
102
116
  // Annotate the CommonJS export names for ESM import in node:
103
117
  0 && (module.exports = {
104
- Adaptor
118
+ alterState,
119
+ dataPath,
120
+ dataValue,
121
+ each,
122
+ execute,
123
+ field,
124
+ fields,
125
+ fn,
126
+ getForms,
127
+ getSubmissions,
128
+ http,
129
+ lastReferenceValue,
130
+ merge,
131
+ sourceValue
105
132
  });
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ __export(Adaptor_exports, {
14
14
  execute: () => execute,
15
15
  field: () => field,
16
16
  fields: () => fields,
17
+ fn: () => fn,
17
18
  getForms: () => getForms,
18
19
  getSubmissions: () => getSubmissions,
19
20
  http: () => http2,
@@ -28,6 +29,7 @@ import {
28
29
  http
29
30
  } from "@openfn/language-common";
30
31
  import {
32
+ fn,
31
33
  alterState,
32
34
  dataPath,
33
35
  dataValue,
@@ -96,6 +98,19 @@ function getSubmissions(params, callback) {
96
98
  // src/index.js
97
99
  var src_default = Adaptor_exports;
98
100
  export {
99
- Adaptor_exports as Adaptor,
100
- src_default as default
101
+ alterState,
102
+ dataPath,
103
+ dataValue,
104
+ src_default as default,
105
+ each,
106
+ execute,
107
+ field,
108
+ fields,
109
+ fn,
110
+ getForms,
111
+ getSubmissions,
112
+ http2 as http,
113
+ lastReferenceValue,
114
+ merge,
115
+ sourceValue
101
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-kobotoolbox",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A Kobo Toolbox Language Pack for OpenFn",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "configuration-schema.json"
18
18
  ],
19
19
  "dependencies": {
20
- "@openfn/language-common": "1.7.4"
20
+ "@openfn/language-common": "^1.7.5"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@openfn/buildtools": "^1.0.2",
@@ -27,13 +27,17 @@
27
27
  "esno": "^0.16.3",
28
28
  "mocha": "^7.1.1",
29
29
  "nock": "^12.0.3",
30
- "rimraf": "^3.0.2"
30
+ "rimraf": "^3.0.2",
31
+ "@openfn/simple-ast": "0.4.1"
31
32
  },
32
33
  "type": "module",
33
34
  "types": "types/index.d.ts",
34
35
  "exports": {
35
- "import": "./dist/index.js",
36
- "require": "./dist/index.cjs"
36
+ ".": {
37
+ "import": "./dist/index.js",
38
+ "require": "./dist/index.cjs"
39
+ },
40
+ "./package.json": "./package.json"
37
41
  },
38
42
  "scripts": {
39
43
  "build": "pnpm clean && build-adaptor kobotoolbox",
@@ -38,4 +38,4 @@ export function getForms(params: object, callback: Function): Operation;
38
38
  * @returns {Operation}
39
39
  */
40
40
  export function getSubmissions(params: object, callback: Function): Operation;
41
- export { alterState, dataPath, dataValue, each, field, fields, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
41
+ export { fn, alterState, 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";