@openfn/language-http 6.4.0 → 6.4.2
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 +227 -78
- package/dist/index.cjs +3 -1
- package/dist/index.js +3 -1
- package/package.json +2 -2
- package/types/Adaptor.d.ts +41 -42
package/ast.json
CHANGED
|
@@ -1,5 +1,112 @@
|
|
|
1
1
|
{
|
|
2
2
|
"operations": [
|
|
3
|
+
{
|
|
4
|
+
"name": "execute",
|
|
5
|
+
"params": [
|
|
6
|
+
"operations"
|
|
7
|
+
],
|
|
8
|
+
"docs": {
|
|
9
|
+
"description": "Options provided to the HTTP request",
|
|
10
|
+
"tags": [
|
|
11
|
+
{
|
|
12
|
+
"title": "typedef",
|
|
13
|
+
"description": null,
|
|
14
|
+
"type": {
|
|
15
|
+
"type": "NameExpression",
|
|
16
|
+
"name": "Object"
|
|
17
|
+
},
|
|
18
|
+
"name": "RequestOptions"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"title": "public",
|
|
22
|
+
"description": null,
|
|
23
|
+
"type": null
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"title": "property",
|
|
27
|
+
"description": "body data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).",
|
|
28
|
+
"type": {
|
|
29
|
+
"type": "UnionType",
|
|
30
|
+
"elements": [
|
|
31
|
+
{
|
|
32
|
+
"type": "NameExpression",
|
|
33
|
+
"name": "object"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "NameExpression",
|
|
37
|
+
"name": "string"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"name": "body"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"title": "property",
|
|
45
|
+
"description": "Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.",
|
|
46
|
+
"type": {
|
|
47
|
+
"type": "NameExpression",
|
|
48
|
+
"name": "object"
|
|
49
|
+
},
|
|
50
|
+
"name": "errors"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"title": "property",
|
|
54
|
+
"description": "Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.",
|
|
55
|
+
"type": {
|
|
56
|
+
"type": "NameExpression",
|
|
57
|
+
"name": "object"
|
|
58
|
+
},
|
|
59
|
+
"name": "form"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"title": "property",
|
|
63
|
+
"description": "An object of query parameters to be encoded into the URL.",
|
|
64
|
+
"type": {
|
|
65
|
+
"type": "NameExpression",
|
|
66
|
+
"name": "object"
|
|
67
|
+
},
|
|
68
|
+
"name": "query"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"title": "property",
|
|
72
|
+
"description": "An object of headers to append to the request.",
|
|
73
|
+
"type": {
|
|
74
|
+
"type": "NameExpression",
|
|
75
|
+
"name": "object"
|
|
76
|
+
},
|
|
77
|
+
"name": "headers"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "property",
|
|
81
|
+
"description": "Parse the response body as json, text or stream. By default will use the response headers.",
|
|
82
|
+
"type": {
|
|
83
|
+
"type": "NameExpression",
|
|
84
|
+
"name": "string"
|
|
85
|
+
},
|
|
86
|
+
"name": "parseAs"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"title": "property",
|
|
90
|
+
"description": "Request timeout in ms. Default: 300 seconds.",
|
|
91
|
+
"type": {
|
|
92
|
+
"type": "NameExpression",
|
|
93
|
+
"name": "number"
|
|
94
|
+
},
|
|
95
|
+
"name": "timeout"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"title": "property",
|
|
99
|
+
"description": "TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions",
|
|
100
|
+
"type": {
|
|
101
|
+
"type": "NameExpression",
|
|
102
|
+
"name": "object"
|
|
103
|
+
},
|
|
104
|
+
"name": "tls"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"valid": false
|
|
109
|
+
},
|
|
3
110
|
{
|
|
4
111
|
"name": "request",
|
|
5
112
|
"params": [
|
|
@@ -9,7 +116,7 @@
|
|
|
9
116
|
"callback"
|
|
10
117
|
],
|
|
11
118
|
"docs": {
|
|
12
|
-
"description": "Make a HTTP request",
|
|
119
|
+
"description": "Make a HTTP request. If `configuration.baseUrl` is set, paths must be relative.",
|
|
13
120
|
"tags": [
|
|
14
121
|
{
|
|
15
122
|
"title": "public",
|
|
@@ -27,7 +134,7 @@
|
|
|
27
134
|
},
|
|
28
135
|
{
|
|
29
136
|
"title": "param",
|
|
30
|
-
"description": "The HTTP method to use",
|
|
137
|
+
"description": "The HTTP method to use.",
|
|
31
138
|
"type": {
|
|
32
139
|
"type": "NameExpression",
|
|
33
140
|
"name": "string"
|
|
@@ -36,7 +143,7 @@
|
|
|
36
143
|
},
|
|
37
144
|
{
|
|
38
145
|
"title": "param",
|
|
39
|
-
"description": "Path to resource",
|
|
146
|
+
"description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
|
|
40
147
|
"type": {
|
|
41
148
|
"type": "NameExpression",
|
|
42
149
|
"name": "string"
|
|
@@ -61,6 +168,10 @@
|
|
|
61
168
|
},
|
|
62
169
|
"name": "callback"
|
|
63
170
|
},
|
|
171
|
+
{
|
|
172
|
+
"title": "state",
|
|
173
|
+
"description": "{HttpState}"
|
|
174
|
+
},
|
|
64
175
|
{
|
|
65
176
|
"title": "returns",
|
|
66
177
|
"description": null,
|
|
@@ -81,7 +192,7 @@
|
|
|
81
192
|
"callback"
|
|
82
193
|
],
|
|
83
194
|
"docs": {
|
|
84
|
-
"description": "Make a GET request",
|
|
195
|
+
"description": "Make a GET request. If `configuration.baseUrl` is set, paths must be relative.",
|
|
85
196
|
"tags": [
|
|
86
197
|
{
|
|
87
198
|
"title": "public",
|
|
@@ -99,7 +210,7 @@
|
|
|
99
210
|
},
|
|
100
211
|
{
|
|
101
212
|
"title": "param",
|
|
102
|
-
"description": "Path to resource",
|
|
213
|
+
"description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
|
|
103
214
|
"type": {
|
|
104
215
|
"type": "NameExpression",
|
|
105
216
|
"name": "string"
|
|
@@ -124,6 +235,10 @@
|
|
|
124
235
|
},
|
|
125
236
|
"name": "callback"
|
|
126
237
|
},
|
|
238
|
+
{
|
|
239
|
+
"title": "state",
|
|
240
|
+
"description": "{HttpState}"
|
|
241
|
+
},
|
|
127
242
|
{
|
|
128
243
|
"title": "returns",
|
|
129
244
|
"description": null,
|
|
@@ -144,7 +259,7 @@
|
|
|
144
259
|
"callback"
|
|
145
260
|
],
|
|
146
261
|
"docs": {
|
|
147
|
-
"description": "Make a POST request",
|
|
262
|
+
"description": "Make a POST request. If `configuration.baseUrl` is set, paths must be relative.",
|
|
148
263
|
"tags": [
|
|
149
264
|
{
|
|
150
265
|
"title": "public",
|
|
@@ -162,7 +277,7 @@
|
|
|
162
277
|
},
|
|
163
278
|
{
|
|
164
279
|
"title": "param",
|
|
165
|
-
"description": "Path to resource",
|
|
280
|
+
"description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
|
|
166
281
|
"type": {
|
|
167
282
|
"type": "NameExpression",
|
|
168
283
|
"name": "string"
|
|
@@ -187,6 +302,10 @@
|
|
|
187
302
|
},
|
|
188
303
|
"name": "callback"
|
|
189
304
|
},
|
|
305
|
+
{
|
|
306
|
+
"title": "state",
|
|
307
|
+
"description": "{HttpState}"
|
|
308
|
+
},
|
|
190
309
|
{
|
|
191
310
|
"title": "returns",
|
|
192
311
|
"description": null,
|
|
@@ -207,7 +326,7 @@
|
|
|
207
326
|
"callback"
|
|
208
327
|
],
|
|
209
328
|
"docs": {
|
|
210
|
-
"description": "Make a PUT request",
|
|
329
|
+
"description": "Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.",
|
|
211
330
|
"tags": [
|
|
212
331
|
{
|
|
213
332
|
"title": "public",
|
|
@@ -225,7 +344,7 @@
|
|
|
225
344
|
},
|
|
226
345
|
{
|
|
227
346
|
"title": "param",
|
|
228
|
-
"description": "Path to resource",
|
|
347
|
+
"description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
|
|
229
348
|
"type": {
|
|
230
349
|
"type": "NameExpression",
|
|
231
350
|
"name": "string"
|
|
@@ -250,6 +369,10 @@
|
|
|
250
369
|
},
|
|
251
370
|
"name": "callback"
|
|
252
371
|
},
|
|
372
|
+
{
|
|
373
|
+
"title": "state",
|
|
374
|
+
"description": "{HttpState}"
|
|
375
|
+
},
|
|
253
376
|
{
|
|
254
377
|
"title": "returns",
|
|
255
378
|
"description": null,
|
|
@@ -270,7 +393,7 @@
|
|
|
270
393
|
"callback"
|
|
271
394
|
],
|
|
272
395
|
"docs": {
|
|
273
|
-
"description": "Make a PATCH request",
|
|
396
|
+
"description": "Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.",
|
|
274
397
|
"tags": [
|
|
275
398
|
{
|
|
276
399
|
"title": "public",
|
|
@@ -288,7 +411,7 @@
|
|
|
288
411
|
},
|
|
289
412
|
{
|
|
290
413
|
"title": "param",
|
|
291
|
-
"description": "Path to resource",
|
|
414
|
+
"description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
|
|
292
415
|
"type": {
|
|
293
416
|
"type": "NameExpression",
|
|
294
417
|
"name": "string"
|
|
@@ -313,6 +436,10 @@
|
|
|
313
436
|
},
|
|
314
437
|
"name": "callback"
|
|
315
438
|
},
|
|
439
|
+
{
|
|
440
|
+
"title": "state",
|
|
441
|
+
"description": "{HttpState}"
|
|
442
|
+
},
|
|
316
443
|
{
|
|
317
444
|
"title": "returns",
|
|
318
445
|
"description": null,
|
|
@@ -333,7 +460,7 @@
|
|
|
333
460
|
"callback"
|
|
334
461
|
],
|
|
335
462
|
"docs": {
|
|
336
|
-
"description": "Make a DELETE request",
|
|
463
|
+
"description": "Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.",
|
|
337
464
|
"tags": [
|
|
338
465
|
{
|
|
339
466
|
"title": "public",
|
|
@@ -351,7 +478,7 @@
|
|
|
351
478
|
},
|
|
352
479
|
{
|
|
353
480
|
"title": "param",
|
|
354
|
-
"description": "Path to resource",
|
|
481
|
+
"description": "Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.",
|
|
355
482
|
"type": {
|
|
356
483
|
"type": "NameExpression",
|
|
357
484
|
"name": "string"
|
|
@@ -376,6 +503,10 @@
|
|
|
376
503
|
},
|
|
377
504
|
"name": "callback"
|
|
378
505
|
},
|
|
506
|
+
{
|
|
507
|
+
"title": "state",
|
|
508
|
+
"description": "{HttpState}"
|
|
509
|
+
},
|
|
379
510
|
{
|
|
380
511
|
"title": "returns",
|
|
381
512
|
"description": null,
|
|
@@ -444,6 +575,14 @@
|
|
|
444
575
|
},
|
|
445
576
|
"name": "callback"
|
|
446
577
|
},
|
|
578
|
+
{
|
|
579
|
+
"title": "state",
|
|
580
|
+
"description": "data - the parsed XML as a JSON object"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
"title": "state",
|
|
584
|
+
"description": "references - an array of all previous data objects used in the Job"
|
|
585
|
+
},
|
|
447
586
|
{
|
|
448
587
|
"title": "returns",
|
|
449
588
|
"description": null,
|
|
@@ -472,15 +611,15 @@
|
|
|
472
611
|
"description": null,
|
|
473
612
|
"type": null
|
|
474
613
|
},
|
|
475
|
-
{
|
|
476
|
-
"title": "example",
|
|
477
|
-
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
478
|
-
},
|
|
479
614
|
{
|
|
480
615
|
"title": "function",
|
|
481
616
|
"description": null,
|
|
482
617
|
"name": null
|
|
483
618
|
},
|
|
619
|
+
{
|
|
620
|
+
"title": "example",
|
|
621
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
622
|
+
},
|
|
484
623
|
{
|
|
485
624
|
"title": "param",
|
|
486
625
|
"description": "is the function",
|
|
@@ -516,15 +655,15 @@
|
|
|
516
655
|
"description": null,
|
|
517
656
|
"type": null
|
|
518
657
|
},
|
|
519
|
-
{
|
|
520
|
-
"title": "example",
|
|
521
|
-
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
522
|
-
},
|
|
523
658
|
{
|
|
524
659
|
"title": "function",
|
|
525
660
|
"description": null,
|
|
526
661
|
"name": null
|
|
527
662
|
},
|
|
663
|
+
{
|
|
664
|
+
"title": "example",
|
|
665
|
+
"description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
|
|
666
|
+
},
|
|
528
667
|
{
|
|
529
668
|
"title": "param",
|
|
530
669
|
"description": "The condition that returns true",
|
|
@@ -568,15 +707,15 @@
|
|
|
568
707
|
"description": null,
|
|
569
708
|
"type": null
|
|
570
709
|
},
|
|
571
|
-
{
|
|
572
|
-
"title": "example",
|
|
573
|
-
"description": "sourceValue('$.key')"
|
|
574
|
-
},
|
|
575
710
|
{
|
|
576
711
|
"title": "function",
|
|
577
712
|
"description": null,
|
|
578
713
|
"name": null
|
|
579
714
|
},
|
|
715
|
+
{
|
|
716
|
+
"title": "example",
|
|
717
|
+
"description": "sourceValue('$.key')"
|
|
718
|
+
},
|
|
580
719
|
{
|
|
581
720
|
"title": "param",
|
|
582
721
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -611,15 +750,15 @@
|
|
|
611
750
|
"description": null,
|
|
612
751
|
"type": null
|
|
613
752
|
},
|
|
614
|
-
{
|
|
615
|
-
"title": "example",
|
|
616
|
-
"description": "dataPath('key')"
|
|
617
|
-
},
|
|
618
753
|
{
|
|
619
754
|
"title": "function",
|
|
620
755
|
"description": null,
|
|
621
756
|
"name": null
|
|
622
757
|
},
|
|
758
|
+
{
|
|
759
|
+
"title": "example",
|
|
760
|
+
"description": "dataPath('key')"
|
|
761
|
+
},
|
|
623
762
|
{
|
|
624
763
|
"title": "param",
|
|
625
764
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -654,15 +793,15 @@
|
|
|
654
793
|
"description": null,
|
|
655
794
|
"type": null
|
|
656
795
|
},
|
|
657
|
-
{
|
|
658
|
-
"title": "example",
|
|
659
|
-
"description": "dataValue('key')"
|
|
660
|
-
},
|
|
661
796
|
{
|
|
662
797
|
"title": "function",
|
|
663
798
|
"description": null,
|
|
664
799
|
"name": null
|
|
665
800
|
},
|
|
801
|
+
{
|
|
802
|
+
"title": "example",
|
|
803
|
+
"description": "dataValue('key')"
|
|
804
|
+
},
|
|
666
805
|
{
|
|
667
806
|
"title": "param",
|
|
668
807
|
"description": "JSONPath referencing a point in `data`.",
|
|
@@ -697,15 +836,15 @@
|
|
|
697
836
|
"description": null,
|
|
698
837
|
"type": null
|
|
699
838
|
},
|
|
700
|
-
{
|
|
701
|
-
"title": "example",
|
|
702
|
-
"description": "lastReferenceValue('key')"
|
|
703
|
-
},
|
|
704
839
|
{
|
|
705
840
|
"title": "function",
|
|
706
841
|
"description": null,
|
|
707
842
|
"name": null
|
|
708
843
|
},
|
|
844
|
+
{
|
|
845
|
+
"title": "example",
|
|
846
|
+
"description": "lastReferenceValue('key')"
|
|
847
|
+
},
|
|
709
848
|
{
|
|
710
849
|
"title": "param",
|
|
711
850
|
"description": "JSONPath referencing a point in `references`.",
|
|
@@ -741,15 +880,15 @@
|
|
|
741
880
|
"description": null,
|
|
742
881
|
"type": null
|
|
743
882
|
},
|
|
744
|
-
{
|
|
745
|
-
"title": "example",
|
|
746
|
-
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
747
|
-
},
|
|
748
883
|
{
|
|
749
884
|
"title": "function",
|
|
750
885
|
"description": null,
|
|
751
886
|
"name": null
|
|
752
887
|
},
|
|
888
|
+
{
|
|
889
|
+
"title": "example",
|
|
890
|
+
"description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
|
|
891
|
+
},
|
|
753
892
|
{
|
|
754
893
|
"title": "param",
|
|
755
894
|
"description": "JSONPath referencing a point in `state`.",
|
|
@@ -793,15 +932,15 @@
|
|
|
793
932
|
"description": null,
|
|
794
933
|
"type": null
|
|
795
934
|
},
|
|
796
|
-
{
|
|
797
|
-
"title": "example",
|
|
798
|
-
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
799
|
-
},
|
|
800
935
|
{
|
|
801
936
|
"title": "function",
|
|
802
937
|
"description": null,
|
|
803
938
|
"name": null
|
|
804
939
|
},
|
|
940
|
+
{
|
|
941
|
+
"title": "example",
|
|
942
|
+
"description": "combine(\n create('foo'),\n delete('bar')\n)"
|
|
943
|
+
},
|
|
805
944
|
{
|
|
806
945
|
"title": "param",
|
|
807
946
|
"description": "Operations to be performed.",
|
|
@@ -837,15 +976,15 @@
|
|
|
837
976
|
"description": null,
|
|
838
977
|
"type": null
|
|
839
978
|
},
|
|
840
|
-
{
|
|
841
|
-
"title": "example",
|
|
842
|
-
"description": "field('destination_field_name__c', 'value')"
|
|
843
|
-
},
|
|
844
979
|
{
|
|
845
980
|
"title": "function",
|
|
846
981
|
"description": null,
|
|
847
982
|
"name": null
|
|
848
983
|
},
|
|
984
|
+
{
|
|
985
|
+
"title": "example",
|
|
986
|
+
"description": "field('destination_field_name__c', 'value')"
|
|
987
|
+
},
|
|
849
988
|
{
|
|
850
989
|
"title": "param",
|
|
851
990
|
"description": "Name of the field",
|
|
@@ -889,15 +1028,15 @@
|
|
|
889
1028
|
"description": null,
|
|
890
1029
|
"type": null
|
|
891
1030
|
},
|
|
892
|
-
{
|
|
893
|
-
"title": "example",
|
|
894
|
-
"description": "fields(list_of_fields)"
|
|
895
|
-
},
|
|
896
1031
|
{
|
|
897
1032
|
"title": "function",
|
|
898
1033
|
"description": null,
|
|
899
1034
|
"name": null
|
|
900
1035
|
},
|
|
1036
|
+
{
|
|
1037
|
+
"title": "example",
|
|
1038
|
+
"description": "fields(list_of_fields)"
|
|
1039
|
+
},
|
|
901
1040
|
{
|
|
902
1041
|
"title": "param",
|
|
903
1042
|
"description": "a list of fields",
|
|
@@ -942,6 +1081,11 @@
|
|
|
942
1081
|
"description": null,
|
|
943
1082
|
"name": null
|
|
944
1083
|
},
|
|
1084
|
+
{
|
|
1085
|
+
"title": "public",
|
|
1086
|
+
"description": null,
|
|
1087
|
+
"type": null
|
|
1088
|
+
},
|
|
945
1089
|
{
|
|
946
1090
|
"title": "param",
|
|
947
1091
|
"description": null,
|
|
@@ -996,6 +1140,11 @@
|
|
|
996
1140
|
"description": null,
|
|
997
1141
|
"name": null
|
|
998
1142
|
},
|
|
1143
|
+
{
|
|
1144
|
+
"title": "public",
|
|
1145
|
+
"description": null,
|
|
1146
|
+
"type": null
|
|
1147
|
+
},
|
|
999
1148
|
{
|
|
1000
1149
|
"title": "param",
|
|
1001
1150
|
"description": "The array of objects to be grouped.",
|
|
@@ -1058,15 +1207,15 @@
|
|
|
1058
1207
|
"description": null,
|
|
1059
1208
|
"type": null
|
|
1060
1209
|
},
|
|
1061
|
-
{
|
|
1062
|
-
"title": "example",
|
|
1063
|
-
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
1064
|
-
},
|
|
1065
1210
|
{
|
|
1066
1211
|
"title": "function",
|
|
1067
1212
|
"description": null,
|
|
1068
1213
|
"name": null
|
|
1069
1214
|
},
|
|
1215
|
+
{
|
|
1216
|
+
"title": "example",
|
|
1217
|
+
"description": "field(\"destination_string__c\", function(state) {\n return arrayToString(dataValue(\"path_of_array\")(state), ', ')\n})"
|
|
1218
|
+
},
|
|
1070
1219
|
{
|
|
1071
1220
|
"title": "param",
|
|
1072
1221
|
"description": "Array of toString'able primatives.",
|
|
@@ -1110,15 +1259,15 @@
|
|
|
1110
1259
|
"description": null,
|
|
1111
1260
|
"type": null
|
|
1112
1261
|
},
|
|
1113
|
-
{
|
|
1114
|
-
"title": "example",
|
|
1115
|
-
"description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
|
|
1116
|
-
},
|
|
1117
1262
|
{
|
|
1118
1263
|
"title": "function",
|
|
1119
1264
|
"description": null,
|
|
1120
1265
|
"name": null
|
|
1121
1266
|
},
|
|
1267
|
+
{
|
|
1268
|
+
"title": "example",
|
|
1269
|
+
"description": "each(function(state) {\n return toArray( dataValue(\"path_of_array\")(state) )\n}, ...)"
|
|
1270
|
+
},
|
|
1122
1271
|
{
|
|
1123
1272
|
"title": "param",
|
|
1124
1273
|
"description": "Data required to be in an array",
|
|
@@ -1153,15 +1302,15 @@
|
|
|
1153
1302
|
"description": null,
|
|
1154
1303
|
"type": null
|
|
1155
1304
|
},
|
|
1156
|
-
{
|
|
1157
|
-
"title": "example",
|
|
1158
|
-
"description": "field(\"destination_string__c\", humanProper(state.data.path_to_string))"
|
|
1159
|
-
},
|
|
1160
1305
|
{
|
|
1161
1306
|
"title": "function",
|
|
1162
1307
|
"description": null,
|
|
1163
1308
|
"name": null
|
|
1164
1309
|
},
|
|
1310
|
+
{
|
|
1311
|
+
"title": "example",
|
|
1312
|
+
"description": "field(\"destination_string__c\", humanProper(state.data.path_to_string))"
|
|
1313
|
+
},
|
|
1165
1314
|
{
|
|
1166
1315
|
"title": "param",
|
|
1167
1316
|
"description": "String that needs converting",
|
|
@@ -1264,15 +1413,15 @@
|
|
|
1264
1413
|
"description": null,
|
|
1265
1414
|
"type": null
|
|
1266
1415
|
},
|
|
1267
|
-
{
|
|
1268
|
-
"title": "example",
|
|
1269
|
-
"description": "scrubEmojis('Dove🕊️⭐ 29')"
|
|
1270
|
-
},
|
|
1271
1416
|
{
|
|
1272
1417
|
"title": "function",
|
|
1273
1418
|
"description": null,
|
|
1274
1419
|
"name": null
|
|
1275
1420
|
},
|
|
1421
|
+
{
|
|
1422
|
+
"title": "example",
|
|
1423
|
+
"description": "scrubEmojis('Dove🕊️⭐ 29')"
|
|
1424
|
+
},
|
|
1276
1425
|
{
|
|
1277
1426
|
"title": "param",
|
|
1278
1427
|
"description": "String that needs to be cleaned",
|
|
@@ -1317,15 +1466,15 @@
|
|
|
1317
1466
|
"description": null,
|
|
1318
1467
|
"type": null
|
|
1319
1468
|
},
|
|
1320
|
-
{
|
|
1321
|
-
"title": "example",
|
|
1322
|
-
"description": "chunk([1,2,3,4,5], 2)"
|
|
1323
|
-
},
|
|
1324
1469
|
{
|
|
1325
1470
|
"title": "function",
|
|
1326
1471
|
"description": null,
|
|
1327
1472
|
"name": null
|
|
1328
1473
|
},
|
|
1474
|
+
{
|
|
1475
|
+
"title": "example",
|
|
1476
|
+
"description": "chunk([1,2,3,4,5], 2)"
|
|
1477
|
+
},
|
|
1329
1478
|
{
|
|
1330
1479
|
"title": "param",
|
|
1331
1480
|
"description": "Array to be chunked",
|
|
@@ -1444,6 +1593,11 @@
|
|
|
1444
1593
|
"description": null,
|
|
1445
1594
|
"type": null
|
|
1446
1595
|
},
|
|
1596
|
+
{
|
|
1597
|
+
"title": "function",
|
|
1598
|
+
"description": null,
|
|
1599
|
+
"name": null
|
|
1600
|
+
},
|
|
1447
1601
|
{
|
|
1448
1602
|
"title": "example",
|
|
1449
1603
|
"description": "cursor($.cursor, { defaultValue: 'today' })",
|
|
@@ -1454,11 +1608,6 @@
|
|
|
1454
1608
|
"description": "cursor(22)",
|
|
1455
1609
|
"caption": "Use a pagination cursor"
|
|
1456
1610
|
},
|
|
1457
|
-
{
|
|
1458
|
-
"title": "function",
|
|
1459
|
-
"description": null,
|
|
1460
|
-
"name": null
|
|
1461
|
-
},
|
|
1462
1611
|
{
|
|
1463
1612
|
"title": "param",
|
|
1464
1613
|
"description": "the cursor value. Usually an ISO date, natural language date, or page number",
|
package/dist/index.cjs
CHANGED
|
@@ -137,7 +137,9 @@ function request(method, path, params, callback = (s) => s) {
|
|
|
137
137
|
body = encodeFormBody(resolvedParams.form);
|
|
138
138
|
}
|
|
139
139
|
const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
|
|
140
|
-
|
|
140
|
+
if (baseUrl) {
|
|
141
|
+
addAuth(state.configuration, headers);
|
|
142
|
+
}
|
|
141
143
|
const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
|
|
142
144
|
const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
|
|
143
145
|
if (resolvedParams.agentOptions) {
|
package/dist/index.js
CHANGED
|
@@ -87,7 +87,9 @@ function request(method, path, params, callback = (s) => s) {
|
|
|
87
87
|
body = encodeFormBody(resolvedParams.form);
|
|
88
88
|
}
|
|
89
89
|
const baseUrl = (_a = state.configuration) == null ? void 0 : _a.baseUrl;
|
|
90
|
-
|
|
90
|
+
if (baseUrl) {
|
|
91
|
+
addAuth(state.configuration, headers);
|
|
92
|
+
}
|
|
91
93
|
const maxRedirections = resolvedParams.maxRedirections ?? (resolvedParams.followAllRedirects === false ? 0 : 5);
|
|
92
94
|
const tls = resolvedParams.tls ?? resolvedParams.agentOptions;
|
|
93
95
|
if (resolvedParams.agentOptions) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-http",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"description": "An HTTP request language package for use with Open Function",
|
|
5
5
|
"homepage": "https://docs.openfn.org",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"cheerio": "1.0.0-rc.12",
|
|
29
29
|
"cheerio-tableparser": "^1.0.1",
|
|
30
|
-
"@openfn/language-common": "
|
|
30
|
+
"@openfn/language-common": "2.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@openfn/simple-ast": "0.4.1",
|
package/types/Adaptor.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Options provided to the HTTP request
|
|
3
3
|
* @typedef {Object} RequestOptions
|
|
4
|
+
* @public
|
|
4
5
|
* @property {object|string} body - body data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
|
|
5
6
|
* @property {object} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.
|
|
6
7
|
* @property {object} form - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
|
|
@@ -11,20 +12,26 @@
|
|
|
11
12
|
* @property {object} tls - TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions
|
|
12
13
|
*/
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* State object
|
|
16
|
+
* @typedef {Object} HttpState
|
|
17
|
+
* @property data - the parsed response body
|
|
18
|
+
* @property response - the response from the HTTP server, including headers, statusCode, body, etc
|
|
19
|
+
* @property references - an array of all previous data objects used in the Job
|
|
20
|
+
**/
|
|
21
|
+
/**
|
|
22
|
+
* Execute a sequence of operations
|
|
15
23
|
* Wraps `language-common/execute`, and prepends initial state for http.
|
|
16
24
|
* @example
|
|
17
25
|
* execute(
|
|
18
26
|
* create('foo'),
|
|
19
27
|
* delete('bar')
|
|
20
28
|
* )(state)
|
|
21
|
-
* @private
|
|
22
29
|
* @param {Operations} operations - Operations to be performed.
|
|
23
30
|
* @returns {Operation}
|
|
24
31
|
*/
|
|
25
32
|
export function execute(...operations: Operations): Operation;
|
|
26
33
|
/**
|
|
27
|
-
* Make a HTTP request
|
|
34
|
+
* Make a HTTP request. If `configuration.baseUrl` is set, paths must be relative.
|
|
28
35
|
* @public
|
|
29
36
|
* @example
|
|
30
37
|
* request(
|
|
@@ -36,15 +43,16 @@ export function execute(...operations: Operations): Operation;
|
|
|
36
43
|
* }
|
|
37
44
|
* )
|
|
38
45
|
* @function
|
|
39
|
-
* @param {string} method - The HTTP method to use
|
|
40
|
-
* @param {string} path - Path to resource
|
|
46
|
+
* @param {string} method - The HTTP method to use.
|
|
47
|
+
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
41
48
|
* @param {RequestOptions} params - Query, Headers and Authentication parameters
|
|
42
49
|
* @param {function} callback - (Optional) Callback function
|
|
50
|
+
* @state {HttpState}
|
|
43
51
|
* @returns {Operation}
|
|
44
52
|
*/
|
|
45
53
|
export function request(method: string, path: string, params: RequestOptions, callback: Function): Operation;
|
|
46
54
|
/**
|
|
47
|
-
* Make a GET request
|
|
55
|
+
* Make a GET request. If `configuration.baseUrl` is set, paths must be relative.
|
|
48
56
|
* @public
|
|
49
57
|
* @example
|
|
50
58
|
* get('/myEndpoint', {
|
|
@@ -52,14 +60,15 @@ export function request(method: string, path: string, params: RequestOptions, ca
|
|
|
52
60
|
* headers: {'content-type': 'application/json'},
|
|
53
61
|
* })
|
|
54
62
|
* @function
|
|
55
|
-
* @param {string} path - Path to resource
|
|
63
|
+
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
56
64
|
* @param {RequestOptions} params - Query, Headers and Authentication parameters
|
|
57
65
|
* @param {function} callback - (Optional) Callback function
|
|
66
|
+
* @state {HttpState}
|
|
58
67
|
* @returns {Operation}
|
|
59
68
|
*/
|
|
60
69
|
export function get(path: string, params: RequestOptions, callback: Function): Operation;
|
|
61
70
|
/**
|
|
62
|
-
* Make a POST request
|
|
71
|
+
* Make a POST request. If `configuration.baseUrl` is set, paths must be relative.
|
|
63
72
|
* @public
|
|
64
73
|
* @example
|
|
65
74
|
* post('/myEndpoint', {
|
|
@@ -67,14 +76,15 @@ export function get(path: string, params: RequestOptions, callback: Function): O
|
|
|
67
76
|
* headers: {'content-type': 'application/json'},
|
|
68
77
|
* })
|
|
69
78
|
* @function
|
|
70
|
-
* @param {string} path - Path to resource
|
|
79
|
+
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
71
80
|
* @param {RequestOptions} params - Body, Query, Headers and Authentication parameters
|
|
72
81
|
* @param {function} callback - (Optional) Callback function
|
|
82
|
+
* @state {HttpState}
|
|
73
83
|
* @returns {operation}
|
|
74
84
|
*/
|
|
75
85
|
export function post(path: string, params: RequestOptions, callback: Function): operation;
|
|
76
86
|
/**
|
|
77
|
-
* Make a PUT request
|
|
87
|
+
* Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.
|
|
78
88
|
* @public
|
|
79
89
|
* @example
|
|
80
90
|
* put('/myEndpoint', {
|
|
@@ -82,14 +92,15 @@ export function post(path: string, params: RequestOptions, callback: Function):
|
|
|
82
92
|
* headers: {'content-type': 'application/json'},
|
|
83
93
|
* })
|
|
84
94
|
* @function
|
|
85
|
-
* @param {string} path - Path to resource
|
|
95
|
+
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
86
96
|
* @param {RequestOptions} params - Body, Query, Headers and Auth parameters
|
|
87
97
|
* @param {function} callback - (Optional) Callback function
|
|
98
|
+
* @state {HttpState}
|
|
88
99
|
* @returns {Operation}
|
|
89
100
|
*/
|
|
90
101
|
export function put(path: string, params: RequestOptions, callback: Function): Operation;
|
|
91
102
|
/**
|
|
92
|
-
* Make a PATCH request
|
|
103
|
+
* Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.
|
|
93
104
|
* @public
|
|
94
105
|
* @example
|
|
95
106
|
* patch('/myEndpoint', {
|
|
@@ -97,23 +108,25 @@ export function put(path: string, params: RequestOptions, callback: Function): O
|
|
|
97
108
|
* headers: {'content-type': 'application/json'},
|
|
98
109
|
* })
|
|
99
110
|
* @function
|
|
100
|
-
* @param {string} path - Path to resource
|
|
111
|
+
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
101
112
|
* @param {RequestOptions} params - Body, Query, Headers and Auth parameters
|
|
102
113
|
* @param {function} callback - (Optional) Callback function
|
|
114
|
+
* @state {HttpState}
|
|
103
115
|
* @returns {Operation}
|
|
104
116
|
*/
|
|
105
117
|
export function patch(path: string, params: RequestOptions, callback: Function): Operation;
|
|
106
118
|
/**
|
|
107
|
-
* Make a DELETE request
|
|
119
|
+
* Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.
|
|
108
120
|
* @public
|
|
109
121
|
* @example
|
|
110
122
|
* del(`/myendpoint/${state => state.data.id}`, {
|
|
111
123
|
* headers: {'content-type': 'application/json'}
|
|
112
124
|
* })
|
|
113
125
|
* @function
|
|
114
|
-
* @param {string} path - Path to resource
|
|
126
|
+
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
115
127
|
* @param {RequestOptions} params - Body, Query, Headers and Auth parameters
|
|
116
128
|
* @param {function} callback - (Optional) Callback function
|
|
129
|
+
* @state {HttpState}
|
|
117
130
|
* @returns {Operation}
|
|
118
131
|
*/
|
|
119
132
|
export function del(path: string, params: RequestOptions, callback: Function): Operation;
|
|
@@ -139,44 +152,30 @@ export function del(path: string, params: RequestOptions, callback: Function): O
|
|
|
139
152
|
* @param {String} body - data string to be parsed
|
|
140
153
|
* @param {function} script - script for extracting data
|
|
141
154
|
* @param {function} callback - (Optional) Callback function
|
|
155
|
+
* @state data - the parsed XML as a JSON object
|
|
156
|
+
* @state references - an array of all previous data objects used in the Job
|
|
142
157
|
* @returns {Operation}
|
|
143
158
|
*/
|
|
144
159
|
export function parseXML(body: string, script: Function, callback: Function): Operation;
|
|
145
160
|
/**
|
|
146
161
|
* Options provided to the HTTP request
|
|
147
162
|
*/
|
|
148
|
-
export type RequestOptions =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.
|
|
155
|
-
*/
|
|
156
|
-
errors: object;
|
|
157
|
-
/**
|
|
158
|
-
* - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
|
|
159
|
-
*/
|
|
160
|
-
form: object;
|
|
161
|
-
/**
|
|
162
|
-
* - An object of query parameters to be encoded into the URL.
|
|
163
|
-
*/
|
|
164
|
-
query: object;
|
|
165
|
-
/**
|
|
166
|
-
* - An object of headers to append to the request.
|
|
167
|
-
*/
|
|
168
|
-
headers: object;
|
|
163
|
+
export type RequestOptions = any;
|
|
164
|
+
/**
|
|
165
|
+
* State object
|
|
166
|
+
*/
|
|
167
|
+
export type HttpState = {
|
|
169
168
|
/**
|
|
170
|
-
* -
|
|
169
|
+
* - the parsed response body
|
|
171
170
|
*/
|
|
172
|
-
|
|
171
|
+
data: any;
|
|
173
172
|
/**
|
|
174
|
-
* -
|
|
173
|
+
* - the response from the HTTP server, including headers, statusCode, body, etc
|
|
175
174
|
*/
|
|
176
|
-
|
|
175
|
+
response: any;
|
|
177
176
|
/**
|
|
178
|
-
* -
|
|
177
|
+
* - an array of all previous data objects used in the Job
|
|
179
178
|
*/
|
|
180
|
-
|
|
179
|
+
references: any;
|
|
181
180
|
};
|
|
182
181
|
export { alterState, arrayToString, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, chunk, group, humanProper, lastReferenceValue, merge, scrubEmojis, sourceValue, splitKeys, toArray, parseCsv } from "@openfn/language-common";
|