@openfn/language-kobotoolbox 4.1.1 → 4.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 CHANGED
@@ -879,6 +879,125 @@
879
879
  ]
880
880
  },
881
881
  "valid": false
882
+ },
883
+ {
884
+ "name": "as",
885
+ "params": [
886
+ "key",
887
+ "operation"
888
+ ],
889
+ "docs": {
890
+ "description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
891
+ "tags": [
892
+ {
893
+ "title": "public",
894
+ "description": null,
895
+ "type": null
896
+ },
897
+ {
898
+ "title": "function",
899
+ "description": null,
900
+ "name": null
901
+ },
902
+ {
903
+ "title": "example",
904
+ "description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
905
+ "caption": "Fetch cce-data from collections and store them under state.cceData"
906
+ },
907
+ {
908
+ "title": "param",
909
+ "description": "The state key to assign the result of the operation to.",
910
+ "type": {
911
+ "type": "NameExpression",
912
+ "name": "string"
913
+ },
914
+ "name": "key"
915
+ },
916
+ {
917
+ "title": "param",
918
+ "description": " An operation that returns a new state object with a `data` property",
919
+ "type": {
920
+ "type": "NameExpression",
921
+ "name": "function"
922
+ },
923
+ "name": "operation"
924
+ },
925
+ {
926
+ "title": "returns",
927
+ "description": null,
928
+ "type": {
929
+ "type": "NameExpression",
930
+ "name": "Operation"
931
+ }
932
+ }
933
+ ]
934
+ },
935
+ "valid": true
936
+ },
937
+ {
938
+ "name": "map",
939
+ "params": {},
940
+ "docs": {
941
+ "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.",
942
+ "tags": [
943
+ {
944
+ "title": "public",
945
+ "description": null,
946
+ "type": null
947
+ },
948
+ {
949
+ "title": "function",
950
+ "description": null,
951
+ "name": null
952
+ },
953
+ {
954
+ "title": "example",
955
+ "description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
956
+ "caption": "Transform an array of items in state"
957
+ },
958
+ {
959
+ "title": "example",
960
+ "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});",
961
+ "caption": "Map items asynchronously (e.g. fetch extra info)"
962
+ },
963
+ {
964
+ "title": "param",
965
+ "description": "An array of items or a a JSONPath string which points to an array of items.",
966
+ "type": {
967
+ "type": "UnionType",
968
+ "elements": [
969
+ {
970
+ "type": "NameExpression",
971
+ "name": "string"
972
+ },
973
+ {
974
+ "type": "NameExpression",
975
+ "name": "Array"
976
+ }
977
+ ]
978
+ },
979
+ "name": "path"
980
+ },
981
+ {
982
+ "title": "param",
983
+ "description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
984
+ "type": {
985
+ "type": "NameExpression",
986
+ "name": "function"
987
+ },
988
+ "name": "callback"
989
+ },
990
+ {
991
+ "title": "returns",
992
+ "description": null,
993
+ "type": {
994
+ "type": "NameExpression",
995
+ "name": "State"
996
+ }
997
+ }
998
+ ]
999
+ },
1000
+ "valid": false
882
1001
  }
883
1002
  ]
884
1003
  }
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
22
  alterState: () => import_language_common3.alterState,
23
+ as: () => import_language_common3.as,
23
24
  cursor: () => import_language_common3.cursor,
24
25
  dataPath: () => import_language_common3.dataPath,
25
26
  dataValue: () => import_language_common3.dataValue,
@@ -36,6 +37,7 @@ __export(src_exports, {
36
37
  group: () => import_language_common3.group,
37
38
  http: () => http_exports,
38
39
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
40
+ map: () => import_language_common3.map,
39
41
  merge: () => import_language_common3.merge,
40
42
  sourceValue: () => import_language_common3.sourceValue
41
43
  });
@@ -45,6 +47,7 @@ module.exports = __toCommonJS(src_exports);
45
47
  var Adaptor_exports = {};
46
48
  __export(Adaptor_exports, {
47
49
  alterState: () => import_language_common3.alterState,
50
+ as: () => import_language_common3.as,
48
51
  cursor: () => import_language_common3.cursor,
49
52
  dataPath: () => import_language_common3.dataPath,
50
53
  dataValue: () => import_language_common3.dataValue,
@@ -59,6 +62,7 @@ __export(Adaptor_exports, {
59
62
  getSubmissions: () => getSubmissions,
60
63
  group: () => import_language_common3.group,
61
64
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
65
+ map: () => import_language_common3.map,
62
66
  merge: () => import_language_common3.merge,
63
67
  sourceValue: () => import_language_common3.sourceValue
64
68
  });
@@ -305,6 +309,7 @@ var src_default = Adaptor_exports;
305
309
  // Annotate the CommonJS export names for ESM import in node:
306
310
  0 && (module.exports = {
307
311
  alterState,
312
+ as,
308
313
  cursor,
309
314
  dataPath,
310
315
  dataValue,
@@ -320,6 +325,7 @@ var src_default = Adaptor_exports;
320
325
  group,
321
326
  http,
322
327
  lastReferenceValue,
328
+ map,
323
329
  merge,
324
330
  sourceValue
325
331
  });
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ var __export = (target, all) => {
8
8
  var Adaptor_exports = {};
9
9
  __export(Adaptor_exports, {
10
10
  alterState: () => alterState,
11
+ as: () => as,
11
12
  cursor: () => cursor,
12
13
  dataPath: () => dataPath,
13
14
  dataValue: () => dataValue,
@@ -22,6 +23,7 @@ __export(Adaptor_exports, {
22
23
  getSubmissions: () => getSubmissions,
23
24
  group: () => group,
24
25
  lastReferenceValue: () => lastReferenceValue,
26
+ map: () => map,
25
27
  merge: () => merge,
26
28
  sourceValue: () => sourceValue
27
29
  });
@@ -128,6 +130,7 @@ function maybeStringify(query) {
128
130
  // src/Adaptor.js
129
131
  import {
130
132
  alterState,
133
+ as,
131
134
  cursor,
132
135
  dataPath,
133
136
  dataValue,
@@ -138,6 +141,7 @@ import {
138
141
  fnIf,
139
142
  group,
140
143
  lastReferenceValue,
144
+ map,
141
145
  merge,
142
146
  sourceValue
143
147
  } from "@openfn/language-common";
@@ -288,6 +292,7 @@ function put(path, data, options) {
288
292
  var src_default = Adaptor_exports;
289
293
  export {
290
294
  alterState,
295
+ as,
291
296
  cursor,
292
297
  dataPath,
293
298
  dataValue,
@@ -304,6 +309,7 @@ export {
304
309
  group,
305
310
  http_exports as http,
306
311
  lastReferenceValue,
312
+ map,
307
313
  merge,
308
314
  sourceValue
309
315
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfn/language-kobotoolbox",
3
3
  "label": "KoboToolbox",
4
- "version": "4.1.1",
4
+ "version": "4.2.0",
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.5.0"
21
+ "@openfn/language-common": "3.0.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "assertion-error": "^1.0.1",
@@ -63,4 +63,4 @@ export function getSubmissions(formId: string, options?: {
63
63
  * @returns {Operation}
64
64
  */
65
65
  export function getDeploymentInfo(formId: string): Operation;
66
- export { alterState, cursor, dataPath, dataValue, each, field, fields, fn, fnIf, group, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
66
+ export { alterState, as, cursor, dataPath, dataValue, each, field, fields, fn, fnIf, group, lastReferenceValue, map, merge, sourceValue } from "@openfn/language-common";