@openfn/language-http 7.0.7 → 7.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 +9 -3
- package/package.json +2 -2
- package/types/Adaptor.d.ts +1 -1
package/ast.json
CHANGED
|
@@ -1555,6 +1555,125 @@
|
|
|
1555
1555
|
]
|
|
1556
1556
|
},
|
|
1557
1557
|
"valid": false
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
"name": "as",
|
|
1561
|
+
"params": [
|
|
1562
|
+
"key",
|
|
1563
|
+
"operation"
|
|
1564
|
+
],
|
|
1565
|
+
"docs": {
|
|
1566
|
+
"description": "Run an operation and save the result to a custom key in state instead of overwriting state.data.",
|
|
1567
|
+
"tags": [
|
|
1568
|
+
{
|
|
1569
|
+
"title": "public",
|
|
1570
|
+
"description": null,
|
|
1571
|
+
"type": null
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
"title": "function",
|
|
1575
|
+
"description": null,
|
|
1576
|
+
"name": null
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
"title": "example",
|
|
1580
|
+
"description": "as('cceData', collections.get('cce-data-dhis2', { key: `*:*:${$.syncedAt}*` }));",
|
|
1581
|
+
"caption": "Fetch cce-data from collections and store them under state.cceData"
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
"title": "param",
|
|
1585
|
+
"description": "The state key to assign the result of the operation to.",
|
|
1586
|
+
"type": {
|
|
1587
|
+
"type": "NameExpression",
|
|
1588
|
+
"name": "string"
|
|
1589
|
+
},
|
|
1590
|
+
"name": "key"
|
|
1591
|
+
},
|
|
1592
|
+
{
|
|
1593
|
+
"title": "param",
|
|
1594
|
+
"description": " An operation that returns a new state object with a `data` property",
|
|
1595
|
+
"type": {
|
|
1596
|
+
"type": "NameExpression",
|
|
1597
|
+
"name": "function"
|
|
1598
|
+
},
|
|
1599
|
+
"name": "operation"
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
"title": "returns",
|
|
1603
|
+
"description": null,
|
|
1604
|
+
"type": {
|
|
1605
|
+
"type": "NameExpression",
|
|
1606
|
+
"name": "Operation"
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
]
|
|
1610
|
+
},
|
|
1611
|
+
"valid": true
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
"name": "map",
|
|
1615
|
+
"params": {},
|
|
1616
|
+
"docs": {
|
|
1617
|
+
"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.",
|
|
1618
|
+
"tags": [
|
|
1619
|
+
{
|
|
1620
|
+
"title": "public",
|
|
1621
|
+
"description": null,
|
|
1622
|
+
"type": null
|
|
1623
|
+
},
|
|
1624
|
+
{
|
|
1625
|
+
"title": "function",
|
|
1626
|
+
"description": null,
|
|
1627
|
+
"name": null
|
|
1628
|
+
},
|
|
1629
|
+
{
|
|
1630
|
+
"title": "example",
|
|
1631
|
+
"description": "map($.items', (data, index, state) => {\n return {\n id: index + 1,\n name: data.name,\n createdAt: state.cursor,\n };\n});",
|
|
1632
|
+
"caption": "Transform an array of items in state"
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
"title": "example",
|
|
1636
|
+
"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});",
|
|
1637
|
+
"caption": "Map items asynchronously (e.g. fetch extra info)"
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
"title": "param",
|
|
1641
|
+
"description": "An array of items or a a JSONPath string which points to an array of items.",
|
|
1642
|
+
"type": {
|
|
1643
|
+
"type": "UnionType",
|
|
1644
|
+
"elements": [
|
|
1645
|
+
{
|
|
1646
|
+
"type": "NameExpression",
|
|
1647
|
+
"name": "string"
|
|
1648
|
+
},
|
|
1649
|
+
{
|
|
1650
|
+
"type": "NameExpression",
|
|
1651
|
+
"name": "Array"
|
|
1652
|
+
}
|
|
1653
|
+
]
|
|
1654
|
+
},
|
|
1655
|
+
"name": "path"
|
|
1656
|
+
},
|
|
1657
|
+
{
|
|
1658
|
+
"title": "param",
|
|
1659
|
+
"description": "The mapping function, invoked with `(data, index, state)` for each item in the array.",
|
|
1660
|
+
"type": {
|
|
1661
|
+
"type": "NameExpression",
|
|
1662
|
+
"name": "function"
|
|
1663
|
+
},
|
|
1664
|
+
"name": "callback"
|
|
1665
|
+
},
|
|
1666
|
+
{
|
|
1667
|
+
"title": "returns",
|
|
1668
|
+
"description": null,
|
|
1669
|
+
"type": {
|
|
1670
|
+
"type": "NameExpression",
|
|
1671
|
+
"name": "State"
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
]
|
|
1675
|
+
},
|
|
1676
|
+
"valid": false
|
|
1558
1677
|
}
|
|
1559
1678
|
]
|
|
1560
1679
|
}
|
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
|
chunk: () => import_language_common3.chunk,
|
|
31
32
|
combine: () => import_language_common3.combine,
|
|
32
33
|
cursor: () => import_language_common3.cursor,
|
|
@@ -45,6 +46,7 @@ __export(src_exports, {
|
|
|
45
46
|
group: () => import_language_common3.group,
|
|
46
47
|
humanProper: () => import_language_common3.humanProper,
|
|
47
48
|
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
49
|
+
map: () => import_language_common3.map,
|
|
48
50
|
merge: () => import_language_common3.merge,
|
|
49
51
|
parseCsv: () => import_language_common3.parseCsv,
|
|
50
52
|
parseXML: () => parseXML,
|
|
@@ -65,6 +67,7 @@ var Adaptor_exports = {};
|
|
|
65
67
|
__export(Adaptor_exports, {
|
|
66
68
|
alterState: () => import_language_common3.alterState,
|
|
67
69
|
arrayToString: () => import_language_common3.arrayToString,
|
|
70
|
+
as: () => import_language_common3.as,
|
|
68
71
|
chunk: () => import_language_common3.chunk,
|
|
69
72
|
combine: () => import_language_common3.combine,
|
|
70
73
|
cursor: () => import_language_common3.cursor,
|
|
@@ -82,6 +85,7 @@ __export(Adaptor_exports, {
|
|
|
82
85
|
group: () => import_language_common3.group,
|
|
83
86
|
humanProper: () => import_language_common3.humanProper,
|
|
84
87
|
lastReferenceValue: () => import_language_common3.lastReferenceValue,
|
|
88
|
+
map: () => import_language_common3.map,
|
|
85
89
|
merge: () => import_language_common3.merge,
|
|
86
90
|
parseCsv: () => import_language_common3.parseCsv,
|
|
87
91
|
parseXML: () => parseXML,
|
|
@@ -266,6 +270,7 @@ var src_default = Adaptor_exports;
|
|
|
266
270
|
0 && (module.exports = {
|
|
267
271
|
alterState,
|
|
268
272
|
arrayToString,
|
|
273
|
+
as,
|
|
269
274
|
chunk,
|
|
270
275
|
combine,
|
|
271
276
|
cursor,
|
|
@@ -283,6 +288,7 @@ var src_default = Adaptor_exports;
|
|
|
283
288
|
group,
|
|
284
289
|
humanProper,
|
|
285
290
|
lastReferenceValue,
|
|
291
|
+
map,
|
|
286
292
|
merge,
|
|
287
293
|
parseCsv,
|
|
288
294
|
parseXML,
|
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
|
chunk: () => chunk,
|
|
13
14
|
combine: () => combine,
|
|
14
15
|
cursor: () => cursor,
|
|
@@ -26,6 +27,7 @@ __export(Adaptor_exports, {
|
|
|
26
27
|
group: () => group,
|
|
27
28
|
humanProper: () => humanProper,
|
|
28
29
|
lastReferenceValue: () => lastReferenceValue,
|
|
30
|
+
map: () => map,
|
|
29
31
|
merge: () => merge,
|
|
30
32
|
parseCsv: () => parseCsv,
|
|
31
33
|
parseXML: () => parseXML,
|
|
@@ -183,6 +185,8 @@ function xmlParser(body, script) {
|
|
|
183
185
|
import {
|
|
184
186
|
alterState,
|
|
185
187
|
arrayToString,
|
|
188
|
+
as,
|
|
189
|
+
chunk,
|
|
186
190
|
combine,
|
|
187
191
|
cursor,
|
|
188
192
|
dataPath,
|
|
@@ -193,16 +197,16 @@ import {
|
|
|
193
197
|
fields,
|
|
194
198
|
fn,
|
|
195
199
|
fnIf,
|
|
196
|
-
chunk,
|
|
197
200
|
group,
|
|
198
201
|
humanProper,
|
|
199
202
|
lastReferenceValue,
|
|
203
|
+
map,
|
|
200
204
|
merge,
|
|
205
|
+
parseCsv,
|
|
201
206
|
scrubEmojis,
|
|
202
207
|
sourceValue,
|
|
203
208
|
splitKeys,
|
|
204
|
-
toArray
|
|
205
|
-
parseCsv
|
|
209
|
+
toArray
|
|
206
210
|
} from "@openfn/language-common";
|
|
207
211
|
function execute(...operations) {
|
|
208
212
|
const initialState = {
|
|
@@ -240,6 +244,7 @@ var src_default = Adaptor_exports;
|
|
|
240
244
|
export {
|
|
241
245
|
alterState,
|
|
242
246
|
arrayToString,
|
|
247
|
+
as,
|
|
243
248
|
chunk,
|
|
244
249
|
combine,
|
|
245
250
|
cursor,
|
|
@@ -258,6 +263,7 @@ export {
|
|
|
258
263
|
group,
|
|
259
264
|
humanProper,
|
|
260
265
|
lastReferenceValue,
|
|
266
|
+
map,
|
|
261
267
|
merge,
|
|
262
268
|
parseCsv,
|
|
263
269
|
parseXML,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-http",
|
|
3
3
|
"label": "HTTP",
|
|
4
|
-
"version": "7.0
|
|
4
|
+
"version": "7.1.0",
|
|
5
5
|
"description": "An HTTP request language package for use with Open Function",
|
|
6
6
|
"homepage": "https://docs.openfn.org",
|
|
7
7
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"cheerio": "1.0.0-rc.12",
|
|
31
31
|
"cheerio-tableparser": "^1.0.1",
|
|
32
|
-
"@openfn/language-common": "
|
|
32
|
+
"@openfn/language-common": "3.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"chai": "^4.3.10",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -175,4 +175,4 @@ export type HttpState = {
|
|
|
175
175
|
*/
|
|
176
176
|
references: any;
|
|
177
177
|
};
|
|
178
|
-
export { alterState, arrayToString, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf,
|
|
178
|
+
export { alterState, arrayToString, as, chunk, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, humanProper, lastReferenceValue, map, merge, parseCsv, scrubEmojis, sourceValue, splitKeys, toArray } from "@openfn/language-common";
|