@openfn/language-http 7.0.0 → 7.0.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 CHANGED
@@ -17,7 +17,8 @@
17
17
  },
18
18
  {
19
19
  "title": "example",
20
- "description": "request(\n 'GET',\n '/patient',\n {\n query: {foo: 'bar', a: 1},\n headers: {'content-type': 'application/json'},\n }\n)"
20
+ "description": "request('GET', '/patient', {\n query: { foo: 'bar', a: 1 },\n headers: { 'content-type': 'application/json' },\n});",
21
+ "caption": "Make a GET request"
21
22
  },
22
23
  {
23
24
  "title": "function",
@@ -83,7 +84,8 @@
83
84
  },
84
85
  {
85
86
  "title": "example",
86
- "description": "get('/patient', {\n query: {foo: 'bar', a: 1},\n headers: {'content-type': 'application/json'},\n})"
87
+ "description": "get('/patient', {\n query: { foo: 'bar', a: 1 },\n headers: { 'content-type': 'application/json' },\n});",
88
+ "caption": "GET request with query parameters and custom headers"
87
89
  },
88
90
  {
89
91
  "title": "function",
@@ -141,12 +143,12 @@
141
143
  },
142
144
  {
143
145
  "title": "example",
144
- "description": "post('/patient' $.data)",
146
+ "description": "post('/patient', $.data);",
145
147
  "caption": "POST a resource with from state"
146
148
  },
147
149
  {
148
150
  "title": "example",
149
- "description": "post('/patient' $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n})",
151
+ "description": "post('/patient', $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n});",
150
152
  "caption": "POST a resource with custom headers"
151
153
  },
152
154
  {
@@ -214,7 +216,7 @@
214
216
  },
215
217
  {
216
218
  "title": "example",
217
- "description": "put('/patient', $.data)",
219
+ "description": "put('/patient', $.data);",
218
220
  "caption": "PUT a resource from state"
219
221
  },
220
222
  {
@@ -287,12 +289,12 @@
287
289
  },
288
290
  {
289
291
  "title": "example",
290
- "description": "patch('/patient', $.data)",
292
+ "description": "patch('/patient', $.data);",
291
293
  "caption": "PATCH a resource from state"
292
294
  },
293
295
  {
294
296
  "title": "example",
295
- "description": "patch('/patient', $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n})",
297
+ "description": "patch('/patient', $.data, {\n headers: { 'content-type': 'application/fhir+json' },\n});",
296
298
  "caption": "PATCH a resource with custom headers"
297
299
  },
298
300
  {
@@ -359,7 +361,8 @@
359
361
  },
360
362
  {
361
363
  "title": "example",
362
- "description": "del(`/myendpoint/${$.data.id}`)"
364
+ "description": "del(`/myendpoint/${$.data.id}`);",
365
+ "caption": "DELETE a resource by ID"
363
366
  },
364
367
  {
365
368
  "title": "function",
@@ -416,12 +419,13 @@
416
419
  },
417
420
  {
418
421
  "title": "example",
419
- "description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n }\n);"
422
+ "description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n }\n);",
423
+ "caption": "Parse XML from state.response"
420
424
  },
421
425
  {
422
426
  "title": "example",
423
- "description": "parseXML(\n (state) => state.response,\n ($) => {\n return $(\"table[class=your_table]\").parsetable(true, true, true);\n },\n (next) => ({ ...next, results: next.data.data })\n);",
424
- "caption": "Using parseXML with a callback"
427
+ "description": "parseXML(\n (state) => state.response,\n ($) => $(\"table[class=your_table]\").parsetable(true, true, true)\n).then((next) => ({ ...next, results: next.data.data }));",
428
+ "caption": "Using parseXML with a callback to extract data"
425
429
  },
426
430
  {
427
431
  "title": "function",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-http",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "An HTTP request language package for use with Open Function",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "cheerio": "1.0.0-rc.12",
30
30
  "cheerio-tableparser": "^1.0.1",
31
- "@openfn/language-common": "2.3.0"
31
+ "@openfn/language-common": "2.3.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "chai": "^4.3.10",
@@ -33,15 +33,11 @@ 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
- * 'GET',
39
- * '/patient',
40
- * {
41
- * query: {foo: 'bar', a: 1},
42
- * headers: {'content-type': 'application/json'},
43
- * }
44
- * )
36
+ * @example <caption>Make a GET request</caption>
37
+ * request('GET', '/patient', {
38
+ * query: { foo: 'bar', a: 1 },
39
+ * headers: { 'content-type': 'application/json' },
40
+ * });
45
41
  * @function
46
42
  * @param {string} method - The HTTP method to use.
47
43
  * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
@@ -53,11 +49,11 @@ export function request(method: string, path: string, options: RequestOptions):
53
49
  /**
54
50
  * Make a GET request. If `configuration.baseUrl` is set, paths must be relative.
55
51
  * @public
56
- * @example
52
+ * @example <caption>GET request with query parameters and custom headers</caption>
57
53
  * get('/patient', {
58
- * query: {foo: 'bar', a: 1},
59
- * headers: {'content-type': 'application/json'},
60
- * })
54
+ * query: { foo: 'bar', a: 1 },
55
+ * headers: { 'content-type': 'application/json' },
56
+ * });
61
57
  * @function
62
58
  * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
63
59
  * @param {RequestOptions} options - Body, Query, Headers and Authentication parameters
@@ -69,11 +65,11 @@ export function get(path: string, options: RequestOptions): Operation;
69
65
  * Make a POST request. If `configuration.baseUrl` is set, paths must be relative.
70
66
  * @public
71
67
  * @example <caption>POST a resource with from state</caption>
72
- * post('/patient' $.data)
73
- @example <caption>POST a resource with custom headers</caption>
74
- * post('/patient' $.data, {
68
+ * post('/patient', $.data);
69
+ * @example <caption>POST a resource with custom headers</caption>
70
+ * post('/patient', $.data, {
75
71
  * headers: { 'content-type': 'application/fhir+json' },
76
- * })
72
+ * });
77
73
  * @function
78
74
  * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
79
75
  * @param {object} data - Body data to append to the request. JSON will be converted to a string.
@@ -86,7 +82,7 @@ export function post(path: string, data: object, options: RequestOptions): opera
86
82
  * Make a PUT request. If `configuration.baseUrl` is set, paths must be relative.
87
83
  * @public
88
84
  * @example <caption>PUT a resource from state</caption>
89
- * put('/patient', $.data)
85
+ * put('/patient', $.data);
90
86
  * @example <caption>PUT a resource with custom headers</caption>
91
87
  * put('/patient', $.data, {
92
88
  * headers: { 'content-type': 'application/fhir+json' },
@@ -103,11 +99,11 @@ export function put(path: string, data: object, options: any): Operation;
103
99
  * Make a PATCH request. If `configuration.baseUrl` is set, paths must be relative.
104
100
  * @public
105
101
  * @example <caption>PATCH a resource from state</caption>
106
- * patch('/patient', $.data)
102
+ * patch('/patient', $.data);
107
103
  * @example <caption>PATCH a resource with custom headers</caption>
108
104
  * patch('/patient', $.data, {
109
105
  * headers: { 'content-type': 'application/fhir+json' },
110
- * })
106
+ * });
111
107
  * @function
112
108
  * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
113
109
  * @param {object} data - Body data to append to the request. JSON will be converted to a string.
@@ -119,8 +115,8 @@ export function patch(path: string, data: object, options: RequestOptions): Oper
119
115
  /**
120
116
  * Make a DELETE request. If `configuration.baseUrl` is set, paths must be relative.
121
117
  * @public
122
- * @example
123
- * del(`/myendpoint/${$.data.id}`)
118
+ * @example <caption>DELETE a resource by ID</caption>
119
+ * del(`/myendpoint/${$.data.id}`);
124
120
  * @function
125
121
  * @param {string} path - Path to resource. Can be an absolute URL if baseURL is NOT set on `state.configuration`.
126
122
  * @param {RequestOptions} options - Query, Headers and Auth parameters
@@ -131,21 +127,18 @@ export function del(path: string, options: RequestOptions): Operation;
131
127
  /**
132
128
  * Parse XML with the Cheerio parser
133
129
  * @public
134
- * @example
130
+ * @example <caption>Parse XML from state.response</caption>
135
131
  * parseXML(
136
132
  * (state) => state.response,
137
133
  * ($) => {
138
134
  * return $("table[class=your_table]").parsetable(true, true, true);
139
135
  * }
140
136
  * );
141
- * @example <caption>Using parseXML with a callback</caption>
142
- * parseXML(
137
+ * @example <caption>Using parseXML with a callback to extract data</caption>
138
+ * parseXML(
143
139
  * (state) => state.response,
144
- * ($) => {
145
- * return $("table[class=your_table]").parsetable(true, true, true);
146
- * },
147
- * (next) => ({ ...next, results: next.data.data })
148
- * );
140
+ * ($) => $("table[class=your_table]").parsetable(true, true, true)
141
+ * ).then((next) => ({ ...next, results: next.data.data }));
149
142
  * @function
150
143
  * @param {String} data - Body string to be parsed
151
144
  * @param {function} script - script for extracting data