@openfn/language-commcare 3.2.13 → 3.3.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 CHANGED
@@ -1195,6 +1195,125 @@
1195
1195
  ]
1196
1196
  },
1197
1197
  "valid": false
1198
+ },
1199
+ {
1200
+ "name": "as",
1201
+ "params": [
1202
+ "key",
1203
+ "operation"
1204
+ ],
1205
+ "docs": {
1206
+ "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
1207
+ "tags": [
1208
+ {
1209
+ "title": "public",
1210
+ "description": null,
1211
+ "type": null
1212
+ },
1213
+ {
1214
+ "title": "function",
1215
+ "description": null,
1216
+ "name": null
1217
+ },
1218
+ {
1219
+ "title": "example",
1220
+ "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
1221
+ "caption": "Fetch cce-data from collections and store them under state.cceData"
1222
+ },
1223
+ {
1224
+ "title": "param",
1225
+ "description": "The state key to assign the result of the operation to.",
1226
+ "type": {
1227
+ "type": "NameExpression",
1228
+ "name": "string"
1229
+ },
1230
+ "name": "key"
1231
+ },
1232
+ {
1233
+ "title": "param",
1234
+ "description": " An operation that returns a new state object with a `data` property",
1235
+ "type": {
1236
+ "type": "NameExpression",
1237
+ "name": "function"
1238
+ },
1239
+ "name": "operation"
1240
+ },
1241
+ {
1242
+ "title": "returns",
1243
+ "description": null,
1244
+ "type": {
1245
+ "type": "NameExpression",
1246
+ "name": "Operation"
1247
+ }
1248
+ }
1249
+ ]
1250
+ },
1251
+ "valid": true
1252
+ },
1253
+ {
1254
+ "name": "map",
1255
+ "params": {},
1256
+ "docs": {
1257
+ "description": "Iterates over a collection of items and returns a new array of mapped values,\nlike Javascript's `Array.map()` function.\n\nEach item in the source array will be passed into the callback function. The returned value\nwill be added to the new array. The callback is passed the original item, the current index\nin the source array (ie, the nth item number), and the state object.\n\nWrites a new array to `state.data` with transformed values.c array.",
1258
+ "tags": [
1259
+ {
1260
+ "title": "public",
1261
+ "description": null,
1262
+ "type": null
1263
+ },
1264
+ {
1265
+ "title": "function",
1266
+ "description": null,
1267
+ "name": null
1268
+ },
1269
+ {
1270
+ "title": "example",
1271
+ "description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
1272
+ "caption": "Transform an array of items in state"
1273
+ },
1274
+ {
1275
+ "title": "example",
1276
+ "description": "map($.items, async (data, index, state) => {\n const userInfo = await fetchUserInfo(data.userId);\n return {\n id: index + 1,\n name: data.name,\n extra: userInfo,\n };\n});",
1277
+ "caption": "Map items asynchronously (e.g. fetch extra info)"
1278
+ },
1279
+ {
1280
+ "title": "param",
1281
+ "description": "An array of items or a a JSONPath string which points to an array of items.",
1282
+ "type": {
1283
+ "type": "UnionType",
1284
+ "elements": [
1285
+ {
1286
+ "type": "NameExpression",
1287
+ "name": "string"
1288
+ },
1289
+ {
1290
+ "type": "NameExpression",
1291
+ "name": "Array"
1292
+ }
1293
+ ]
1294
+ },
1295
+ "name": "path"
1296
+ },
1297
+ {
1298
+ "title": "param",
1299
+ "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
1300
+ "type": {
1301
+ "type": "NameExpression",
1302
+ "name": "function"
1303
+ },
1304
+ "name": "callback"
1305
+ },
1306
+ {
1307
+ "title": "returns",
1308
+ "description": null,
1309
+ "type": {
1310
+ "type": "NameExpression",
1311
+ "name": "State"
1312
+ }
1313
+ }
1314
+ ]
1315
+ },
1316
+ "valid": false
1198
1317
  }
1199
1318
  ]
1200
1319
  }
package/dist/index.cjs CHANGED
@@ -27,6 +27,7 @@ var src_exports = {};
27
27
  __export(src_exports, {
28
28
  alterState: () => import_language_common3.alterState,
29
29
  arrayToString: () => import_language_common3.arrayToString,
30
+ as: () => import_language_common3.as,
30
31
  bulk: () => bulk,
31
32
  combine: () => import_language_common3.combine,
32
33
  cursor: () => import_language_common3.cursor,
@@ -44,6 +45,7 @@ __export(src_exports, {
44
45
  get: () => get,
45
46
  http: () => import_language_common3.http,
46
47
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
48
+ map: () => import_language_common3.map,
47
49
  merge: () => import_language_common3.merge,
48
50
  post: () => post,
49
51
  request: () => request2,
@@ -58,6 +60,7 @@ var Adaptor_exports = {};
58
60
  __export(Adaptor_exports, {
59
61
  alterState: () => import_language_common3.alterState,
60
62
  arrayToString: () => import_language_common3.arrayToString,
63
+ as: () => import_language_common3.as,
61
64
  bulk: () => bulk,
62
65
  combine: () => import_language_common3.combine,
63
66
  cursor: () => import_language_common3.cursor,
@@ -74,6 +77,7 @@ __export(Adaptor_exports, {
74
77
  get: () => get,
75
78
  http: () => import_language_common3.http,
76
79
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
80
+ map: () => import_language_common3.map,
77
81
  merge: () => import_language_common3.merge,
78
82
  post: () => post,
79
83
  request: () => request2,
@@ -366,6 +370,7 @@ var src_default = Adaptor_exports;
366
370
  0 && (module.exports = {
367
371
  alterState,
368
372
  arrayToString,
373
+ as,
369
374
  bulk,
370
375
  combine,
371
376
  cursor,
@@ -382,6 +387,7 @@ var src_default = Adaptor_exports;
382
387
  get,
383
388
  http,
384
389
  lastReferenceValue,
390
+ map,
385
391
  merge,
386
392
  post,
387
393
  request,
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ var Adaptor_exports = {};
9
9
  __export(Adaptor_exports, {
10
10
  alterState: () => alterState,
11
11
  arrayToString: () => arrayToString,
12
+ as: () => as,
12
13
  bulk: () => bulk,
13
14
  combine: () => combine,
14
15
  cursor: () => cursor,
@@ -25,6 +26,7 @@ __export(Adaptor_exports, {
25
26
  get: () => get,
26
27
  http: () => http,
27
28
  lastReferenceValue: () => lastReferenceValue,
29
+ map: () => map,
28
30
  merge: () => merge,
29
31
  post: () => post,
30
32
  request: () => request2,
@@ -94,20 +96,22 @@ async function request(configuration, path, opts) {
94
96
 
95
97
  // src/Adaptor.js
96
98
  import {
97
- fn,
98
- fnIf,
99
- cursor,
100
99
  alterState,
101
100
  arrayToString,
102
- dateFns,
101
+ as,
103
102
  combine,
103
+ cursor,
104
104
  dataPath,
105
105
  dataValue,
106
+ dateFns,
106
107
  each,
107
108
  field,
108
109
  fields,
110
+ fn,
111
+ fnIf,
109
112
  http,
110
113
  lastReferenceValue,
114
+ map,
111
115
  merge,
112
116
  sourceValue
113
117
  } from "@openfn/language-common";
@@ -337,6 +341,7 @@ var src_default = Adaptor_exports;
337
341
  export {
338
342
  alterState,
339
343
  arrayToString,
344
+ as,
340
345
  bulk,
341
346
  combine,
342
347
  cursor,
@@ -354,6 +359,7 @@ export {
354
359
  get,
355
360
  http,
356
361
  lastReferenceValue,
362
+ map,
357
363
  merge,
358
364
  post,
359
365
  request2 as request,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@openfn/language-commcare",
3
- "version": "3.2.13",
3
+ "label": "CommCare",
4
+ "version": "3.3.0",
4
5
  "description": "Commcare Language Pack for OpenFn",
5
6
  "homepage": "https://docs.openfn.org",
6
7
  "repository": {
@@ -21,13 +22,12 @@
21
22
  "js2xmlparser": "^1.0.0",
22
23
  "lodash-fp": "^0.10.4",
23
24
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz",
24
- "@openfn/language-common": "2.4.0"
25
+ "@openfn/language-common": "3.0.0"
25
26
  },
26
27
  "devDependencies": {
27
28
  "assertion-error": "^1.1.0",
28
29
  "chai": "^4.3.7",
29
30
  "deep-eql": "^4.1.3",
30
- "esno": "^0.16.3",
31
31
  "rimraf": "^3.0.2"
32
32
  },
33
33
  "type": "module",
@@ -190,4 +190,4 @@ export type CommcareHttpState = {
190
190
  */
191
191
  references: any;
192
192
  };
193
- export { fn, fnIf, cursor, alterState, arrayToString, dateFns, combine, dataPath, dataValue, each, field, fields, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
193
+ export { alterState, arrayToString, as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, http, lastReferenceValue, map, merge, sourceValue } from "@openfn/language-common";