@openfn/language-satusehat 2.0.15 → 2.1.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 +119 -0
- package/dist/index.cjs +6 -0
- package/dist/index.js +8 -2
- package/package.json +3 -3
- package/types/Adaptor.d.ts +1 -1
package/ast.json
CHANGED
|
@@ -900,6 +900,125 @@
|
|
|
900
900
|
]
|
|
901
901
|
},
|
|
902
902
|
"valid": true
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"name": "as",
|
|
906
|
+
"params": [
|
|
907
|
+
"key",
|
|
908
|
+
"operation"
|
|
909
|
+
],
|
|
910
|
+
"docs": {
|
|
911
|
+
"description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
|
|
912
|
+
"tags": [
|
|
913
|
+
{
|
|
914
|
+
"title": "public",
|
|
915
|
+
"description": null,
|
|
916
|
+
"type": null
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
"title": "function",
|
|
920
|
+
"description": null,
|
|
921
|
+
"name": null
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
"title": "example",
|
|
925
|
+
"description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
|
|
926
|
+
"caption": "Fetch cce-data from collections and store them under state.cceData"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"title": "param",
|
|
930
|
+
"description": "The state key to assign the result of the operation to.",
|
|
931
|
+
"type": {
|
|
932
|
+
"type": "NameExpression",
|
|
933
|
+
"name": "string"
|
|
934
|
+
},
|
|
935
|
+
"name": "key"
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
"title": "param",
|
|
939
|
+
"description": " An operation that returns a new state object with a `data` property",
|
|
940
|
+
"type": {
|
|
941
|
+
"type": "NameExpression",
|
|
942
|
+
"name": "function"
|
|
943
|
+
},
|
|
944
|
+
"name": "operation"
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
"title": "returns",
|
|
948
|
+
"description": null,
|
|
949
|
+
"type": {
|
|
950
|
+
"type": "NameExpression",
|
|
951
|
+
"name": "Operation"
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
]
|
|
955
|
+
},
|
|
956
|
+
"valid": true
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
"name": "map",
|
|
960
|
+
"params": {},
|
|
961
|
+
"docs": {
|
|
962
|
+
"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.",
|
|
963
|
+
"tags": [
|
|
964
|
+
{
|
|
965
|
+
"title": "public",
|
|
966
|
+
"description": null,
|
|
967
|
+
"type": null
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
"title": "function",
|
|
971
|
+
"description": null,
|
|
972
|
+
"name": null
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
"title": "example",
|
|
976
|
+
"description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
|
|
977
|
+
"caption": "Transform an array of items in state"
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
"title": "example",
|
|
981
|
+
"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});",
|
|
982
|
+
"caption": "Map items asynchronously (e.g. fetch extra info)"
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"title": "param",
|
|
986
|
+
"description": "An array of items or a a JSONPath string which points to an array of items.",
|
|
987
|
+
"type": {
|
|
988
|
+
"type": "UnionType",
|
|
989
|
+
"elements": [
|
|
990
|
+
{
|
|
991
|
+
"type": "NameExpression",
|
|
992
|
+
"name": "string"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"type": "NameExpression",
|
|
996
|
+
"name": "Array"
|
|
997
|
+
}
|
|
998
|
+
]
|
|
999
|
+
},
|
|
1000
|
+
"name": "path"
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
"title": "param",
|
|
1004
|
+
"description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
|
|
1005
|
+
"type": {
|
|
1006
|
+
"type": "NameExpression",
|
|
1007
|
+
"name": "function"
|
|
1008
|
+
},
|
|
1009
|
+
"name": "callback"
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
"title": "returns",
|
|
1013
|
+
"description": null,
|
|
1014
|
+
"type": {
|
|
1015
|
+
"type": "NameExpression",
|
|
1016
|
+
"name": "State"
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
]
|
|
1020
|
+
},
|
|
1021
|
+
"valid": false
|
|
903
1022
|
}
|
|
904
1023
|
]
|
|
905
1024
|
}
|
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
|
combine: () => import_language_common3.combine,
|
|
31
32
|
dataPath: () => import_language_common3.dataPath,
|
|
32
33
|
dataValue: () => import_language_common3.dataValue,
|
|
@@ -40,6 +41,7 @@ __export(src_exports, {
|
|
|
40
41
|
get: () => get,
|
|
41
42
|
http: () => import_language_common3.http,
|
|
42
43
|
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
44
|
+
map: () => import_language_common3.map,
|
|
43
45
|
merge: () => import_language_common3.merge,
|
|
44
46
|
patch: () => patch,
|
|
45
47
|
post: () => post,
|
|
@@ -54,6 +56,7 @@ var Adaptor_exports = {};
|
|
|
54
56
|
__export(Adaptor_exports, {
|
|
55
57
|
alterState: () => import_language_common3.alterState,
|
|
56
58
|
arrayToString: () => import_language_common3.arrayToString,
|
|
59
|
+
as: () => import_language_common3.as,
|
|
57
60
|
combine: () => import_language_common3.combine,
|
|
58
61
|
dataPath: () => import_language_common3.dataPath,
|
|
59
62
|
dataValue: () => import_language_common3.dataValue,
|
|
@@ -66,6 +69,7 @@ __export(Adaptor_exports, {
|
|
|
66
69
|
get: () => get,
|
|
67
70
|
http: () => import_language_common3.http,
|
|
68
71
|
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
72
|
+
map: () => import_language_common3.map,
|
|
69
73
|
merge: () => import_language_common3.merge,
|
|
70
74
|
patch: () => patch,
|
|
71
75
|
post: () => post,
|
|
@@ -265,6 +269,7 @@ var src_default = Adaptor_exports;
|
|
|
265
269
|
0 && (module.exports = {
|
|
266
270
|
alterState,
|
|
267
271
|
arrayToString,
|
|
272
|
+
as,
|
|
268
273
|
combine,
|
|
269
274
|
dataPath,
|
|
270
275
|
dataValue,
|
|
@@ -277,6 +282,7 @@ var src_default = Adaptor_exports;
|
|
|
277
282
|
get,
|
|
278
283
|
http,
|
|
279
284
|
lastReferenceValue,
|
|
285
|
+
map,
|
|
280
286
|
merge,
|
|
281
287
|
patch,
|
|
282
288
|
post,
|
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
|
combine: () => combine,
|
|
13
14
|
dataPath: () => dataPath,
|
|
14
15
|
dataValue: () => dataValue,
|
|
@@ -21,6 +22,7 @@ __export(Adaptor_exports, {
|
|
|
21
22
|
get: () => get,
|
|
22
23
|
http: () => http,
|
|
23
24
|
lastReferenceValue: () => lastReferenceValue,
|
|
25
|
+
map: () => map,
|
|
24
26
|
merge: () => merge,
|
|
25
27
|
patch: () => patch,
|
|
26
28
|
post: () => post,
|
|
@@ -123,18 +125,20 @@ async function request(configuration, path, opts) {
|
|
|
123
125
|
|
|
124
126
|
// src/Adaptor.js
|
|
125
127
|
import {
|
|
126
|
-
fn,
|
|
127
|
-
fnIf,
|
|
128
128
|
alterState,
|
|
129
129
|
arrayToString,
|
|
130
|
+
as,
|
|
130
131
|
combine,
|
|
131
132
|
dataPath,
|
|
132
133
|
dataValue,
|
|
133
134
|
each,
|
|
134
135
|
field,
|
|
135
136
|
fields,
|
|
137
|
+
fn,
|
|
138
|
+
fnIf,
|
|
136
139
|
http,
|
|
137
140
|
lastReferenceValue,
|
|
141
|
+
map,
|
|
138
142
|
merge,
|
|
139
143
|
sourceValue,
|
|
140
144
|
util
|
|
@@ -239,6 +243,7 @@ var src_default = Adaptor_exports;
|
|
|
239
243
|
export {
|
|
240
244
|
alterState,
|
|
241
245
|
arrayToString,
|
|
246
|
+
as,
|
|
242
247
|
combine,
|
|
243
248
|
dataPath,
|
|
244
249
|
dataValue,
|
|
@@ -252,6 +257,7 @@ export {
|
|
|
252
257
|
get,
|
|
253
258
|
http,
|
|
254
259
|
lastReferenceValue,
|
|
260
|
+
map,
|
|
255
261
|
merge,
|
|
256
262
|
patch,
|
|
257
263
|
post,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-satusehat",
|
|
3
3
|
"label": "Satusehat",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "OpenFn Satusehat adaptor",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"configuration-schema.json"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@openfn/language-common": "
|
|
24
|
+
"@openfn/language-common": "3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"assertion-error": "2.0.0",
|
|
28
28
|
"chai": "4.3.6",
|
|
29
29
|
"deep-eql": "4.1.1",
|
|
30
30
|
"rimraf": "3.0.2",
|
|
31
|
-
"undici": "^5.
|
|
31
|
+
"undici": "^5.29.0"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -108,4 +108,4 @@ export type SatusehatHttpState = {
|
|
|
108
108
|
*/
|
|
109
109
|
references: any;
|
|
110
110
|
};
|
|
111
|
-
export {
|
|
111
|
+
export { alterState, arrayToString, as, combine, dataPath, dataValue, each, field, fields, fn, fnIf, http, lastReferenceValue, map, merge, sourceValue, util } from "@openfn/language-common";
|