@openfn/language-http 5.1.1 → 6.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 CHANGED
@@ -1,5 +1,78 @@
1
1
  {
2
2
  "operations": [
3
+ {
4
+ "name": "request",
5
+ "params": [
6
+ "method",
7
+ "path",
8
+ "params",
9
+ "callback"
10
+ ],
11
+ "docs": {
12
+ "description": "Make a HTTP request",
13
+ "tags": [
14
+ {
15
+ "title": "public",
16
+ "description": null,
17
+ "type": null
18
+ },
19
+ {
20
+ "title": "example",
21
+ "description": "request(\n 'GET',\n '/myEndpoint',\n {\n query: {foo: 'bar', a: 1},\n headers: {'content-type': 'application/json'},\n }\n)"
22
+ },
23
+ {
24
+ "title": "function",
25
+ "description": null,
26
+ "name": null
27
+ },
28
+ {
29
+ "title": "param",
30
+ "description": "The HTTP method to use",
31
+ "type": {
32
+ "type": "NameExpression",
33
+ "name": "string"
34
+ },
35
+ "name": "method"
36
+ },
37
+ {
38
+ "title": "param",
39
+ "description": "Path to resource",
40
+ "type": {
41
+ "type": "NameExpression",
42
+ "name": "string"
43
+ },
44
+ "name": "path"
45
+ },
46
+ {
47
+ "title": "param",
48
+ "description": "Query, Headers and Authentication parameters",
49
+ "type": {
50
+ "type": "NameExpression",
51
+ "name": "RequestOptions"
52
+ },
53
+ "name": "params"
54
+ },
55
+ {
56
+ "title": "param",
57
+ "description": "(Optional) Callback function",
58
+ "type": {
59
+ "type": "NameExpression",
60
+ "name": "function"
61
+ },
62
+ "name": "callback"
63
+ },
64
+ {
65
+ "title": "returns",
66
+ "description": null,
67
+ "type": {
68
+ "type": "NameExpression",
69
+ "name": "Operation"
70
+ }
71
+ }
72
+ ]
73
+ },
74
+ "valid": true
75
+ },
3
76
  {
4
77
  "name": "get",
5
78
  "params": [
@@ -17,7 +90,7 @@
17
90
  },
18
91
  {
19
92
  "title": "example",
20
- "description": "get('/myEndpoint', {\n query: {foo: 'bar', a: 1},\n headers: {'content-type': 'application/json'},\n authentication: {username: 'user', password: 'pass'}\n })"
93
+ "description": "get('/myEndpoint', {\n query: {foo: 'bar', a: 1},\n headers: {'content-type': 'application/json'},\n})"
21
94
  },
22
95
  {
23
96
  "title": "function",
@@ -38,7 +111,7 @@
38
111
  "description": "Query, Headers and Authentication parameters",
39
112
  "type": {
40
113
  "type": "NameExpression",
41
- "name": "object"
114
+ "name": "RequestOptions"
42
115
  },
43
116
  "name": "params"
44
117
  },
@@ -80,7 +153,7 @@
80
153
  },
81
154
  {
82
155
  "title": "example",
83
- "description": "post('/myEndpoint', {\n body: {'foo': 'bar'},\n headers: {'content-type': 'application/json'},\n authentication: {username: 'user', password: 'pass'}\n })"
156
+ "description": "post('/myEndpoint', {\n body: {'foo': 'bar'},\n headers: {'content-type': 'application/json'},\n })"
84
157
  },
85
158
  {
86
159
  "title": "function",
@@ -101,7 +174,7 @@
101
174
  "description": "Body, Query, Headers and Authentication parameters",
102
175
  "type": {
103
176
  "type": "NameExpression",
104
- "name": "object"
177
+ "name": "RequestOptions"
105
178
  },
106
179
  "name": "params"
107
180
  },
@@ -143,7 +216,7 @@
143
216
  },
144
217
  {
145
218
  "title": "example",
146
- "description": "put('/myEndpoint', {\n body: {'foo': 'bar'},\n headers: {'content-type': 'application/json'},\n authentication: {username: 'user', password: 'pass'}\n })"
219
+ "description": "put('/myEndpoint', {\n body: {'foo': 'bar'},\n headers: {'content-type': 'application/json'},\n })"
147
220
  },
148
221
  {
149
222
  "title": "function",
@@ -164,7 +237,7 @@
164
237
  "description": "Body, Query, Headers and Auth parameters",
165
238
  "type": {
166
239
  "type": "NameExpression",
167
- "name": "object"
240
+ "name": "RequestOptions"
168
241
  },
169
242
  "name": "params"
170
243
  },
@@ -206,7 +279,7 @@
206
279
  },
207
280
  {
208
281
  "title": "example",
209
- "description": "patch('/myEndpoint', {\n body: {'foo': 'bar'},\n headers: {'content-type': 'application/json'},\n authentication: {username: 'user', password: 'pass'}\n })"
282
+ "description": "patch('/myEndpoint', {\n body: {'foo': 'bar'},\n headers: {'content-type': 'application/json'},\n })"
210
283
  },
211
284
  {
212
285
  "title": "function",
@@ -227,7 +300,7 @@
227
300
  "description": "Body, Query, Headers and Auth parameters",
228
301
  "type": {
229
302
  "type": "NameExpression",
230
- "name": "object"
303
+ "name": "RequestOptions"
231
304
  },
232
305
  "name": "params"
233
306
  },
@@ -290,7 +363,7 @@
290
363
  "description": "Body, Query, Headers and Auth parameters",
291
364
  "type": {
292
365
  "type": "NameExpression",
293
- "name": "object"
366
+ "name": "RequestOptions"
294
367
  },
295
368
  "name": "params"
296
369
  },
@@ -319,7 +392,8 @@
319
392
  "name": "parseXML",
320
393
  "params": [
321
394
  "body",
322
- "script"
395
+ "script",
396
+ "callback"
323
397
  ],
324
398
  "docs": {
325
399
  "description": "Parse XML with the Cheerio parser",
@@ -331,7 +405,12 @@
331
405
  },
332
406
  {
333
407
  "title": "example",
334
- "description": "parseXML(body, function($){\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n })"
408
+ "description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n }\n);"
409
+ },
410
+ {
411
+ "title": "example",
412
+ "description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n },\n (next) => ({ ...next, results: next.data.body })\n);",
413
+ "caption": "Using parseXML with a callback"
335
414
  },
336
415
  {
337
416
  "title": "function",
@@ -356,6 +435,15 @@
356
435
  },
357
436
  "name": "script"
358
437
  },
438
+ {
439
+ "title": "param",
440
+ "description": "(Optional) Callback function",
441
+ "type": {
442
+ "type": "NameExpression",
443
+ "name": "function"
444
+ },
445
+ "name": "callback"
446
+ },
359
447
  {
360
448
  "title": "returns",
361
449
  "description": null,
@@ -1090,6 +1178,59 @@
1090
1178
  },
1091
1179
  "valid": true
1092
1180
  },
1181
+ {
1182
+ "name": "chunk",
1183
+ "params": [
1184
+ "array",
1185
+ "chunkSize"
1186
+ ],
1187
+ "docs": {
1188
+ "description": "Chunks an array into an array of arrays, each with no more than a certain size.",
1189
+ "tags": [
1190
+ {
1191
+ "title": "public",
1192
+ "description": null,
1193
+ "type": null
1194
+ },
1195
+ {
1196
+ "title": "example",
1197
+ "description": "chunk([1,2,3,4,5], 2)"
1198
+ },
1199
+ {
1200
+ "title": "function",
1201
+ "description": null,
1202
+ "name": null
1203
+ },
1204
+ {
1205
+ "title": "param",
1206
+ "description": "Array to be chunked",
1207
+ "type": {
1208
+ "type": "NameExpression",
1209
+ "name": "Object"
1210
+ },
1211
+ "name": "array"
1212
+ },
1213
+ {
1214
+ "title": "param",
1215
+ "description": "The maxiumum size of each chunks",
1216
+ "type": {
1217
+ "type": "NameExpression",
1218
+ "name": "Integer"
1219
+ },
1220
+ "name": "chunkSize"
1221
+ },
1222
+ {
1223
+ "title": "returns",
1224
+ "description": null,
1225
+ "type": {
1226
+ "type": "NameExpression",
1227
+ "name": "Object"
1228
+ }
1229
+ }
1230
+ ]
1231
+ },
1232
+ "valid": true
1233
+ },
1093
1234
  {
1094
1235
  "name": "parseCsv",
1095
1236
  "params": [