@openfn/language-http 7.0.1 → 7.0.3
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 +20 -11
- package/package.json +1 -1
- package/types/Adaptor.d.ts +29 -30
package/ast.json
CHANGED
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"title": "example",
|
|
20
|
-
"description": "request(
|
|
20
|
+
"description": "request('GET', '/patient', {\n query: { foo: 'bar', a: 1 },\n});",
|
|
21
|
+
"caption": "Make a GET request"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"title": "example",
|
|
25
|
+
"description": "request('POST', '/todos', {\n body:{\n \"userId\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n },\n});",
|
|
26
|
+
"caption": "Make a POST request with a body"
|
|
21
27
|
},
|
|
22
28
|
{
|
|
23
29
|
"title": "function",
|
|
@@ -83,7 +89,8 @@
|
|
|
83
89
|
},
|
|
84
90
|
{
|
|
85
91
|
"title": "example",
|
|
86
|
-
"description": "get('/patient', {\n query: {foo: 'bar', a: 1
|
|
92
|
+
"description": "get('/patient', {\n query: { foo: 'bar', a: 1 },\n});",
|
|
93
|
+
"caption": "GET request with query parameters and custom headers"
|
|
87
94
|
},
|
|
88
95
|
{
|
|
89
96
|
"title": "function",
|
|
@@ -141,12 +148,12 @@
|
|
|
141
148
|
},
|
|
142
149
|
{
|
|
143
150
|
"title": "example",
|
|
144
|
-
"description": "post('/patient' $.data)",
|
|
151
|
+
"description": "post('/patient', $.data);",
|
|
145
152
|
"caption": "POST a resource with from state"
|
|
146
153
|
},
|
|
147
154
|
{
|
|
148
155
|
"title": "example",
|
|
149
|
-
"description": "post('/patient' $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n})",
|
|
156
|
+
"description": "post('/patient', $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n});",
|
|
150
157
|
"caption": "POST a resource with custom headers"
|
|
151
158
|
},
|
|
152
159
|
{
|
|
@@ -214,7 +221,7 @@
|
|
|
214
221
|
},
|
|
215
222
|
{
|
|
216
223
|
"title": "example",
|
|
217
|
-
"description": "put('/patient', $.data)",
|
|
224
|
+
"description": "put('/patient', $.data);",
|
|
218
225
|
"caption": "PUT a resource from state"
|
|
219
226
|
},
|
|
220
227
|
{
|
|
@@ -287,12 +294,12 @@
|
|
|
287
294
|
},
|
|
288
295
|
{
|
|
289
296
|
"title": "example",
|
|
290
|
-
"description": "patch('/patient', $.data)",
|
|
297
|
+
"description": "patch('/patient', $.data);",
|
|
291
298
|
"caption": "PATCH a resource from state"
|
|
292
299
|
},
|
|
293
300
|
{
|
|
294
301
|
"title": "example",
|
|
295
|
-
"description": "patch('/patient', $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n})",
|
|
302
|
+
"description": "patch('/patient', $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n});",
|
|
296
303
|
"caption": "PATCH a resource with custom headers"
|
|
297
304
|
},
|
|
298
305
|
{
|
|
@@ -359,7 +366,8 @@
|
|
|
359
366
|
},
|
|
360
367
|
{
|
|
361
368
|
"title": "example",
|
|
362
|
-
"description": "del(`/myendpoint/${$.data.id}`)"
|
|
369
|
+
"description": "del(`/myendpoint/${$.data.id}`);",
|
|
370
|
+
"caption": "DELETE a resource by ID"
|
|
363
371
|
},
|
|
364
372
|
{
|
|
365
373
|
"title": "function",
|
|
@@ -416,12 +424,13 @@
|
|
|
416
424
|
},
|
|
417
425
|
{
|
|
418
426
|
"title": "example",
|
|
419
|
-
"description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n }\n);"
|
|
427
|
+
"description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n }\n);",
|
|
428
|
+
"caption": "Parse XML from state.response"
|
|
420
429
|
},
|
|
421
430
|
{
|
|
422
431
|
"title": "example",
|
|
423
|
-
"description": "parseXML(\n (state) => state.response,\n ($) =>
|
|
424
|
-
"caption": "Using parseXML with a callback"
|
|
432
|
+
"description": "parseXML(\n (state) => state.response,\n ($) => $(\"table[class=your_table]\").parsetable(true, true, true)\n).then((next) => ({ ...next, results: next.data.data }));",
|
|
433
|
+
"caption": "Using parseXML with a callback to extract data"
|
|
425
434
|
},
|
|
426
435
|
{
|
|
427
436
|
"title": "function",
|
package/package.json
CHANGED
package/types/Adaptor.d.ts
CHANGED
|
@@ -33,15 +33,18 @@ export function execute(...operations: Operations): Operation;
|
|
|
33
33
|
/**
|
|
34
34
|
* Make a HTTP request. If `configuration.baseUrl` is set, paths must be relative.
|
|
35
35
|
* @public
|
|
36
|
-
* @example
|
|
37
|
-
* request(
|
|
38
|
-
* '
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
36
|
+
* @example <caption>Make a GET request</caption>
|
|
37
|
+
* request('GET', '/patient', {
|
|
38
|
+
* query: { foo: 'bar', a: 1 },
|
|
39
|
+
* });
|
|
40
|
+
* @example <caption>Make a POST request with a body</caption>
|
|
41
|
+
* request('POST', '/todos', {
|
|
42
|
+
* body:{
|
|
43
|
+
* "userId": 1,
|
|
44
|
+
* "title": "delectus aut autem",
|
|
45
|
+
* "completed": false
|
|
46
|
+
* },
|
|
47
|
+
* });
|
|
45
48
|
* @function
|
|
46
49
|
* @param {string} method - The HTTP method to use.
|
|
47
50
|
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
@@ -53,11 +56,10 @@ export function request(method: string, path: string, options: RequestOptions):
|
|
|
53
56
|
/**
|
|
54
57
|
* Make a GET request. If `configuration.baseUrl` is set, paths must be relative.
|
|
55
58
|
* @public
|
|
56
|
-
* @example
|
|
59
|
+
* @example <caption>GET request with query parameters and custom headers</caption>
|
|
57
60
|
* get('/patient', {
|
|
58
|
-
* query: {foo: 'bar', a: 1},
|
|
59
|
-
*
|
|
60
|
-
* })
|
|
61
|
+
* query: { foo: 'bar', a: 1 },
|
|
62
|
+
* });
|
|
61
63
|
* @function
|
|
62
64
|
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
63
65
|
* @param {RequestOptions} options - Body, Query, Headers and Authentication parameters
|
|
@@ -69,11 +71,11 @@ export function get(path: string, options: RequestOptions): Operation;
|
|
|
69
71
|
* Make a POST request. If `configuration.baseUrl` is set, paths must be relative.
|
|
70
72
|
* @public
|
|
71
73
|
* @example <caption>POST a resource with from state</caption>
|
|
72
|
-
* post('/patient' $.data)
|
|
73
|
-
|
|
74
|
-
* post('/patient' $.data, {
|
|
74
|
+
* post('/patient', $.data);
|
|
75
|
+
* @example <caption>POST a resource with custom headers</caption>
|
|
76
|
+
* post('/patient', $.data, {
|
|
75
77
|
* headers: { 'content-type': 'application/fhir+json' },
|
|
76
|
-
* })
|
|
78
|
+
* });
|
|
77
79
|
* @function
|
|
78
80
|
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
79
81
|
* @param {object} data - Body data to append to the request. JSON will be converted to a string.
|
|
@@ -86,7 +88,7 @@ export function post(path: string, data: object, options: RequestOptions): opera
|
|
|
86
88
|
* Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.
|
|
87
89
|
* @public
|
|
88
90
|
* @example <caption>PUT a resource from state</caption>
|
|
89
|
-
* put('/patient', $.data)
|
|
91
|
+
* put('/patient', $.data);
|
|
90
92
|
* @example <caption>PUT a resource with custom headers</caption>
|
|
91
93
|
* put('/patient', $.data, {
|
|
92
94
|
* headers: { 'content-type': 'application/fhir+json' },
|
|
@@ -103,11 +105,11 @@ export function put(path: string, data: object, options: any): Operation;
|
|
|
103
105
|
* Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.
|
|
104
106
|
* @public
|
|
105
107
|
* @example <caption>PATCH a resource from state</caption>
|
|
106
|
-
* patch('/patient', $.data)
|
|
108
|
+
* patch('/patient', $.data);
|
|
107
109
|
* @example <caption>PATCH a resource with custom headers</caption>
|
|
108
110
|
* patch('/patient', $.data, {
|
|
109
111
|
* headers: { 'content-type': 'application/fhir+json' },
|
|
110
|
-
* })
|
|
112
|
+
* });
|
|
111
113
|
* @function
|
|
112
114
|
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
113
115
|
* @param {object} data - Body data to append to the request. JSON will be converted to a string.
|
|
@@ -119,8 +121,8 @@ export function patch(path: string, data: object, options: RequestOptions): Oper
|
|
|
119
121
|
/**
|
|
120
122
|
* Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.
|
|
121
123
|
* @public
|
|
122
|
-
* @example
|
|
123
|
-
* del(`/myendpoint/${$.data.id}`)
|
|
124
|
+
* @example <caption>DELETE a resource by ID</caption>
|
|
125
|
+
* del(`/myendpoint/${$.data.id}`);
|
|
124
126
|
* @function
|
|
125
127
|
* @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
|
|
126
128
|
* @param {RequestOptions} options - Query, Headers and Auth parameters
|
|
@@ -131,21 +133,18 @@ export function del(path: string, options: RequestOptions): Operation;
|
|
|
131
133
|
/**
|
|
132
134
|
* Parse XML with the Cheerio parser
|
|
133
135
|
* @public
|
|
134
|
-
* @example
|
|
136
|
+
* @example <caption>Parse XML from state.response</caption>
|
|
135
137
|
* parseXML(
|
|
136
138
|
* (state) => state.response,
|
|
137
139
|
* ($) => {
|
|
138
140
|
* return $("table[class=your_table]").parsetable(true, true, true);
|
|
139
141
|
* }
|
|
140
142
|
* );
|
|
141
|
-
* @example <caption>Using parseXML with a callback</caption>
|
|
142
|
-
*
|
|
143
|
+
* @example <caption>Using parseXML with a callback to extract data</caption>
|
|
144
|
+
* parseXML(
|
|
143
145
|
* (state) => state.response,
|
|
144
|
-
* ($) =>
|
|
145
|
-
*
|
|
146
|
-
* },
|
|
147
|
-
* (next) => ({ ...next, results: next.data.data })
|
|
148
|
-
* );
|
|
146
|
+
* ($) => $("table[class=your_table]").parsetable(true, true, true)
|
|
147
|
+
* ).then((next) => ({ ...next, results: next.data.data }));
|
|
149
148
|
* @function
|
|
150
149
|
* @param {String} data - Body string to be parsed
|
|
151
150
|
* @param {function} script - script for extracting data
|